Address Contract Verified
Address
0x2c7aE5688199c56eFc8766084a426392d34A3ff9
Balance
0 ETH
Nonce
4
Code Size
10163 bytes
Creator
0xAA864b71...49Ec at tx 0x2e1c8a60...b02c65
Indexed Transactions
0
Contract Bytecode
10163 bytes
0x6080806040526004361015610012575f80fd5b5f3560e01c9081630a09c89c14610fdb57508063103db6da14610fb557806313a3bc4b14610f6257806315d05a5314610b175780632cf9942214610af45780634d24f5b214610aab5780634eeb55f71461091b57806368637695146108fe57806380bdd4b81461087957806396ce07951461085d578063a176459514610819578063b7d1f8cf146106a5578063bc3506fa1461064b578063bd62039a1461062a578063cab63661146105e1578063cefe23c81461059d578063d7da0abd146101c1578063eb3611d91461017d578063f0a8d51a14610155578063f2d2a751146101245763f462901614610103575f80fd5b34610120575f366003190112610120576020600554604051908152f35b5f80fd5b34610120576040366003190112610120576003546001600160a01b0316330361012057600480359055602435600555005b34610120575f366003190112610120576003546040516001600160a01b039091168152602090f35b34610120575f366003190112610120576040517f0000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f6001600160a01b03168152602090f35b34610120576020366003190112610120576001600160a01b036101e2610ffe565b16805f52600160205260405f20604051906101fc82611066565b805482526001810154602083015260028101546040830152600381015490606083019260018060a01b038316845260ff608082019360a01c1615158352600482015460a082015260e061025d600660058501549460c0850195865201611131565b91015282516001600160a01b0316330361056a57516301e1338081018091116105565742111561051157516104db577f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316828110156104d457825b6040519060208201926001600160601b03199060601b1683526001600160601b03199060601b166034820152602881526102fb60488261109f565b51902060405190602082019060ff60f81b82526001600160601b03197f0000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f60601b16602184015260358301527f96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f60558301526055825261037b60758361109f565b905190206040516370a0823160e01b8152306004820152916001600160a01b0390911690602083602481855afa928315610492575f9361049d575b505160405163a9059cbb60e01b81526001600160a01b0390911660048201526024810183905290602090829060449082905f905af1908115610492575f91610463575b501561042c5760207fb244b9a17ad633c6e83b7983ee04320484956a68ddbe96a0b70dfca1cf19d72391604051908152a2005b60405162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c8819985a5b1959608a1b6044820152606490fd5b610485915060203d60201161048b575b61047d818361109f565b8101906111d8565b836103f9565b503d610473565b6040513d5f823e3d90fd5b909192506020813d6020116104cc575b816104ba6020938361109f565b810103126101205751919060206103b6565b3d91506104ad565b82906102c0565b60405162461bcd60e51b815260206004820152600e60248201526d185b1c9958591e48189d5c9b995960921b6044820152606490fd5b60405162461bcd60e51b815260206004820152601860248201527f6e6f742074696d6520746f2077697468647261772079657400000000000000006044820152606490fd5b634e487b7160e01b5f52601160045260245ffd5b60405162461bcd60e51b815260206004820152600b60248201526a3737ba1031b932b0ba37b960a91b6044820152606490fd5b34610120575f366003190112610120576040517f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b03168152602090f35b34610120576020366003190112610120576004356001600160a01b0381169081900361012057600354336001600160a01b03821603610120576001600160a01b03191617600355005b34610120575f366003190112610120576020604051668e1bc9bf0400008152f35b3461012057604036600319011261012057610664610ffe565b602435906001600160a01b0382168203610120576001600160a01b039081165f90815260208181526040808320949093168252928352819020549051908152f35b34610120576040366003190112610120576004356001600160a01b036106c9611014565b1690815f52600160205260405f206106e66004820154421161125c565b6106f760016005830154141561121b565b5f838152602081815260408083203384529091529020546107e65781156107ac575f8381526020818152604080832033845290915290208290556006018054600160401b81101561079857610751916001820181556112f9565b81549060031b9033821b9160018060a01b03901b19161790556040519081527ffc00f587be42d08396df8a70d85838b17242cdfb83c99d552c843d88c77ef87460203392a3005b634e487b7160e01b5f52604160045260245ffd5b60405162461bcd60e51b8152602060048201526012602482015271070726963652063616e206e6f7420626520360741b6044820152606490fd5b60405162461bcd60e51b815260206004820152600b60248201526a185b1c9958591e48189a5960aa1b6044820152606490fd5b34610120575f366003190112610120576040517f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b03168152602090f35b34610120575f3660031901126101205760206040516127108152f35b34610120576020366003190112610120576001600160a01b0361089a610ffe565b165f52600160205260e060405f2080549060018101549060ff600282015460038301549060056004850154940154946040519687526020870152604086015260018060a01b038116606086015260a01c161515608084015260a083015260c0820152f35b34610120575f366003190112610120576020600454604051908152f35b34610120576040366003190112610120576004356001600160a01b0361093f611014565b1690815f5260016020526109d1600160405f206109c960405161096181611066565b825481528383015460208201526002830154604082015260ff6003840154858060a01b038116606084015260a01c161515608082015260048301549060a0810191825260e06109be600660058701549660c0850197885201611131565b91015251421161125c565b51141561121b565b5f828152602081815260408083203384529091529020548015610a7757811115610a4257815f525f60205260405f2060018060a01b0333165f526020528060405f20556040519081527f0a3381f6dda336379973c90a4ba9024301ba841c3c68b1e0a1501004f96d6caf60203392a3005b60405162461bcd60e51b815260206004820152600d60248201526c31b0b7103737ba103637bbb2b960991b6044820152606490fd5b60405162461bcd60e51b815260206004820152600c60248201526b1a185d99481b9bdd08189a5960a21b6044820152606490fd5b34610120576020366003190112610120576004356001600160a01b0381169081900361012057600254336001600160a01b03821603610120576001600160a01b03191617600255005b3461012057602036600319011261012057610b15610b10610ffe565b611379565b005b60e03660031901126101205760043567ffffffffffffffff811161012057610b439036906004016110dd565b60243567ffffffffffffffff811161012057610b639036906004016110dd565b90604435906064359160843560a43560c435908115158092036101205742811115610f1d5783861115610ed957668e1bc9bf040000341115610e8957604051610a1780820182811067ffffffffffffffff821117610798578291611d67833960608152886040610be7610bd9606085018c6111a7565b84810360208601528d6111a7565b92015203905ff092831561049257668e1bc9bf03ffff19340193348511610556575f808080668e1bc9bf04000060018060a01b036003541682f1156104925760405163095ea7b360e01b81526001600160a01b037f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81166004830152602482018a90529190911697906020816044815f8d5af1801561049257610e6c575b506020988960068886868d8a8c60405197610ca0818a61109f565b5f89525f36813760405196610cb488611066565b87526001818801918c835260408901938452606089019533875260808a0195865260a08a0197885260c08a0198895260e08a019b8c525f525260405f2096518755516001870155516002860155600385019160018060a01b039051166001600160601b0360a01b83541617825551151581549060ff60a01b9060a01b169060ff60a01b19161790555160048301555160058201550190519081519167ffffffffffffffff831161079857600160401b8311610798578c90825484845584818110610e42575b505091818d9c9b9a99989796959394929401905f52835f205f5b838110610e22575050505091610df1610de4989694927f707bc57678fcadb8863a3e15dde19ce9fbd79a5aff2ecc8cde359d1efbdfa3789a9896946040519a8b9a6101208c526101208c01906111a7565b918a8303908b01526111a7565b9560408801526060870152608086015260a085015260c084015260e0830152336101008301520390a2604051908152f35b82516001600160a01b0316818301558e9d508f9590920191600101610d93565b50835f5284835f2091820191015b818110610e5e575084610d79565b5f81558f9350600101610e50565b610e849060203d60201161048b5761047d818361109f565b610c85565b60405162461bcd60e51b815260206004820152602260248201527f657468206c657373207468616e2061756374696f6e5f6372656174696f6e5f66604482015261656560f01b6064820152608490fd5b606460405162461bcd60e51b815260206004820152602060248201527f7265717569726520746f74616c537570706c79203e206f6e6365416d6f756e746044820152fd5b60405162461bcd60e51b815260206004820152601960248201527f72657175697265207075626c69736854696d65203e206e6f77000000000000006044820152606490fd5b34610120576020366003190112610120576001600160a01b03610f83610ffe565b165f526001602052610fb1610f9d600660405f2001611131565b60405191829160208352602083019061102a565b0390f35b34610120576020366003190112610120576020610fd3600435611123565b604051908152f35b34610120575f366003190112610120576002546001600160a01b03168152602090f35b600435906001600160a01b038216820361012057565b602435906001600160a01b038216820361012057565b90602080835192838152019201905f5b8181106110475750505090565b82516001600160a01b031684526020938401939092019160010161103a565b610100810190811067ffffffffffffffff82111761079857604052565b6040810190811067ffffffffffffffff82111761079857604052565b90601f8019910116810190811067ffffffffffffffff82111761079857604052565b67ffffffffffffffff811161079857601f01601f191660200190565b81601f82011215610120578035906110f4826110c1565b92611102604051948561109f565b8284526020838301011161012057815f926020809301838601378301015290565b8061112b5790565b5f190190565b90604051918281549182825260208201905f5260205f20925f5b8181106111625750506111609250038361109f565b565b84546001600160a01b031683526001948501948794506020909301920161114b565b6020906060518082528060808484015e5f828201840152601f01601f1916010190565b805180835260209291819084018484015e5f828201840152601f01601f1916010190565b9190820391821161055657565b90816020910312610120575180151581036101205790565b67ffffffffffffffff81116107985760051b60200190565b8181029291811591840414171561055657565b1561122257565b60405162461bcd60e51b8152602060048201526012602482015271185b1c9958591e48081c1d589b1a5cda195960721b6044820152606490fd5b1561126357565b60405162461bcd60e51b8152602060048201526011602482015270189a59191a5b99c81b9bdd081cdd185c9d607a1b6044820152606490fd5b9190820180921161055657565b90816060910312610120578051916040602083015192015190565b8051156112d15760200190565b634e487b7160e01b5f52603260045260245ffd5b80518210156112d15760209160051b010190565b80548210156112d1575f5260205f2001905f90565b3d15611338573d9061131f826110c1565b9161132d604051938461109f565b82523d5f602084013e565b606090565b60146020611160928195946040519682889351918291018585015e8201906001600160601b031916838201520301600b1981018552018361109f565b9060018060a01b0382165f52600160205260405f2091600583015442811015611c485760016113a991141561121b565b6113b84260048501541061125c565b60608061012c420193844211610556576006860193845415611b3657600287015460018089015460405163f305d71960e01b81526001600160a01b038581166004830152602482019290925260448101839052606481019290925230608483015260a482018990527f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d1693918690829060c4908290885af1801561049257611b09575b506040519161146a868461109f565b60028352601f1986013660208501377f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b03166114ac846112c4565b528251600110156112d1576001600160a01b038116604084015286546114d1816111f0565b976114df604051998a61109f565b818952601f196114ee836111f0565b015f5b818110611ae55750505f5b828110611a5f57505050865160018111611a43575b505f989796958995869590915b885180891015611a31575f198101908111610556578861153d916111cb565b9b6115488d8b6112e5565b51519c611555908b6112e5565b51602001518d60405160208101916323b872dd60e01b8352600160a01b600190031660248201523060448201528260648201526064815261159760848261109f565b517f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316905a925f8094938194f16115d461130e565b5015611a09575f808f8f8f918c61163f9161161c9354946040519485936020850197634401edf760e11b895260248601528a604486015260a0606486015260c485019061102a565b6001600160a01b03909216608484015260a483015203601f19810183528261109f565b519082885af161164d61130e565b90156117fa5780518101906020818184019303126101205760208101519067ffffffffffffffff821161012057019080603f8301121561012057602082015190611696826111f0565b926116a4604051948561109f565b8284526020808086019460051b8301010191821161012057604001915b8183106117ea575050506117356117299a9b9c9d9e9f9361172f6116f561176697956116ee6020966112c4565b51906111cb565b9161271061170560055485611208565b049d8e9361172461271061171b60045484611208565b049586926111cb565b6111cb565b9061129c565b9c61129c565b60405163a9059cbb60e01b81526001600160a01b0385166004820152602481019b909b529993849081906044820190565b03815f7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b03165af1918215610492576001936117c1936117ce575b5060601b6bffffffffffffffffffffffff19169061133d565b985b01969a99989761151e565b6117e59060203d811161048b5761047d818361109f565b6117a8565b82518152602092830192016116c1565b5060405163a9059cbb60e01b81526001600160a01b03909e1660048f015260248e0152949b939a949950919750909550919392509050602081806044810103815f7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b03165af18015610492576119ed575b505b60025460405163a9059cbb60e01b81526001600160a01b0391821660048201526024810196909652602090869060449082905f907f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2165af190811561049257611916956020926119d2575b50600383015460405163a9059cbb60e01b81526001600160a01b039091166004820152602481019190915294859081906044820190565b03815f7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b03165af192831561049257600160056119a4937ff694ca8568a92fd9002bda521627e02434dcb64414127600fd9c73a3f6b4661597611996976119b5575b5001556040519384936040855260408501906111a7565b9083820360208501526111a7565b6001600160a01b03909416930390a2565b6119cd9060203d60201161048b5761047d818361109f565b61197f565b6119e890833d851161048b5761047d818361109f565b6118df565b611a049060203d811161048b5761047d818361109f565b611872565b509792611a2b906001929a9b9c9d6001600160601b03199060601b169061133d565b926117c3565b50965050955096929150969450611874565b5f19810190811161055657611a59905f89611c85565b5f611511565b80611a6c600192846112f9565b838060a01b0391549060031b1c16828060a01b0386165f525f60205260405f20611a9683866112f9565b858060a01b0391549060031b1c16848060a01b03165f5260205260405f205460405191611ac283611083565b82526020820152611ad3828d6112e5565b52611ade818c6112e5565b50016114fc565b808b6020809360405192611af884611083565b5f84525f83850152010152016114f1565b611b2890863d8811611b2f575b611b20818361109f565b8101906112a9565b505061145b565b503d611b16565b60016005880181905560028801549781015460405163f305d71960e01b81526001600160a01b0384166004820152602481019190915260448101829052606481019190915230608482015260a4810196909652909590949293508391508290818060c4810103917f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b03165af1801561049257611c2c575b50507ff694ca8568a92fd9002bda521627e02434dcb64414127600fd9c73a3f6b466156040516040815280611c27611c0e60408301611184565b82810360208401526001600160a01b0390951694611184565b0390a2565b81611c4292903d10611b2f57611b20818361109f565b50611bd4565b60405162461bcd60e51b81526020600482015260156024820152740dcdee840e4cac2c8f240ccdee440e0eac4d8d2e6d605b1b6044820152606490fd5b929091906020611c9c84840360011c8501866112e5565b5101519282815b856020611cb0838a6112e5565b5101511015611cc157600101611ca3565b935b6020611ccf82896112e5565b510151861015611ce757611ce290611123565b611cc3565b9493858111611d30576001611d2991611d00888a6112e5565b51611d0b828b6112e5565b51611d168a8c6112e5565b52611d21828b6112e5565b520195611123565b9394611ca3565b919295949350808210611d55575b5050818110611d4c57505050565b61116092611c85565b611d5f9185611c85565b5f80611d3e56fe60806040523461039557610a178038038061001981610399565b9283398101906060818303126103955780516001600160401b03811161039557826100459183016103be565b60208201519092906001600160401b038111610395576040916100699184016103be565b91015182516001600160401b0381116102a657600354600181811c9116801561038b575b602082101461028857601f8111610328575b506020601f82116001146102c557819293945f926102ba575b50508160011b915f199060031b1c1916176003555b81516001600160401b0381116102a657600454600181811c9116801561029c575b602082101461028857601f8111610225575b50602092601f82116001146101c457928192935f926101b9575b50508160011b915f199060031b1c1916176004555b33156101a65760025481810180911161019257600255335f525f60205260405f208181540190556040519081525f7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60203393a360405161060790816104108239f35b634e487b7160e01b5f52601160045260245ffd5b63ec442f0560e01b5f525f60045260245ffd5b015190505f8061011a565b601f1982169360045f52805f20915f5b86811061020d57508360019596106101f5575b505050811b0160045561012f565b01515f1960f88460031b161c191690555f80806101e7565b919260206001819286850151815501940192016101d4565b60045f527f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b601f830160051c8101916020841061027e575b601f0160051c01905b8181106102735750610100565b5f8155600101610266565b909150819061025d565b634e487b7160e01b5f52602260045260245ffd5b90607f16906100ee565b634e487b7160e01b5f52604160045260245ffd5b015190505f806100b8565b601f1982169060035f52805f20915f5b818110610310575095836001959697106102f8575b505050811b016003556100cd565b01515f1960f88460031b161c191690555f80806102ea565b9192602060018192868b0151815501940192016102d5565b60035f527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b601f830160051c81019160208410610381575b601f0160051c01905b818110610376575061009f565b5f8155600101610369565b9091508190610360565b90607f169061008d565b5f80fd5b6040519190601f01601f191682016001600160401b038111838210176102a657604052565b81601f82011215610395578051906001600160401b0382116102a6576103ed601f8301601f1916602001610399565b928284526020838301011161039557815f9260208093018386015e830101529056fe6080806040526004361015610012575f80fd5b5f3560e01c90816306fdde03146103ef57508063095ea7b31461036d57806318160ddd1461035057806323b872dd14610271578063313ce5671461025657806370a082311461021f57806395d89b4114610104578063a9059cbb146100d35763dd62ed3e1461007f575f80fd5b346100cf5760403660031901126100cf576100986104e8565b6100a06104fe565b6001600160a01b039182165f908152600160209081526040808320949093168252928352819020549051908152f35b5f80fd5b346100cf5760403660031901126100cf576100f96100ef6104e8565b6024359033610514565b602060405160018152f35b346100cf575f3660031901126100cf576040515f6004548060011c90600181168015610215575b602083108114610201578285529081156101e55750600114610190575b50819003601f01601f191681019067ffffffffffffffff82118183101761017c57610178829182604052826104be565b0390f35b634e487b7160e01b5f52604160045260245ffd5b905060045f527f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b5f905b8282106101cf57506020915082010182610148565b60018160209254838588010152019101906101ba565b90506020925060ff191682840152151560051b82010182610148565b634e487b7160e01b5f52602260045260245ffd5b91607f169161012b565b346100cf5760203660031901126100cf576001600160a01b036102406104e8565b165f525f602052602060405f2054604051908152f35b346100cf575f3660031901126100cf57602060405160128152f35b346100cf5760603660031901126100cf5761028a6104e8565b6102926104fe565b6001600160a01b0382165f818152600160209081526040808320338452909152902054909260443592915f1981106102d0575b506100f99350610514565b83811061033557841561032257331561030f576100f9945f52600160205260405f2060018060a01b0333165f526020528360405f2091039055846102c5565b634a1406b160e11b5f525f60045260245ffd5b63e602df0560e01b5f525f60045260245ffd5b8390637dc7a0d960e11b5f523360045260245260445260645ffd5b346100cf575f3660031901126100cf576020600254604051908152f35b346100cf5760403660031901126100cf576103866104e8565b602435903315610322576001600160a01b031690811561030f57335f52600160205260405f20825f526020528060405f20556040519081527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560203392a3602060405160018152f35b346100cf575f3660031901126100cf575f6003548060011c906001811680156104b4575b602083108114610201578285529081156101e5575060011461045f5750819003601f01601f191681019067ffffffffffffffff82118183101761017c57610178829182604052826104be565b905060035f527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b5f905b82821061049e57506020915082010182610148565b6001816020925483858801015201910190610489565b91607f1691610413565b602060409281835280519182918282860152018484015e5f828201840152601f01601f1916010190565b600435906001600160a01b03821682036100cf57565b602435906001600160a01b03821682036100cf57565b6001600160a01b03169081156105be576001600160a01b03169182156105ab57815f525f60205260405f205481811061059257817fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92602092855f525f84520360405f2055845f525f825260405f20818154019055604051908152a3565b8263391434e360e21b5f5260045260245260445260645ffd5b63ec442f0560e01b5f525f60045260245ffd5b634b637e8f60e11b5f525f60045260245ffdfea26469706673582212200d255a8ea2d10019bd36684484c49aaa3a4651ae126e3a36473655b2c5c6383e64736f6c634300081c0033a26469706673582212207026418376368b2b9c7e8526b476be2ddb2b42b8adad3acdb538ad2861237dc764736f6c634300081c0033
Verified Source Code Full Match
Compiler: v0.8.28+commit.7893614a
EVM: cancun
Optimization: Yes (200 runs)
PreSale_pre_prod.sol 246 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
import {IPreSale, MemeToken} from "./IPreSale.sol";
import "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol";
import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "./Lib.sol";
contract PreSale is IPreSale {
mapping(MemeToken => mapping(address => uint)) public _bids;
mapping(MemeToken => Auction) public _auctions;
IERC20 immutable public _weth;
address immutable public _uniFactory;
IUniswapV2Router02 immutable public _uniRouter2;
address payable public _feeReceipt;
address payable public _publisher;
uint constant public denominator = 10000;
uint public starter_fee_rate = 2000;
uint public user_fee_rate = 7900;
uint constant public auction_creation_fee = 4 ether / 100;
constructor(IUniswapV2Router02 uniRouter2, address feeReceipt, address publisher) {
_weth = IERC20(uniRouter2.WETH());
_uniRouter2 = uniRouter2;
_uniFactory = _uniRouter2.factory();
_feeReceipt = payable(feeReceipt);
_publisher = payable(publisher);
_weth.approve(address(_uniRouter2), 2 ** 200);
}
function setFeeReceipt(address payable newFeeRec) external {
require(_feeReceipt == msg.sender);
_feeReceipt = newFeeRec;
}
function setPublisher(address payable newPub) external {
require(_publisher == msg.sender);
_publisher = newPub;
}
function setFeeRate(uint _starter_fee_rate ,uint _user_fee_rate) external {
require(_publisher == msg.sender);
starter_fee_rate = _starter_fee_rate;
user_fee_rate = _user_fee_rate;
}
// function init() external {
//
// }
function createAuction(
string memory name,
string memory symbol,
uint256 onceAmount,
uint256 totalSupply,
uint startTime,
uint publishTime,
bool isBurnLpToken
) external payable returns (MemeToken) {
require(publishTime > block.timestamp, "require publishTime > now");
require(totalSupply > onceAmount, "require totalSupply > onceAmount");
require(msg.value > auction_creation_fee, "eth less than auction_creation_fee");
// require(totalSupply % onceAmount == 0, "require totalSupply is multiple onceAmount");
// todo update to proxy
MemeToken token = new MemeToken(name, symbol, totalSupply);
uint256 trueValue = msg.value - auction_creation_fee;
_publisher.transfer(auction_creation_fee);
token.approve(address(_uniRouter2), totalSupply);
_auctions[token] = Auction(onceAmount, totalSupply, trueValue, msg.sender, isBurnLpToken, startTime, publishTime, new address[](0));
emit AuctionCreated(token, name, symbol, onceAmount, totalSupply, startTime, publishTime, isBurnLpToken, trueValue, msg.sender);
return token;
}
function getBidders(MemeToken token) external view returns (address[] memory) {
return _auctions[token].bidders;
}
function newBid(uint256 amount, MemeToken token) external {
Auction storage auction = _auctions[token];
// require(auction.publishTime + 60 > block.timestamp, "bidding finished");
require(auction.startTime < block.timestamp, "bidding not start");
require(auction.publishTime != 1, "already published");
address msgSender = msg.sender;
// bytes32 id = calculateBidId(msgSender, token);
uint price = _bids[token][msgSender];
require(price == 0, "already bid");
require(amount > 0, "price can not be 0");
// bid.bidder = msgSender;
_bids[token][msgSender] = amount;
auction.bidders.push(msgSender);
emit BiddingCreated(msgSender, token, amount);
}
function updateBid(uint256 amount, MemeToken token) external {
Auction memory auction = _auctions[token];
// require(auction.publishTime + 60 > block.timestamp, "bidding finished");
require(auction.startTime < block.timestamp, "bidding not start");
require(auction.publishTime != 1, "already published");
address msgSender = msg.sender;
// bytes32 id = calculateBidId(msgSender, token);
uint price = _bids[token][msgSender];
require(price != 0, "have not bid");
// require(msg.sender == bid.bidder, "not bidder");
require(amount > price, "can not lower");
_bids[token][msgSender] = amount;
emit BiddingUpdated(msgSender, token, amount);
}
function publish(MemeToken token) external {
Auction storage auction = _auctions[token];
require(auction.publishTime < block.timestamp, "not ready for publish");
require(auction.publishTime != 1, "already published");
require(auction.startTime < block.timestamp, "bidding not start");
bytes memory succeedUsers;
bytes memory failedToApprove;
address wethAddr = address(_weth);
address tokenAddr = address(token);
address thisAddr = address(this);
uint deadline = block.timestamp + 300;
if (auction.bidders.length == 0) {
auction.publishTime = 1;
_uniRouter2.addLiquidityETH{value: auction.totalEth}(tokenAddr, auction.totalSupply, 1, 1, address(this), deadline);
emit Published(token, succeedUsers, failedToApprove);
return;
}
_uniRouter2.addLiquidityETH{value: auction.totalEth}(tokenAddr, auction.totalSupply, 1, 1, address(this), deadline);
address[] memory path = new address[](2);
path[0] = wethAddr;
path[1] = tokenAddr;
Bid[] memory bidders = new Bid[](auction.bidders.length);
for (uint i = 0; i < auction.bidders.length; ++i) {
bidders[i] = Bid(auction.bidders[i], _bids[token][auction.bidders[i]]);
}
if (bidders.length > 1) {
quickSort(bidders, 0, bidders.length - 1);
}
uint fee_for_project;
uint fee_for_starter;
for (uint i = 0; i < bidders.length; ++i) {
uint j = bidders.length - 1 - i;
address bidder = bidders[j].bidder;
uint bidAmount = bidders[j].amount;
(bool isSuccess,) = wethAddr.call(abi.encodeCall(IERC20.transferFrom, (bidder, thisAddr, bidAmount)));
if (!isSuccess) {
failedToApprove = bytes.concat(failedToApprove, bytes20(bidder));
continue;
}
(bool isSuccess2,bytes memory returnAmounts) = address(_uniRouter2).call(abi.encodeCall(_uniRouter2.swapTokensForExactTokens, (auction.onceAmount, bidAmount, path, bidder, deadline)));
if (!isSuccess2) {
_weth.transfer(bidder, bidAmount);
break;
}
uint[] memory amounts = abi.decode(returnAmounts, (uint[]));
uint remaining_weth = bidAmount - amounts[0];
uint user_weth = remaining_weth * user_fee_rate / denominator;
uint starter_weth = remaining_weth * starter_fee_rate / denominator;
uint project_weth = remaining_weth - user_weth - starter_weth;
fee_for_project += project_weth;
fee_for_starter += starter_weth;
_weth.transfer(bidder, user_weth);
succeedUsers = bytes.concat(succeedUsers, bytes20(bidder));
}
_weth.transfer(_feeReceipt, fee_for_project);
_weth.transfer(auction.creator, fee_for_starter);
auction.publishTime = 1;
emit Published(token, succeedUsers, failedToApprove);
}
function withdrawLPToken(MemeToken token) external {
Auction memory auction = _auctions[token];
require(auction.creator == msg.sender, "not creator");
require(auction.publishTime + 365 days < block.timestamp, "not time to withdraw yet");
require(!auction.isBurnLpToken, "already burned");
IUniswapV2Pair pair = IUniswapV2Pair(Lib.pairFor(_uniFactory, address(_weth), address(token)));
uint balance = pair.balanceOf(address(this));
require(pair.transfer(auction.creator, balance), "transfer failed");
emit Withdrew(token, balance);
}
// function calculateBidId(address bidder, MemeToken token) public view returns (bytes32){
// return keccak256(abi.encodePacked(bidder, token, address(this)));
// }
function safeSub(uint256 a) public pure returns (uint256) {
unchecked {
if (a == 0) return a;
else return a - 1;
}
}
//time complexity O(N*log(N))
function quickSort(Bid[] memory bids, uint256 left, uint256 right) internal pure {
unchecked {
uint256 pivot = bids[left + ((right - left) / 2)].amount;
uint256 i = left;
uint256 j = right;
while (true) {
while (bids[i].amount < pivot) i++;
while (pivot < bids[j].amount) {
j = safeSub(j);
}
if (i > j) break;
(bids[i], bids[j]) = (bids[j], bids[i]);
i++;
j = safeSub(j);
}
if (i < right) quickSort(bids, i, right);
if (left < j) quickSort(bids, left, j);
}
}
// function sort(Bid[] memory data) public pure returns (Bid[] memory) {
// unchecked {
// quickSort(data, 0, data.length - 1);
// }
// return data;
// }
}
Lib.sol 32 lines
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
library Lib {
function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
// require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES');
(token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
// require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS');
}
// calculates the CREATE2 address for a pair without making any external calls
function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = sortTokens(tokenA, tokenB);
pair = address(uint160(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
)))));
}
// function sort(Bid[] memory data) public pure returns (uint256[] memory) {
// unchecked {
// quickSort(data, 0, data.length - 1);
// }
// return data;
// }
}
IERC20.sol 79 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
IUniswapV2Pair.sol 52 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;
}
IUniswapV2Router02.sol 44 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;
}
IPreSale.sol 62 lines
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import {MemeToken} from "./MemeToken.sol";
interface IPreSale {
event AuctionCreated(
MemeToken indexed token,
string name,
string symbol,
uint256 onceAmount,
uint256 totalSupply,
uint startTime,
uint publishTime,
bool isBurnLpToken,
uint totalEth,
address creator);
event BiddingCreated(address indexed bidder, MemeToken indexed token, uint amount);
event BiddingUpdated(address indexed bidder, MemeToken indexed token, uint amount);
event Published(MemeToken indexed token, bytes succeedUsers, bytes failedToApprove);
event Withdrew(MemeToken indexed token, uint amount);
struct Bid {
address bidder;
uint256 amount;
}
struct Auction {
uint256 onceAmount;
uint256 totalSupply;
uint256 totalEth;
address creator;
bool isBurnLpToken;
uint startTime;
uint publishTime;
address[] bidders;
}
function createAuction(
string memory name,
string memory symbol,
uint256 onceAmount,
uint256 totalSupply,
uint startTime,
uint publishTime,
bool isBurnLpToken
) external payable returns (MemeToken);
function newBid(uint256 amount, MemeToken token) external;
function updateBid(uint256 amount, MemeToken token) external;
function publish(MemeToken token) external;
function withdrawLPToken(MemeToken token) external;
}
MemeToken.sol 10 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract MemeToken is ERC20 {
constructor(string memory name, string memory symbol, uint256 totalSupply) ERC20(name, symbol) {
_mint(msg.sender, totalSupply);
}
}
IUniswapV2Router01.sol 95 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);
}
ERC20.sol 312 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.2.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 ERC-20
* applications.
*/
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}.
*
* Skips emitting an {Approval} event indicating an allowance update. This is not
* required by the ERC. See {xref-ERC20-_approve-address-address-uint256-bool-}[_approve].
*
* 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:
*
* ```solidity
* 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);
}
}
}
}
draft-IERC6093.sol 161 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC6093.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard ERC-20 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 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 ERC-721 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens.
*/
interface IERC721Errors {
/**
* @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-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 ERC-1155 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 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);
}
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;
}
}
IERC20Metadata.sol 26 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.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 ERC-20 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
_auctions 0x80bdd4b8 → uint256, uint256, uint256, address, bool, uint256, uint256
_bids 0xbc3506fa → uint256
_feeReceipt 0x0a09c89c → address
_publisher 0xf0a8d51a → address
_uniFactory 0xeb3611d9 → address
_uniRouter2 0xcefe23c8 → address
_weth 0xa1764595 → address
auction_creation_fee 0xbd62039a → uint256
denominator 0x96ce0795 → uint256
getBidders 0x13a3bc4b → address[]
safeSub 0x103db6da → uint256
starter_fee_rate 0x68637695 → uint256
user_fee_rate 0xf4629016 → uint256
Write Contract 8 functions
These functions modify contract state and require a wallet transaction to execute.
createAuction 0x15d05a53
string name
string symbol
uint256 onceAmount
uint256 totalSupply
uint256 startTime
uint256 publishTime
bool isBurnLpToken
returns: address
newBid 0xb7d1f8cf
uint256 amount
address token
publish 0x2cf99422
address token
setFeeRate 0xf2d2a751
uint256 _starter_fee_rate
uint256 _user_fee_rate
setFeeReceipt 0x4d24f5b2
address newFeeRec
setPublisher 0xcab63661
address newPub
updateBid 0x4eeb55f7
uint256 amount
address token
withdrawLPToken 0xd7da0abd
address token
Recent Transactions
No transactions found for this address