Address Contract Verified
Address
0x30b60bA2CD26dCf355745Ba52dFAC2FdDefE8072
Balance
0.200991 ETH
Nonce
1
Code Size
12534 bytes
Creator
0x82270e5b...F367 at tx 0x41308b60...91106b
Indexed Transactions
0
Contract Bytecode
12534 bytes
0x60806040526004361061026e5760003560e01c80638255217011610153578063c884ef83116100cb578063e5047b301161007f578063f196248611610064578063f196248614610a34578063f570ee6b14610a49578063fb5d5d4d1461080f57600080fd5b8063e5047b30146109ca578063ec309038146109fe57600080fd5b8063d35e7efc116100b0578063d35e7efc14610916578063d7b96d4e14610943578063dd62ed3e1461097757600080fd5b8063c884ef83146108d1578063c885044e1461090157600080fd5b80639ecf009011610122578063a9059cbb11610107578063a9059cbb1461085d578063a92bc58a1461087d578063c45a01551461089d57600080fd5b80639ecf009014610672578063a4475ce41461082957600080fd5b806382552170146107ab5780638bdb2afa146107c657806395d89b41146107fa578063996eba2d1461080f57600080fd5b806332c4f2bf116101e65780635ce38d99116101b557806370a082311161019a57806370a082311461071457806373dd250c146107575780637b0fa9541461077757600080fd5b80635ce38d99146106c057806368b63c24146106f457600080fd5b806332c4f2bf146106035780633fc8cef314610619578063475a519f14610672578063544d46a31461068c57600080fd5b806318160ddd1161023d5780631f2698ab116102225780631f2698ab146105ad57806323b872dd146105c7578063313ce567146105e757600080fd5b806318160ddd146105685780631e7269c51461057d57600080fd5b806306fdde03146104b9578063089fe6aa146104e4578063095ea7b3146105145780630a4625af1461054457600080fd5b366104b45761027b610a7d565b3373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe881614610352573233146103325760405162461bcd60e51b815260206004820152602d60248201527f466169724d696e743a2063616e206e6f742073656e6420636f6d6d616e64206660448201527f726f6d20636f6e74726163742e0000000000000000000000000000000000000060648201526084015b60405180910390fd5b60075460ff16156103d757655af3107a4000340361035457610352610ac1565b005b65b5e620f48000340361036957610352610d73565b60405162461bcd60e51b815260206004820152602e60248201527f466169724d696e743a20696e76616c696420636f6d6d616e64202d206d696e7460448201527f206f7220636c61696d206f6e6c790000000000000000000000000000000000006064820152608401610329565b7f00000000000000000000000000000000000000000000000000000000013c2bd943106104975765b5e620f480003403610413576103526110ee565b6601c6bf52634000340361042957610352611456565b60405162461bcd60e51b815260206004820152603060248201527f466169724d696e743a20696e76616c696420636f6d6d616e64202d207374617260448201527f74206f7220726566756e64206f6e6c79000000000000000000000000000000006064820152608401610329565b65b5e620f4800034036104ac576103526110ee565b610352611dcb565b600080fd5b3480156104c557600080fd5b506104ce611efe565b6040516104db9190612ca9565b60405180910390f35b3480156104f057600080fd5b50600d546105009062ffffff1681565b60405162ffffff90911681526020016104db565b34801561052057600080fd5b5061053461052f366004612d3b565b611f90565b60405190151581526020016104db565b34801561055057600080fd5b5061055a600a5481565b6040519081526020016104db565b34801561057457600080fd5b5060025461055a565b34801561058957600080fd5b50610534610598366004612d67565b60096020526000908152604090205460ff1681565b3480156105b957600080fd5b506007546105349060ff1681565b3480156105d357600080fd5b506105346105e2366004612d84565b611faa565b3480156105f357600080fd5b50604051601281526020016104db565b34801561060f57600080fd5b5061055a600b5481565b34801561062557600080fd5b5061064d7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016104db565b34801561067e57600080fd5b5061055a655af3107a400081565b34801561069857600080fd5b5061064d7f00000000000000000000000069691ce612c244b0829b9e124cca063816da144881565b3480156106cc57600080fd5b5061055a7f00000000000000000000000000000000000000000000000000000000013c2bd981565b34801561070057600080fd5b5061055a61070f366004612d67565b611fce565b34801561072057600080fd5b5061055a61072f366004612d67565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b34801561076357600080fd5b50610352610772366004612dc5565b612056565b34801561078357600080fd5b5061055a7f0000000000000000000000000000000000000000409f9cbc7c4a04c22000000081565b3480156107b757600080fd5b5061055a6601c6bf5263400081565b3480156107d257600080fd5b5061064d7f0000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f98481565b34801561080657600080fd5b506104ce61219b565b34801561081b57600080fd5b5061055a65b5e620f4800081565b34801561083557600080fd5b5061064d7f000000000000000000000000c7ac038a6706321a8033d504c6cc96b3636027ac81565b34801561086957600080fd5b50610534610878366004612d3b565b6121aa565b34801561088957600080fd5b5061055a610898366004612d67565b6121b8565b3480156108a957600080fd5b5061064d7f00000000000000000000000082270e5b2827b9c6730037b729072d073ac8f36781565b3480156108dd57600080fd5b506105346108ec366004612d67565b600c6020526000908152604090205460ff1681565b34801561090d57600080fd5b506104ce61224c565b34801561092257600080fd5b5061055a610931366004612d67565b60086020526000908152604090205481565b34801561094f57600080fd5b5061064d7f00000000000000000000000099090d2d220901de904c6e3d003d7ced4b6ec2a481565b34801561098357600080fd5b5061055a610992366004612dea565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260016020908152604080832093909416825291909152205490565b3480156109d657600080fd5b5061064d7f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe8881565b348015610a0a57600080fd5b507f00000000000000000000000000000000000000000000000000000000013c2bd9431015610534565b348015610a4057600080fd5b506103526122da565b348015610a5557600080fd5b5061055a7f000000000000000000000000000000000000000000000001158e460913d0000081565b3073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000030b60ba2cd26dcf355745ba52dfac2fddefe80721614610abf57600080fd5b565b610ac96123f0565b60075460ff16610b1b5760405162461bcd60e51b815260206004820152601560248201527f466169724d696e743a206e6f74207374617274656400000000000000000000006044820152606401610329565b333214610b905760405162461bcd60e51b815260206004820152602360248201527f466169724d696e743a2063616e206e6f74206d696e7420746f20636f6e74726160448201527f63742e00000000000000000000000000000000000000000000000000000000006064820152608401610329565b3360009081526009602052604090205460ff1615610bf05760405162461bcd60e51b815260206004820152601860248201527f466169724d696e743a20616c7265616479206d696e74656400000000000000006044820152606401610329565b33600081815260096020526040812080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905590610c3290611fce565b905060008111610c845760405162461bcd60e51b815260206004820152601d60248201527f466169724d696e743a206d696e7420616d6f756e74206973207a65726f0000006044820152606401610329565b610caf60027f0000000000000000000000000000000000000000409f9cbc7c4a04c220000000612e52565b811115610cbe57610cbe612e8d565b610cc9303383612433565b6040516000903390655af3107a4000908381818185875af1925050503d8060008114610d11576040519150601f19603f3d011682016040523d82523d6000602084013e610d16565b606091505b5050905080610d675760405162461bcd60e51b815260206004820152601560248201527f466169724d696e743a206d696e74206661696c656400000000000000000000006044820152606401610329565b5050610abf6001600655565b610d7b6123f0565b60075460ff16610df35760405162461bcd60e51b815260206004820152602d60248201527f466169724d696e743a20776974686472617720657874726120657468206d757360448201527f74206166746572207374617274000000000000000000000000000000000000006064820152608401610329565b60007f000000000000000000000000000000000000000000000001158e460913d0000011610e895760405162461bcd60e51b815260206004820152602260248201527f466169724d696e743a20736f667420746f7020636170206d757374206265207360448201527f65740000000000000000000000000000000000000000000000000000000000006064820152608401610329565b7f000000000000000000000000000000000000000000000001158e460913d00000600a5411610efa5760405162461bcd60e51b815260206004820152601660248201527f466169724d696e743a206e6f20657874726120657468000000000000000000006044820152606401610329565b60007f000000000000000000000000000000000000000000000001158e460913d00000600a54610f2a9190612ebc565b3360009081526008602052604090205490915080610f8a5760405162461bcd60e51b815260206004820152601160248201527f466169724d696e743a206e6f2066756e640000000000000000000000000000006044820152606401610329565b336000908152600c602052604090205460ff1615610fea5760405162461bcd60e51b815260206004820152601960248201527f466169724d696e743a20616c726561647920636c61696d6564000000000000006044820152606401610329565b336000908152600c6020526040812080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055600a5461102f8484612ecf565b6110399190612e52565b905060003361104e65b5e620f4800084612ee6565b604051600081818185875af1925050503d806000811461108a576040519150601f19603f3d011682016040523d82523d6000602084013e61108f565b606091505b50509050806110e05760405162461bcd60e51b815260206004820152601960248201527f466169724d696e743a207769746864726177206661696c6564000000000000006044820152606401610329565b50505050610abf6001600655565b6110f66123f0565b60075460ff16156111495760405162461bcd60e51b815260206004820152601960248201527f466169724d696e743a20616c72656164792073746172746564000000000000006044820152606401610329565b33600081815260086020526040902054806111a65760405162461bcd60e51b815260206004820152601160248201527f466169724d696e743a206e6f2066756e640000000000000000000000000000006044820152606401610329565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600860205260408120819055600a80548392906111e0908490612ebc565b9091555050600b54600090612710906111f99084612ecf565b6112039190612e52565b905081811061121457611214612e8d565b60008111801561125957507f00000000000000000000000069691ce612c244b0829b9e124cca063816da144873ffffffffffffffffffffffffffffffffffffffff1615155b156113305760007f00000000000000000000000069691ce612c244b0829b9e124cca063816da144873ffffffffffffffffffffffffffffffffffffffff168260405160006040518083038185875af1925050503d80600081146112d8576040519150601f19603f3d011682016040523d82523d6000602084013e6112dd565b606091505b505090508061132e5760405162461bcd60e51b815260206004820152601b60248201527f466169724d696e743a20726566756e6420666565206661696c656400000000006044820152606401610329565b505b600073ffffffffffffffffffffffffffffffffffffffff841665b5e620f4800061135a8486612ebc565b6113649190612ee6565b604051600081818185875af1925050503d80600081146113a0576040519150601f19603f3d011682016040523d82523d6000602084013e6113a5565b606091505b50509050806113f65760405162461bcd60e51b815260206004820152601760248201527f466169724d696e743a20726566756e64206661696c65640000000000000000006044820152606401610329565b60408051600081526020810185905273ffffffffffffffffffffffffffffffffffffffff8616917fb24b09fd2e8e4d8904c3c26f3e935824e032891520ffda419dec9f086b0e1eea910160405180910390a250505050610abf6001600655565b61145e6123f0565b60075460ff16156114b15760405162461bcd60e51b815260206004820152601960248201527f466169724d696e743a20616c72656164792073746172746564000000000000006044820152606401610329565b306000908152602081905260408120541161150e5760405162461bcd60e51b815260206004820152601460248201527f466169724d696e743a206e6f2062616c616e63650000000000000000000000006044820152606401610329565b7f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe8860007f000000000000000000000000000000000000000000000001158e460913d0000061155e57600a546115b1565b600a547f000000000000000000000000000000000000000000000001158e460913d000001061158f57600a546115b1565b7f000000000000000000000000000000000000000000000001158e460913d000005b9050611600307f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe887fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60006124e3565b600080600080611610858761262c565b50604080516101608101825273ffffffffffffffffffffffffffffffffffffffff8087168083528187166020840152600d5462ffffff16938301939093527ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff2764c6060830152620d89b4608083015260a0820185905260c08201849052959950939750919550935060009260e08301917f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2909116146116ce5760006116e7565b6127106116dd86612648612ecf565b6116e79190612e52565b81526020018573ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff161461174657600061175f565b61271061175585612648612ecf565b61175f9190612e52565b81526020017f00000000000000000000000099090d2d220901de904c6e3d003d7ced4b6ec2a473ffffffffffffffffffffffffffffffffffffffff16156117a657306117a9565b60005b73ffffffffffffffffffffffffffffffffffffffff1681526020016117d042610e10612ee6565b81525090506000806000808a73ffffffffffffffffffffffffffffffffffffffff1663883164568b876040518363ffffffff1660e01b81526004016118159190612ef9565b60806040518083038185885af1158015611833573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906118589190612fe4565b93509350935093508a73ffffffffffffffffffffffffffffffffffffffff166312210e8a6040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156118a857600080fd5b505af11580156118bc573d6000803e3d6000fd5b5050600780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905550611917905060027f0000000000000000000000000000000000000000409f9cbc7c4a04c220000000612e52565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201819052906370a0823190602401602060405180830381865afa15801561196c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119909190613037565b11156119e4576119e4306119c560027f0000000000000000000000000000000000000000409f9cbc7c4a04c220000000612e52565b306000908152602081905260409020546119df9190612ebc565b61282b565b60408051838152602081018390526fffffffffffffffffffffffffffffffff851681830152905130917fef1e73540aed31615f5f09b178cff91261e831560c37718c23862e93a3fc3ceb919081900360600190a27f00000000000000000000000099090d2d220901de904c6e3d003d7ced4b6ec2a473ffffffffffffffffffffffffffffffffffffffff1615611d16576040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000099090d2d220901de904c6e3d003d7ced4b6ec2a481166004830152602482018690527f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe88169063095ea7b390604401600060405180830381600087803b158015611b2457600080fd5b505af1158015611b38573d6000803e3d6000fd5b50506040517fe2ab691d00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe8881166004830152602482018890527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60448301527f00000000000000000000000099090d2d220901de904c6e3d003d7ced4b6ec2a493506000925083169063e2ab691d906064016020604051808303816000875af1158015611c1c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c409190613037565b6040517f23b872dd00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000c7ac038a6706321a8033d504c6cc96b3636027ac81166024830152604482018390529192507f00000000000000000000000099090d2d220901de904c6e3d003d7ced4b6ec2a4909116906323b872dd90606401600060405180830381600087803b158015611cfb57600080fd5b505af1158015611d0f573d6000803e3d6000fd5b5050505050505b60405160009033906601c6bf52634000908381818185875af1925050503d8060008114611d5f576040519150601f19603f3d011682016040523d82523d6000602084013e611d64565b606091505b5050905080611db55760405162461bcd60e51b815260206004820152601560248201527f466169724d696e743a206d696e74206661696c656400000000000000000000006044820152606401610329565b505050505050505050505050610abf6001600655565b611dd36123f0565b60075460ff1615611e265760405162461bcd60e51b815260206004820152601960248201527f466169724d696e743a20616c72656164792073746172746564000000000000006044820152606401610329565b655af3107a4000341015611e7c5760405162461bcd60e51b815260206004820152601760248201527f466169724d696e743a2076616c756520746f6f206c6f770000000000000000006044820152606401610329565b3360009081526008602052604081208054349290611e9b908490612ee6565b9250508190555034600a6000828254611eb49190612ee6565b9091555050604080513481526000602082015233917f4c10b3a5590fcdc7a6f3b564c09870bd275facbd00a0bcf68c8b069e32f9508b910160405180910390a2610abf6001600655565b606060038054611f0d90613050565b80601f0160208091040260200160405190810160405280929190818152602001828054611f3990613050565b8015611f865780601f10611f5b57610100808354040283529160200191611f86565b820191906000526020600020905b815481529060010190602001808311611f6957829003601f168201915b5050505050905090565b600033611f9e81858561288b565b60019150505b92915050565b600033611fb8858285612898565b611fc3858585612433565b506001949350505050565b6000600a54600003611fe257506000919050565b600a5473ffffffffffffffffffffffffffffffffffffffff831660009081526008602052604081205490919060029061203b907f0000000000000000000000000000000000000000409f9cbc7c4a04c220000000612ecf565b6120459190612e52565b61204f9190612e52565b9392505050565b60007f00000000000000000000000082270e5b2827b9c6730037b729072d073ac8f36790508073ffffffffffffffffffffffffffffffffffffffff16638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156120c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120ea91906130a3565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146121645760405162461bcd60e51b815260206004820152601460248201527f466169724d696e743a206f6e6c79206f776e65720000000000000000000000006044820152606401610329565b50600d80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000001662ffffff92909216919091179055565b606060048054611f0d90613050565b600033611f9e818585612433565b60007f000000000000000000000000000000000000000000000001158e460913d00000600a54111561224457600a546000906122147f000000000000000000000000000000000000000000000001158e460913d0000082612ebc565b73ffffffffffffffffffffffffffffffffffffffff85166000908152600860205260409020546120459190612ecf565b506000919050565b6005805461225990613050565b80601f016020809104026020016040519081016040528092919081815260200182805461228590613050565b80156122d25780601f106122a7576101008083540402835291602001916122d2565b820191906000526020600020905b8154815290600101906020018083116122b557829003601f168201915b505050505081565b60007f00000000000000000000000082270e5b2827b9c6730037b729072d073ac8f36790508073ffffffffffffffffffffffffffffffffffffffff16638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561234a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061236e91906130a3565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146123e85760405162461bcd60e51b815260206004820152601460248201527f466169724d696e743a206f6e6c79206f776e65720000000000000000000000006044820152606401610329565b506000600b55565b60026006540361242c576040517f3ee5aeb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6002600655565b73ffffffffffffffffffffffffffffffffffffffff8316612483576040517f96c6fd1e00000000000000000000000000000000000000000000000000000000815260006004820152602401610329565b73ffffffffffffffffffffffffffffffffffffffff82166124d3576040517fec442f0500000000000000000000000000000000000000000000000000000000815260006004820152602401610329565b6124de838383612961565b505050565b73ffffffffffffffffffffffffffffffffffffffff8416612533576040517fe602df0500000000000000000000000000000000000000000000000000000000815260006004820152602401610329565b73ffffffffffffffffffffffffffffffffffffffff8316612583576040517f94280d6200000000000000000000000000000000000000000000000000000000815260006004820152602401610329565b73ffffffffffffffffffffffffffffffffffffffff80851660009081526001602090815260408083209387168352929052208290558015612626578273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258460405161261d91815260200190565b60405180910390a35b50505050565b60008080808073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2163010612696577f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2306126b9565b307f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc25b909550935073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc216301061272c578661272760027f0000000000000000000000000000000000000000409f9cbc7c4a04c220000000612e52565b612759565b61275760027f0000000000000000000000000000000000000000409f9cbc7c4a04c220000000612e52565b875b9093509150600061276a84846129e2565b600d546040517f13ead56200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8981166004830152888116602483015262ffffff909216604482015281831660648201529192508816906313ead562906084016020604051808303816000875af11580156127fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061281e91906130a3565b9150509295509295909350565b73ffffffffffffffffffffffffffffffffffffffff821661287b576040517f96c6fd1e00000000000000000000000000000000000000000000000000000000815260006004820152602401610329565b61288782600083612961565b5050565b6124de83838360016124e3565b73ffffffffffffffffffffffffffffffffffffffff8381166000908152600160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81146126265781811015612952576040517ffb8f41b200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff841660048201526024810182905260448101839052606401610329565b612626848484840360006124e3565b600081116129d75760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610329565b6124de838383612a8b565b600080831180156129f35750600082115b612a3f5760405162461bcd60e51b815260206004820152601e60248201527f416d6f756e7473206d7573742062652067726561746572207468616e203000006044820152606401610329565b600083612a5484670de0b6b3a7640000612ecf565b612a5e9190612e52565b90506000612a6b82612a96565b90506000612a81633b9aca00606084901b612e52565b9695505050505050565b6124de838383612afe565b600081600003612aa857506000919050565b816000612ab6600283612e52565b612ac1906001612ee6565b90505b81811015612af757905080600281612adc8187612e52565b612ae69190612ee6565b612af09190612e52565b9050612ac4565b5092915050565b73ffffffffffffffffffffffffffffffffffffffff8316612b36578060026000828254612b2b9190612ee6565b90915550612be89050565b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604090205481811015612bbc576040517fe450d38c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff851660048201526024810182905260448101839052606401610329565b73ffffffffffffffffffffffffffffffffffffffff841660009081526020819052604090209082900390555b73ffffffffffffffffffffffffffffffffffffffff8216612c1157600280548290039055612c3d565b73ffffffffffffffffffffffffffffffffffffffff821660009081526020819052604090208054820190555b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051612c9c91815260200190565b60405180910390a3505050565b60006020808352835180602085015260005b81811015612cd757858101830151858201604001528201612cbb565b5060006040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b73ffffffffffffffffffffffffffffffffffffffff81168114612d3857600080fd5b50565b60008060408385031215612d4e57600080fd5b8235612d5981612d16565b946020939093013593505050565b600060208284031215612d7957600080fd5b813561204f81612d16565b600080600060608486031215612d9957600080fd5b8335612da481612d16565b92506020840135612db481612d16565b929592945050506040919091013590565b600060208284031215612dd757600080fd5b813562ffffff8116811461204f57600080fd5b60008060408385031215612dfd57600080fd5b8235612e0881612d16565b91506020830135612e1881612d16565b809150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600082612e88577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b81810381811115611fa457611fa4612e23565b8082028115828204841417611fa457611fa4612e23565b80820180821115611fa457611fa4612e23565b815173ffffffffffffffffffffffffffffffffffffffff16815261016081016020830151612f3f602084018273ffffffffffffffffffffffffffffffffffffffff169052565b506040830151612f56604084018262ffffff169052565b506060830151612f6b606084018260020b9052565b506080830151612f80608084018260020b9052565b5060a083015160a083015260c083015160c083015260e083015160e083015261010080840151818401525061012080840151612fd38285018273ffffffffffffffffffffffffffffffffffffffff169052565b505061014092830151919092015290565b60008060008060808587031215612ffa57600080fd5b8451935060208501516fffffffffffffffffffffffffffffffff8116811461302157600080fd5b6040860151606090960151949790965092505050565b60006020828403121561304957600080fd5b5051919050565b600181811c9082168061306457607f821691505b60208210810361309d577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b6000602082840312156130b557600080fd5b815161204f81612d1656fea26469706673582212208880f2ec3b4ce7bf28d4a88cabffeaf3e6bedbef24fff6740e969bf69f3159fe64736f6c63430008180033
Verified Source Code Full Match
Compiler: v0.8.24+commit.e11b9ed9
EVM: paris
Optimization: Yes (20000 runs)
Meme.sol 20 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import {IMeme} from "./IMeme.sol";
import {ERC20} from "openzeppelin-contracts/contracts/token/ERC20/ERC20.sol";
contract Meme is IMeme, ERC20 {
string public override meta;
constructor(
string memory name,
string memory symbol,
string memory _meta) ERC20(name, symbol) {
meta = _meta;
}
function _update(address from, address to, uint256 value) internal virtual override {
super._update(from, to, value);
}
}
IMeme.sol 8 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import {IERC20Metadata} from "openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol";
interface IMeme is IERC20Metadata {
function meta() external view returns (string memory);
}
IFairLaunch.sol 47 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
interface IFairLaunch {
event Deployed(address indexed addr, uint256 _type);
event FundEvent(
address indexed to,
uint256 ethAmount,
uint256 amountOfTokens
);
event LaunchEvent(
address indexed to,
uint256 amount,
uint256 ethAmount,
uint256 liquidity
);
event RefundEvent(address indexed from, uint256 amount, uint256 eth);
}
struct FairLaunchLimitAmountStruct {
uint256 price;
uint256 amountPerUnits;
uint256 totalSupply;
address launcher;
address uniswapRouter;
address uniswapFactory;
string name;
string symbol;
string meta;
uint256 eachAddressLimitEthers;
uint256 refundFeeRate;
address refundFeeTo;
}
struct FairLaunchLimitBlockStruct {
uint256 totalSupply;
address uniswapRouter;
address uniswapFactory;
string name;
string symbol;
string meta;
uint256 afterBlock;
uint256 softTopCap;
uint256 refundFeeRate;
address refundFeeTo;
}
NoDelegateCall.sol 27 lines
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.19;
/// @title Prevents delegatecall to a contract
/// @notice Base contract that provides a modifier for preventing delegatecall to methods in a child contract
abstract contract NoDelegateCall {
/// @dev The original address of this contract
address private immutable original;
constructor() {
// Immutables are computed in the init code of the contract, and then inlined into the deployed bytecode.
// In other words, this variable won't change when it's checked at runtime.
original = address(this);
}
/// @dev Private method is used instead of inlining into modifier because modifiers are copied into each method,
/// and the use of immutable means the address bytes are copied in every place the modifier is used.
function checkNotDelegateCall() private view {
require(address(this) == original);
}
/// @notice Prevents delegatecall into the modified method
modifier noDelegateCall() {
checkNotDelegateCall();
_;
}
}
FairLaunchLimitBlockV3.sol 504 lines
// SPDX-License-Identifier: MIT
pragma solidity =0.8.24;
// IERC20
import {IERC20} from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol";
import {ReentrancyGuard} from "openzeppelin-contracts/contracts/utils/ReentrancyGuard.sol";
import {Meme} from "./Meme.sol";
import {IFairLaunch, FairLaunchLimitBlockStruct} from "./IFairLaunch.sol";
import {NoDelegateCall} from "./NoDelegateCall.sol";
import {IERC721} from "openzeppelin-contracts/contracts/token/ERC721/IERC721.sol";
interface IUniLocker {
function lock(
address lpToken,
uint256 amountOrId,
uint256 unlockBlock
) external returns (uint256 id);
}
interface IUniswapV3Factory {
function getPool(
address tokenA,
address tokenB,
uint24 fee
) external view returns (address pool);
function createPool(
address tokenA,
address tokenB,
uint24 fee
) external returns (address pool);
}
interface IFactory {
function owner() external view returns (address);
}
interface INonfungiblePositionManager {
function WETH9() external pure returns (address);
struct MintParams {
address token0;
address token1;
uint24 fee;
int24 tickLower;
int24 tickUpper;
uint256 amount0Desired;
uint256 amount1Desired;
uint256 amount0Min;
uint256 amount1Min;
address recipient;
uint256 deadline;
}
function mint(
MintParams calldata params
)
external
payable
returns (
uint256 tokenId,
uint128 liquidity,
uint256 amount0,
uint256 amount1
);
function createAndInitializePoolIfNecessary(
address token0,
address token1,
uint24 fee,
uint160 sqrtPriceX96
) external payable returns (address pool);
function refundETH() external payable;
}
contract FairLaunchLimitBlockTokenV3 is
IFairLaunch,
Meme,
ReentrancyGuard,
NoDelegateCall
{
using SafeERC20 for IERC20;
using Math for uint256;
// refund command
// before start, you can always refund
// send 0.0002 ether to the contract address to refund all ethers
uint256 public constant REFUND_COMMAND = 0.0002 ether;
// claim command
// after start, you can claim extra eth
// send 0.0002 ether to the contract address to claim extra eth
uint256 public constant CLAIM_COMMAND = 0.0002 ether;
// start trading command
// if the untilBlockNumber reached, you can start trading with this command
// send 0.0005 ether to the contract address to start trading
uint256 public constant START_COMMAND = 0.0005 ether;
// mint command
// if the untilBlockNumber reached, you can mint token with this command
// send 0.0001 ether to the contract address to get tokens
uint256 public constant MINT_COMMAND = 0.0001 ether;
// minimal fund
uint256 public constant MINIMAL_FUND = 0.0001 ether;
// is trading started
bool public started;
address public immutable uniswapPositionManager;
address public immutable uniswapFactory;
// fund balance
mapping(address => uint256) public fundBalanceOf;
// is address minted
mapping(address => bool) public minted;
// total dispatch amount
uint256 public immutable totalDispatch;
// until block number
uint256 public immutable untilBlockNumber;
// total ethers funded
uint256 public totalEthers;
// soft top cap
uint256 public immutable softTopCap;
// refund fee rate
uint256 public refundFeeRate;
// refund fee to
address public immutable refundFeeTo;
// is address claimed extra eth
mapping(address => bool) public claimed;
// recipient must be a contract address of IUniLocker
address public immutable locker;
// feePool
uint24 public poolFee;
// project owner, whill receive the locked lp
address public immutable projectOwner;
// fair launch factory
address public immutable factory;
// weth
address public immutable weth;
constructor(
address _locker,
uint24 _poolFee,
address _projectOwner,
FairLaunchLimitBlockStruct memory params
) Meme(params.name, params.symbol, params.meta) {
started = false;
totalDispatch = params.totalSupply;
_mint(address(this), totalDispatch);
// set uniswap router
uniswapPositionManager = params.uniswapRouter;
uniswapFactory = params.uniswapFactory;
meta = params.meta;
untilBlockNumber = params.afterBlock + block.number;
softTopCap = params.softTopCap;
refundFeeRate = params.refundFeeRate;
refundFeeTo = params.refundFeeTo;
locker = _locker;
projectOwner = _projectOwner;
poolFee = _poolFee;
factory = msg.sender;
weth = INonfungiblePositionManager(uniswapPositionManager).WETH9();
(address token0, address token1) = address(this) < weth
? (address(this), weth)
: (weth, address(this));
(uint256 amount0, uint256 amount1) = address(this) < weth
? (totalDispatch / 2, softTopCap)
: (softTopCap, totalDispatch / 2);
uint160 sqrtPriceX96 = getSqrtPriceX96(amount0, amount1);
INonfungiblePositionManager(uniswapPositionManager)
.createAndInitializePoolIfNecessary(
token0,
token1,
poolFee,
sqrtPriceX96
);
}
// set pool fee - for change pool fee
function setPoolFee(uint24 _poolFee) public {
IFactory _factory = IFactory(factory);
require(msg.sender == _factory.owner(), "FairMint: only owner");
poolFee = _poolFee;
}
// clear refund fee - for emergency refund
function clearRefundFee() public {
IFactory _factory = IFactory(factory);
require(msg.sender == _factory.owner(), "FairMint: only owner");
refundFeeRate = 0;
}
receive() external payable noDelegateCall {
if (msg.sender == uniswapPositionManager) {
return;
}
require(
tx.origin == msg.sender,
"FairMint: can not send command from contract."
);
if (started) {
// after started
if (msg.value == MINT_COMMAND) {
// mint token
_mintToken();
} else if (msg.value == CLAIM_COMMAND) {
_claimExtraETH();
} else {
revert("FairMint: invalid command - mint or claim only");
}
} else {
// before started
if (canStart()) {
if (msg.value == REFUND_COMMAND) {
// before start, you can always refund
_refund();
} else if (msg.value == START_COMMAND) {
// start trading, add liquidity to uniswap
_start();
} else {
revert("FairMint: invalid command - start or refund only");
}
} else {
if (msg.value == REFUND_COMMAND) {
// before start, you can always refund
_refund();
} else {
// before start, any other value will be considered as fund
_fund();
}
}
}
}
function canStart() public view returns (bool) {
// return block.number >= untilBlockNumber || totalEthers >= softTopCap;
// eth balance of this contract is more than zero
return block.number >= untilBlockNumber;
}
// get extra eth
function getExtraETH(address _addr) public view returns (uint256) {
if (totalEthers > softTopCap) {
uint256 claimAmount = (fundBalanceOf[_addr] *
(totalEthers - softTopCap)) / totalEthers;
return claimAmount;
}
return 0;
}
// claim extra eth
function _claimExtraETH() private nonReentrant {
// if the eth balance of this contract is more than soft top cap, withdraw it
// must after start
require(started, "FairMint: withdraw extra eth must after start");
require(softTopCap > 0, "FairMint: soft top cap must be set");
require(totalEthers > softTopCap, "FairMint: no extra eth");
uint256 extra = totalEthers - softTopCap;
uint256 fundAmount = fundBalanceOf[msg.sender];
require(fundAmount > 0, "FairMint: no fund");
require(!claimed[msg.sender], "FairMint: already claimed");
claimed[msg.sender] = true;
uint256 claimAmount = (fundAmount * extra) / totalEthers;
// send to msg sender
(bool success, ) = msg.sender.call{value: claimAmount + CLAIM_COMMAND}(
""
);
require(success, "FairMint: withdraw failed");
}
// estimate how many tokens you might get
function mightGet(address account) public view returns (uint256) {
if (totalEthers == 0) {
return 0;
}
uint256 _mintAmount = (totalDispatch * fundBalanceOf[account]) /
2 /
totalEthers;
return _mintAmount;
}
function _fund() private nonReentrant {
// require msg.value > 0.0001 ether
require(!started, "FairMint: already started");
require(msg.value >= MINIMAL_FUND, "FairMint: value too low");
fundBalanceOf[msg.sender] += msg.value;
totalEthers += msg.value;
emit FundEvent(msg.sender, msg.value, 0);
}
function _refund() private nonReentrant {
require(!started, "FairMint: already started");
address account = msg.sender;
uint256 amount = fundBalanceOf[account];
require(amount > 0, "FairMint: no fund");
fundBalanceOf[account] = 0;
totalEthers -= amount;
uint256 fee = (amount * refundFeeRate) / 10000;
assert(fee < amount);
if (fee > 0 && refundFeeTo != address(0)) {
(bool success, ) = refundFeeTo.call{value: fee}("");
require(success, "FairMint: refund fee failed");
}
(bool success1, ) = account.call{value: amount - fee + REFUND_COMMAND}(
""
);
require(success1, "FairMint: refund failed");
emit RefundEvent(account, 0, amount);
}
function _mintToken() private nonReentrant {
require(started, "FairMint: not started");
require(msg.sender == tx.origin, "FairMint: can not mint to contract.");
require(!minted[msg.sender], "FairMint: already minted");
minted[msg.sender] = true;
uint256 _mintAmount = mightGet(msg.sender);
require(_mintAmount > 0, "FairMint: mint amount is zero");
assert(_mintAmount <= totalDispatch / 2);
_transfer(address(this), msg.sender, _mintAmount);
(bool success, ) = msg.sender.call{value: MINT_COMMAND}("");
require(success, "FairMint: mint failed");
}
function _start() private nonReentrant {
require(!started, "FairMint: already started");
require(balanceOf(address(this)) > 0, "FairMint: no balance");
INonfungiblePositionManager _positionManager = INonfungiblePositionManager(
uniswapPositionManager
);
uint256 totalAdd = softTopCap > 0
? softTopCap < totalEthers ? softTopCap : totalEthers
: totalEthers;
_approve(
address(this),
uniswapPositionManager,
type(uint256).max,
false
);
(
address token0,
address token1,
uint256 amount0,
uint256 amount1,
) = _initPool(totalAdd, _positionManager);
INonfungiblePositionManager.MintParams memory params = INonfungiblePositionManager
.MintParams({
token0: token0,
token1: token1,
fee: poolFee,
tickLower: -887220, // 887250
tickUpper: 887220,
amount0Desired: amount0,
amount1Desired: amount1,
amount0Min: weth == token0 ? (amount0 * 9800) / 10000 : 0,
amount1Min: weth == token1 ? (amount1 * 9800) / 10000 : 0,
recipient: locker == address(0) ? address(0) : address(this),
deadline: block.timestamp + 1 hours
});
(
uint256 tokenId,
uint128 liquidity,
uint256 _amount0,
uint256 _amount1
) = _positionManager.mint{value: totalAdd}(params);
_positionManager.refundETH();
started = true;
// drop all of the rest tokens to zero
if (
IERC20(address(this)).balanceOf(address(this)) > totalDispatch / 2
) {
_burn(address(this), balanceOf(address(this)) - totalDispatch / 2);
}
emit LaunchEvent(address(this), _amount0, _amount1, liquidity);
// lock lp into contract forever
if (locker != address(0)) {
IERC721(uniswapPositionManager).approve(locker, tokenId);
IUniLocker _locker = IUniLocker(locker);
uint256 _lockId = _locker.lock(
uniswapPositionManager,
tokenId,
type(uint256).max
);
IERC721(locker).transferFrom(address(this), projectOwner, _lockId);
}
// mint token
(bool success, ) = msg.sender.call{value: START_COMMAND}("");
require(success, "FairMint: mint failed");
}
function _initPool(
uint256 totalAdd,
INonfungiblePositionManager _positionManager
)
private
returns (
address token0,
address token1,
uint256 amount0,
uint256 amount1,
address pool
)
{
(token0, token1) = address(this) < weth
? (address(this), weth)
: (weth, address(this));
(amount0, amount1) = address(this) < weth
? (totalDispatch / 2, totalAdd)
: (totalAdd, totalDispatch / 2);
uint160 sqrtPriceX96 = getSqrtPriceX96(amount0, amount1);
pool = _positionManager.createAndInitializePoolIfNecessary(
token0,
token1,
poolFee,
sqrtPriceX96
);
}
function _update(
address from,
address to,
uint256 value
) internal override {
require(value > 0, "ERC20: transfer from the zero address");
super._update(from, to, value);
}
function getSqrtPriceX96(
uint256 amount0,
uint256 amount1
) internal pure returns (uint160) {
require(amount0 > 0 && amount1 > 0, "Amounts must be greater than 0");
uint256 price = (amount1 * 1e18) / amount0;
uint256 sqrtPrice = price.sqrt();
uint256 sqrtPriceX96Full = (sqrtPrice << 96) / 1e9;
return uint160(sqrtPriceX96Full);
}
}
library Math {
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) return 0;
uint256 result = a;
uint256 k = a / 2 + 1;
while (k < result) {
result = k;
k = (a / k + k) / 2;
}
return result;
}
}
Address.sol 159 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error AddressInsufficientBalance(address account);
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedInnerCall();
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert AddressInsufficientBalance(address(this));
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert FailedInnerCall();
}
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {FailedInnerCall} error.
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert AddressInsufficientBalance(address(this));
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
* unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {FailedInnerCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
*/
function _revert(bytes memory returndata) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert FailedInnerCall();
}
}
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
ERC20.sol 316 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.sol";
import {IERC20Metadata} from "./extensions/IERC20Metadata.sol";
import {Context} from "../../utils/Context.sol";
import {IERC20Errors} from "../../interfaces/draft-IERC6093.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}.
*
* 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].
*
* The default value of {decimals} is 18. To change this, you should override
* this function so it returns a different value.
*
* 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.
*/
abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {
mapping(address account => uint256) private _balances;
mapping(address account => mapping(address spender => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* 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 returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev 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 default value returned by this function, unless
* it's 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 returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual 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 `value`.
*/
function transfer(address to, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_transfer(owner, to, value);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `value` 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 value) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, value);
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 `value`.
* - the caller must have allowance for ``from``'s tokens of at least
* `value`.
*/
function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, value);
_transfer(from, to, value);
return true;
}
/**
* @dev Moves a `value` 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.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _transfer(address from, address to, uint256 value) internal {
if (from == address(0)) {
revert ERC20InvalidSender(address(0));
}
if (to == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(from, to, value);
}
/**
* @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
* (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
* this function.
*
* Emits a {Transfer} event.
*/
function _update(address from, address to, uint256 value) internal virtual {
if (from == address(0)) {
// Overflow check required: The rest of the code assumes that totalSupply never overflows
_totalSupply += value;
} else {
uint256 fromBalance = _balances[from];
if (fromBalance < value) {
revert ERC20InsufficientBalance(from, fromBalance, value);
}
unchecked {
// Overflow not possible: value <= fromBalance <= totalSupply.
_balances[from] = fromBalance - value;
}
}
if (to == address(0)) {
unchecked {
// Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
_totalSupply -= value;
}
} else {
unchecked {
// Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
_balances[to] += value;
}
}
emit Transfer(from, to, value);
}
/**
* @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
* Relies on the `_update` mechanism
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _mint(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(address(0), account, value);
}
/**
* @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
* Relies on the `_update` mechanism.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead
*/
function _burn(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidSender(address(0));
}
_update(account, address(0), value);
}
/**
* @dev Sets `value` 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.
*
* Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
*/
function _approve(address owner, address spender, uint256 value) internal {
_approve(owner, spender, value, true);
}
/**
* @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
*
* By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
* `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any
* `Approval` event during `transferFrom` operations.
*
* Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to
* true using the following override:
* ```
* function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
* super._approve(owner, spender, value, true);
* }
* ```
*
* Requirements are the same as {_approve}.
*/
function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
if (owner == address(0)) {
revert ERC20InvalidApprover(address(0));
}
if (spender == address(0)) {
revert ERC20InvalidSpender(address(0));
}
_allowances[owner][spender] = value;
if (emitEvent) {
emit Approval(owner, spender, value);
}
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `value`.
*
* Does not update the allowance value in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Does not emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
if (currentAllowance < value) {
revert ERC20InsufficientAllowance(spender, currentAllowance, value);
}
unchecked {
_approve(owner, spender, currentAllowance - value, false);
}
}
}
}
IERC20.sol 79 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @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 value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
IERC721.sol 135 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
* a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must have been allowed to move this token by either {approve} or
* {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
* a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
* or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
* understand this adds an external call which potentially creates a reentrancy vulnerability.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the address zero.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
}
ReentrancyGuard.sol 84 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
uint256 private _status;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
constructor() {
_status = NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be NOT_ENTERED
if (_status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
_status = ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == ENTERED;
}
}
draft-IERC6093.sol 161 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard ERC20 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.
*/
interface IERC20Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC20InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC20InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
* @param spender Address that may be allowed to operate on tokens without being their owner.
* @param allowance Amount of tokens a `spender` is allowed to operate with.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC20InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `spender` to be approved. Used in approvals.
* @param spender Address that may be allowed to operate on tokens without being their owner.
*/
error ERC20InvalidSpender(address spender);
}
/**
* @dev Standard ERC721 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.
*/
interface IERC721Errors {
/**
* @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.
* Used in balance queries.
* @param owner Address of the current owner of a token.
*/
error ERC721InvalidOwner(address owner);
/**
* @dev Indicates a `tokenId` whose `owner` is the zero address.
* @param tokenId Identifier number of a token.
*/
error ERC721NonexistentToken(uint256 tokenId);
/**
* @dev Indicates an error related to the ownership over a particular token. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param tokenId Identifier number of a token.
* @param owner Address of the current owner of a token.
*/
error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC721InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC721InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param tokenId Identifier number of a token.
*/
error ERC721InsufficientApproval(address operator, uint256 tokenId);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC721InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC721InvalidOperator(address operator);
}
/**
* @dev Standard ERC1155 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens.
*/
interface IERC1155Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
* @param tokenId Identifier number of a token.
*/
error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC1155InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC1155InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param owner Address of the current owner of a token.
*/
error ERC1155MissingApprovalForAll(address operator, address owner);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC1155InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC1155InvalidOperator(address operator);
/**
* @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
* Used in batch transfers.
* @param idsLength Length of the array of token identifiers
* @param valuesLength Length of the array of token amounts
*/
error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}
SafeERC20.sol 118 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev An operation with an ERC20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data);
if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
}
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @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);
}
IERC20Permit.sol 90 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*
* CAUTION: See Security Considerations above.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}
IERC20Metadata.sol 26 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*/
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
CLAIM_COMMAND 0xfb5d5d4d → uint256
MINIMAL_FUND 0x9ecf0090 → uint256
MINT_COMMAND 0x475a519f → uint256
REFUND_COMMAND 0x996eba2d → uint256
START_COMMAND 0x82552170 → uint256
allowance 0xdd62ed3e → uint256
balanceOf 0x70a08231 → uint256
canStart 0xec309038 → bool
claimed 0xc884ef83 → bool
decimals 0x313ce567 → uint8
factory 0xc45a0155 → address
fundBalanceOf 0xd35e7efc → uint256
getExtraETH 0xa92bc58a → uint256
locker 0xd7b96d4e → address
meta 0xc885044e → string
mightGet 0x68b63c24 → uint256
minted 0x1e7269c5 → bool
name 0x06fdde03 → string
poolFee 0x089fe6aa → uint24
projectOwner 0xa4475ce4 → address
refundFeeRate 0x32c4f2bf → uint256
refundFeeTo 0x544d46a3 → address
softTopCap 0xf570ee6b → uint256
started 0x1f2698ab → bool
symbol 0x95d89b41 → string
totalDispatch 0x7b0fa954 → uint256
totalEthers 0x0a4625af → uint256
totalSupply 0x18160ddd → uint256
uniswapFactory 0x8bdb2afa → address
uniswapPositionManager 0xe5047b30 → address
untilBlockNumber 0x5ce38d99 → uint256
weth 0x3fc8cef3 → address
Write Contract 5 functions
These functions modify contract state and require a wallet transaction to execute.
approve 0x095ea7b3
address spender
uint256 value
returns: bool
clearRefundFee 0xf1962486
No parameters
setPoolFee 0x73dd250c
uint24 _poolFee
transfer 0xa9059cbb
address to
uint256 value
returns: bool
transferFrom 0x23b872dd
address from
address to
uint256 value
returns: bool
Recent Transactions
No transactions found for this address