Address Contract Verified
Address
0x360FB871C91087662b9289dd264F93Ea8ad3f53c
Balance
0 ETH
Nonce
10
Code Size
24518 bytes
Creator
0x7aC820c0...3fDC at tx 0x329acdac...b4cf1b
Indexed Transactions
0
Contract Bytecode
24518 bytes
0x6080604052600436106102bf575f3560e01c80638456cb591161016f578063ad3cb1cc116100d8578063eff1d50e11610092578063f6f032b01161006d578063f6f032b0146109ee578063f72c0d8b14610a1c578063fea5fca514610a4f578063ff142d5314610a6e575f5ffd5b8063eff1d50e14610968578063f5b541a614610987578063f5dab711146109ba575f5ffd5b8063ad3cb1cc14610890578063b43121b2146108cd578063d547741f146108ec578063db3fa4cc1461090b578063ebd292001461092a578063ed2bc95914610949575f5ffd5b80639ba4fd8c116101295780639ba4fd8c1461075d5780639d23c4c71461078b578063a0c0f720146107a9578063a217fddf146105d0578063a5bc29c2146107e2578063a781d20814610822575f5ffd5b80638456cb591461069a57806387cb5f94146106ae5780638a241c1c146106c957806391d14854146106e857806395cf00de146107075780639a57bcdb14610732575f5ffd5b80634219dc401161022b5780636a0c97fe116101e55780636bf3d05a116101c05780636bf3d05a1461061d5780636fa237951461063c57806375b238fc1461065b57806383f3fc9a1461067b575f5ffd5b80636a0c97fe146105d05780636bb70283146105e35780636bd969b314610600575f5ffd5b80634219dc40146105065780634f069251146105255780634f1ef2861461056757806352d1902d1461057a5780635c975abb1461058e578063634282af146105b1575f5ffd5b80631f69565f1161027c5780631f69565f146103e7578063248a9ca31461041357806328b74c95146104405780632f2ff15d146104b457806336568abe146104d35780633f4ba83a146104f2575f5ffd5b806301ffc9a7146102c3578063057838bd146102f757806310c83009146103275780631130e83d14610394578063164e68de146103a7578063179aecb1146103c8575b5f5ffd5b3480156102ce575f5ffd5b506102e26102dd366004612c9f565b610a8b565b60405190151581526020015b60405180910390f35b348015610302575f5ffd5b505f546001600160a01b03165b6040516001600160a01b0390911681526020016102ee565b348015610332575f5ffd5b50600954600a54600b54600c54600d54600e54600f54601054610359979695949392919088565b604080519889526020890197909752958701949094526060860192909252608085015260a084015260c083015260e0820152610100016102ee565b61030f6103a2366004612cc6565b610ac1565b3480156103b2575f5ffd5b506103c66103c1366004612d1c565b610b14565b005b3480156103d3575f5ffd5b506103c66103e2366004612d44565b610b93565b3480156103f2575f5ffd5b50610406610401366004612d1c565b610c0a565b6040516102ee9190612e03565b34801561041e575f5ffd5b5061043261042d366004612edb565b611004565b6040519081526020016102ee565b34801561044b575f5ffd5b50610454611024565b6040516102ee91905f61010082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015260c083015160c083015260e083015160e083015292915050565b3480156104bf575f5ffd5b506103c66104ce366004612ef2565b6110b2565b3480156104de575f5ffd5b506103c66104ed366004612ef2565b6110ce565b3480156104fd575f5ffd5b506103c6611101565b348015610511575f5ffd5b5060015461030f906001600160a01b031681565b348015610530575f5ffd5b50601954601a54601b54601c546105479392919084565b6040805194855260208501939093529183015260608201526080016102ee565b6103c6610575366004612fc6565b611123565b348015610585575f5ffd5b50610432611142565b348015610599575f5ffd5b505f516020615f515f395f51905f525460ff166102e2565b3480156105bc575f5ffd5b5061030f6105cb366004612edb565b61115d565b3480156105db575f5ffd5b506104325f81565b3480156105ee575f5ffd5b506003546001600160a01b031661030f565b34801561060b575f5ffd5b506001546001600160a01b031661030f565b348015610628575f5ffd5b5060035461030f906001600160a01b031681565b348015610647575f5ffd5b506103c6610656366004612edb565b611185565b348015610666575f5ffd5b506104325f516020615f715f395f51905f5281565b348015610686575f5ffd5b5060025461030f906001600160a01b031681565b3480156106a5575f5ffd5b506103c6611234565b3480156106b9575f5ffd5b50610432670de0b6b3a764000081565b3480156106d4575f5ffd5b506103c66106e3366004613025565b611253565b3480156106f3575f5ffd5b506102e2610702366004612ef2565b61130b565b348015610712575f5ffd5b50610432610721366004612d1c565b60156020525f908152604090205481565b34801561073d575f5ffd5b5061043261074c366004612d1c565b60166020525f908152604090205481565b348015610768575f5ffd5b506102e2610777366004612d1c565b60176020525f908152604090205460ff1681565b348015610796575f5ffd5b505f5461030f906001600160a01b031681565b3480156107b4575f5ffd5b506102e26107c3366004612d1c565b6001600160a01b03165f90815260116020526040902060050154151590565b3480156107ed575f5ffd5b5061030f6107fc36600461303e565b80516020818301810180516014825292820191909301209152546001600160a01b031681565b34801561082d575f5ffd5b5060055460065460075460085461085a9392916001600160a01b03811691600160a01b90910460ff169085565b6040805195865260208601949094526001600160a01b03909216928401929092529015156060830152608082015260a0016102ee565b34801561089b575f5ffd5b506108c0604051806040016040528060058152602001640352e302e360dc1b81525081565b6040516102ee919061308a565b3480156108d8575f5ffd5b506103c66108e736600461309c565b611341565b3480156108f7575f5ffd5b506103c6610906366004612ef2565b611557565b348015610916575f5ffd5b5061030f61092536600461312e565b611573565b348015610935575f5ffd5b506103c6610944366004613158565b6115a7565b348015610954575f5ffd5b506103c661096336600461316a565b61174a565b348015610973575f5ffd5b5060045461030f906001600160a01b031681565b348015610992575f5ffd5b506104327f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b92981565b3480156109c5575f5ffd5b506109d96109d4366004612d1c565b611800565b6040516102ee999897969594939291906131c3565b3480156109f9575f5ffd5b506102e2610a08366004612d1c565b60186020525f908152604090205460ff1681565b348015610a27575f5ffd5b506104327f189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e381565b348015610a5a575f5ffd5b506103c6610a69366004612d44565b611a5d565b348015610a79575f5ffd5b506002546001600160a01b031661030f565b5f6001600160e01b03198216637965db0b60e01b1480610abb57506301ffc9a760e01b6001600160e01b03198316145b92915050565b5f610aca611acb565b610ad2611b15565b610adb82611b47565b610ae482611c2b565b9050610b0f60017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b919050565b5f516020615f715f395f51905f52610b2b81611ce5565b6001600160a01b038216610b525760405163e481c26960e01b815260040160405180910390fd5b478015610b8e576040516001600160a01b0384169082156108fc029083905f818181858888f19350505050158015610b8c573d5f5f3e3d5ffd5b505b505050565b5f516020615f715f395f51905f52610baa81611ce5565b6001600160a01b0383165f81815260176020908152604091829020805460ff191686151590811790915591519182527fd46b004935f36193d0d334d243a01d2d34c6655122ceb74e29ff853183ad711891015b60405180910390a2505050565b610c5b60405180610140016040528060608152602001606081526020016060815260200160608152602001606081526020015f81526020015f81526020015f81526020015f81526020015f81525090565b6001600160a01b0382165f908152601160205260408120600501549003610c955760405163c5723b5160e01b815260040160405180910390fd5b6001600160a01b0382165f908152601160205260409081902081516101408101909252805482908290610cc79061323f565b80601f0160208091040260200160405190810160405280929190818152602001828054610cf39061323f565b8015610d3e5780601f10610d1557610100808354040283529160200191610d3e565b820191905f5260205f20905b815481529060010190602001808311610d2157829003601f168201915b50505050508152602001600182018054610d579061323f565b80601f0160208091040260200160405190810160405280929190818152602001828054610d839061323f565b8015610dce5780601f10610da557610100808354040283529160200191610dce565b820191905f5260205f20905b815481529060010190602001808311610db157829003601f168201915b50505050508152602001600282018054610de79061323f565b80601f0160208091040260200160405190810160405280929190818152602001828054610e139061323f565b8015610e5e5780601f10610e3557610100808354040283529160200191610e5e565b820191905f5260205f20905b815481529060010190602001808311610e4157829003601f168201915b50505050508152602001600382018054610e779061323f565b80601f0160208091040260200160405190810160405280929190818152602001828054610ea39061323f565b8015610eee5780601f10610ec557610100808354040283529160200191610eee565b820191905f5260205f20905b815481529060010190602001808311610ed157829003601f168201915b5050505050815260200160048201805480602002602001604051908101604052809291908181526020015f905b82821015610fc3578382905f5260205f20018054610f389061323f565b80601f0160208091040260200160405190810160405280929190818152602001828054610f649061323f565b8015610faf5780601f10610f8657610100808354040283529160200191610faf565b820191905f5260205f20905b815481529060010190602001808311610f9257829003601f168201915b505050505081526020019060010190610f1b565b505050508152602001600582015481526020016006820154815260200160078201548152602001600882015481526020016009820154815250509050919050565b5f9081525f516020615f315f395f51905f52602052604090206001015490565b6110646040518061010001604052805f81526020015f81526020015f81526020015f81526020015f81526020015f81526020015f81526020015f81525090565b5060408051610100810182526009548152600a546020820152600b5491810191909152600c546060820152600d546080820152600e5460a0820152600f5460c082015260105460e082015290565b6110bb82611004565b6110c481611ce5565b610b8c8383611cef565b6001600160a01b03811633146110f75760405163334bd91960e11b815260040160405180910390fd5b610b8e8282611d90565b5f516020615f715f395f51905f5261111881611ce5565b611120611e09565b50565b61112b611e68565b61113482611f0c565b61113e8282611f36565b5050565b5f61114b611ff7565b505f516020615f115f395f51905f5290565b6013818154811061116c575f80fd5b5f918252602090912001546001600160a01b0316905081565b5f516020615f715f395f51905f5261119c81611ce5565b670de0b6b3a76400008211156111c557604051635435b28960e11b815260040160405180910390fd5b60058290556040805183815260065460208201526007546001600160a01b0381169282019290925260ff60a092831c161515606082015260085460808201527f570fe650097a913e472498161c527b9f66beafb2eed361db413ea4bd4420088991015b60405180910390a15050565b5f516020615f715f395f51905f5261124b81611ce5565b611120612040565b5f516020615f715f395f51905f5261126a81611ce5565b670de0b6b3a76400008235111561129457604051635435b28960e11b815260040160405180910390fd5b5f6112a56060840160408501612d1c565b6001600160a01b0316036112cc5760405163e481c26960e01b815260040160405180910390fd5b8160056112d98282613277565b9050507f570fe650097a913e472498161c527b9f66beafb2eed361db413ea4bd442008898260405161122891906132df565b5f9182525f516020615f315f395f51905f52602090815260408084206001600160a01b0393909316845291905290205460ff1690565b5f61134a612088565b805490915060ff600160401b82041615906001600160401b03165f811580156113705750825b90505f826001600160401b0316600114801561138b5750303b155b905081158015611399575080155b156113b75760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff1916600117855583156113e157845460ff60401b1916600160401b1785555b6113e96120b0565b6113f2886120d0565b61145887878151600555602082015160065560408201516007805460608501511515600160a01b026001600160a81b03199091166001600160a01b039384161717905560809092015160085560038054919092166001600160a01b031991909116179055565b611507604080516101008101825269d3c21bcecceda10000008082526c0c9f2c9cd04674edea40000000602083018190526103e89383018490526123286060840181905264e8d4a510006080850181905267016345785d8a000060a08601819052678ac7230489e8000060c08701819052683635c9adc5dea0000060e0909701879052600995909555600a93909355600b95909555600c55600d93909355600e92909255600f91909155601055565b831561154d57845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b5050505050505050565b61156082611004565b61156981611ce5565b610b8c8383611d90565b6012602052815f5260405f20818154811061158c575f80fd5b5f918252602090912001546001600160a01b03169150829050565b5f516020615f715f395f51905f526115be81611ce5565b813515806115ce57506020820135155b156115ec57604051635435b28960e11b815260040160405180910390fd5b60208201358235111561161257604051635435b28960e11b815260040160405180910390fd5b81606001358260400135111561163b57604051635435b28960e11b815260040160405180910390fd5b8160a001358260800135111561166457604051635435b28960e11b815260040160405180910390fd5b8160e001358260c00135111561168d57604051635435b28960e11b815260040160405180910390fd5b813560099081556020830135600a556040830135600b556060830135600c556080830135600d5560a0830135600e5560c0830135600f5560e0830135601055829050506040805183358152602080850135908201528184013591810191909152606080840135908201526080808401359082015260a0808401359082015260c0808401359082015260e080840135908201527fd2b0e3eb5b554882a2b0dbe7ff6a3e5fb21bb0e06512c592cb53848533ff4bb59061010001611228565b5f516020615f715f395f51905f5261176181611ce5565b5f80546001600160a01b038781166001600160a01b03199283168117909355600180548883169084168117909155600280548884169085168117909155600480548885169516949094179093556003546040805195865260208601929092528482019390935291166060830152517f76fd69d8fcd4b30dd75c1e8d6d4234ab3fe7313bf8c14f070d272bb4dcf308cd9181900360800190a15050505050565b60116020525f908152604090208054819061181a9061323f565b80601f01602080910402602001604051908101604052809291908181526020018280546118469061323f565b80156118915780601f1061186857610100808354040283529160200191611891565b820191905f5260205f20905b81548152906001019060200180831161187457829003601f168201915b5050505050908060010180546118a69061323f565b80601f01602080910402602001604051908101604052809291908181526020018280546118d29061323f565b801561191d5780601f106118f45761010080835404028352916020019161191d565b820191905f5260205f20905b81548152906001019060200180831161190057829003601f168201915b5050505050908060020180546119329061323f565b80601f016020809104026020016040519081016040528092919081815260200182805461195e9061323f565b80156119a95780601f10611980576101008083540402835291602001916119a9565b820191905f5260205f20905b81548152906001019060200180831161198c57829003601f168201915b5050505050908060030180546119be9061323f565b80601f01602080910402602001604051908101604052809291908181526020018280546119ea9061323f565b8015611a355780601f10611a0c57610100808354040283529160200191611a35565b820191905f5260205f20905b815481529060010190602001808311611a1857829003601f168201915b5050505050908060050154908060060154908060070154908060080154908060090154905089565b5f516020615f715f395f51905f52611a7481611ce5565b6001600160a01b0383165f81815260186020908152604091829020805460ff191686151590811790915591519182527f126359bdd213b27cb49a58a36f6448d7faba63af356a522d8dc479f29c3a4b409101610bfd565b7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00805460011901611b0f57604051633ee5aeb560e01b815260040160405180910390fd5b60029055565b5f516020615f515f395f51905f525460ff1615611b455760405163d93c066560e01b815260040160405180910390fd5b565b335f9081526018602052604090205460ff1615611b77576040516309550c7760e01b815260040160405180910390fd5b600754600160a01b900460ff168015611b9f5750335f9081526017602052604090205460ff16155b8015611bbf5750611bbd5f516020615f715f395f51905f523361130b565b155b15611bdd5760405163060a6aeb60e51b815260040160405180910390fd5b600854335f90815260156020526040902054611bf99190613347565b421015611c19576040516339d7381360e01b815260040160405180910390fd5b611c228161216f565b611120816122f1565b5f5f604051611c3990612c0c565b604051809103905ff080158015611c52573d5f5f3e3d5ffd5b50335f90815260266020526040902080546001600160a01b0319166001600160a01b0383161790559150819050611c898184612368565b611c93828461238f565b611c9d828461247c565b50335f90815260266020526040902080546001600160a01b0319169055919050565b60017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b611120813361255c565b5f5f516020615f315f395f51905f52611d08848461130b565b611d87575f848152602082815260408083206001600160a01b03871684529091529020805460ff19166001179055611d3d3390565b6001600160a01b0316836001600160a01b0316857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a46001915050610abb565b5f915050610abb565b5f5f516020615f315f395f51905f52611da9848461130b565b15611d87575f848152602082815260408083206001600160a01b0387168085529252808320805460ff1916905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a46001915050610abb565b611e11612595565b5f516020615f515f395f51905f52805460ff191681557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a150565b306001600160a01b037f000000000000000000000000360fb871c91087662b9289dd264f93ea8ad3f53c161480611eee57507f000000000000000000000000360fb871c91087662b9289dd264f93ea8ad3f53c6001600160a01b0316611ee25f516020615f115f395f51905f52546001600160a01b031690565b6001600160a01b031614155b15611b455760405163703e46dd60e11b815260040160405180910390fd5b7f189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e361113e81611ce5565b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015611f90575060408051601f3d908101601f19168201909252611f8d9181019061335a565b60015b611fbd57604051634c9c8ce360e01b81526001600160a01b03831660048201526024015b60405180910390fd5b5f516020615f115f395f51905f528114611fed57604051632a87526960e21b815260048101829052602401611fb4565b610b8e83836125c4565b306001600160a01b037f000000000000000000000000360fb871c91087662b9289dd264f93ea8ad3f53c1614611b455760405163703e46dd60e11b815260040160405180910390fd5b612048611b15565b5f516020615f515f395f51905f52805460ff191660011781557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25833611e4a565b5f807ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00610abb565b6120b8612619565b6120c0612629565b6120c8612629565b611b45612629565b6001600160a01b0381166120f75760405163e481c26960e01b815260040160405180910390fd5b6121015f82611cef565b506121195f516020615f715f395f51905f5282611cef565b506121447f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b92982611cef565b5061113e7f189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e382611cef565b6040516333ad99bf60e21b8152737ae30e6426c1241c2e163dc642c6ccf67a17dd9a9063ceb666fc906121a690849060040161347a565b5f6040518083038186803b1580156121bc575f5ffd5b505af41580156121ce573d5f5f3e3d5ffd5b5050505060095f01548160a0013510806121ed5750600a5460a0820135115b1561220b57604051635435b28960e11b815260040160405180910390fd5b60c081013515612269575f60a082013561222b60c084013561271061358a565b61223591906135a1565b600b549091508110806122495750600c5481115b1561226757604051635435b28960e11b815260040160405180910390fd5b505b610100810135156122ad57600d54610100820135108061228f5750600e54610100820135115b156122ad57604051635435b28960e11b815260040160405180910390fd5b6101208101351561112057600f5461012082013510806122d35750601054610120820135115b1561112057604051635435b28960e11b815260040160405180910390fd5b6005543410156123135760405162976f7560e21b815260040160405180910390fd5b5f601461232360208401846135c0565b604051612331929190613602565b908152604051908190036020019020546001600160a01b031614611120576040516372fb5c6960e11b815260040160405180910390fd5b5f5f8260a001351161237c57600654612382565b8160a001355b9050610b8e838383612631565b6001600160a01b0382165f90815260116020526040902081906123b2828261383f565b5050335f90815260126020908152604082208054600181810183559184528284200180546001600160a01b0387166001600160a01b031991821681179092556013805493840181559094527f66de8ffda797e3de9c05e8fc57b3bf0ec28a930d40b0d285d93c06501cf6a090909101805490931617909155829060149061243b908401846135c0565b604051612449929190613602565b90815260405190819003602001902080546001600160a01b03929092166001600160a01b03199092169190911790555050565b612484612672565b6004546001600160a01b03161561249f5761249f82826126ba565b5f341180156124b857506007546001600160a01b031615155b156124f5576007546040516001600160a01b03909116903480156108fc02915f818181858888f193505050501580156124f3573d5f5f3e3d5ffd5b505b336001600160a01b0383167fc12630d761ddbf18b9530f31d91e67493535a2b635711bcff59fded8bf381cce61252b84806135c0565b61253860208701876135c0565b8760a001353460405161255096959493929190613902565b60405180910390a35050565b612566828261130b565b61113e5760405163e2517d3f60e01b81526001600160a01b038216600482015260248101839052604401611fb4565b5f516020615f515f395f51905f525460ff16611b4557604051638dfc202b60e01b815260040160405180910390fd5b6125cd8261280f565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b905f90a280511561261157610b8e8282612872565b61113e6128e4565b612621612903565b611b45612928565b611b45612903565b601d80546001600160a01b0385166001600160a01b031991821617909155601e829055601f80548216331790556020805490911630179055610b8e82612930565b335f908152601560209081526040808320429055601690915281208054916126998361393e565b9091555050335f908152601660205260409020546001146111203482612949565b6004546001600160a01b03166126ce575050565b8060c001355f036126dd575050565b5f5f826101000135116126fd57600d546126f890600a61358a565b612704565b8161010001355b90505f5f836101200135116127225768049b9ca9a694340000612729565b8261012001355b600480546040516340c10f1960e01b81526001600160a01b039182169281019290925260c0860135602483015291925085918216906340c10f19906044015f604051808303815f87803b15801561277e575f5ffd5b505af1158015612790573d5f5f3e3d5ffd5b505060048054604051634d3fc19760e01b81526001600160a01b038a81169382019390935260c08901356024820152604481018890526064810187905291169250634d3fc19791506084015f604051808303815f87803b1580156127f2575f5ffd5b505af1158015612804573d5f5f3e3d5ffd5b505050505050505050565b806001600160a01b03163b5f0361284457604051634c9c8ce360e01b81526001600160a01b0382166004820152602401611fb4565b5f516020615f115f395f51905f5280546001600160a01b0319166001600160a01b0392909216919091179055565b60605f5f846001600160a01b03168460405161288e9190613956565b5f60405180830381855af49150503d805f81146128c6576040519150601f19603f3d011682016040523d82523d5f602084013e6128cb565b606091505b50915091506128db8583836129a8565b95945050505050565b3415611b455760405163b398979f60e01b815260040160405180910390fd5b61290b612a07565b611b4557604051631afcd79f60e31b815260040160405180910390fd5b611cbf612903565b61293981612a20565b612941612b09565b611120612b81565b60198054905f6129588361393e565b9190505550801561297857601a8054905f6129728361393e565b91905055505b8160196002015f82825461298c9190613347565b9091555050601954601b546129a191906135a1565b601c555050565b6060826129bd576129b882612be4565b612a00565b81511580156129d457506001600160a01b0384163b155b156129fd57604051639996b31560e01b81526001600160a01b0385166004820152602401611fb4565b50805b9392505050565b5f612a10612088565b54600160401b900460ff16919050565b612a2a81806135c0565b602291612a38919083613663565b50612a4660208201826135c0565b602391612a54919083613663565b50612a6260408201826135c0565b602491612a70919083613663565b50612a7e60608201826135c0565b602591612a8c919083613663565b50612a9860215f612c19565b5f5b612aa7608083018361371c565b905081101561113e576021612abf608084018461371c565b83818110612acf57612acf61396c565b9050602002810190612ae191906135c0565b82546001810184555f938452602090932090920191612b009183613663565b50600101612a9a565b601d54601e54601f5460205460405163ee71129960e01b81526001600160a01b039485169463ee71129994612b58946022946023946024946025946021949093908216929116906004016139ff565b5f604051808303815f87803b158015612b6f575f5ffd5b505af1158015610b8c573d5f5f3e3d5ffd5b601d80546001600160a01b03199081169091555f601e819055601f80548316905560208054909216909155612bb890602190612c19565b612bc360225f612c34565b612bce60235f612c34565b612bd960245f612c34565b611b4560255f612c34565b805115612bf357805160208201fd5b60405163d6bda27560e01b815260040160405180910390fd5b61242c80613ae583390190565b5080545f8255905f5260205f20908101906111209190612c6b565b508054612c409061323f565b5f825580601f10612c4f575050565b601f0160209004905f5260205f20908101906111209190612c8b565b80821115612c87575f612c7e8282612c34565b50600101612c6b565b5090565b5b80821115612c87575f8155600101612c8c565b5f60208284031215612caf575f5ffd5b81356001600160e01b031981168114612a00575f5ffd5b5f60208284031215612cd6575f5ffd5b81356001600160401b03811115612ceb575f5ffd5b82016101408185031215612a00575f5ffd5b6001600160a01b0381168114611120575f5ffd5b8035610b0f81612cfd565b5f60208284031215612d2c575f5ffd5b8135612a0081612cfd565b8015158114611120575f5ffd5b5f5f60408385031215612d55575f5ffd5b8235612d6081612cfd565b91506020830135612d7081612d37565b809150509250929050565b5f81518084528060208401602086015e5f602082860101526020601f19601f83011685010191505092915050565b5f82825180855260208501945060208160051b830101602085015f5b83811015612df757601f19858403018852612de1838351612d7b565b6020988901989093509190910190600101612dc5565b50909695505050505050565b602081525f82516101406020840152612e20610160840182612d7b565b90506020840151601f19848303016040850152612e3d8282612d7b565b9150506040840151601f19848303016060850152612e5b8282612d7b565b9150506060840151601f19848303016080850152612e798282612d7b565b9150506080840151601f198483030160a0850152612e978282612da9565b91505060a084015160c084015260c084015160e084015260e08401516101008401526101008401516101208401526101208401516101408401528091505092915050565b5f60208284031215612eeb575f5ffd5b5035919050565b5f5f60408385031215612f03575f5ffd5b823591506020830135612d7081612cfd565b634e487b7160e01b5f52604160045260245ffd5b60405160a081016001600160401b0381118282101715612f4b57612f4b612f15565b60405290565b5f5f6001600160401b03841115612f6a57612f6a612f15565b50604051601f19601f85018116603f011681018181106001600160401b0382111715612f9857612f98612f15565b604052838152905080828401851015612faf575f5ffd5b838360208301375f60208583010152509392505050565b5f5f60408385031215612fd7575f5ffd5b8235612fe281612cfd565b915060208301356001600160401b03811115612ffc575f5ffd5b8301601f8101851361300c575f5ffd5b61301b85823560208401612f51565b9150509250929050565b5f60a0828403128015613036575f5ffd5b509092915050565b5f6020828403121561304e575f5ffd5b81356001600160401b03811115613063575f5ffd5b8201601f81018413613073575f5ffd5b61308284823560208401612f51565b949350505050565b602081525f612a006020830184612d7b565b5f5f5f83850360e08112156130af575f5ffd5b84356130ba81612cfd565b935060a0601f19820112156130cd575f5ffd5b506130d6612f29565b602085810135825260408601359082015260608501356130f581612cfd565b6040820152608085013561310881612d37565b606082015260a08501356080820152915061312560c08501612d11565b90509250925092565b5f5f6040838503121561313f575f5ffd5b823561314a81612cfd565b946020939093013593505050565b5f610100828403128015613036575f5ffd5b5f5f5f5f6080858703121561317d575f5ffd5b843561318881612cfd565b9350602085013561319881612cfd565b925060408501356131a881612cfd565b915060608501356131b881612cfd565b939692955090935050565b61012081525f6131d761012083018c612d7b565b82810360208401526131e9818c612d7b565b905082810360408401526131fd818b612d7b565b90508281036060840152613211818a612d7b565b6080840198909852505060a081019490945260c084019290925260e083015261010090910152949350505050565b600181811c9082168061325357607f821691505b60208210810361327157634e487b7160e01b5f52602260045260245ffd5b50919050565b813581556020820135600182015560028101604083013561329781612cfd565b815460608501356132a781612d37565b60ff60a01b90151560a01b166001600160a01b03929092166001600160a81b0319919091161717905560809190910135600390910155565b813581526020808301359082015260a0810160408301356132ff81612cfd565b6001600160a01b03166040830152606083013561331b81612d37565b15156060830152608092830135929091019190915290565b634e487b7160e01b5f52601160045260245ffd5b80820180821115610abb57610abb613333565b5f6020828403121561336a575f5ffd5b5051919050565b5f5f8335601e19843603018112613386575f5ffd5b83016020810192503590506001600160401b038111156133a4575f5ffd5b8036038213156133b2575f5ffd5b9250929050565b81835281816020850137505f828201602090810191909152601f909101601f19169091010190565b5f5f8335601e198436030181126133f6575f5ffd5b83016020810192503590506001600160401b03811115613414575f5ffd5b8060051b36038213156133b2575f5ffd5b5f8383855260208501945060208460051b820101835f5b86811015612df757838303601f190188526134578287613371565b6134628582846133b9565b60209a8b019a9095509390930192505060010161343c565b602081525f6134898384613371565b61014060208501526134a0610160850182846133b9565b9150506134b06020850185613371565b848303601f190160408601526134c78382846133b9565b925050506134d86040850185613371565b848303601f190160608601526134ef8382846133b9565b925050506135006060850185613371565b848303601f190160808601526135178382846133b9565b9250505061352860808501856133e1565b848303601f190160a086015261353f838284613425565b60a087013560c08781019190915287013560e0808801919091528701356101008088019190915287013561012080880191909152909601356101409095019490945250929392505050565b8082028115828204841417610abb57610abb613333565b5f826135bb57634e487b7160e01b5f52601260045260245ffd5b500490565b5f5f8335601e198436030181126135d5575f5ffd5b8301803591506001600160401b038211156135ee575f5ffd5b6020019150368190038213156133b2575f5ffd5b818382375f9101908152919050565b5b8181101561113e575f8155600101613612565b601f821115610b8e57805f5260205f20601f840160051c8101602085101561364a5750805b61365c601f850160051c830182613611565b5050505050565b6001600160401b0383111561367a5761367a612f15565b61368e83613688835461323f565b83613625565b5f601f8411600181146136bf575f85156136a85750838201355b5f19600387901b1c1916600186901b17835561365c565b5f83815260208120601f198716915b828110156136ee57868501358255602094850194600190920191016136ce565b508682101561370a575f1960f88860031b161c19848701351681555b505060018560011b0183555050505050565b5f5f8335601e19843603018112613731575f5ffd5b8301803591506001600160401b0382111561374a575f5ffd5b6020019150600581901b36038213156133b2575f5ffd5b600160401b83111561377557613775612f15565b8054838255808410156137f9575f828152602090208481019082015b808210156137f6576137a3825461323f565b80156137ea57601f8111600181146137bd575f84556137e8565b5f848152602090206137da601f840160051c820160018301613611565b505f84815260208120818655555b505b50600182019150613791565b50505b505f8181526020812083915b858110156138375761381783866135c0565b613822818386613663565b50506020929092019160019182019101613805565b505050505050565b61384982836135c0565b613854818385613663565b505061386360208301836135c0565b613871818360018601613663565b505061388060408301836135c0565b61388e818360028601613663565b505061389d60608301836135c0565b6138ab818360038601613663565b50506138ba608083018361371c565b6138c8818360048601613761565b505060a0820135600582015560c0820135600682015560e08201356007820155610100820135600882015561012090910135600990910155565b608081525f61391560808301888a6133b9565b82810360208401526139288187896133b9565b6040840195909552505060600152949350505050565b5f6001820161394f5761394f613333565b5060010190565b5f82518060208501845e5f920191825250919050565b634e487b7160e01b5f52603260045260245ffd5b5f815461398c8161323f565b8085526001821680156139a657600181146139c2576139f6565b60ff1983166020870152602082151560051b87010193506139f6565b845f5260205f205f5b838110156139ed5781546020828a0101526001820191506020810190506139cb565b87016020019450505b50505092915050565b61010081525f613a1361010083018b613980565b8281036020840152613a25818b613980565b90508281036040840152613a39818a613980565b90508281036060840152613a4d8189613980565b9050828103608084015280875480835260208301915060208160051b840101895f5260205f205f5b83811015613aa557858303601f19018552613a908383613980565b60209590950194925060019182019101613a75565b505060a086018990526001600160a01b03881660c08701529350613ac892505050565b6001600160a01b03831660e0830152999850505050505050505056fe608060405234801561000f575f5ffd5b5060408051602080820183525f808352835191820190935291825233916003610038838261016d565b506004610045828261016d565b5050506001600160a01b03811661007557604051631e4fbdf760e01b81525f600482015260240160405180910390fd5b61007e81610084565b50610227565b600580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b634e487b7160e01b5f52604160045260245ffd5b600181811c908216806100fd57607f821691505b60208210810361011b57634e487b7160e01b5f52602260045260245ffd5b50919050565b601f82111561016857805f5260205f20601f840160051c810160208510156101465750805b601f840160051c820191505b81811015610165575f8155600101610152565b50505b505050565b81516001600160401b03811115610186576101866100d5565b61019a8161019484546100e9565b84610121565b6020601f8211600181146101cc575f83156101b55750848201515b5f19600385901b1c1916600184901b178455610165565b5f84815260208120601f198516915b828110156101fb57878501518255602094850194600190920191016101db565b508482101561021857868401515f19600387901b60f8161c191681555b50505050600190811b01905550565b6121f8806102345f395ff3fe608060405234801561000f575f5ffd5b506004361061021e575f3560e01c806379cc67901161012a578063aa2fe91b116100b4578063d5abeb0111610079578063d5abeb0114610490578063dd62ed3e14610499578063ec0cdf62146104ac578063ee711299146104ce578063f2fde38b146104e1575f5ffd5b8063aa2fe91b14610429578063aba831501461044b578063abb1dc4414610453578063cd059a6414610472578063cf09e0d014610487575f5ffd5b80637d64bcb4116100fa5780637d64bcb4146103e2578063842392c2146103ea5780638da5cb5b146103fd57806395d89b411461040e578063a9059cbb14610416575f5ffd5b806379cc6790146103925780637a5b4f59146103a55780637b912633146103bc5780637c86819f146103cf575f5ffd5b806340c10f19116101ab5780635f710f5c1161017b5780635f710f5c146103345780636902ee941461034757806370a082311461035a578063715018a6146103825780637284e4161461038a575f5ffd5b806340c10f19146102e657806342966c68146102fb578063475ae0391461030e5780635f44b42a14610321575f5ffd5b80630e79fe4f116101f15780630e79fe4f1461029757806318160ddd146102a957806320c02918146102b157806323b872dd146102c4578063313ce567146102d7575f5ffd5b806302d05d3f1461022257806305d2035b1461025257806306fdde031461026f578063095ea7b314610284575b5f5ffd5b600b54610235906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b60105461025f9060ff1681565b6040519015158152602001610249565b6102776104f4565b6040516102499190611883565b61025f6102923660046118b7565b610584565b600a545b604051908152602001610249565b60025461029b565b61025f6102bf3660046118df565b61059d565b61025f6102d23660046118f8565b6105e5565b60405160128152602001610249565b6102f96102f43660046118b7565b610608565b005b6102f9610309366004611932565b6106fe565b6102f961031c3660046118df565b61072b565b6102f961032f36600461198d565b61077b565b6102f96103423660046118df565b6108bd565b6102f96103553660046118df565b610937565b61029b6103683660046118df565b6001600160a01b03165f9081526020819052604090205490565b6102f9610987565b61027761099a565b6102f96103a03660046118b7565b6109a9565b6103ad610a95565b60405161024993929190611ab3565b6102776103ca366004611932565b610c8d565b6102f96103dd3660046118df565b610d80565b6102f9610dfa565b61025f6103f83660046118df565b610e39565b6005546001600160a01b0316610235565b610277610e6b565b61025f6104243660046118b7565b610e7a565b61025f6104373660046118df565b600d6020525f908152604090205460ff1681565b610277610e87565b61045b610e96565b6040516102499b9a99989796959493929190611af5565b61047a6110e5565b6040516102499190611ba1565b61029b600c5481565b61029b600f5481565b61029b6104a7366004611bb3565b6111b9565b61025f6104ba3660046118df565b600e6020525f908152604090205460ff1681565b6102f96104dc366004611d2b565b6111e3565b6102f96104ef3660046118df565b61139e565b60606003805461050390611e33565b80601f016020809104026020016040519081016040528092919081815260200182805461052f90611e33565b801561057a5780601f106105515761010080835404028352916020019161057a565b820191905f5260205f20905b81548152906001019060200180831161055d57829003601f168201915b5050505050905090565b5f336105918185856113d8565b60019150505b92915050565b6001600160a01b0381165f908152600e602052604081205460ff168061059757506005546001600160a01b03165b6001600160a01b0316826001600160a01b03161492915050565b5f336105f28582856113e5565b6105fd858585611449565b506001949350505050565b335f908152600d602052604090205460ff1615801561063257506005546001600160a01b03163314155b156106505760405163086ca11d60e31b815260040160405180910390fd5b60105460ff16156106745760405163b6ac1cf960e01b815260040160405180910390fd5b6001600160a01b03821661069b57604051633682629560e11b815260040160405180910390fd5b805f036106bb576040516363fcd3b960e11b815260040160405180910390fd5b600f54816106c860025490565b6106d29190611e6b565b11156106f0576040516272084360e61b815260040160405180910390fd5b6106fa82826114a6565b5050565b805f0361071e576040516363fcd3b960e11b815260040160405180910390fd5b61072833826114da565b50565b61073361150e565b6001600160a01b0381165f818152600d6020526040808220805460ff19169055517fc6711413797b8a562634e98c95d50e7619d39702ed5b82ce335dc93546c3a88c9190a250565b600b546001600160a01b031633148015906107a157506005546001600160a01b03163314155b156107bf5760405163086ca11d60e31b815260040160405180910390fd5b60086107cc868883611ed5565b5060096107da848683611ed5565b506107e6600a5f611784565b5f5b8181101561083e57600a83838381811061080457610804611f8e565b90506020028101906108169190611fa2565b82546001810184555f9384526020909320909201916108359183611ed5565b506001016107e8565b507f30f5c4b652f95e2a697bda3258896c421eee4f29adce8fe38060f47f7aed91ad86868686604051610874949392919061200c565b60405180910390a17f7df797e625699c133589f41655ee1105feb3d9ad58de1da49d5a7a8151f3c21282826040516108ad92919061203d565b60405180910390a1505050505050565b6108c561150e565b6001600160a01b0381166108ec57604051633682629560e11b815260040160405180910390fd5b6001600160a01b0381165f818152600d6020526040808220805460ff19166001179055517fe6be4d6cc04eb0219337b22db08c688969a9ec8e34d9a0a2ba38a114e050f1ae9190a250565b61093f61150e565b6001600160a01b0381165f818152600e6020526040808220805460ff19169055517f6bdf1f211a30127658f9585e208ab17600bbccd6e493a51ea9242f3e6ab712149190a250565b61098f61150e565b6109985f61153b565b565b60606008805461050390611e33565b335f908152600e602052604090205460ff161580156109d357506005546001600160a01b03163314155b156109f15760405163086ca11d60e31b815260040160405180910390fd5b6001600160a01b038216610a1857604051633682629560e11b815260040160405180910390fd5b805f03610a38576040516363fcd3b960e11b815260040160405180910390fd5b5f610a4383336111b9565b905081811015610a7b57604051637dc7a0d960e11b815233600482015260248101829052604481018390526064015b60405180910390fd5b610a868333846113e5565b610a9083836114da565b505050565b606080606060086009600a828054610aac90611e33565b80601f0160208091040260200160405190810160405280929190818152602001828054610ad890611e33565b8015610b235780601f10610afa57610100808354040283529160200191610b23565b820191905f5260205f20905b815481529060010190602001808311610b0657829003601f168201915b50505050509250818054610b3690611e33565b80601f0160208091040260200160405190810160405280929190818152602001828054610b6290611e33565b8015610bad5780601f10610b8457610100808354040283529160200191610bad565b820191905f5260205f20905b815481529060010190602001808311610b9057829003601f168201915b5050505050915080805480602002602001604051908101604052809291908181526020015f905b82821015610c7c578382905f5260205f20018054610bf190611e33565b80601f0160208091040260200160405190810160405280929190818152602001828054610c1d90611e33565b8015610c685780601f10610c3f57610100808354040283529160200191610c68565b820191905f5260205f20905b815481529060010190602001808311610c4b57829003601f168201915b505050505081526020019060010190610bd4565b505050509050925092509250909192565b600a546060908210610cd75760405162461bcd60e51b8152602060048201526013602482015272496e646578206f7574206f6620626f756e647360681b6044820152606401610a72565b600a8281548110610cea57610cea611f8e565b905f5260205f20018054610cfd90611e33565b80601f0160208091040260200160405190810160405280929190818152602001828054610d2990611e33565b8015610d745780601f10610d4b57610100808354040283529160200191610d74565b820191905f5260205f20905b815481529060010190602001808311610d5757829003601f168201915b50505050509050919050565b610d8861150e565b6001600160a01b038116610daf57604051633682629560e11b815260040160405180910390fd5b6001600160a01b0381165f818152600e6020526040808220805460ff19166001179055517f0f0faf33f6e4834272eed76906acd77c4b6c98d32c41169d08086a8658cecd319190a250565b610e0261150e565b6010805460ff191660011790556040517fb828d9b5c78095deeeeff2eca2e5d4fe046ce3feb4c99702624a3fd384ad2dbc905f90a1565b6001600160a01b0381165f908152600d602052604081205460ff168061059757506005546001600160a01b03166105cb565b60606004805461050390611e33565b5f33610591818585611449565b60606009805461050390611e33565b6060805f5f5f5f5f5f6060806060610eac6104f4565b610eb4610e6b565b6012600254600f54600b54600c54601054600880546001600160a01b039094169360ff90921691600990600a908390610eec90611e33565b80601f0160208091040260200160405190810160405280929190818152602001828054610f1890611e33565b8015610f635780601f10610f3a57610100808354040283529160200191610f63565b820191905f5260205f20905b815481529060010190602001808311610f4657829003601f168201915b50505050509250818054610f7690611e33565b80601f0160208091040260200160405190810160405280929190818152602001828054610fa290611e33565b8015610fed5780601f10610fc457610100808354040283529160200191610fed565b820191905f5260205f20905b815481529060010190602001808311610fd057829003601f168201915b5050505050915080805480602002602001604051908101604052809291908181526020015f905b828210156110bc578382905f5260205f2001805461103190611e33565b80601f016020809104026020016040519081016040528092919081815260200182805461105d90611e33565b80156110a85780601f1061107f576101008083540402835291602001916110a8565b820191905f5260205f20905b81548152906001019060200180831161108b57829003601f168201915b505050505081526020019060010190611014565b5050505090509a509a509a509a509a509a509a509a509a509a509a50909192939495969798999a565b6060600a805480602002602001604051908101604052809291908181526020015f905b828210156111b0578382905f5260205f2001805461112590611e33565b80601f016020809104026020016040519081016040528092919081815260200182805461115190611e33565b801561119c5780601f106111735761010080835404028352916020019161119c565b820191905f5260205f20905b81548152906001019060200180831161117f57829003601f168201915b505050505081526020019060010190611108565b50505050905090565b6001600160a01b039182165f90815260016020908152604080832093909416825291909152205490565b601054610100900460ff161561120c5760405163086ca11d60e31b815260040160405180910390fd5b6001600160a01b038216158061122957506001600160a01b038116155b1561124757604051633682629560e11b815260040160405180910390fd5b825f03611267576040516363fcd3b960e11b815260040160405180910390fd5b6010805461ff001916610100179055600661128289826120db565b50600761128f88826120db565b506112998161153b565b60086112a587826120db565b5060096112b286826120db565b5083516112c690600a90602087019061179f565b50600f839055600b80546001600160a01b0319166001600160a01b038481169190911790915542600c5581165f908152600d60209081526040808320805460ff199081166001908117909255600e9093529281902080549092169092179055517f30f5c4b652f95e2a697bda3258896c421eee4f29adce8fe38060f47f7aed91ad906113559088908890612195565b60405180910390a17f7df797e625699c133589f41655ee1105feb3d9ad58de1da49d5a7a8151f3c2128460405161138c9190611ba1565b60405180910390a15050505050505050565b6113a661150e565b6001600160a01b0381166113cf57604051631e4fbdf760e01b81525f6004820152602401610a72565b6107288161153b565b610a90838383600161158c565b5f6113f084846111b9565b90505f19811015611443578181101561143557604051637dc7a0d960e11b81526001600160a01b03841660048201526024810182905260448101839052606401610a72565b61144384848484035f61158c565b50505050565b6001600160a01b03831661147257604051634b637e8f60e11b81525f6004820152602401610a72565b6001600160a01b03821661149b5760405163ec442f0560e01b81525f6004820152602401610a72565b610a9083838361165e565b6001600160a01b0382166114cf5760405163ec442f0560e01b81525f6004820152602401610a72565b6106fa5f838361165e565b6001600160a01b03821661150357604051634b637e8f60e11b81525f6004820152602401610a72565b6106fa825f8361165e565b6005546001600160a01b031633146109985760405163118cdaa760e01b8152336004820152602401610a72565b600580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b6001600160a01b0384166115b55760405163e602df0560e01b81525f6004820152602401610a72565b6001600160a01b0383166115de57604051634a1406b160e11b81525f6004820152602401610a72565b6001600160a01b038085165f908152600160209081526040808320938716835292905220829055801561144357826001600160a01b0316846001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258460405161165091815260200190565b60405180910390a350505050565b6001600160a01b038316611688578060025f82825461167d9190611e6b565b909155506116f89050565b6001600160a01b0383165f90815260208190526040902054818110156116da5760405163391434e360e21b81526001600160a01b03851660048201526024810182905260448101839052606401610a72565b6001600160a01b0384165f9081526020819052604090209082900390555b6001600160a01b03821661171457600280548290039055611732565b6001600160a01b0382165f9081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161177791815260200190565b60405180910390a3505050565b5080545f8255905f5260205f209081019061072891906117f3565b828054828255905f5260205f209081019282156117e3579160200282015b828111156117e357825182906117d390826120db565b50916020019190600101906117bd565b506117ef9291506117f3565b5090565b808211156117ef575f611806828261180f565b506001016117f3565b50805461181b90611e33565b5f825580601f1061182a575050565b601f0160209004905f5260205f209081019061072891905b808211156117ef575f8155600101611842565b5f81518084528060208401602086015e5f602082860101526020601f19601f83011685010191505092915050565b602081525f6118956020830184611855565b9392505050565b80356001600160a01b03811681146118b2575f5ffd5b919050565b5f5f604083850312156118c8575f5ffd5b6118d18361189c565b946020939093013593505050565b5f602082840312156118ef575f5ffd5b6118958261189c565b5f5f5f6060848603121561190a575f5ffd5b6119138461189c565b92506119216020850161189c565b929592945050506040919091013590565b5f60208284031215611942575f5ffd5b5035919050565b5f5f83601f840112611959575f5ffd5b5081356001600160401b0381111561196f575f5ffd5b602083019150836020828501011115611986575f5ffd5b9250929050565b5f5f5f5f5f5f606087890312156119a2575f5ffd5b86356001600160401b038111156119b7575f5ffd5b6119c389828a01611949565b90975095505060208701356001600160401b038111156119e1575f5ffd5b6119ed89828a01611949565b90955093505060408701356001600160401b03811115611a0b575f5ffd5b8701601f81018913611a1b575f5ffd5b80356001600160401b03811115611a30575f5ffd5b8960208260051b8401011115611a44575f5ffd5b60208201935080925050509295509295509295565b5f82825180855260208501945060208160051b830101602085015f5b83811015611aa757601f19858403018852611a91838351611855565b6020988901989093509190910190600101611a75565b50909695505050505050565b606081525f611ac56060830186611855565b8281036020840152611ad78186611855565b90508281036040840152611aeb8185611a59565b9695505050505050565b61016081525f611b0961016083018e611855565b8281036020840152611b1b818e611855565b60ff8d166040850152606084018c9052608084018b90526001600160a01b038a1660a085015260c0840189905287151560e08501529050828103610100840152611b658187611855565b9050828103610120840152611b7a8186611855565b9050828103610140840152611b8f8185611a59565b9e9d5050505050505050505050505050565b602081525f6118956020830184611a59565b5f5f60408385031215611bc4575f5ffd5b611bcd8361189c565b9150611bdb6020840161189c565b90509250929050565b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f191681016001600160401b0381118282101715611c2057611c20611be4565b604052919050565b5f82601f830112611c37575f5ffd5b81356001600160401b03811115611c5057611c50611be4565b611c63601f8201601f1916602001611bf8565b818152846020838601011115611c77575f5ffd5b816020850160208301375f918101602001919091529392505050565b5f82601f830112611ca2575f5ffd5b81356001600160401b03811115611cbb57611cbb611be4565b8060051b611ccb60208201611bf8565b91825260208185018101929081019086841115611ce6575f5ffd5b6020860192505b83831015611aeb5782356001600160401b03811115611d0a575f5ffd5b611d19886020838a0101611c28565b83525060209283019290910190611ced565b5f5f5f5f5f5f5f5f610100898b031215611d43575f5ffd5b88356001600160401b03811115611d58575f5ffd5b611d648b828c01611c28565b98505060208901356001600160401b03811115611d7f575f5ffd5b611d8b8b828c01611c28565b97505060408901356001600160401b03811115611da6575f5ffd5b611db28b828c01611c28565b96505060608901356001600160401b03811115611dcd575f5ffd5b611dd98b828c01611c28565b95505060808901356001600160401b03811115611df4575f5ffd5b611e008b828c01611c93565b94505060a08901359250611e1660c08a0161189c565b9150611e2460e08a0161189c565b90509295985092959890939650565b600181811c90821680611e4757607f821691505b602082108103611e6557634e487b7160e01b5f52602260045260245ffd5b50919050565b8082018082111561059757634e487b7160e01b5f52601160045260245ffd5b601f821115610a9057805f5260205f20601f840160051c81016020851015611eaf5750805b601f840160051c820191505b81811015611ece575f8155600101611ebb565b5050505050565b6001600160401b03831115611eec57611eec611be4565b611f0083611efa8354611e33565b83611e8a565b5f601f841160018114611f31575f8515611f1a5750838201355b5f19600387901b1c1916600186901b178355611ece565b5f83815260208120601f198716915b82811015611f605786850135825560209485019460019092019101611f40565b5086821015611f7c575f1960f88860031b161c19848701351681555b505060018560011b0183555050505050565b634e487b7160e01b5f52603260045260245ffd5b5f5f8335601e19843603018112611fb7575f5ffd5b8301803591506001600160401b03821115611fd0575f5ffd5b602001915036819003821315611986575f5ffd5b81835281816020850137505f828201602090810191909152601f909101601f19169091010190565b604081525f61201f604083018688611fe4565b8281036020840152612032818587611fe4565b979650505050505050565b602080825281018290525f6040600584901b830181019083018583601e1936839003015b878210156120ce57868503603f19018452823581811261207f575f5ffd5b89016020810190356001600160401b0381111561209a575f5ffd5b8036038213156120a8575f5ffd5b6120b3878284611fe4565b96505050602083019250602084019350600182019150612061565b5092979650505050505050565b81516001600160401b038111156120f4576120f4611be4565b612108816121028454611e33565b84611e8a565b6020601f82116001811461213a575f83156121235750848201515b5f19600385901b1c1916600184901b178455611ece565b5f84815260208120601f198516915b828110156121695787850151825560209485019460019092019101612149565b508482101561218657868401515f19600387901b60f8161c191681555b50505050600190811b01905550565b604081525f6121a76040830185611855565b82810360208401526121b98185611855565b9594505050505056fea2646970667358221220058d598cbfea19513122f9f97d8ca65ccc4d2f0d4d16ae86cb42a70ea945942a64736f6c634300081e0033360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800cd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300a49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775a2646970667358221220ba378661b3c78139a9d73d3c220d7522c574fe99afd942602652c7a622fbcf0964736f6c634300081e0033
Verified Source Code Full Match
Compiler: v0.8.30+commit.73712a01
EVM: prague
Optimization: Yes (200 runs)
TokenFactory.sol 470 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol";
import "./ILaxcePadInterfaces.sol";
import "./LaxcePadToken.sol";
import "./ValidationLibrary.sol";
contract TokenFactory is
Initializable,
ReentrancyGuardUpgradeable,
UUPSUpgradeable,
AccessControlUpgradeable,
PausableUpgradeable,
ITokenFactory,
IDEXIntegration
{
bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE");
bytes32 public constant OPERATOR_ROLE = keccak256("OPERATOR_ROLE");
bytes32 public constant UPGRADER_ROLE = keccak256("UPGRADER_ROLE");
uint256 public constant MIN_CREATION_FEE = 0;
uint256 public constant MAX_CREATION_FEE = 1 ether;
address public tokenRegistry;
address public poolFactory;
address public dexEngine;
address public coreRegistry;
address public bondingCurve;
struct FactorySettings {
uint256 creationFee;
uint256 defaultMaxSupply;
address feeRecipient;
bool requireApproval;
uint256 minCreationDelay;
}
FactorySettings public factorySettings;
ITokenFactory.SupplyLimits public supplyLimits;
mapping(address => ITokenFactory.TokenParams) public tokenInfo;
mapping(address => address[]) public creatorTokens;
address[] public allTokens;
mapping(string => address) public symbolToToken;
mapping(address => uint256) public creatorLastCreation;
mapping(address => uint256) public creatorTokenCount;
mapping(address => bool) public creatorWhitelist;
mapping(address => bool) public creatorBlacklist;
struct FactoryStats {
uint256 totalTokens;
uint256 totalCreators;
uint256 totalFeesCollected;
uint256 averageCreationFee;
}
FactoryStats public factoryStats;
event TokenCreated(
address indexed token,
address indexed creator,
string name,
string symbol,
uint256 maxSupply,
uint256 creationFee
);
event FactorySettingsUpdated(FactorySettings settings);
event DEXIntegrationUpdated(
address tokenRegistry,
address poolFactory,
address dexEngine,
address coreRegistry
);
event CreatorWhitelisted(address indexed creator, bool whitelisted);
event CreatorBlacklisted(address indexed creator, bool blacklisted);
error InvalidParams();
error InsufficientFee();
error SymbolExists();
error Blacklisted();
error DelayNotMet();
error InvalidAddr();
error NotFound();
error NotAuth();
error InvalidLen();
function initialize(
address _admin,
FactorySettings memory _settings,
address _coreRegistry
) external initializer {
_initializeContracts();
_setupAdmin(_admin);
_configureSettings(_settings, _coreRegistry);
_setDefaultLimits();
}
function _setDefaultLimits() internal {
supplyLimits = ITokenFactory.SupplyLimits({
minTotalSupply: 1000000 * 1e18,
maxTotalSupply: 1000000000000 * 1e18,
minBondingCurvePercent: 1000,
maxBondingCurvePercent: 9000,
minStartPrice: 1e12,
maxStartPrice: 1e17,
minTargetMarketCap: 10 ether,
maxTargetMarketCap: 1000 ether
});
}
function _initializeContracts() internal {
__ReentrancyGuard_init();
__UUPSUpgradeable_init();
__AccessControl_init();
__Pausable_init();
}
function _setupAdmin(address _admin) internal {
if (_admin == address(0)) {
revert InvalidAddr();
}
_grantRole(DEFAULT_ADMIN_ROLE, _admin);
_grantRole(ADMIN_ROLE, _admin);
_grantRole(OPERATOR_ROLE, _admin);
_grantRole(UPGRADER_ROLE, _admin);
}
function _configureSettings(FactorySettings memory _settings, address _coreRegistry) internal {
factorySettings = _settings;
coreRegistry = _coreRegistry;
}
function _updateFactoryStats(uint256 feeAmount, bool isFirstToken) internal {
factoryStats.totalTokens++;
if (isFirstToken) {
factoryStats.totalCreators++;
}
factoryStats.totalFeesCollected += feeAmount;
factoryStats.averageCreationFee = factoryStats.totalFeesCollected / factoryStats.totalTokens;
}
function _initializeToken(address token, ITokenFactory.TokenParams calldata params) internal {
uint256 maxSupply = params.totalSupply > 0 ? params.totalSupply : factorySettings.defaultMaxSupply;
_initializeTokenWithParams(token, params, maxSupply);
}
function _initializeTokenWithParams(address token, ITokenFactory.TokenParams calldata params, uint256 maxSupply) internal {
_tempTokenData.token = token;
_tempTokenData.maxSupply = maxSupply;
_tempTokenData.creator = msg.sender;
_tempTokenData.factory = address(this);
_performTokenInitialization(params);
}
struct TempTokenData {
address token;
uint256 maxSupply;
address creator;
address factory;
}
TempTokenData private _tempTokenData;
string[] private _tempSocialLinks;
string private _tempName;
string private _tempSymbol;
string private _tempDescription;
string private _tempImageUrl;
function _performTokenInitialization(ITokenFactory.TokenParams calldata params) internal {
_storeTokenParams(params);
_callTokenInitialize();
_clearTempData();
}
function _storeTokenParams(ITokenFactory.TokenParams calldata params) internal {
_tempName = params.name;
_tempSymbol = params.symbol;
_tempDescription = params.description;
_tempImageUrl = params.imageUrl;
delete _tempSocialLinks;
for (uint256 i = 0; i < params.socialLinks.length; i++) {
_tempSocialLinks.push(params.socialLinks[i]);
}
}
function _callTokenInitialize() internal {
LaxcePadToken(_tempTokenData.token).initialize(
_tempName,
_tempSymbol,
_tempDescription,
_tempImageUrl,
_tempSocialLinks,
_tempTokenData.maxSupply,
_tempTokenData.creator,
_tempTokenData.factory
);
}
function _clearTempData() internal {
delete _tempTokenData;
delete _tempSocialLinks;
delete _tempName;
delete _tempSymbol;
delete _tempDescription;
delete _tempImageUrl;
}
function _registerToken(address token, ITokenFactory.TokenParams calldata params) internal {
tokenInfo[token] = params;
creatorTokens[msg.sender].push(token);
allTokens.push(token);
symbolToToken[params.symbol] = token;
}
function _updateStats() internal {
creatorLastCreation[msg.sender] = block.timestamp;
creatorTokenCount[msg.sender]++;
bool isFirstToken = (creatorTokenCount[msg.sender] == 1);
_updateFactoryStats(msg.value, isFirstToken);
}
mapping(address => address) private pendingTokens;
function createToken(
ITokenFactory.TokenParams calldata params
) external payable nonReentrant whenNotPaused returns (address token) {
_performAllValidations(params);
token = _deployAndSetupToken(params);
return token;
}
function _performAllValidations(ITokenFactory.TokenParams calldata params) internal view {
if (creatorBlacklist[msg.sender]) revert Blacklisted();
if (factorySettings.requireApproval && !creatorWhitelist[msg.sender] && !hasRole(ADMIN_ROLE, msg.sender)) {
revert NotAuth();
}
if (block.timestamp < creatorLastCreation[msg.sender] + factorySettings.minCreationDelay) {
revert DelayNotMet();
}
_validateTokenParams(params);
_validateCreationRequirements(params);
}
function _validateCreationRequirements(ITokenFactory.TokenParams calldata params) internal view {
if (msg.value < factorySettings.creationFee) revert InsufficientFee();
if (symbolToToken[params.symbol] != address(0)) revert SymbolExists();
}
function _deployAndSetupToken(ITokenFactory.TokenParams calldata params) internal returns (address token) {
LaxcePadToken newToken = new LaxcePadToken();
token = address(newToken);
pendingTokens[msg.sender] = token;
_initializeToken(token, params);
_registerToken(token, params);
_completeTokenFinalization(token, params);
delete pendingTokens[msg.sender];
}
function _completeTokenFinalization(address token, ITokenFactory.TokenParams calldata params) internal {
_updateStats();
if (bondingCurve != address(0)) {
_initializeBondingCurve(token, params);
}
if (msg.value > 0 && factorySettings.feeRecipient != address(0)) {
payable(factorySettings.feeRecipient).transfer(msg.value);
}
emit TokenCreated(token, msg.sender, params.name, params.symbol, params.totalSupply, msg.value);
}
function _validateTokenParams(ITokenFactory.TokenParams calldata params) internal view {
ValidationLibrary.validateTokenParams(params);
if (params.totalSupply < supplyLimits.minTotalSupply ||
params.totalSupply > supplyLimits.maxTotalSupply) {
revert InvalidParams();
}
if (params.bondingCurveSupply > 0) {
uint256 bondingCurvePercent = (params.bondingCurveSupply * 10000) / params.totalSupply;
if (bondingCurvePercent < supplyLimits.minBondingCurvePercent ||
bondingCurvePercent > supplyLimits.maxBondingCurvePercent) {
revert InvalidParams();
}
}
if (params.startPrice > 0) {
if (params.startPrice < supplyLimits.minStartPrice ||
params.startPrice > supplyLimits.maxStartPrice) {
revert InvalidParams();
}
}
if (params.targetMarketCap > 0) {
if (params.targetMarketCap < supplyLimits.minTargetMarketCap ||
params.targetMarketCap > supplyLimits.maxTargetMarketCap) {
revert InvalidParams();
}
}
}
function _initializeBondingCurve(address token, ITokenFactory.TokenParams calldata params) internal {
if (bondingCurve == address(0)) return;
if (params.bondingCurveSupply == 0) return;
uint256 startPrice = params.startPrice > 0
? params.startPrice
: supplyLimits.minStartPrice * 10;
uint256 targetMarketCap = params.targetMarketCap > 0
? params.targetMarketCap
: 85 ether;
LaxcePadToken tokenContract = LaxcePadToken(token);
tokenContract.mint(bondingCurve, params.bondingCurveSupply);
IBondingCurve(bondingCurve).initializeCurve(
token,
params.bondingCurveSupply,
startPrice,
targetMarketCap
);
}
function getTokenInfo(address token) external view returns (ITokenFactory.TokenParams memory) {
if (tokenInfo[token].totalSupply == 0) revert NotFound();
return tokenInfo[token];
}
function isTokenCreated(address token) external view returns (bool) {
return tokenInfo[token].totalSupply > 0;
}
function getSupplyLimits() external view returns (ITokenFactory.SupplyLimits memory) {
return supplyLimits;
}
function getTokenRegistry() external view returns (address) {
return tokenRegistry;
}
function getPoolFactory() external view returns (address) {
return poolFactory;
}
function getDEXEngine() external view returns (address) {
return dexEngine;
}
function getCoreRegistry() external view returns (address) {
return coreRegistry;
}
function updateFactorySettings(FactorySettings calldata settings) external onlyRole(ADMIN_ROLE) {
if (settings.creationFee > MAX_CREATION_FEE) {
revert InvalidParams();
}
if (settings.feeRecipient == address(0)) revert InvalidAddr();
factorySettings = settings;
emit FactorySettingsUpdated(settings);
}
function updateCreationFee(uint256 newFee) external onlyRole(ADMIN_ROLE) {
if (newFee > MAX_CREATION_FEE) {
revert InvalidParams();
}
factorySettings.creationFee = newFee;
emit FactorySettingsUpdated(factorySettings);
}
function updateSupplyLimits(ITokenFactory.SupplyLimits calldata newLimits) external onlyRole(ADMIN_ROLE) {
if (newLimits.minTotalSupply == 0 || newLimits.maxTotalSupply == 0) {
revert InvalidParams();
}
if (newLimits.minTotalSupply > newLimits.maxTotalSupply) {
revert InvalidParams();
}
if (newLimits.minBondingCurvePercent > newLimits.maxBondingCurvePercent) {
revert InvalidParams();
}
if (newLimits.minStartPrice > newLimits.maxStartPrice) {
revert InvalidParams();
}
if (newLimits.minTargetMarketCap > newLimits.maxTargetMarketCap) {
revert InvalidParams();
}
supplyLimits = newLimits;
emit SupplyLimitsUpdated(newLimits);
}
event SupplyLimitsUpdated(ITokenFactory.SupplyLimits limits);
function updateDEXIntegration(
address _tokenRegistry,
address _poolFactory,
address _dexEngine,
address _bondingCurve
) external onlyRole(ADMIN_ROLE) {
_setDEXAddresses(_tokenRegistry, _poolFactory, _dexEngine, _bondingCurve);
emit DEXIntegrationUpdated(_tokenRegistry, _poolFactory, _dexEngine, coreRegistry);
}
function _setDEXAddresses(
address _tokenRegistry,
address _poolFactory,
address _dexEngine,
address _bondingCurve
) internal {
tokenRegistry = _tokenRegistry;
poolFactory = _poolFactory;
dexEngine = _dexEngine;
bondingCurve = _bondingCurve;
}
function setCreatorWhitelist(address creator, bool whitelisted) external onlyRole(ADMIN_ROLE) {
creatorWhitelist[creator] = whitelisted;
emit CreatorWhitelisted(creator, whitelisted);
}
function setCreatorBlacklist(address creator, bool blacklisted) external onlyRole(ADMIN_ROLE) {
creatorBlacklist[creator] = blacklisted;
emit CreatorBlacklisted(creator, blacklisted);
}
function pause() external onlyRole(ADMIN_ROLE) {
_pause();
}
function unpause() external onlyRole(ADMIN_ROLE) {
_unpause();
}
function withdrawFees(address to) external onlyRole(ADMIN_ROLE) {
if (to == address(0)) revert InvalidAddr();
uint256 balance = address(this).balance;
if (balance > 0) {
payable(to).transfer(balance);
}
}
function _authorizeUpgrade(address newImplementation) internal view override onlyRole(UPGRADER_ROLE) {
newImplementation;
}
}
ValidationLibrary.sol 102 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "./ILaxcePadInterfaces.sol";
/**
* @title ValidationLibrary
* @dev Library to reduce TokenFactory contract size by moving validation logic
*/
library ValidationLibrary {
uint256 public constant MAX_NAME_LENGTH = 50;
uint256 public constant MAX_SYMBOL_LENGTH = 10;
uint256 public constant MAX_DESCRIPTION_LENGTH = 500;
uint256 public constant MAX_SOCIAL_LINKS = 10;
error InvalidParams();
error InvalidLen();
function validateTokenParams(ITokenFactory.TokenParams calldata params) external pure {
validateStringParams(params);
validateSupplyParams(params);
}
function validateStringParams(ITokenFactory.TokenParams calldata params) public pure {
validateName(params.name);
validateSymbol(params.symbol);
validateDescription(params.description);
validateSocialLinks(params.socialLinks);
}
function validateName(string calldata name) public pure {
if (bytes(name).length == 0 || bytes(name).length > MAX_NAME_LENGTH) {
revert InvalidLen();
}
}
function validateSymbol(string calldata symbol) public pure {
if (bytes(symbol).length == 0 || bytes(symbol).length > MAX_SYMBOL_LENGTH) {
revert InvalidLen();
}
}
function validateDescription(string calldata description) public pure {
if (bytes(description).length > MAX_DESCRIPTION_LENGTH) {
revert InvalidLen();
}
}
function validateSocialLinks(string[] calldata socialLinks) public pure {
if (socialLinks.length > MAX_SOCIAL_LINKS) {
revert InvalidParams();
}
}
function validateSupplyParams(ITokenFactory.TokenParams calldata params) public pure {
validateTotalSupply(params.totalSupply);
validateSupplyDistribution(params.totalSupply, params.bondingCurveSupply, params.liquiditySupply);
}
function validateTotalSupply(uint256 totalSupply) public pure {
if (totalSupply == 0) {
revert InvalidParams();
}
}
function validateSupplyDistribution(
uint256 totalSupply,
uint256 bondingCurveSupply,
uint256 liquiditySupply
) public pure {
if (bondingCurveSupply > totalSupply) {
revert InvalidParams();
}
if (liquiditySupply > totalSupply) {
revert InvalidParams();
}
if (bondingCurveSupply + liquiditySupply > totalSupply) {
revert InvalidParams();
}
}
function stringContains(string memory str, string memory substr) external pure returns (bool) {
bytes memory strBytes = bytes(str);
bytes memory substrBytes = bytes(substr);
if (substrBytes.length > strBytes.length) return false;
if (substrBytes.length == 0) return true;
for (uint256 i = 0; i <= strBytes.length - substrBytes.length; i++) {
bool found = true;
for (uint256 j = 0; j < substrBytes.length; j++) {
if (strBytes[i + j] != substrBytes[j]) {
found = false;
break;
}
}
if (found) return true;
}
return false;
}
}
LaxcePadToken.sol 236 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "./ILaxcePadInterfaces.sol";
contract LaxcePadToken is ERC20, Ownable, ILaxcePadToken {
string private _name;
string private _symbol;
string private _description;
string private _imageUrl;
string[] private _socialLinks;
address public creator;
uint256 public createdAt;
mapping(address => bool) public authorizedMinters;
mapping(address => bool) public authorizedBurners;
uint256 public maxSupply;
bool public mintingFinished;
event MetadataUpdated(string description, string imageUrl);
event SocialLinksUpdated(string[] socialLinks);
event AuthorizedMinterAdded(address indexed minter);
event AuthorizedMinterRemoved(address indexed minter);
event AuthorizedBurnerAdded(address indexed burner);
event AuthorizedBurnerRemoved(address indexed burner);
event MintingFinished();
error Token__NotAuthorized();
error Token__ExceedsMaxSupply();
error Token__MintingFinished();
error Token__InvalidAddress();
error Token__InvalidAmount();
modifier onlyAuthorizedMinter() {
if (!authorizedMinters[msg.sender] && msg.sender != owner()) {
revert Token__NotAuthorized();
}
_;
}
modifier onlyAuthorizedBurner() {
if (!authorizedBurners[msg.sender] && msg.sender != owner()) {
revert Token__NotAuthorized();
}
_;
}
modifier whenMintingNotFinished() {
if (mintingFinished) revert Token__MintingFinished();
_;
}
bool private _initialized;
constructor() ERC20("", "") Ownable(msg.sender) {
}
function initialize(
string memory name,
string memory symbol,
string memory desc,
string memory imgUrl,
string[] memory socLinks,
uint256 _maxSupply,
address _creator,
address _owner
) external {
if (_initialized) revert Token__NotAuthorized();
if (_creator == address(0) || _owner == address(0)) revert Token__InvalidAddress();
if (_maxSupply == 0) revert Token__InvalidAmount();
_initialized = true;
_name = name;
_symbol = symbol;
_transferOwnership(_owner);
_description = desc;
_imageUrl = imgUrl;
_socialLinks = socLinks;
maxSupply = _maxSupply;
creator = _creator;
createdAt = block.timestamp;
authorizedMinters[_owner] = true;
authorizedBurners[_owner] = true;
emit MetadataUpdated(desc, imgUrl);
emit SocialLinksUpdated(socLinks);
}
function mint(address to, uint256 amount) external onlyAuthorizedMinter whenMintingNotFinished {
if (to == address(0)) revert Token__InvalidAddress();
if (amount == 0) revert Token__InvalidAmount();
if (totalSupply() + amount > maxSupply) revert Token__ExceedsMaxSupply();
_mint(to, amount);
}
function burn(uint256 amount) external {
if (amount == 0) revert Token__InvalidAmount();
_burn(msg.sender, amount);
}
function burnFrom(address from, uint256 amount) external onlyAuthorizedBurner {
if (from == address(0)) revert Token__InvalidAddress();
if (amount == 0) revert Token__InvalidAmount();
uint256 currentAllowance = allowance(from, msg.sender);
if (currentAllowance < amount) {
revert ERC20InsufficientAllowance(msg.sender, currentAllowance, amount);
}
_spendAllowance(from, msg.sender, amount);
_burn(from, amount);
}
function setMetadata(
string calldata desc,
string calldata imgUrl,
string[] calldata socLinks
) external {
if (msg.sender != creator && msg.sender != owner()) revert Token__NotAuthorized();
_description = desc;
_imageUrl = imgUrl;
delete _socialLinks;
for (uint256 i = 0; i < socLinks.length; i++) {
_socialLinks.push(socLinks[i]);
}
emit MetadataUpdated(desc, imgUrl);
emit SocialLinksUpdated(socLinks);
}
function getMetadata() external view returns (
string memory desc,
string memory imgUrl,
string[] memory socLinks
) {
return (_description, _imageUrl, _socialLinks);
}
function addAuthorizedMinter(address minter) external onlyOwner {
if (minter == address(0)) revert Token__InvalidAddress();
authorizedMinters[minter] = true;
emit AuthorizedMinterAdded(minter);
}
function removeAuthorizedMinter(address minter) external onlyOwner {
authorizedMinters[minter] = false;
emit AuthorizedMinterRemoved(minter);
}
function addAuthorizedBurner(address burner) external onlyOwner {
if (burner == address(0)) revert Token__InvalidAddress();
authorizedBurners[burner] = true;
emit AuthorizedBurnerAdded(burner);
}
function removeAuthorizedBurner(address burner) external onlyOwner {
authorizedBurners[burner] = false;
emit AuthorizedBurnerRemoved(burner);
}
function finishMinting() external onlyOwner {
mintingFinished = true;
emit MintingFinished();
}
function description() external view returns (string memory) {
return _description;
}
function imageUrl() external view returns (string memory) {
return _imageUrl;
}
function socialLinks() external view returns (string[] memory) {
return _socialLinks;
}
function socialLinksCount() external view returns (uint256) {
return _socialLinks.length;
}
function socialLink(uint256 index) external view returns (string memory) {
require(index < _socialLinks.length, "Index out of bounds");
return _socialLinks[index];
}
function isAuthorizedMinter(address account) external view returns (bool) {
return authorizedMinters[account] || account == owner();
}
function isAuthorizedBurner(address account) external view returns (bool) {
return authorizedBurners[account] || account == owner();
}
function getTokenInfo() external view returns (
string memory tokenName,
string memory tokenSymbol,
uint8 tokenDecimals,
uint256 tokenTotalSupply,
uint256 tokenMaxSupply,
address tokenCreator,
uint256 tokenCreatedAt,
bool tokenMintingFinished,
string memory tokenDesc,
string memory tokenImgUrl,
string[] memory tokenSocLinks
) {
return (
name(),
symbol(),
decimals(),
totalSupply(),
maxSupply,
creator,
createdAt,
mintingFinished,
_description,
_imageUrl,
_socialLinks
);
}
}
ILaxcePadInterfaces.sol 113 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
interface ITokenFactory {
struct TokenParams {
string name;
string symbol;
string description;
string imageUrl;
string[] socialLinks;
uint256 totalSupply;
uint256 bondingCurveSupply;
uint256 liquiditySupply;
uint256 startPrice;
uint256 targetMarketCap;
}
struct SupplyLimits {
uint256 minTotalSupply;
uint256 maxTotalSupply;
uint256 minBondingCurvePercent;
uint256 maxBondingCurvePercent;
uint256 minStartPrice;
uint256 maxStartPrice;
uint256 minTargetMarketCap;
uint256 maxTargetMarketCap;
}
function createToken(TokenParams calldata params) external payable returns (address token);
function getTokenInfo(address token) external view returns (TokenParams memory);
function isTokenCreated(address token) external view returns (bool);
function getSupplyLimits() external view returns (SupplyLimits memory);
}
interface IBondingCurve {
struct CurveParams {
uint256 startPrice;
uint256 targetMarketCap;
uint256 currentMarketCap;
uint256 totalSupply;
uint256 availableSupply;
uint256 reserveETH;
bool isGraduated;
}
function initializeCurve(
address token,
uint256 supply,
uint256 startPrice,
uint256 targetMarketCap
) external;
function updateCurveParams(
address token,
uint256 newSupply,
uint256 newStartPrice,
uint256 newTargetMarketCap
) external;
function buy(address token, uint256 minTokensOut) external payable returns (uint256 tokensOut);
function sell(address token, uint256 tokenAmount, uint256 minETHOut) external returns (uint256 ethOut);
function getCurrentPrice(address token) external view returns (uint256);
function getMarketCap(address token) external view returns (uint256);
function canGraduate(address token) external view returns (bool);
function graduateToken(address token) external returns (bool);
function getCurveParams(address token) external view returns (CurveParams memory);
event TokenBought(address indexed token, address indexed buyer, uint256 ethAmount, uint256 tokenAmount, uint256 newPrice);
event TokenSold(address indexed token, address indexed seller, uint256 tokenAmount, uint256 ethAmount, uint256 newPrice);
event CurveInitialized(address indexed token, uint256 supply, uint256 startPrice, uint256 targetMarketCap);
event CurveParamsUpdated(address indexed token, uint256 supply, uint256 startPrice, uint256 targetMarketCap);
}
interface IGraduationManager {
function graduateToken(address token) external returns (address pool);
function isGraduated(address token) external view returns (bool);
function getGraduatedPool(address token) external view returns (address);
event TokenGraduated(address indexed token, address indexed pool, uint256 marketCap, uint256 liquidityAdded);
}
interface IRevenueDistribution {
struct RevenueShare {
address recipient;
uint256 percentage;
string description;
}
function distributeRevenue() external;
function setRevenueShare(address recipient, uint256 percentage, string calldata description) external;
function getRevenueShare(address recipient) external view returns (uint256);
function getTotalRevenue() external view returns (uint256);
event RevenueDistributed(uint256 totalAmount, uint256 timestamp);
event RevenueShareUpdated(address indexed recipient, uint256 percentage);
}
interface ILaxcePadToken {
function mint(address to, uint256 amount) external;
function burn(uint256 amount) external;
function setMetadata(string calldata description, string calldata imageUrl, string[] calldata socialLinks) external;
function getMetadata() external view returns (string memory description, string memory imageUrl, string[] memory socialLinks);
function creator() external view returns (address);
function createdAt() external view returns (uint256);
}
interface IDEXIntegration {
function getTokenRegistry() external view returns (address);
function getPoolFactory() external view returns (address);
function getDEXEngine() external view returns (address);
function getCoreRegistry() external view returns (address);
}
PausableUpgradeable.sol 133 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/Pausable.sol)
pragma solidity ^0.8.20;
import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
/// @custom:storage-location erc7201:openzeppelin.storage.Pausable
struct PausableStorage {
bool _paused;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Pausable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant PausableStorageLocation = 0xcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300;
function _getPausableStorage() private pure returns (PausableStorage storage $) {
assembly {
$.slot := PausableStorageLocation
}
}
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
/**
* @dev The operation failed because the contract is paused.
*/
error EnforcedPause();
/**
* @dev The operation failed because the contract is not paused.
*/
error ExpectedPause();
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
function __Pausable_init() internal onlyInitializing {
}
function __Pausable_init_unchained() internal onlyInitializing {
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
PausableStorage storage $ = _getPausableStorage();
return $._paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
if (paused()) {
revert EnforcedPause();
}
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
if (!paused()) {
revert ExpectedPause();
}
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
PausableStorage storage $ = _getPausableStorage();
$._paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
PausableStorage storage $ = _getPausableStorage();
$._paused = false;
emit Unpaused(_msgSender());
}
}
AccessControlUpgradeable.sol 232 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (access/AccessControl.sol)
pragma solidity ^0.8.20;
import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol";
import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import {ERC165Upgradeable} from "../utils/introspection/ERC165Upgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```solidity
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```solidity
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
* to enforce additional security measures for this role.
*/
abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {
struct RoleData {
mapping(address account => bool) hasRole;
bytes32 adminRole;
}
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/// @custom:storage-location erc7201:openzeppelin.storage.AccessControl
struct AccessControlStorage {
mapping(bytes32 role => RoleData) _roles;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.AccessControl")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;
function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {
assembly {
$.slot := AccessControlStorageLocation
}
}
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with an {AccessControlUnauthorizedAccount} error including the required role.
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
function __AccessControl_init() internal onlyInitializing {
}
function __AccessControl_init_unchained() internal onlyInitializing {
}
/// @inheritdoc IERC165
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual returns (bool) {
AccessControlStorage storage $ = _getAccessControlStorage();
return $._roles[role].hasRole[account];
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
* is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
* is missing `role`.
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert AccessControlUnauthorizedAccount(account, role);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {
AccessControlStorage storage $ = _getAccessControlStorage();
return $._roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address callerConfirmation) public virtual {
if (callerConfirmation != _msgSender()) {
revert AccessControlBadConfirmation();
}
_revokeRole(role, callerConfirmation);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
AccessControlStorage storage $ = _getAccessControlStorage();
bytes32 previousAdminRole = getRoleAdmin(role);
$._roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
AccessControlStorage storage $ = _getAccessControlStorage();
if (!hasRole(role, account)) {
$._roles[role].hasRole[account] = true;
emit RoleGranted(role, account, _msgSender());
return true;
} else {
return false;
}
}
/**
* @dev Attempts to revoke `role` from `account` and returns a boolean indicating if `role` was revoked.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
AccessControlStorage storage $ = _getAccessControlStorage();
if (hasRole(role, account)) {
$._roles[role].hasRole[account] = false;
emit RoleRevoked(role, account, _msgSender());
return true;
} else {
return false;
}
}
}
ReentrancyGuardUpgradeable.sol 108 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @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 EIP-1153 (transient storage) is available on the chain you're deploying at,
* consider using {ReentrancyGuardTransient} instead.
*
* 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 ReentrancyGuardUpgradeable is Initializable {
// 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;
/// @custom:storage-location erc7201:openzeppelin.storage.ReentrancyGuard
struct ReentrancyGuardStorage {
uint256 _status;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant ReentrancyGuardStorageLocation = 0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00;
function _getReentrancyGuardStorage() private pure returns (ReentrancyGuardStorage storage $) {
assembly {
$.slot := ReentrancyGuardStorageLocation
}
}
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
function __ReentrancyGuard_init() internal onlyInitializing {
__ReentrancyGuard_init_unchained();
}
function __ReentrancyGuard_init_unchained() internal onlyInitializing {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
$._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 {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
// 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 {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
// 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) {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
return $._status == ENTERED;
}
}
UUPSUpgradeable.sol 152 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (proxy/utils/UUPSUpgradeable.sol)
pragma solidity ^0.8.22;
import {IERC1822Proxiable} from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol";
import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol";
import {Initializable} from "./Initializable.sol";
/**
* @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
* {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
*
* A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
* reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
* `UUPSUpgradeable` with a custom implementation of upgrades.
*
* The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
*/
abstract contract UUPSUpgradeable is Initializable, IERC1822Proxiable {
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
address private immutable __self = address(this);
/**
* @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgradeTo(address)`
* and `upgradeToAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called,
* while `upgradeToAndCall` will invoke the `receive` function if the second argument is the empty byte string.
* If the getter returns `"5.0.0"`, only `upgradeToAndCall(address,bytes)` is present, and the second argument must
* be the empty byte string if no function should be called, making it impossible to invoke the `receive` function
* during an upgrade.
*/
string public constant UPGRADE_INTERFACE_VERSION = "5.0.0";
/**
* @dev The call is from an unauthorized context.
*/
error UUPSUnauthorizedCallContext();
/**
* @dev The storage `slot` is unsupported as a UUID.
*/
error UUPSUnsupportedProxiableUUID(bytes32 slot);
/**
* @dev Check that the execution is being performed through a delegatecall call and that the execution context is
* a proxy contract with an implementation (as defined in ERC-1967) pointing to self. This should only be the case
* for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
* function through ERC-1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
* fail.
*/
modifier onlyProxy() {
_checkProxy();
_;
}
/**
* @dev Check that the execution is not being performed through a delegate call. This allows a function to be
* callable on the implementing contract but not through proxies.
*/
modifier notDelegated() {
_checkNotDelegated();
_;
}
function __UUPSUpgradeable_init() internal onlyInitializing {
}
function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
}
/**
* @dev Implementation of the ERC-1822 {proxiableUUID} function. This returns the storage slot used by the
* implementation. It is used to validate the implementation's compatibility when performing an upgrade.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
*/
function proxiableUUID() external view virtual notDelegated returns (bytes32) {
return ERC1967Utils.IMPLEMENTATION_SLOT;
}
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
* encoded in `data`.
*
* Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*
* @custom:oz-upgrades-unsafe-allow-reachable delegatecall
*/
function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallUUPS(newImplementation, data);
}
/**
* @dev Reverts if the execution is not performed via delegatecall or the execution
* context is not of a proxy with an ERC-1967 compliant implementation pointing to self.
*/
function _checkProxy() internal view virtual {
if (
address(this) == __self || // Must be called through delegatecall
ERC1967Utils.getImplementation() != __self // Must be called through an active proxy
) {
revert UUPSUnauthorizedCallContext();
}
}
/**
* @dev Reverts if the execution is performed via delegatecall.
* See {notDelegated}.
*/
function _checkNotDelegated() internal view virtual {
if (address(this) != __self) {
// Must not be called through delegatecall
revert UUPSUnauthorizedCallContext();
}
}
/**
* @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
* {upgradeToAndCall}.
*
* Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
*
* ```solidity
* function _authorizeUpgrade(address) internal onlyOwner {}
* ```
*/
function _authorizeUpgrade(address newImplementation) internal virtual;
/**
* @dev Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call.
*
* As a security check, {proxiableUUID} is invoked in the new implementation, and the return value
* is expected to be the implementation slot in ERC-1967.
*
* Emits an {IERC1967-Upgraded} event.
*/
function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private {
try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) {
revert UUPSUnsupportedProxiableUUID(slot);
}
ERC1967Utils.upgradeToAndCall(newImplementation, data);
} catch {
// The implementation is not UUPS
revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation);
}
}
}
Initializable.sol 238 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.20;
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```solidity
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
*
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Storage of the initializable contract.
*
* It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions
* when using with upgradeable contracts.
*
* @custom:storage-location erc7201:openzeppelin.storage.Initializable
*/
struct InitializableStorage {
/**
* @dev Indicates that the contract has been initialized.
*/
uint64 _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool _initializing;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;
/**
* @dev The contract is already initialized.
*/
error InvalidInitialization();
/**
* @dev The contract is not initializing.
*/
error NotInitializing();
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint64 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
* number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
* production.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
// Cache values to avoid duplicated sloads
bool isTopLevelCall = !$._initializing;
uint64 initialized = $._initialized;
// Allowed calls:
// - initialSetup: the contract is not in the initializing state and no previous version was
// initialized
// - construction: the contract is initialized at version 1 (no reinitialization) and the
// current contract is just being deployed
bool initialSetup = initialized == 0 && isTopLevelCall;
bool construction = initialized == 1 && address(this).code.length == 0;
if (!initialSetup && !construction) {
revert InvalidInitialization();
}
$._initialized = 1;
if (isTopLevelCall) {
$._initializing = true;
}
_;
if (isTopLevelCall) {
$._initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint64 version) {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing || $._initialized >= version) {
revert InvalidInitialization();
}
$._initialized = version;
$._initializing = true;
_;
$._initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
_checkInitializing();
_;
}
/**
* @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
*/
function _checkInitializing() internal view virtual {
if (!_isInitializing()) {
revert NotInitializing();
}
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing) {
revert InvalidInitialization();
}
if ($._initialized != type(uint64).max) {
$._initialized = type(uint64).max;
emit Initialized(type(uint64).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint64) {
return _getInitializableStorage()._initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _getInitializableStorage()._initializing;
}
/**
* @dev Pointer to storage slot. Allows integrators to override it with a custom storage location.
*
* NOTE: Consider following the ERC-7201 formula to derive storage locations.
*/
function _initializableStorageSlot() internal pure virtual returns (bytes32) {
return INITIALIZABLE_STORAGE;
}
/**
* @dev Returns a pointer to the storage namespace.
*/
// solhint-disable-next-line var-name-mixedcase
function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
bytes32 slot = _initializableStorageSlot();
assembly {
$.slot := slot
}
}
}
Ownable.sol 100 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
ERC20.sol 305 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.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}.
*
* Both 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;
}
/// @inheritdoc IERC20
function totalSupply() public view virtual returns (uint256) {
return _totalSupply;
}
/// @inheritdoc IERC20
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;
}
/// @inheritdoc IERC20
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);
}
}
}
}
ContextUpgradeable.sol 34 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @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 ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
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;
}
}
ERC1967Utils.sol 177 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (proxy/ERC1967/ERC1967Utils.sol)
pragma solidity ^0.8.21;
import {IBeacon} from "../beacon/IBeacon.sol";
import {IERC1967} from "../../interfaces/IERC1967.sol";
import {Address} from "../../utils/Address.sol";
import {StorageSlot} from "../../utils/StorageSlot.sol";
/**
* @dev This library provides getters and event emitting update functions for
* https://eips.ethereum.org/EIPS/eip-1967[ERC-1967] slots.
*/
library ERC1967Utils {
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @dev The `implementation` of the proxy is invalid.
*/
error ERC1967InvalidImplementation(address implementation);
/**
* @dev The `admin` of the proxy is invalid.
*/
error ERC1967InvalidAdmin(address admin);
/**
* @dev The `beacon` of the proxy is invalid.
*/
error ERC1967InvalidBeacon(address beacon);
/**
* @dev An upgrade function sees `msg.value > 0` that may be lost.
*/
error ERC1967NonPayable();
/**
* @dev Returns the current implementation address.
*/
function getImplementation() internal view returns (address) {
return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value;
}
/**
* @dev Stores a new address in the ERC-1967 implementation slot.
*/
function _setImplementation(address newImplementation) private {
if (newImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(newImplementation);
}
StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation;
}
/**
* @dev Performs implementation upgrade with additional setup call if data is nonempty.
* This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
* to avoid stuck value in the contract.
*
* Emits an {IERC1967-Upgraded} event.
*/
function upgradeToAndCall(address newImplementation, bytes memory data) internal {
_setImplementation(newImplementation);
emit IERC1967.Upgraded(newImplementation);
if (data.length > 0) {
Address.functionDelegateCall(newImplementation, data);
} else {
_checkNonPayable();
}
}
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Returns the current admin.
*
* TIP: To get this value clients can read directly from the storage slot shown below (specified by ERC-1967) using
* the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
* `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
*/
function getAdmin() internal view returns (address) {
return StorageSlot.getAddressSlot(ADMIN_SLOT).value;
}
/**
* @dev Stores a new address in the ERC-1967 admin slot.
*/
function _setAdmin(address newAdmin) private {
if (newAdmin == address(0)) {
revert ERC1967InvalidAdmin(address(0));
}
StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin;
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {IERC1967-AdminChanged} event.
*/
function changeAdmin(address newAdmin) internal {
emit IERC1967.AdminChanged(getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
/**
* @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
* This is the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
/**
* @dev Returns the current beacon.
*/
function getBeacon() internal view returns (address) {
return StorageSlot.getAddressSlot(BEACON_SLOT).value;
}
/**
* @dev Stores a new beacon in the ERC-1967 beacon slot.
*/
function _setBeacon(address newBeacon) private {
if (newBeacon.code.length == 0) {
revert ERC1967InvalidBeacon(newBeacon);
}
StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon;
address beaconImplementation = IBeacon(newBeacon).implementation();
if (beaconImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(beaconImplementation);
}
}
/**
* @dev Change the beacon and trigger a setup call if data is nonempty.
* This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
* to avoid stuck value in the contract.
*
* Emits an {IERC1967-BeaconUpgraded} event.
*
* CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since
* it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for
* efficiency.
*/
function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal {
_setBeacon(newBeacon);
emit IERC1967.BeaconUpgraded(newBeacon);
if (data.length > 0) {
Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
} else {
_checkNonPayable();
}
}
/**
* @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract
* if an upgrade doesn't perform an initialization call.
*/
function _checkNonPayable() private {
if (msg.value > 0) {
revert ERC1967NonPayable();
}
}
}
draft-IERC1822.sol 20 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/draft-IERC1822.sol)
pragma solidity >=0.4.16;
/**
* @dev ERC-1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
* proxy whose upgrades are fully controlled by the current implementation.
*/
interface IERC1822Proxiable {
/**
* @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
* address.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy.
*/
function proxiableUUID() external view returns (bytes32);
}
ERC165Upgradeable.sol 31 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/ERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import {Initializable} from "../../proxy/utils/Initializable.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC-165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*/
abstract contract ERC165Upgradeable is Initializable, IERC165 {
function __ERC165_init() internal onlyInitializing {
}
function __ERC165_init_unchained() internal onlyInitializing {
}
/// @inheritdoc IERC165
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/IERC165.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* 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[ERC 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);
}
IAccessControl.sol 98 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (access/IAccessControl.sol)
pragma solidity >=0.8.4;
/**
* @dev External interface of AccessControl declared to support ERC-165 detection.
*/
interface IAccessControl {
/**
* @dev The `account` is missing a role.
*/
error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);
/**
* @dev The caller of a function is not the expected one.
*
* NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
*/
error AccessControlBadConfirmation();
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted to signal this.
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call. This account bears the admin role (for the granted role).
* Expected in cases where the role was granted using the internal {AccessControl-_grantRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*/
function renounceRole(bytes32 role, address callerConfirmation) external;
}
draft-IERC6093.sol 161 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/draft-IERC6093.sol)
pragma solidity >=0.8.4;
/**
* @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.4.0) (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity >=0.6.2;
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);
}
IERC20.sol 79 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/IERC20.sol)
pragma solidity >=0.4.16;
/**
* @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);
}
StorageSlot.sol 143 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.
pragma solidity ^0.8.20;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC-1967 implementation slot:
* ```solidity
* contract ERC1967 {
* // Define the slot. Alternatively, use the SlotDerivation library to derive the slot.
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(newImplementation.code.length > 0);
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* TIP: Consider using this library along with {SlotDerivation}.
*/
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
struct Int256Slot {
int256 value;
}
struct StringSlot {
string value;
}
struct BytesSlot {
bytes value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Int256Slot` with member `value` located at `slot`.
*/
function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `StringSlot` with member `value` located at `slot`.
*/
function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` representation of the string storage pointer `store`.
*/
function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
assembly ("memory-safe") {
r.slot := store.slot
}
}
/**
* @dev Returns a `BytesSlot` with member `value` located at `slot`.
*/
function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
*/
function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
assembly ("memory-safe") {
r.slot := store.slot
}
}
}
Address.sol 149 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/Address.sol)
pragma solidity ^0.8.20;
import {Errors} from "./Errors.sol";
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @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 Errors.InsufficientBalance(address(this).balance, amount);
}
(bool success, bytes memory returndata) = recipient.call{value: amount}("");
if (!success) {
_revert(returndata);
}
}
/**
* @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
* {Errors.FailedCall} 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 Errors.InsufficientBalance(address(this).balance, value);
}
(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 {Errors.FailedCall}) 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 {Errors.FailedCall} 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 {Errors.FailedCall}.
*/
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
assembly ("memory-safe") {
revert(add(returndata, 0x20), mload(returndata))
}
} else {
revert Errors.FailedCall();
}
}
}
IERC1967.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC1967.sol)
pragma solidity >=0.4.11;
/**
* @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.
*/
interface IERC1967 {
/**
* @dev Emitted when the implementation is upgraded.
*/
event Upgraded(address indexed implementation);
/**
* @dev Emitted when the admin account has changed.
*/
event AdminChanged(address previousAdmin, address newAdmin);
/**
* @dev Emitted when the beacon is changed.
*/
event BeaconUpgraded(address indexed beacon);
}
IBeacon.sol 16 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (proxy/beacon/IBeacon.sol)
pragma solidity >=0.4.16;
/**
* @dev This is the interface that {BeaconProxy} expects of its beacon.
*/
interface IBeacon {
/**
* @dev Must return an address that can be used as a delegate call target.
*
* {UpgradeableBeacon} will check that this address is a contract.
*/
function implementation() external view returns (address);
}
Errors.sol 34 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of common custom errors used in multiple contracts
*
* IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library.
* It is recommended to avoid relying on the error API for critical functionality.
*
* _Available since v5.1._
*/
library Errors {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error InsufficientBalance(uint256 balance, uint256 needed);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedCall();
/**
* @dev The deployment failed.
*/
error FailedDeployment();
/**
* @dev A necessary precompile is missing.
*/
error MissingPrecompile(address);
}
Read Contract
ADMIN_ROLE 0x75b238fc → bytes32
DEFAULT_ADMIN_ROLE 0xa217fddf → bytes32
MAX_CREATION_FEE 0x87cb5f94 → uint256
MIN_CREATION_FEE 0x6a0c97fe → uint256
OPERATOR_ROLE 0xf5b541a6 → bytes32
UPGRADER_ROLE 0xf72c0d8b → bytes32
UPGRADE_INTERFACE_VERSION 0xad3cb1cc → string
allTokens 0x634282af → address
bondingCurve 0xeff1d50e → address
coreRegistry 0x6bf3d05a → address
creatorBlacklist 0xf6f032b0 → bool
creatorLastCreation 0x95cf00de → uint256
creatorTokenCount 0x9a57bcdb → uint256
creatorTokens 0xdb3fa4cc → address
creatorWhitelist 0x9ba4fd8c → bool
dexEngine 0x83f3fc9a → address
factorySettings 0xa781d208 → uint256, uint256, address, bool, uint256
factoryStats 0x4f069251 → uint256, uint256, uint256, uint256
getCoreRegistry 0x6bb70283 → address
getDEXEngine 0xff142d53 → address
getPoolFactory 0x6bd969b3 → address
getRoleAdmin 0x248a9ca3 → bytes32
getSupplyLimits 0x28b74c95 → tuple
getTokenInfo 0x1f69565f → tuple
getTokenRegistry 0x057838bd → address
hasRole 0x91d14854 → bool
isTokenCreated 0xa0c0f720 → bool
paused 0x5c975abb → bool
poolFactory 0x4219dc40 → address
proxiableUUID 0x52d1902d → bytes32
supplyLimits 0x10c83009 → uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256
supportsInterface 0x01ffc9a7 → bool
symbolToToken 0xa5bc29c2 → address
tokenInfo 0xf5dab711 → string, string, string, string, uint256, uint256, uint256, uint256, uint256
tokenRegistry 0x9d23c4c7 → address
Write Contract 15 functions
These functions modify contract state and require a wallet transaction to execute.
createToken 0xe44ee97e
tuple params
returns: address
grantRole 0x2f2ff15d
bytes32 role
address account
initialize 0xf2b7b702
address _admin
tuple _settings
address _coreRegistry
pause 0x8456cb59
No parameters
renounceRole 0x36568abe
bytes32 role
address callerConfirmation
revokeRole 0xd547741f
bytes32 role
address account
setCreatorBlacklist 0xfea5fca5
address creator
bool blacklisted
setCreatorWhitelist 0x179aecb1
address creator
bool whitelisted
unpause 0x3f4ba83a
No parameters
updateCreationFee 0x6fa23795
uint256 newFee
updateDEXIntegration 0xed2bc959
address _tokenRegistry
address _poolFactory
address _dexEngine
address _bondingCurve
updateFactorySettings 0x710c70cb
tuple settings
updateSupplyLimits 0xc0578aae
tuple newLimits
upgradeToAndCall 0x4f1ef286
address newImplementation
bytes data
withdrawFees 0x164e68de
address to
Recent Transactions
No transactions found for this address