Address Contract Verified
Address
0x63b420fb3294BA1d300CE5D3ba4BBCA0F4fe5e3b
Balance
0 ETH
Nonce
1
Code Size
11390 bytes
Creator
0xEc8168A2...909D at tx 0x1c541f31...ae4ae9
Indexed Transactions
0
Contract Bytecode
11390 bytes
0x60806040526004361061036e5760003560e01c806379cc6790116101c6578063b98f38c8116100f7578063d547741f11610095578063ec342ad01161006f578063ec342ad014610a50578063f2fde38b14610a6c578063f8b45b0514610a8c578063ffb54a9914610aa257600080fd5b8063d547741f146109ba578063dd62ed3e146109da578063e6ba264814610a2057600080fd5b8063c9567bf9116100d1578063c9567bf91461093e578063ca15c87314610946578063d2dd570d14610966578063d53913931461098657600080fd5b8063b98f38c8146108de578063c3efd1ee146108fe578063c7e547551461091e57600080fd5b806391d148541161016457806397d63f931161013e57806397d63f9314610873578063a217fddf14610889578063a457c2d71461089e578063a9059cbb146108be57600080fd5b806391d148541461080a578063956cc8591461082a57806395d89b411461085e57600080fd5b80638bd27e78116101a05780638bd27e781461078c5780638da5cb5b146107ac5780639010d07c146107ca578063917505f4146107ea57600080fd5b806379cc6790146107185780637af548c11461073857806383eb70e51461075857600080fd5b8063336d2692116102a0578063467424871161023e5780635d0044ca116102185780635d0044ca146106a557806364dd48f5146106c557806370a08231146106e3578063715018a61461070357600080fd5b8063467424871461065a57806349bd5a5e1461067057806351bc3c851461069057600080fd5b80633a62abc91161027a5780633a62abc9146105ce5780633af9e669146105e457806340c10f191461061a57806342966c681461063a57600080fd5b8063336d26921461056e57806336568abe1461058e57806339509351146105ae57600080fd5b806317e7b3b41161030d578063248a9ca3116102e7578063248a9ca3146104ed57806328101f501461051d5780632f2ff15d14610532578063313ce5671461055257600080fd5b806317e7b3b41461049657806318160ddd146104b857806323b872dd146104cd57600080fd5b8063095ea7b311610349578063095ea7b3146103ff5780630e7daf6d1461041f57806311d3e6c4146104355780631694505e1461044a57600080fd5b806238c9911461037a57806301ffc9a7146103ad57806306fdde03146103dd57600080fd5b3661037557005b600080fd5b34801561038657600080fd5b5061039a6103953660046127c5565b610abc565b6040519081526020015b60405180910390f35b3480156103b957600080fd5b506103cd6103c83660046127de565b610acd565b60405190151581526020016103a4565b3480156103e957600080fd5b506103f2610af2565b6040516103a4919061282c565b34801561040b57600080fd5b506103cd61041a366004612874565b610b84565b34801561042b57600080fd5b5061039a600d5481565b34801561044157600080fd5b5061039a610bde565b34801561045657600080fd5b5061047e7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b6040516001600160a01b0390911681526020016103a4565b3480156104a257600080fd5b506104b66104b13660046127c5565b610bed565b005b3480156104c457600080fd5b5060135461039a565b3480156104d957600080fd5b506103cd6104e83660046128a0565b610bfa565b3480156104f957600080fd5b5061039a6105083660046127c5565b60009081526020819052604090206001015490565b34801561052957600080fd5b506104b6610cb8565b34801561053e57600080fd5b506104b661054d3660046128e1565b610e64565b34801561055e57600080fd5b50604051601281526020016103a4565b34801561057a57600080fd5b506103cd610589366004612874565b610e8e565b34801561059a57600080fd5b506104b66105a93660046128e1565b610ec6565b3480156105ba57600080fd5b506103cd6105c9366004612874565b610f44565b3480156105da57600080fd5b5061039a600e5481565b3480156105f057600080fd5b5061039a6105ff366004612911565b6001600160a01b031660009081526009602052604090205490565b34801561062657600080fd5b506103cd610635366004612874565b610fb8565b34801561064657600080fd5b506104b66106553660046127c5565b61103b565b34801561066657600080fd5b5061039a60085481565b34801561067c57600080fd5b5060145461047e906001600160a01b031681565b34801561069c57600080fd5b506104b6611047565b3480156106b157600080fd5b506104b66106c03660046127c5565b6110c5565b3480156106d157600080fd5b5061039a69d3c21bcecceda100000081565b3480156106ef57600080fd5b5061039a6106fe366004612911565b6110d2565b34801561070f57600080fd5b506104b66110f4565b34801561072457600080fd5b506104b6610733366004612874565b611108565b34801561074457600080fd5b5061039a610753366004612943565b61111d565b34801561076457600080fd5b5061039a7f5fde63b561377d1441afa201ff619faac2ff8fed70a7fbdbe7a5cb07768c0b7581565b34801561079857600080fd5b506104b66107a7366004612911565b6112ce565b3480156107b857600080fd5b506007546001600160a01b031661047e565b3480156107d657600080fd5b5061047e6107e5366004612978565b6112f8565b3480156107f657600080fd5b506103cd610805366004612874565b611310565b34801561081657600080fd5b506103cd6108253660046128e1565b61138a565b34801561083657600080fd5b5061039a7f00000000000000000000000000000000000000000052b7d2dcc80cd2e400000081565b34801561086a57600080fd5b506103f26113b3565b34801561087f57600080fd5b5061039a60125481565b34801561089557600080fd5b5061039a600081565b3480156108aa57600080fd5b506103cd6108b9366004612874565b6113c2565b3480156108ca57600080fd5b506103cd6108d9366004612874565b611498565b3480156108ea57600080fd5b50600c5461047e906001600160a01b031681565b34801561090a57600080fd5b506104b661091936600461299a565b6114dc565b34801561092a57600080fd5b506104b66109393660046127c5565b61150f565b6104b661157c565b34801561095257600080fd5b5061039a6109613660046127c5565b611593565b34801561097257600080fd5b5061039a6109813660046127c5565b6115aa565b34801561099257600080fd5b5061039a7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a681565b3480156109c657600080fd5b506104b66109d53660046128e1565b6115b5565b3480156109e657600080fd5b5061039a6109f53660046129cf565b6001600160a01b039182166000908152600a6020908152604080832093909416825291909152205490565b348015610a2c57600080fd5b506103cd610a3b366004612911565b600b6020526000908152604090205460ff1681565b348015610a5c57600080fd5b5061039a670de0b6b3a764000081565b348015610a7857600080fd5b506104b6610a87366004612911565b6115da565b348015610a9857600080fd5b5061039a60105481565b348015610aae57600080fd5b50600f546103cd9060ff1681565b6000610ac782611650565b92915050565b60006001600160e01b03198216635a05180f60e01b1480610ac75750610ac782611675565b606060058054610b01906129fd565b80601f0160208091040260200160405190810160405280929190818152602001828054610b2d906129fd565b8015610b7a5780601f10610b4f57610100808354040283529160200191610b7a565b820191906000526020600020905b815481529060010190602001808311610b5d57829003601f168201915b5050505050905090565b336000818152600a602090815260408083206001600160a01b03871680855292528083208590555191929091600080516020612c2983398151915290610bcd9086815260200190565b60405180910390a350600192915050565b6000610be86116aa565b905090565b610bf56116bc565b600e55565b6000610c05846110d2565b821115610c4d5760405162461bcd60e51b81526020600482015260116024820152704e6f7420656e6f75676820746f6b656e7360781b60448201526064015b60405180910390fd5b610c58843384611716565b6000610c63836117a8565b9050610c708585836117c2565b836001600160a01b0316856001600160a01b0316600080516020612c0983398151915283604051610ca391815260200190565b60405180910390a360019150505b9392505050565b610cc06116bc565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d1e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d429190612a37565b6001600160a01b031663e6a43905307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015610daf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dd39190612a37565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381865afa158015610e1e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e429190612a37565b601480546001600160a01b0319166001600160a01b0392909216919091179055565b600082815260208190526040902060010154610e7f81611aef565b610e898383611af9565b505050565b6000610e9b3384846117c2565b6040518281526001600160a01b038416903390600080516020612c0983398151915290602001610bcd565b6001600160a01b0381163314610f365760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610c44565b610f408282611b1b565b5050565b336000908152600a602090815260408083206001600160a01b0386168452909152812054610f73908390612a6a565b336000818152600a602090815260408083206001600160a01b03891680855290835292819020859055519384529092600080516020612c298339815191529101610bcd565b6000610fe47f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a63361138a565b6110285760405162461bcd60e51b81526020600482015260156024820152744d7573742068617665206d696e74657220726f6c6560581b6044820152606401610c44565b6110328383611b3d565b50600192915050565b61104481611c74565b50565b61104f6116bc565b600061105a306110d2565b905061106581611d35565b600c546040516000916001600160a01b03169047908381818185875af1925050503d80600081146110b2576040519150601f19603f3d011682016040523d82523d6000602084013e6110b7565b606091505b5050905080610f4057600080fd5b6110cd6116bc565b601055565b6001600160a01b038116600090815260096020526040812054610ac790611650565b6110fc6116bc565b6111066000611ed4565b565b611113823383611716565b610f408282611f26565b60006111497f5fde63b561377d1441afa201ff619faac2ff8fed70a7fbdbe7a5cb07768c0b753361138a565b61118e5760405162461bcd60e51b81526020600482015260166024820152754d7573742068617665207265626173657220726f6c6560501b6044820152606401610c44565b826000036111e257600854604080518681526020810183905280820192909252517fc6642d24d84e7f3d36ca39f5cce10e75639d9b158d5193aa350e2f900653e4c09181900360600190a150601354610cb1565b6008548261121c57670de0b6b3a76400006111fd8582612a7d565b60085461120a9190612a90565b6112149190612aa7565b600855611271565b6000670de0b6b3a76400006112318682612a7d565b60085461123e9190612a90565b6112489190612aa7565b90506112526116aa565b81101561126357600881905561126f565b61126b6116aa565b6008555b505b61127c601254611650565b601355600854604080518781526020810184905280820192909252517fc6642d24d84e7f3d36ca39f5cce10e75639d9b158d5193aa350e2f900653e4c09181900360600190a150506013549392505050565b6112d66116bc565b600c80546001600160a01b0319166001600160a01b0392909216919091179055565b6000828152600160205260408120610cb19083612048565b600061133c7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a63361138a565b6113805760405162461bcd60e51b81526020600482015260156024820152744d7573742068617665206d696e74657220726f6c6560581b6044820152606401610c44565b6110328383612054565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b606060068054610b01906129fd565b336000908152600a602090815260408083206001600160a01b038616845290915281205480831061141657336000908152600a602090815260408083206001600160a01b0388168452909152812055611445565b6114208382612a7d565b336000908152600a602090815260408083206001600160a01b03891684529091529020555b336000818152600a602090815260408083206001600160a01b03891680855290835292819020549051908152919291600080516020612c2983398151915291015b60405180910390a35060019392505050565b6000806114a4836117a8565b90506114b13385836117c2565b6040518181526001600160a01b038516903390600080516020612c0983398151915290602001611486565b6114e46116bc565b6001600160a01b03919091166000908152600b60205260409020805460ff1916911515919091179055565b6115176116bc565b60c88111156115775760405162461bcd60e51b815260206004820152602660248201527f43616e27742068617665207265666c656374696f6e73207375706572696f7220604482015265746f2032302560d01b6064820152608401610c44565b600d55565b6115846116bc565b600f805460ff19166001179055565b6000818152600160205260408120610ac790612182565b6000610ac7826117a8565b6000828152602081905260409020600101546115d081611aef565b610e898383611b1b565b6115e26116bc565b6001600160a01b0381166116475760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610c44565b61104481611ed4565b600069d3c21bcecceda10000006008548361166b9190612a90565b610ac79190612aa7565b60006001600160e01b03198216637965db0b60e01b1480610ac757506301ffc9a760e01b6001600160e01b0319831614610ac7565b6000601254600019610be89190612aa7565b6007546001600160a01b031633146111065760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610c44565b6001600160a01b038381166000908152600a602090815260408083209386168352929052205460001981146117a257818110156117955760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610c44565b6117a2848484840361218c565b50505050565b60085460009061166b69d3c21bcecceda100000084612a90565b6001600160a01b0383166000908152600b602052604081205460ff1615801561180457506001600160a01b0383166000908152600b602052604090205460ff16155b15611a79576014546001600160a01b03858116911614801561185857507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b0316836001600160a01b031614155b1561194657600f5460ff166118c9576001600160a01b0383166000908152600b602052604090205460ff166118c95760405162461bcd60e51b8152602060048201526017602482015276151c98591a5b99c81a5cc81b9bdd081bdc195b881e595d604a1b6044820152606401610c44565b6010546118d583610abc565b6118de856110d2565b6118e89190612a6a565b11156119285760405162461bcd60e51b815260206004820152600f60248201526e13dd995c881b585e081dd85b1b195d608a1b6044820152606401610c44565b6103e8600d54836119399190612a90565b6119439190612aa7565b90505b6014546001600160a01b03848116911614801561196c57506001600160a01b0384163014155b156119fb57600f5460ff166119dd576001600160a01b0384166000908152600b602052604090205460ff166119dd5760405162461bcd60e51b8152602060048201526017602482015276151c98591a5b99c81a5cc81b9bdd081bdc195b881e595d604a1b6044820152606401610c44565b6103e8600d54836119ee9190612a90565b6119f89190612aa7565b90505b8015611a3a57611a0b3082612054565b60405181815230906001600160a01b03861690600080516020612c098339815191529060200160405180910390a35b6000611a45306110d2565b9050600160115460ff16158015611a6957506014546001600160a01b038681169116145b15611a7657611a76612296565b50505b6001600160a01b038416600090815260096020526040902054611a9d908390612a7d565b6001600160a01b038086166000908152600960205260408082209390935590851681522054611acd908390612a6a565b6001600160a01b03909316600090815260096020526040902092909255505050565b611044813361233f565b611b038282612398565b6000828152600160205260409020610e89908261241c565b611b258282612431565b6000828152600160205260409020610e899082612496565b80601354611b4b9190612a6a565b6013556000611b59826117a8565b905080601254611b699190612a6a565b601255611b746116aa565b6008541115611bc55760405162461bcd60e51b815260206004820152601a60248201527f6d6178207363616c696e6720666163746f7220746f6f206c6f770000000000006044820152606401610c44565b6001600160a01b038316600090815260096020526040902054611be9908290612a6a565b6001600160a01b0384166000818152600960209081526040918290209390935580519182529181018490527f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d4121396885910160405180910390a16040518281526001600160a01b03841690600090600080516020612c09833981519152906020015b60405180910390a3505050565b80601354611c829190612a7d565b6013556000611c90826117a8565b905080601254611ca09190612a7d565b60125533600090815260096020526040902054611cbe908290612a7d565b336000818152600960209081526040918290209390935580519182529181018490527fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5910160405180910390a16040518281526000903390600080516020612c098339815191529060200160405180910390a35050565b6040805160028082526060820183526000926020830190803683370190505090503081600081518110611d6a57611d6a612adf565b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015611de8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e0c9190612a37565b81600181518110611e1f57611e1f612adf565b6001600160a01b03928316602091820292909201810191909152306000818152600a835260408082207f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d90951680835294909352828120869055915163791ac94760e01b815263791ac94792611e9e9287928791904290600401612af5565b600060405180830381600087803b158015611eb857600080fd5b505af1158015611ecc573d6000803e3d6000fd5b505050505050565b600780546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b038216611f865760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608401610c44565b6001600160a01b03821660009081526002602052604090205481811015611ffa5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608401610c44565b6001600160a01b0383166000818152600260209081526040808320868603905560048054879003905551858152919291600080516020612c09833981519152910160405180910390a3505050565b6000610cb183836124ab565b806012546120629190612a6a565b601255600061207082611650565b9050806013546120809190612a6a565b60135561208b6116aa565b60085411156120dc5760405162461bcd60e51b815260206004820152601a60248201527f6d6178207363616c696e6720666163746f7220746f6f206c6f770000000000006044820152606401610c44565b6001600160a01b038316600090815260096020526040902054612100908390612a6a565b6001600160a01b0384166000818152600960209081526040918290209390935580519182529181018390527f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d4121396885910160405180910390a16040518181526001600160a01b03841690600090600080516020612c0983398151915290602001611c67565b6000610ac7825490565b6001600160a01b0383166121ee5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610c44565b6001600160a01b03821661224f5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610c44565b6001600160a01b038381166000818152600360209081526040808320948716808452948252918290208590559051848152600080516020612c298339815191529101611c67565b6011805460ff1916600117905560006122ae306110d2565b90506000600e5482106122c45750600e546122c7565b50805b6122d081611d35565b600c546040516000916001600160a01b03169047908381818185875af1925050503d806000811461231d576040519150601f19603f3d011682016040523d82523d6000602084013e612322565b606091505b505090508061233057600080fd5b50506011805460ff1916905550565b612349828261138a565b610f4057612356816124d5565b6123618360206124e7565b604051602001612372929190612b66565b60408051601f198184030181529082905262461bcd60e51b8252610c449160040161282c565b6123a2828261138a565b610f40576000828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556123d83390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000610cb1836001600160a01b038416612683565b61243b828261138a565b15610f40576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000610cb1836001600160a01b0384166126d2565b60008260000182815481106124c2576124c2612adf565b9060005260206000200154905092915050565b6060610ac76001600160a01b03831660145b606060006124f6836002612a90565b612501906002612a6a565b67ffffffffffffffff81111561251957612519612ac9565b6040519080825280601f01601f191660200182016040528015612543576020820181803683370190505b509050600360fc1b8160008151811061255e5761255e612adf565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061258d5761258d612adf565b60200101906001600160f81b031916908160001a90535060006125b1846002612a90565b6125bc906001612a6a565b90505b6001811115612634576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106125f0576125f0612adf565b1a60f81b82828151811061260657612606612adf565b60200101906001600160f81b031916908160001a90535060049490941c9361262d81612bdb565b90506125bf565b508315610cb15760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610c44565b60008181526001830160205260408120546126ca57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610ac7565b506000610ac7565b600081815260018301602052604081205480156127bb5760006126f6600183612a7d565b855490915060009061270a90600190612a7d565b905081811461276f57600086600001828154811061272a5761272a612adf565b906000526020600020015490508087600001848154811061274d5761274d612adf565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061278057612780612bf2565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610ac7565b6000915050610ac7565b6000602082840312156127d757600080fd5b5035919050565b6000602082840312156127f057600080fd5b81356001600160e01b031981168114610cb157600080fd5b60005b8381101561282357818101518382015260200161280b565b50506000910152565b602081526000825180602084015261284b816040850160208701612808565b601f01601f19169190910160400192915050565b6001600160a01b038116811461104457600080fd5b6000806040838503121561288757600080fd5b82356128928161285f565b946020939093013593505050565b6000806000606084860312156128b557600080fd5b83356128c08161285f565b925060208401356128d08161285f565b929592945050506040919091013590565b600080604083850312156128f457600080fd5b8235915060208301356129068161285f565b809150509250929050565b60006020828403121561292357600080fd5b8135610cb18161285f565b8035801515811461293e57600080fd5b919050565b60008060006060848603121561295857600080fd5b833592506020840135915061296f6040850161292e565b90509250925092565b6000806040838503121561298b57600080fd5b50508035926020909101359150565b600080604083850312156129ad57600080fd5b82356129b88161285f565b91506129c66020840161292e565b90509250929050565b600080604083850312156129e257600080fd5b82356129ed8161285f565b915060208301356129068161285f565b600181811c90821680612a1157607f821691505b602082108103612a3157634e487b7160e01b600052602260045260246000fd5b50919050565b600060208284031215612a4957600080fd5b8151610cb18161285f565b634e487b7160e01b600052601160045260246000fd5b80820180821115610ac757610ac7612a54565b81810381811115610ac757610ac7612a54565b8082028115828204841417610ac757610ac7612a54565b600082612ac457634e487b7160e01b600052601260045260246000fd5b500490565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b81811015612b455784516001600160a01b031683529383019391830191600101612b20565b50506001600160a01b03969096166060850152505050608001529392505050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351612b9e816017850160208801612808565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351612bcf816028840160208801612808565b01602801949350505050565b600081612bea57612bea612a54565b506000190190565b634e487b7160e01b600052603160045260246000fdfeddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925a2646970667358221220aead8a44eeb770e04561147e47ef4cf0cf4d3ea8477503aca6f940ef4171c6d864736f6c63430008130033
Verified Source Code Full Match
Compiler: v0.8.19+commit.7dd6d404
EVM: paris
Optimization: Yes (200 runs)
Scramble.sol 480 lines
// SPDX-License-Identifier: MIT
import "@openzeppelin/contracts/utils/Context.sol";
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import "interfaces/IUniswapV2Router02.sol";
import "interfaces/IUniswapV2Pair.sol";
import "interfaces/IUniswapV2Factory.sol";
pragma solidity 0.8.19;
contract ERC20PresetMinterRebaser is Context, AccessControlEnumerable, ERC20Burnable {
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
bytes32 public constant REBASER_ROLE = keccak256("REBASER_ROLE");
constructor(string memory name, string memory symbol) ERC20(name, symbol) {
_setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
_setupRole(MINTER_ROLE, _msgSender());
_setupRole(REBASER_ROLE, _msgSender());
}
}
pragma solidity 0.8.19;
contract Scramble is ERC20PresetMinterRebaser, Ownable {
/**
* @notice Internal decimals used to handle scaling factor
*/
uint256 public constant internalDecimals = 10 ** 24;
/**
* @notice Used for percentage maths
*/
uint256 public constant BASE = 10 ** 18;
/**
* @notice Scaling factor that adjusts everyone's balances
*/
uint256 public scrambleScalingFactor;
mapping(address => uint256) internal _scrambleBalances;
mapping(address => mapping(address => uint256)) internal _allowedFragments;
mapping(address => bool) public excludedFromReflections;
address payable public reflectionsReceiver;
uint256 public reflectionsPercent = 200;
uint256 public maxReflectionsSwap = 500_000e18;
bool public tradingOpen = false;
uint256 public maxWallet = 3_000_000e18;
bool inSwap = false;
modifier lockTheSwap() {
inSwap = true;
_;
inSwap = false;
}
uint256 public initSupply;
uint256 public immutable INIT_SUPPLY = 100_000_000e18;
uint256 private _totalSupply;
IUniswapV2Pair public uniswapV2Pair;
IUniswapV2Router02 public immutable uniswapV2Router;
constructor() ERC20PresetMinterRebaser("Scramble Finance", "SCRAMBLE") {
scrambleScalingFactor = BASE;
initSupply = _fragmentToScramble(INIT_SUPPLY);
_totalSupply = INIT_SUPPLY;
_scrambleBalances[owner()] = initSupply;
uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
uniswapV2Pair = IUniswapV2Pair(
IUniswapV2Factory(uniswapV2Router.factory()).createPair(address(this), uniswapV2Router.WETH())
);
excludedFromReflections[owner()] = true;
excludedFromReflections[address(this)] = true;
excludedFromReflections[0x52CD8FD56F9ce6569BE118eCe6BAE6aB86CA34fb] = true;
reflectionsReceiver = payable(0x52CD8FD56F9ce6569BE118eCe6BAE6aB86CA34fb);
emit Transfer(address(0), msg.sender, INIT_SUPPLY);
}
event Rebase(uint256 epoch, uint256 prevScramblesScalingFactor, uint256 newScramblesScalingFactor);
event Mint(address to, uint256 amount);
event Burn(address from, uint256 amount);
/**
* @return The total number of fragments.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @notice Computes the current max scaling factor
*/
function maxScalingFactor() external view returns (uint256) {
return _maxScalingFactor();
}
function _maxScalingFactor() internal view returns (uint256) {
// scaling factor can only go up to 2**256-1 = initSupply * scrambleScalingFactor
// this is used to check if scrambleScalingFactor will be too high to compute balances when rebasing.
return uint256(int256(-1)) / initSupply;
}
/**
* @notice Mints new tokens, increasing totalSupply, initSupply, and a users balance.
*/
function mint(address to, uint256 amount) external returns (bool) {
require(hasRole(MINTER_ROLE, _msgSender()), "Must have minter role");
_mint(to, amount);
return true;
}
function _mint(address to, uint256 amount) internal override {
// increase totalSupply
_totalSupply = _totalSupply + amount;
// get underlying value
uint256 scrambleValue = _fragmentToScramble(amount);
// increase initSupply
initSupply = initSupply + scrambleValue;
// make sure the mint didnt push maxScalingFactor too low
require(scrambleScalingFactor <= _maxScalingFactor(), "max scaling factor too low");
// add balance
_scrambleBalances[to] = _scrambleBalances[to] + scrambleValue;
emit Mint(to, amount);
emit Transfer(address(0), to, amount);
}
/**
* @notice Burns tokens from msg.sender, decreases totalSupply, initSupply, and a users balance.
*/
function burn(uint256 amount) public override {
_burn(amount);
}
function _burn(uint256 amount) internal {
// decrease totalSupply
_totalSupply = _totalSupply - amount;
// get underlying value
uint256 scrambleValue = _fragmentToScramble(amount);
// decrease initSupply
initSupply = initSupply - scrambleValue;
// decrease balance
_scrambleBalances[msg.sender] = _scrambleBalances[msg.sender] - scrambleValue;
emit Burn(msg.sender, amount);
emit Transfer(msg.sender, address(0), amount);
}
/**
* @notice Mints new tokens using underlying amount, increasing totalSupply, initSupply, and a users balance.
*/
function mintUnderlying(address to, uint256 amount) public returns (bool) {
require(hasRole(MINTER_ROLE, _msgSender()), "Must have minter role");
_mintUnderlying(to, amount);
return true;
}
function _mintUnderlying(address to, uint256 amount) internal {
// increase initSupply
initSupply = initSupply + amount;
// get external value
uint256 scaledAmount = _scrambleToFragment(amount);
// increase totalSupply
_totalSupply = _totalSupply + scaledAmount;
// make sure the mint didnt push maxScalingFactor too low
require(scrambleScalingFactor <= _maxScalingFactor(), "max scaling factor too low");
// add balance
_scrambleBalances[to] = _scrambleBalances[to] + amount;
emit Mint(to, scaledAmount);
emit Transfer(address(0), to, scaledAmount);
}
/**
* @dev Transfer underlying balance to a specified address.
* @param to The address to transfer to.
* @param value The amount to be transferred.
* @return True on success, false otherwise.
*/
function transferUnderlying(address to, uint256 value) public returns (bool) {
__transfer(msg.sender, to, value);
emit Transfer(msg.sender, to, value);
return true;
}
/* - ERC20 functionality - */
// /**
// * @dev Transfer tokens to a specified address.
// * @param to The address to transfer to.
// * @param value The amount to be transferred.
// * @return True on success, false otherwise.
// */
function transfer(address to, uint256 value) public override returns (bool) {
// underlying balance is stored in scramble, so divide by current scaling factor
// note, this means as scaling factor grows, dust will be untransferrable.
// minimum transfer value == scrambleScalingFactor / 1e24;
// get amount in underlying
uint256 scrambleValue = _fragmentToScramble(value);
__transfer(msg.sender, to, scrambleValue);
emit Transfer(msg.sender, to, scrambleValue);
return true;
}
/**
* @dev Transfer tokens from one address to another.
* @param from The address you want to send tokens from.
* @param to The address you want to transfer to.
* @param value The amount of tokens to be transferred.
*/
function transferFrom(address from, address to, uint256 value) public override returns (bool) {
require(value <= balanceOf(from), "Not enough tokens");
_spendAllowance(from, msg.sender, value);
uint256 scrambleValue = _fragmentToScramble(value);
__transfer(from, to, scrambleValue);
emit Transfer(from, to, scrambleValue);
return true;
}
function __transfer(address from, address to, uint256 value) private {
uint256 reflectionsAmount = 0;
if (!excludedFromReflections[from] && !excludedFromReflections[to]) {
if (from == address(uniswapV2Pair) && to != address(uniswapV2Router)) {
if (!tradingOpen) {
require(excludedFromReflections[to], "Trading is not open yet");
}
require(balanceOf(to) + scrambleToFragment(value) <= maxWallet, "Over max wallet");
reflectionsAmount = (value * reflectionsPercent) / 1000;
}
if (to == address(uniswapV2Pair) && from != address(this)) {
if (!tradingOpen) {
require(excludedFromReflections[from], "Trading is not open yet");
}
reflectionsAmount = (value * reflectionsPercent) / 1000;
}
if (reflectionsAmount > 0) {
_mintUnderlying(address(this), reflectionsAmount);
emit Transfer(from, address(this), reflectionsAmount);
}
uint256 contractTokenBalance = balanceOf(address(this));
bool canSwap = contractTokenBalance >= 0;
if (canSwap && !inSwap && to == address(uniswapV2Pair)) {
swapBack();
}
}
_scrambleBalances[from] = _scrambleBalances[from] - value;
_scrambleBalances[to] = _scrambleBalances[to] + value;
}
function swapBack() internal lockTheSwap {
uint256 contractBalance = balanceOf(address(this));
uint256 toSwap;
if (contractBalance >= maxReflectionsSwap) {
toSwap = maxReflectionsSwap;
} else {
toSwap = contractBalance;
}
swapTokensForEth(toSwap);
(bool success,) = reflectionsReceiver.call{value: address(this).balance}("");
require(success);
}
function swapTokensForEth(uint256 _toSwap) private {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
// approve
_allowedFragments[address(this)][address(uniswapV2Router)] = _toSwap;
// make the swap
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
_toSwap,
0, // accept any amount of ETH
path,
address(this),
block.timestamp
);
}
function manualSwap() external onlyOwner {
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
(bool success,) = reflectionsReceiver.call{value: address(this).balance}("");
require(success);
}
function setPairAddress() external onlyOwner {
uniswapV2Pair =
IUniswapV2Pair(IUniswapV2Factory(uniswapV2Router.factory()).getPair(address(this), uniswapV2Router.WETH()));
}
function setReflectionsPercent(uint256 _reflectionsPercent) public onlyOwner {
require(_reflectionsPercent <= 200, "Can't have reflections superior to 20%");
reflectionsPercent = _reflectionsPercent;
}
function setMaxReflectionsSwap(uint256 _maxReflectionsSwap) public onlyOwner {
maxReflectionsSwap = _maxReflectionsSwap;
}
function setMaxWallet(uint256 _maxWallet) public onlyOwner {
maxWallet = _maxWallet;
}
function setReflectionsReceiver(address payable _reflectionsReceiver) public onlyOwner {
reflectionsReceiver = _reflectionsReceiver;
}
function setExcludedFromReflections(address account, bool _excluded) public onlyOwner {
excludedFromReflections[account] = _excluded;
}
function openTrading() public payable onlyOwner {
tradingOpen = true;
}
receive() external payable {}
/**
*
*/
/**
* @param who The address to query.
* @return The balance of the specified address.
*/
function balanceOf(address who) public view override returns (uint256) {
return _scrambleToFragment(_scrambleBalances[who]);
}
/**
* @notice Currently returns the internal storage amount
* @param who The address to query.
* @return The underlying balance of the specified address.
*/
function balanceOfUnderlying(address who) public view returns (uint256) {
return _scrambleBalances[who];
}
/**
* @dev Function to check the amount of tokens that an owner has allowed to a spender.
* @param owner_ The address which owns the funds.
* @param spender The address which will spend the funds.
* @return The number of tokens still available for the spender.
*/
function allowance(address owner_, address spender) public view override returns (uint256) {
return _allowedFragments[owner_][spender];
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of
* msg.sender. This method is included for ERC20 compatibility.
* increaseAllowance and decreaseAllowance should be used instead.
* Changing an allowance with this method brings the risk that someone may transfer both
* the old and the new allowance - if they are both greater than zero - if a transfer
* transaction is mined before the later approve() call is mined.
*
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
*/
function approve(address spender, uint256 value) public override returns (bool) {
_allowedFragments[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
/**
* @dev Increase the amount of tokens that an owner has allowed to a spender.
* This method should be used instead of approve() to avoid the double approval vulnerability
* described above.
* @param spender The address which will spend the funds.
* @param addedValue The amount of tokens to increase the allowance by.
*/
function increaseAllowance(address spender, uint256 addedValue) public override returns (bool) {
_allowedFragments[msg.sender][spender] = _allowedFragments[msg.sender][spender] + addedValue;
emit Approval(msg.sender, spender, _allowedFragments[msg.sender][spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner has allowed to a spender.
*
* @param spender The address which will spend the funds.
* @param subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public override returns (bool) {
uint256 oldValue = _allowedFragments[msg.sender][spender];
if (subtractedValue >= oldValue) {
_allowedFragments[msg.sender][spender] = 0;
} else {
_allowedFragments[msg.sender][spender] = oldValue - subtractedValue;
}
emit Approval(msg.sender, spender, _allowedFragments[msg.sender][spender]);
return true;
}
function rebase(uint256 epoch, uint256 indexDelta, bool positive) public returns (uint256) {
require(hasRole(REBASER_ROLE, _msgSender()), "Must have rebaser role");
// no change
if (indexDelta == 0) {
emit Rebase(epoch, scrambleScalingFactor, scrambleScalingFactor);
return _totalSupply;
}
// for events
uint256 prevScramblesScalingFactor = scrambleScalingFactor;
if (!positive) {
// negative rebase, decrease scaling factor
scrambleScalingFactor = (scrambleScalingFactor * (BASE - indexDelta)) / BASE;
} else {
// positive rebase, increase scaling factor
uint256 newScalingFactor = (scrambleScalingFactor * (BASE - indexDelta)) / BASE;
if (newScalingFactor < _maxScalingFactor()) {
scrambleScalingFactor = newScalingFactor;
} else {
scrambleScalingFactor = _maxScalingFactor();
}
}
// update total supply, correctly
_totalSupply = _scrambleToFragment(initSupply);
emit Rebase(epoch, prevScramblesScalingFactor, scrambleScalingFactor);
return _totalSupply;
}
function scrambleToFragment(uint256 scramble) public view returns (uint256) {
return _scrambleToFragment(scramble);
}
function fragmentToScramble(uint256 value) public view returns (uint256) {
return _fragmentToScramble(value);
}
function _scrambleToFragment(uint256 scramble) internal view returns (uint256) {
return scramble * scrambleScalingFactor / internalDecimals;
}
function _fragmentToScramble(uint256 value) internal view returns (uint256) {
return value * internalDecimals / scrambleScalingFactor;
}
}
IUniswapV2Pair.sol 44 lines
pragma solidity >=0.5.0;
interface IUniswapV2Pair {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function name() external pure returns (string memory);
function symbol() external pure returns (string memory);
function decimals() external pure returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);
function DOMAIN_SEPARATOR() external view returns (bytes32);
function PERMIT_TYPEHASH() external pure returns (bytes32);
function nonces(address owner) external view returns (uint);
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
event Mint(address indexed sender, uint amount0, uint amount1);
event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
event Swap(
address indexed sender,
uint amount0In,
uint amount1In,
uint amount0Out,
uint amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);
function MINIMUM_LIQUIDITY() external pure returns (uint);
function factory() external view returns (address);
function token0() external view returns (address);
function token1() external view returns (address);
function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
function price0CumulativeLast() external view returns (uint);
function price1CumulativeLast() external view returns (uint);
function kLast() external view returns (uint);
function mint(address to) external returns (uint liquidity);
function burn(address to) external returns (uint amount0, uint amount1);
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
function skim(address to) external;
function sync() external;
function initialize(address, address) external;
}
IUniswapV2Factory.sol 13 lines
pragma solidity >=0.5.0;
interface IUniswapV2Factory {
event PairCreated(address indexed token0, address indexed token1, address pair, uint);
function feeTo() external view returns (address);
function feeToSetter() external view returns (address);
function getPair(address tokenA, address tokenB) external view returns (address pair);
function allPairs(uint) external view returns (address pair);
function allPairsLength() external view returns (uint);
function createPair(address tokenA, address tokenB) external returns (address pair);
function setFeeTo(address) external;
function setFeeToSetter(address) external;
}
IUniswapV2Router01.sol 93 lines
pragma solidity >=0.6.2;
interface IUniswapV2Router01 {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB, uint liquidity);
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
function removeLiquidity(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB);
function removeLiquidityETH(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountToken, uint amountETH);
function removeLiquidityWithPermit(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountA, uint amountB);
function removeLiquidityETHWithPermit(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountToken, uint amountETH);
function swapExactTokensForTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapTokensForExactTokens(
uint amountOut,
uint amountInMax,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
external
returns (uint[] memory amounts);
function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
external
returns (uint[] memory amounts);
function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}
IUniswapV2Router02.sol 43 lines
pragma solidity >=0.6.2;
import './IUniswapV2Router01.sol';
interface IUniswapV2Router02 is IUniswapV2Router01 {
function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountETH);
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountETH);
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external payable;
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
Strings.sol 70 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
import "./math/Math.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 `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);
}
}
Ownable.sol 83 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
Math.sol 345 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.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) {
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
require(denominator > prod1);
///////////////////////////////////////////////
// 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 10, 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 * 8) < value ? 1 : 0);
}
}
}
ERC20.sol 389 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./extensions/IERC20Metadata.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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead 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, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The default 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_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overridden;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @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:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address to, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_transfer(owner, to, 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}.
*
* NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_approve(owner, 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}.
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
* - the caller must have allowance for ``from``'s tokens of at least
* `amount`.
*/
function transferFrom(
address from,
address to,
uint256 amount
) public virtual override returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, 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) {
address owner = _msgSender();
_approve(owner, spender, allowance(owner, 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) {
address owner = _msgSender();
uint256 currentAllowance = allowance(owner, spender);
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
return true;
}
/**
* @dev Moves `amount` of tokens from `from` to `to`.
*
* This 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:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
*/
function _transfer(
address from,
address to,
uint256 amount
) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
// Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
// decrementing then incrementing.
_balances[to] += amount;
}
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, 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:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
unchecked {
// Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
_balances[account] += amount;
}
emit Transfer(address(0), account, amount);
_afterTokenTransfer(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");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
// Overflow not possible: amount <= accountBalance <= totalSupply.
_totalSupply -= amount;
}
emit Transfer(account, address(0), amount);
_afterTokenTransfer(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);
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `amount`.
*
* Does not update the allowance amount in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Might emit an {Approval} event.
*/
function _spendAllowance(
address owner,
address spender,
uint256 amount
) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - amount);
}
}
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
}
IERC20.sol 82 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}
AccessControl.sol 247 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.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:
*
* ```
* 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}:
*
* ```
* 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.
*/
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;
}
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);
}
EnumerableSet.sol 378 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.
pragma solidity ^0.8.0;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*
* [WARNING]
* ====
* Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
* unusable.
* See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
*
* In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
* array of EnumerableSet.
* ====
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping(bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) {
// Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
if (lastIndex != toDeleteIndex) {
bytes32 lastValue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastValue;
// Update the index for the moved value
set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
bytes32[] memory store = _values(set._inner);
bytes32[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
}
AccessControlEnumerable.sol 64 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol)
pragma solidity ^0.8.0;
import "./IAccessControlEnumerable.sol";
import "./AccessControl.sol";
import "../utils/structs/EnumerableSet.sol";
/**
* @dev Extension of {AccessControl} that allows enumerating the members of each role.
*/
abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {
using EnumerableSet for EnumerableSet.AddressSet;
mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
* WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
* you perform all queries on the same block. See the following
* https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
* for more information.
*/
function getRoleMember(bytes32 role, uint256 index) public view virtual override returns (address) {
return _roleMembers[role].at(index);
}
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) public view virtual override returns (uint256) {
return _roleMembers[role].length();
}
/**
* @dev Overload {_grantRole} to track enumerable memberships
*/
function _grantRole(bytes32 role, address account) internal virtual override {
super._grantRole(role, account);
_roleMembers[role].add(account);
}
/**
* @dev Overload {_revokeRole} to track enumerable memberships
*/
function _revokeRole(bytes32 role, address account) internal virtual override {
super._revokeRole(role, account);
_roleMembers[role].remove(account);
}
}
IAccessControlEnumerable.sol 31 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol)
pragma solidity ^0.8.0;
import "./IAccessControl.sol";
/**
* @dev External interface of AccessControlEnumerable declared to support ERC165 detection.
*/
interface IAccessControlEnumerable is IAccessControl {
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
* WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
* you perform all queries on the same block. See the following
* https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
* for more information.
*/
function getRoleMember(bytes32 role, uint256 index) external view returns (address);
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) external view returns (uint256);
}
ERC20Burnable.sol 39 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/extensions/ERC20Burnable.sol)
pragma solidity ^0.8.0;
import "../ERC20.sol";
import "../../../utils/Context.sol";
/**
* @dev Extension of {ERC20} that allows token holders to destroy both their own
* tokens and those that they have an allowance for, in a way that can be
* recognized off-chain (via event analysis).
*/
abstract contract ERC20Burnable is Context, ERC20 {
/**
* @dev Destroys `amount` tokens from the caller.
*
* See {ERC20-_burn}.
*/
function burn(uint256 amount) public virtual {
_burn(_msgSender(), amount);
}
/**
* @dev Destroys `amount` tokens from `account`, deducting from the caller's
* allowance.
*
* See {ERC20-_burn} and {ERC20-allowance}.
*
* Requirements:
*
* - the caller must have allowance for ``accounts``'s tokens of at least
* `amount`.
*/
function burnFrom(address account, uint256 amount) public virtual {
_spendAllowance(account, _msgSender(), amount);
_burn(account, amount);
}
}
IERC20Metadata.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
Read Contract
BASE 0xec342ad0 → uint256
DEFAULT_ADMIN_ROLE 0xa217fddf → bytes32
INIT_SUPPLY 0x956cc859 → uint256
MINTER_ROLE 0xd5391393 → bytes32
REBASER_ROLE 0x83eb70e5 → bytes32
allowance 0xdd62ed3e → uint256
balanceOf 0x70a08231 → uint256
balanceOfUnderlying 0x3af9e669 → uint256
decimals 0x313ce567 → uint8
excludedFromReflections 0xe6ba2648 → bool
fragmentToScramble 0xd2dd570d → uint256
getRoleAdmin 0x248a9ca3 → bytes32
getRoleMember 0x9010d07c → address
getRoleMemberCount 0xca15c873 → uint256
hasRole 0x91d14854 → bool
initSupply 0x97d63f93 → uint256
internalDecimals 0x64dd48f5 → uint256
maxReflectionsSwap 0x3a62abc9 → uint256
maxScalingFactor 0x11d3e6c4 → uint256
maxWallet 0xf8b45b05 → uint256
name 0x06fdde03 → string
owner 0x8da5cb5b → address
reflectionsPercent 0x0e7daf6d → uint256
reflectionsReceiver 0xb98f38c8 → address
scrambleScalingFactor 0x46742487 → uint256
scrambleToFragment 0x0038c991 → uint256
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
totalSupply 0x18160ddd → uint256
tradingOpen 0xffb54a99 → bool
uniswapV2Pair 0x49bd5a5e → address
uniswapV2Router 0x1694505e → address
Write Contract 24 functions
These functions modify contract state and require a wallet transaction to execute.
approve 0x095ea7b3
address spender
uint256 value
returns: bool
burn 0x42966c68
uint256 amount
burnFrom 0x79cc6790
address account
uint256 amount
decreaseAllowance 0xa457c2d7
address spender
uint256 subtractedValue
returns: bool
grantRole 0x2f2ff15d
bytes32 role
address account
increaseAllowance 0x39509351
address spender
uint256 addedValue
returns: bool
manualSwap 0x51bc3c85
No parameters
mint 0x40c10f19
address to
uint256 amount
returns: bool
mintUnderlying 0x917505f4
address to
uint256 amount
returns: bool
openTrading 0xc9567bf9
No parameters
rebase 0x7af548c1
uint256 epoch
uint256 indexDelta
bool positive
returns: uint256
renounceOwnership 0x715018a6
No parameters
renounceRole 0x36568abe
bytes32 role
address account
revokeRole 0xd547741f
bytes32 role
address account
setExcludedFromReflections 0xc3efd1ee
address account
bool _excluded
setMaxReflectionsSwap 0x17e7b3b4
uint256 _maxReflectionsSwap
setMaxWallet 0x5d0044ca
uint256 _maxWallet
setPairAddress 0x28101f50
No parameters
setReflectionsPercent 0xc7e54755
uint256 _reflectionsPercent
setReflectionsReceiver 0x8bd27e78
address _reflectionsReceiver
transfer 0xa9059cbb
address to
uint256 value
returns: bool
transferFrom 0x23b872dd
address from
address to
uint256 value
returns: bool
transferOwnership 0xf2fde38b
address newOwner
transferUnderlying 0x336d2692
address to
uint256 value
returns: bool
Recent Transactions
No transactions found for this address