Address Contract Partially Verified
Address
0x5b4D9A7137E64c679fa75DA62feC961bf0a2683A
Balance
0.096300 ETH
Nonce
1
Code Size
15719 bytes
Creator
0x90E50e76...8e7A at tx 0x38146ac2...f37b02
Indexed Transactions
0
Contract Bytecode
15719 bytes
0x6080604052600436106102515760003560e01c806380bac98911610139578063ae169a50116100b6578063d547741f1161007a578063d547741f1461086f578063ddca3f431461088f578063ea294be3146108a5578063f55dd538146108c5578063f8a0312f14610907578063faaebd211461091a57600080fd5b8063ae169a50146107bf578063b3944d52146107df578063b961cbe1146107f4578063c3149b3a14610814578063c4d66de81461084f57600080fd5b806396826c53116100fd57806396826c53146106a55780639dc97e93146106eb578063a217fddf1461070b578063a57d156014610720578063ac4afa381461074057600080fd5b806380bac989146105e05780638514ba98146106005780638dce1f7c1461063057806391d148541461066557806394678f591461068557600080fd5b8063434f48c4116101d257806369fe0e2d1161019657806369fe0e2d146105125780636c19e783146105325780636ebc51e1146105525780637adbf973146105725780637bca4013146105925780637dc0d1d0146105c057600080fd5b8063434f48c414610433578063501895ae1461045357806356cec5061461048057806356d73568146104c057806363429012146104e257600080fd5b8063248a9ca311610219578063248a9ca3146103585780632f2ff15d1461038857806336568abe146103a857806339c0bd1c146103c85780633beb9842146103f857600080fd5b806301ffc9a714610256578063068bcd8d1461028b5780630e5673b1146102b85780631a27c649146102da578063238ac93314610320575b600080fd5b34801561026257600080fd5b50610276610271366004613692565b610947565b60405190151581526020015b60405180910390f35b34801561029757600080fd5b506102ab6102a636600461364d565b61097e565b6040516102829190613ad8565b3480156102c457600080fd5b506102d86102d33660046136d5565b610a2f565b005b3480156102e657600080fd5b506103126102f53660046135ce565b60cc60209081526000928352604080842090915290825290205481565b604051908152602001610282565b34801561032c57600080fd5b5060c954610340906001600160a01b031681565b6040516001600160a01b039091168152602001610282565b34801561036457600080fd5b5061031261037336600461364d565b60009081526065602052604090206001015490565b34801561039457600080fd5b506102d86103a3366004613666565b610acd565b3480156103b457600080fd5b506102d86103c3366004613666565b610af7565b3480156103d457600080fd5b506102766103e336600461364d565b60d36020526000908152604090205460ff1681565b34801561040457600080fd5b50610276610413366004613666565b60cf60209081526000928352604080842090915290825290205460ff1681565b34801561043f57600080fd5b506102d861044e36600461364d565b610b75565b34801561045f57600080fd5b5061031261046e36600461364d565b60d16020526000908152604090205481565b34801561048c57600080fd5b5061031261049b366004613666565b6001600160a01b0316600090815260cc60209081526040808320938352929052205490565b3480156104cc57600080fd5b50610312600080516020613d1283398151915281565b3480156104ee57600080fd5b506102766104fd36600461364d565b60ce6020526000908152604090205460ff1681565b34801561051e57600080fd5b506102d861052d36600461364d565b611015565b34801561053e57600080fd5b506102d861054d3660046135b3565b61105d565b34801561055e57600080fd5b506102d861056d3660046135b3565b6110b6565b34801561057e57600080fd5b506102d861058d3660046135b3565b6112c8565b34801561059e57600080fd5b506105b26105ad36600461364d565b611321565b60405161028292919061393d565b3480156105cc57600080fd5b5060d254610340906001600160a01b031681565b3480156105ec57600080fd5b506102d86105fb36600461364d565b611397565b34801561060c57600080fd5b5061031261061b36600461364d565b600090815260ce602052604090206001015490565b34801561063c57600080fd5b5061065061064b36600461364d565b61154c565b60408051928352602083019190915201610282565b34801561067157600080fd5b50610276610680366004613666565b611706565b34801561069157600080fd5b506103126106a03660046137c3565b611731565b3480156106b157600080fd5b506102766106c0366004613666565b600091825260cf602090815260408084206001600160a01b0393909316845291905290205460ff1690565b3480156106f757600080fd5b506106506107063660046135ce565b611cf5565b34801561071757600080fd5b50610312600081565b34801561072c57600080fd5b506102d861073b36600461364d565b611d0e565b34801561074c57600080fd5b5061076061075b36600461364d565b611f18565b604080519a8b5260208b019990995297890196909652606088019490945260808701929092526001600160a01b0390811660a087015290811660c086015260e08501919091526101008401919091521661012082015261014001610282565b3480156107cb57600080fd5b506102d86107da36600461364d565b611f8a565b3480156107eb57600080fd5b5060cb54610312565b34801561080057600080fd5b5061027661080f366004613666565b612371565b34801561082057600080fd5b5061083461082f3660046135f8565b612495565b60408051825181526020928301519281019290925201610282565b34801561085b57600080fd5b506102d861086a3660046135b3565b61250f565b34801561087b57600080fd5b506102d861088a366004613666565b61259d565b34801561089b57600080fd5b5061031260ca5481565b3480156108b157600080fd5b506103126108c036600461364d565b6125c2565b3480156108d157600080fd5b506103126108e03660046135ce565b600090815260cd602090815260408083206001600160a01b03949094168352929052205490565b6102d86109153660046136f7565b6125f0565b34801561092657600080fd5b506103126109353660046135b3565b60d06020526000908152604090205481565b60006001600160e01b03198216637965db0b60e01b148061097857506301ffc9a760e01b6001600160e01b03198316145b92915050565b61098661352e565b60cb828154811061099957610999613ce5565b60009182526020918290206040805161014081018252600a90930290910180548352600181015493830193909352600283015490820152600382015460608201526004820154608082015260058201546001600160a01b0390811660a08301526006830154811660c0830152600783015460e0830152600883015461010083015260099092015490911661012082015292915050565b60d2546001600160a01b03163314610a7c5760405162461bcd60e51b815260206004820152600b60248201526a6f6e6c79206f7261636c6560a81b60448201526064015b60405180910390fd5b600082815260d16020526040908190208290555182907f9fc0d41fb4eedc8cd60edba31e4dca80e14af2cabd41b13e880fa2ddfefa94fe90610ac19084815260200190565b60405180910390a25050565b600082815260656020526040902060010154610ae881612ae4565b610af28383612af1565b505050565b6001600160a01b0381163314610b675760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610a73565b610b718282612b77565b5050565b60cb5481908110610b985760405162461bcd60e51b8152600401610a7390613ab2565b814260cb8281548110610bad57610bad613ce5565b90600052602060002090600a02016008015410610bdc5760405162461bcd60e51b8152600401610a7390613a34565b600060cb8481548110610bf157610bf1613ce5565b600091825260209091206009600a90920201908101549091506001600160a01b03163314610c615760405162461bcd60e51b815260206004820181905260248201527f6f6e6c7920706f6f6c206f776e65722063616e20636c61696d20746f6b656e736044820152606401610a73565b600084815260d3602052604090205460ff1615610cb25760405162461bcd60e51b815260206004820152600f60248201526e185b1c9958591e4818db185a5b5959608a1b6044820152606401610a73565b600081600201548260010154610cc89190613b1c565b90506000808360030154831115610cfa5760028401546003850154610ced9085613c30565b610cf79190613c11565b91505b60038401548390811115610d0f575060038401545b6004850154610d1e9082613c11565b600089815260d360205260408120805460ff1916600117905560ca549193509061271090610d4c9085613c11565b610d57906064613c11565b610d619190613b1c565b90508315610e41576005860154600987015460405163a9059cbb60e01b81526001600160a01b0391821660048201526024810187905291169063a9059cbb90604401602060405180830381600087803b158015610dbd57600080fd5b505af1158015610dd1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610df5919061362b565b610e415760405162461bcd60e51b815260206004820152601760248201527f696e73756666696369656e742073656c6c20746f6b656e0000000000000000006044820152606401610a73565b8215610f8c5760068601546001600160a01b0316610ea25760098601546001600160a01b03166108fc610e748386613c30565b6040518115909202916000818181858888f19350505050158015610e9c573d6000803e3d6000fd5b50610f8c565b600686015460098701546001600160a01b039182169163a9059cbb9116610ec98487613c30565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401602060405180830381600087803b158015610f0f57600080fd5b505af1158015610f23573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f47919061362b565b610f8c5760405162461bcd60e51b815260206004820152601660248201527534b739bab33334b1b4b2b73a10313abc903a37b5b2b760511b6044820152606401610a73565b8015610fc45760068601546001600160a01b0316600090815260d0602052604081208054839290610fbe908490613b04565b90915550505b88337f29702d7822c6c28970a07b5646961b2415177e1dcffd5d1104f6bf540e11bbd486610ff28588613c30565b6040805192835260208301919091520160405180910390a3505050505050505050565b600061102081612ae4565b60ca8290556040518281527f6bbc57480a46553fa4d156ce702beef5f3ad66303b0ed1a5d4cb44966c6584c3906020015b60405180910390a15050565b600061106881612ae4565b60c980546001600160a01b0319166001600160a01b0384169081179091556040519081527f5719a5656c5cfdaafa148ecf366fd3b0a7fae06449ce2a46225977fb7417e29d90602001611051565b60006110c181612ae4565b600260975414156111145760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610a73565b60026097556001600160a01b03821661118457600080805260d06020527f790dca8aa28f25f1915553dd78bb1fae41686aabbb62ea6516ab2cafb7d2589954604051339282156108fc02929190818181858888f1935050505015801561117e573d6000803e3d6000fd5b50611253565b6001600160a01b038216600081815260d060205260409081902054905163a9059cbb60e01b8152336004820152602481019190915263a9059cbb90604401602060405180830381600087803b1580156111dc57600080fd5b505af11580156111f0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611214919061362b565b6112535760405162461bcd60e51b815260206004820152601060248201526f696e73756666696369656e742066656560801b6044820152606401610a73565b6001600160a01b038216600081815260d060205260409081902054905133917fa7883b1473a65470aa0a0207935ab0effd60561370f7d2eadc6d28ee2beb3493916112a091815260200190565b60405180910390a3506001600160a01b0316600090815260d060205260408120556001609755565b60006112d381612ae4565b60d280546001600160a01b0319166001600160a01b0384169081179091556040519081527f0e05ae75e8b926552cf6fcd744d19f422561e3ced1e426868730852702dbe41890602001611051565b600081815260ce6020908152604080832080546001909101805483518186028101860190945280845260609460ff90931693919283919083018282801561138757602002820191906000526020600020905b815481526020019060010190808311611373575b5050505050905091509150915091565b600080516020613d128339815191526113af81612ae4565b600082815260d1602052604090205461140a5760405162461bcd60e51b815260206004820152601760248201527f77616974696e6720666f722072616e646f6d20686173680000000000000000006044820152606401610a73565b600082815260ce6020526040902060010154156114695760405162461bcd60e51b815260206004820152601f60248201527f616c7265616c792067656e657261746564206c75636b79206e756d62657273006044820152606401610a73565b600060cb838154811061147e5761147e613ce5565b90600052602060002090600a020190506000816002015482600101546114a49190613b1c565b600085815260ce602052604090205490915060ff16156114d1578082600301546114ce9190613c30565b90505b600084815260d1602052604090205460038301546114f191869184612bde565b600084815260ce6020526040908190208054915186927ff6be6a0f722347fb3a4faa0a127659a873f16093c042a1022bd30bb40979ca8a9261153e9260ff9092169160019091019061398d565b60405180910390a250505050565b600080600060cb848154811061156457611564613ce5565b90600052602060002090600a02016002015460cb858154811061158957611589613ce5565b90600052602060002090600a0201600101546115a59190613b1c565b905060008060cb86815481106115bd576115bd613ce5565b90600052602060002090600a0201600301548311156116385760cb86815481106115e9576115e9613ce5565b90600052602060002090600a02016002015460cb878154811061160e5761160e613ce5565b90600052602060002090600a0201600301548461162b9190613c30565b6116359190613c11565b91505b600083905060cb878154811061165057611650613ce5565b90600052602060002090600a0201600301548411156116915760cb878154811061167c5761167c613ce5565b90600052602060002090600a02016003015490505b60cb87815481106116a4576116a4613ce5565b90600052602060002090600a020160040154816116c19190613c11565b9150600061271060ca54846116d69190613c11565b6116e1906064613c11565b6116eb9190613b1c565b9050836116f88285613c30565b965096505050505050915091565b60009182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6000600080516020613d1283398151915261174b81612ae4565b6001600160a01b0387166117965760405162461bcd60e51b815260206004820152601260248201527134b73b30b634b21039b2b636103a37b5b2b760711b6044820152606401610a73565b6001600160a01b0383166117e45760405162461bcd60e51b8152602060048201526015602482015274696e76616c6964206f776e6572206164647265737360581b6044820152606401610a73565b886118285760405162461bcd60e51b8152602060048201526014602482015273696e76616c696420746f6b656e20737570706c7960601b6044820152606401610a73565b6000876001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561186357600080fd5b505afa158015611877573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061189b91906136bc565b116118e85760405162461bcd60e51b815260206004820152601a60248201527f73656c6c20746f6b656e206469646e2774206d696e74207965740000000000006044820152606401610a73565b6001600160a01b038616156119b7576000866001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561193257600080fd5b505afa158015611946573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061196a91906136bc565b116119b75760405162461bcd60e51b815260206004820152601960248201527f62757920746f6b656e206469646e2774206d696e7420796574000000000000006044820152606401610a73565b6040516323b872dd60e01b8152336004820152306024820152604481018a90526001600160a01b038816906323b872dd90606401602060405180830381600087803b158015611a0557600080fd5b505af1158015611a19573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a3d919061362b565b611a595760405162461bcd60e51b8152600401610a7390613a08565b611a6161352e565b608081018b90526001600160a01b0380891660a0830152602082018b9052871660c082015260e08101869052611a978587613b04565b6101008201908152604082018a81526001600160a01b03808716610120850190815260cb80546001818101835560008390528751600a9092027fa7ce836d032b2bf62b7e2097a8e0a6d8aeb35405ad15271e96d3b0188a1d06fb81019290925560208801517fa7ce836d032b2bf62b7e2097a8e0a6d8aeb35405ad15271e96d3b0188a1d06fc83015594517fa7ce836d032b2bf62b7e2097a8e0a6d8aeb35405ad15271e96d3b0188a1d06fd82015560608701517fa7ce836d032b2bf62b7e2097a8e0a6d8aeb35405ad15271e96d3b0188a1d06fe82015560808701517fa7ce836d032b2bf62b7e2097a8e0a6d8aeb35405ad15271e96d3b0188a1d06ff82015560a08701517fa7ce836d032b2bf62b7e2097a8e0a6d8aeb35405ad15271e96d3b0188a1d0700820180549186166001600160a01b031992831617905560c08801517fa7ce836d032b2bf62b7e2097a8e0a6d8aeb35405ad15271e96d3b0188a1d07018301805491871691831691909117905560e08801517fa7ce836d032b2bf62b7e2097a8e0a6d8aeb35405ad15271e96d3b0188a1d070283015595517fa7ce836d032b2bf62b7e2097a8e0a6d8aeb35405ad15271e96d3b0188a1d070382015591517fa7ce836d032b2bf62b7e2097a8e0a6d8aeb35405ad15271e96d3b0188a1d0704909201805492909316919094161790559054611c989190613c30565b60e082015160405133917ffbe560bfc323a2acdf0236c11a97e47330d186344eedf222d78c13f25e28f02491611ccf918691613ae7565b60405180910390a360cb54611ce690600190613c30565b9b9a5050505050505050505050565b600080611d028484612e21565b915091505b9250929050565b60cb5481908110611d315760405162461bcd60e51b8152600401610a7390613ab2565b814260cb8281548110611d4657611d46613ce5565b90600052602060002090600a02016008015410611d755760405162461bcd60e51b8152600401610a7390613a34565b600080516020613d12833981519152611d8d81612ae4565b600060cb8581548110611da257611da2613ce5565b90600052602060002090600a02019050600081600201548260010154611dc89190613b1c565b825490915015611e0e5760405162461bcd60e51b8152602060048201526011602482015270185b1c9958591e481b1bdd1d195c9a5959607a1b6044820152606401610a73565b4380835560405190815286907f5634ff43044581c3f349069b8c52f6784a8a3c2e5e1bfc72191f1546cf376be99060200160405180910390a280826003015411611e59575050611f12565b6003820154603290611e6c836064613c11565b611e769190613b1c565b1115611e9a57600086815260ce60205260409020805460ff19166001179055611eb1565b600086815260ce60205260409020805460ff191690555b60d25460405163075022b160e11b8152600481018890526001600160a01b0390911690630ea0456290602401600060405180830381600087803b158015611ef757600080fd5b505af1158015611f0b573d6000803e3d6000fd5b5050505050505b50505050565b60cb8181548110611f2857600080fd5b60009182526020909120600a9091020180546001820154600283015460038401546004850154600586015460068701546007880154600889015460099099015497995095979496939592946001600160a01b039283169491831693929091168a565b60cb5481908110611fad5760405162461bcd60e51b8152600401610a7390613ab2565b814260cb8281548110611fc257611fc2613ce5565b90600052602060002090600a02016008015410611ff15760405162461bcd60e51b8152600401610a7390613a34565b600060cb848154811061200657612006613ce5565b90600052602060002090600a02019050600081600001541161205f5760405162461bcd60e51b8152602060048201526012602482015271191a591b89dd081b1bdd1d195c9e481e595d60721b6044820152606401610a73565b600084815260cf6020908152604080832033845290915290205460ff16156120d75760405162461bcd60e51b815260206004820152602560248201527f616c726561647920636c61696d6564207265776172642066726f6d2074686973604482015264081c1bdbdb60da1b6064820152608401610a73565b6000816002015482600101546120ed9190613b1c565b9050808260030154111561215a57600085815260ce60205260408120600101541161215a5760405162461bcd60e51b815260206004820152601e60248201527f77616974696e672063616c63756c617465206c75636b79206e756d62657200006044820152606401610a73565b6000806121673388612e21565b600089815260cf602090815260408083203384529091529020805460ff191660011790559092509050811561223857600584015460405163a9059cbb60e01b8152336004820152602481018490526001600160a01b039091169063a9059cbb90604401602060405180830381600087803b1580156121e457600080fd5b505af11580156121f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061221c919061362b565b6122385760405162461bcd60e51b8152600401610a7390613a08565b801561232b5760068401546001600160a01b031661228357604051339082156108fc029083906000818181858888f1935050505015801561227d573d6000803e3d6000fd5b5061232b565b60068401546040516323b872dd60e01b8152306004820152336024820152604481018390526001600160a01b03909116906323b872dd90606401602060405180830381600087803b1580156122d757600080fd5b505af11580156122eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061230f919061362b565b61232b5760405162461bcd60e51b8152600401610a7390613a08565b6040805183815260208101839052889133917fb26ea8ad92f258bc70244e0ced197b6e05b0dbecd2bfc0950a39d921baafa93f910160405180910390a350505050505050565b600082815260cf602090815260408083206001600160a01b038516845290915281205460ff161515600114156123a957506000610978565b60cb83815481106123bc576123bc613ce5565b90600052602060002090600a020160000154600014156123de57506000610978565b600060cb84815481106123f3576123f3613ce5565b90600052602060002090600a02016002015460cb858154811061241857612418613ce5565b90600052602060002090600a0201600101546124349190613b1c565b90508060cb858154811061244a5761244a613ce5565b90600052602060002090600a0201600301541161246b576001915050610978565b600084815260ce602052604090206001015461248b576000915050610978565b6001915050610978565b6040805180820182526000808252602080830182905285825260cd81528382206001600160a01b03881683529052919091208054839081106124d9576124d9613ce5565b90600052602060002090600202016040518060400160405290816000820154815260200160018201548152505090509392505050565b600061251b6001613051565b90508015612533576000805461ff0019166101001790555b61253e6000836130de565b612556600080516020613d1283398151915283612af1565b600360ca558015610b71576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890602001611051565b6000828152606560205260409020600101546125b881612ae4565b610af28383612b77565b600060cb82815481106125d7576125d7613ce5565b90600052602060002090600a0201600001549050919050565b60cb54849081106126135760405162461bcd60e51b8152600401610a7390613ab2565b844260cb828154811061262857612628613ce5565b90600052602060002090600a02016007015411156126885760405162461bcd60e51b815260206004820152601760248201527f706f6f6c206973206e6f742073746172746564207965740000000000000000006044820152606401610a73565b854260cb828154811061269d5761269d613ce5565b90600052602060002090600a02016008015410156126ee5760405162461bcd60e51b815260206004820152600e60248201526d1c1bdbdb081a5cc818db1bdcd95960921b6044820152606401610a73565b600060cb888154811061270357612703613ce5565b90600052602060002090600a02019050600087116127635760405162461bcd60e51b815260206004820152601c60248201527f7469636b6574207175616e746974792063616e206e6f742062652030000000006044820152606401610a73565b60c95461277d906001600160a01b031633308b898b6130e8565b6127bd5760405162461bcd60e51b8152602060048201526011602482015270696e76616c6964207369676e617475726560781b6044820152606401610a73565b33600090815260cc602090815260408083208b845290915290205485906127e5908990613b04565b11156128245760405162461bcd60e51b815260206004820152600e60248201526d1b1a5b5a5d08195e18d95959195960921b6044820152606401610a73565b60008160020154826001015461283a9190613b1c565b9050612847816019613c11565b8883600301546128579190613b04565b11156128a55760405162461bcd60e51b815260206004820152601760248201527f32352074696d6573206f766572736f6c64206c696d69740000000000000000006044820152606401610a73565b600482015460006128b6828b613c11565b60068501549091506001600160a01b031661291f5734811461291a5760405162461bcd60e51b815260206004820152601a60248201527f696e76616c6964207061796d656e742045544820616d6f756e740000000000006044820152606401610a73565b6129c7565b60068401546040516323b872dd60e01b8152336004820152306024820152604481018390526001600160a01b03909116906323b872dd90606401602060405180830381600087803b15801561297357600080fd5b505af1158015612987573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129ab919061362b565b6129c75760405162461bcd60e51b8152600401610a7390613a08565b60008b815260cd602090815260408083203384528252808320815180830190925283825291810192909252906003860154612a03906001613b04565b815260208082018d81528354600181810186556000868152938420855160029093020191825591519101556003870180548e9290612a42908490613b04565b925050819055508b60cc6000336001600160a01b03166001600160a01b0316815260200190815260200160002060008f81526020019081526020016000206000828254612a8f9190613b04565b90915550506040805182518152602080840151908201528e9133917f86edb35915882549878b2849ab6f0e8d252a73c418cf6660740a974aa7741ac3910160405180910390a350505050505050505050505050565b612aee81336131dc565b50565b612afb8282611706565b610b715760008281526065602090815260408083206001600160a01b03851684529091529020805460ff19166001179055612b333390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b612b818282611706565b15610b715760008281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600084815260ce60205260409020600190819081018385875b8215611f0b576000600a606484612c0f8a6001613b04565b612c1a90600a613b73565b612c249088613c11565b612c2e9190613b1c565b612c389190613ca5565b612c429190613b1c565b9050600080612c5289600a613b73565b612c5c9086613ca5565b90505b600083118015612c6f5750600086115b15612dc157612c7f848a8a613240565b915060016000612c908b600a613b73565b612c9a9088613b1c565b905080158015612ca957508284115b15612cbb57612cb88385613ca5565b93505b60005b8954811015612d3c57898181548110612cd957612cd9613ce5565b906000526020600020015461ffff16601f8b8381548110612cfc57612cfc613ce5565b9060005260206000200154901c600a612d159190613b73565b612d1f9087613ca5565b1415612d2a57600092505b80612d3481613c8a565b915050612cbe565b508115612dad57600084118015612d535750828411155b15612d6657612d63600182613b04565b90505b878111612da657612d78600186613c30565b9450612d848189613c30565b8954600181018b5560008b815260209020601f8e901b87179101559750612dad565b5050612dc1565b612db860018b613b04565b99505050612c5f565b600a606486612dd18c6001613b04565b612ddc90600a613b73565b612de6908a613c11565b612df09190613b1c565b612dfa9190613ca5565b612e049190613b1c565b925082612e1957612e1660018a613b04565b98505b505050612bf7565b600080600060cb8481548110612e3957612e39613ce5565b90600052602060002090600a02019050806000015460001415612e63576000809250925050611d07565b600084815260cd602090815260408083206001600160a01b038916845290915281205460028301546001840154919291612e9d9190613b1c565b9050826003015481108015612ec15750600086815260ce6020526040902060010154155b15612ed55760008094509450505050611d07565b600086815260ce602052604081208054889260ff90911691600101905b8581101561304357600084815260cd602090815260408083206001600160a01b038f1684529091528120805483908110612f2e57612f2e613ce5565b9060005260206000209060020201905085886003015411612f6f5780600101548860020154612f5d9190613c11565b612f67908b613b04565b995050613031565b60005b816001015481101561302e578154600090612f8e908390613b04565b90506000805b8654811015612fe257612fc383888381548110612fb357612fb3613ce5565b90600052602060002001546132f1565b91508115612fd057612fe2565b80612fda81613c8a565b915050612f94565b508615612feb57155b80156130075760028b0154613000908e613b04565b9c50613019565b60048b0154613016908d613b04565b9b505b5050808061302690613c8a565b915050612f72565b50505b8061303b81613c8a565b915050612ef2565b505050505050509250929050565b60008054610100900460ff1615613098578160ff1660011480156130745750303b155b6130905760405162461bcd60e51b8152600401610a7390613a64565b506000919050565b60005460ff8084169116106130bf5760405162461bcd60e51b8152600401610a7390613a64565b506000805460ff191660ff92909216919091179055600190565b919050565b610b718282612af1565b6040516bffffffffffffffffffffffff19606086811b821660208401526034830186905287901b166054820152606881018390526000908190608801604051602081830303815290604052805190602001209050600080600061314a86613317565b9250925092508a6001600160a01b031660018583868660405160008152602001604052604051613196949392919093845260ff9290921660208401526040830152606082015260800190565b6020604051602081039080840390855afa1580156131b8573d6000803e3d6000fd5b505050602060405103516001600160a01b0316149450505050509695505050505050565b6131e68282611706565b610b71576131fe816001600160a01b0316601461338b565b61320983602061338b565b60405160200161321a9291906138c8565b60408051601f198184030181529082905262461bcd60e51b8252610a73916004016139d5565b60008083116132805760405162461bcd60e51b815260206004820152600c60248201526b696e76616c69642073697a6560a01b6044820152606401610a73565b600082116132c15760405162461bcd60e51b815260206004820152600e60248201526d1a5b9d985b1a59081bd9999cd95d60921b6044820152606401610a73565b60018203600a0a8404935082600181146132e25783600a0a850691506132e9565b600a850691505b509392505050565b6000601f82901c600a0a830661ffff83168181141561330f57600192505b505092915050565b6000806000835160411461336d5760405162461bcd60e51b815260206004820152601860248201527f696e76616c6964207369676e6174757265206c656e67746800000000000000006044820152606401610a73565b50505060208101516040820151606090920151909260009190911a90565b6060600061339a836002613c11565b6133a5906002613b04565b67ffffffffffffffff8111156133bd576133bd613cfb565b6040519080825280601f01601f1916602001820160405280156133e7576020820181803683370190505b509050600360fc1b8160008151811061340257613402613ce5565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061343157613431613ce5565b60200101906001600160f81b031916908160001a9053506000613455846002613c11565b613460906001613b04565b90505b60018111156134d8576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061349457613494613ce5565b1a60f81b8282815181106134aa576134aa613ce5565b60200101906001600160f81b031916908160001a90535060049490941c936134d181613c73565b9050613463565b5083156135275760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610a73565b9392505050565b604051806101400160405280600081526020016000815260200160008152602001600081526020016000815260200160006001600160a01b0316815260200160006001600160a01b03168152602001600081526020016000815260200160006001600160a01b031681525090565b80356001600160a01b03811681146130d957600080fd5b6000602082840312156135c557600080fd5b6135278261359c565b600080604083850312156135e157600080fd5b6135ea8361359c565b946020939093013593505050565b60008060006060848603121561360d57600080fd5b6136168461359c565b95602085013595506040909401359392505050565b60006020828403121561363d57600080fd5b8151801515811461352757600080fd5b60006020828403121561365f57600080fd5b5035919050565b6000806040838503121561367957600080fd5b823591506136896020840161359c565b90509250929050565b6000602082840312156136a457600080fd5b81356001600160e01b03198116811461352757600080fd5b6000602082840312156136ce57600080fd5b5051919050565b600080604083850312156136e857600080fd5b50508035926020909101359150565b6000806000806080858703121561370d57600080fd5b8435935060208501359250604085013567ffffffffffffffff8082111561373357600080fd5b818701915087601f83011261374757600080fd5b81358181111561375957613759613cfb565b604051601f8201601f19908116603f0116810190838211818310171561378157613781613cfb565b816040528281528a602084870101111561379a57600080fd5b826020860160208301376000928101602001929092525095989497509495606001359450505050565b600080600080600080600080610100898b0312156137e057600080fd5b8835975060208901359650604089013595506137fe60608a0161359c565b945061380c60808a0161359c565b935060a0890135925060c0890135915061382860e08a0161359c565b90509295985092959890939650565b805182526020810151602083015260408101516040830152606081015160608301526080810151608083015260a081015161387d60a08401826001600160a01b03169052565b5060c081015161389860c08401826001600160a01b03169052565b5060e081810151908301526101008082015190830152610120808201516001600160a01b03811682850152611f12565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351613900816017850160208801613c47565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351613931816028840160208801613c47565b01602801949350505050565b60006040820184151583526020604081850152818551808452606086019150828701935060005b8181101561398057845183529383019391830191600101613964565b5090979650505050505050565b600060408201841515835260206040818501528185548084526060860191508660005282600020935060005b81811015613980578454835260019485019492840192016139b9565b60208152600082518060208401526139f4816040850160208701613c47565b601f01601f19169190910160400192915050565b60208082526012908201527134b739bab33334b1b4b2b73a103a37b5b2b760711b604082015260600190565b6020808252601690820152751c1bdbdb081a5cc81b9bdd0818db1bdcd959081e595d60521b604082015260600190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252600c908201526b1a5b9d985b1a59081c1bdbdb60a21b604082015260600190565b61014081016109788284613837565b6101608101613af68285613837565b826101408301529392505050565b60008219821115613b1757613b17613cb9565b500190565b600082613b2b57613b2b613ccf565b500490565b600181815b80851115613b6b578160001904821115613b5157613b51613cb9565b80851615613b5e57918102915b93841c9390800290613b35565b509250929050565b60006135278383600082613b8957506001610978565b81613b9657506000610978565b816001811461248b5760028114613bac57613bc8565b60ff841115613bbd57613bbd613cb9565b50506001821b610978565b5060208310610133831016604e8410600b8410161715613beb575081810a610978565b613bf58383613b30565b8060001904821115613c0957613c09613cb9565b029392505050565b6000816000190483118215151615613c2b57613c2b613cb9565b500290565b600082821015613c4257613c42613cb9565b500390565b60005b83811015613c62578181015183820152602001613c4a565b83811115611f125750506000910152565b600081613c8257613c82613cb9565b506000190190565b6000600019821415613c9e57613c9e613cb9565b5060010190565b600082613cb457613cb4613ccf565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fdfe6077685936c8169d09204a1d97db12e41713588c38e1d29a61867d3dcee98affa264697066735822122011d311249ccd044b43047e2ec27250c34268ef2d623f952fcb4fd2600b7c41f664736f6c63430008070033
Verified Source Code Partial Match
Compiler: v0.8.7+commit.e28d00a7
EVM: london
Optimization: Yes (200 runs)
CobakPool.sol 1735 lines
// File: interfaces/IOracle.sol
pragma solidity ^0.8.3;
interface IOracle {
function requestRandom(uint256 _poolId) external;
}
// File: @openzeppelin/[email protected]/utils/Strings.sol
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
// File: Signature.sol
pragma solidity ^0.8.1;
contract VerifySignature {
using Strings for bool;
using Strings for uint;
using Strings for address;
function verify(
address _signer,
address _buyer,
address _pool,
uint _poolId,
uint _quantity,
bytes memory signature
) internal pure returns (bool) {
bytes32 messageHash = keccak256(abi.encodePacked(_pool, _poolId, _buyer, _quantity));
(bytes32 r, bytes32 s, uint8 v) = splitSignature(signature);
return ecrecover(messageHash, v, r, s) == _signer;
}
function splitSignature(bytes memory sig)
internal
pure
returns (
bytes32 r,
bytes32 s,
uint8 v
)
{
require(sig.length == 65, "invalid signature length");
assembly {
r := mload(add(sig, 32))
// second 32 bytes
s := mload(add(sig, 64))
// final byte (first byte of the next 32 bytes)
v := byte(0, mload(add(sig, 96)))
}
}
}
// File: @openzeppelin/[email protected]/token/ERC20/IERC20.sol
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}
// File: @openzeppelin/[email protected]/utils/introspection/IERC165Upgradeable.sol
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165Upgradeable {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
// File: @openzeppelin/[email protected]/utils/StringsUpgradeable.sol
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library StringsUpgradeable {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
// File: @openzeppelin/[email protected]/utils/AddressUpgradeable.sol
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library AddressUpgradeable {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// File: @openzeppelin/[email protected]/proxy/utils/Initializable.sol
// OpenZeppelin Contracts (last updated v4.6.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.2;
/**
* @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]
* ```
* 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 Indicates that the contract has been initialized.
* @custom:oz-retyped-from bool
*/
uint8 private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint8 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. Equivalent to `reinitializer(1)`.
*/
modifier initializer() {
bool isTopLevelCall = _setInitializedVersion(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.
*
* `initializer` is equivalent to `reinitializer(1)`, so 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.
*
* 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.
*/
modifier reinitializer(uint8 version) {
bool isTopLevelCall = _setInitializedVersion(version);
if (isTopLevelCall) {
_initializing = true;
}
_;
if (isTopLevelCall) {
_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() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
/**
* @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.
*/
function _disableInitializers() internal virtual {
_setInitializedVersion(type(uint8).max);
}
function _setInitializedVersion(uint8 version) private returns (bool) {
// If the contract is initializing we ignore whether _initialized is set in order to support multiple
// inheritance patterns, but we only do this in the context of a constructor, and for the lowest level
// of initializers, because in other contexts the contract may have been reentered.
if (_initializing) {
require(
version == 1 && !AddressUpgradeable.isContract(address(this)),
"Initializable: contract is already initialized"
);
return false;
} else {
require(_initialized < version, "Initializable: contract is already initialized");
_initialized = version;
return true;
}
}
}
// File: @openzeppelin/[email protected]/security/ReentrancyGuardUpgradeable.sol
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract 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;
uint256 private _status;
function __ReentrancyGuard_init() internal onlyInitializing {
__ReentrancyGuard_init_unchained();
}
function __ReentrancyGuard_init_unchained() internal onlyInitializing {
_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() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}
// File: @openzeppelin/[email protected]/utils/introspection/ERC165Upgradeable.sol
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {
function __ERC165_init() internal onlyInitializing {
}
function __ERC165_init_unchained() internal onlyInitializing {
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165Upgradeable).interfaceId;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}
// File: @openzeppelin/[email protected]/utils/ContextUpgradeable.sol
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract 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;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}
// File: @openzeppelin/[email protected]/access/IAccessControlUpgradeable.sol
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)
pragma solidity ^0.8.0;
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControlUpgradeable {
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*
* _Available since v3.1._
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {AccessControl-_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) external;
}
// File: @openzeppelin/[email protected]/access/AccessControlUpgradeable.sol
// OpenZeppelin Contracts (last updated v4.6.0) (access/AccessControl.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it.
*/
abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable {
function __AccessControl_init() internal onlyInitializing {
}
function __AccessControl_init_unchained() internal onlyInitializing {
}
struct RoleData {
mapping(address => bool) members;
bytes32 adminRole;
}
mapping(bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with a standardized message including the required role.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*
* _Available since v4.1._
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
return _roles[role].members[account];
}
/**
* @dev Revert with a standard message if `_msgSender()` is missing `role`.
* Overriding this function changes the behavior of the {onlyRole} modifier.
*
* Format of the revert message is described in {_checkRole}.
*
* _Available since v4.6._
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Revert with a standard message if `account` is missing `role`.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
"AccessControl: account ",
StringsUpgradeable.toHexString(uint160(account), 20),
" is missing role ",
StringsUpgradeable.toHexString(uint256(role), 32)
)
)
);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) public virtual override {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*
* NOTE: This function is deprecated in favor of {_grantRole}.
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Grants `role` to `account`.
*
* Internal function without access restriction.
*/
function _grantRole(bytes32 role, address account) internal virtual {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
}
/**
* @dev Revokes `role` from `account`.
*
* Internal function without access restriction.
*/
function _revokeRole(bytes32 role, address account) internal virtual {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}
// File: CobakPool.sol
pragma solidity ^0.8.3;
contract CobakPool is AccessControlUpgradeable , VerifySignature, ReentrancyGuardUpgradeable {
bytes32 public constant POOL_MANAGER_ROLE = keccak256("POOL_MANAGER_ROLE");
address public signer;
uint public fee;
struct Ticket {
// ticket id
uint ticketId;
// ticket quantity
uint quantity;
}
struct Pool {
// use last blockhash to determine which ticket win the ido
uint256 number;
// total supply
uint256 supply;
// sellToken per ticket
uint256 rewardPerTicket;
// ticket count sold out
uint ticketSold;
// ticket price
uint256 ticketPrice;
// token to sell
address sellToken ;
// token to buy, 0x0000000000000000000000000000000000000000 means ETH
address buyToken ;
// start time
uint startAt;
// end time
uint closedAt;
address owner;
}
struct Result {
bool isNeg;
uint[] list;
}
Pool[] public pools;
mapping(address => mapping(uint => uint)) public ticketBought;
mapping(uint => mapping(address => Ticket[])) tickets;
mapping(uint => Result) public poolResult;
mapping(uint => mapping(address => bool)) public userClaimed;
mapping(address => uint) public fees;
mapping(uint256 => uint256) public hashes;
address public oracle;
mapping(uint => bool) public poolClaimed;
event Created(address indexed sender, uint indexed index, Pool pool, uint startTime);
event BuyTicket(address indexed sender, uint indexed poolId, Ticket ticket);
event ClaimReward(address indexed sender, uint indexed poolId, uint reward, uint refund);
event OwnerClaim(address indexed sender, uint indexed poolId, uint sell, uint buy);
event ClaimFee(address indexed sender, address indexed token, uint amount);
event Lottery(uint indexed poolId, bool isNeg, uint[] list);
event ClosePool(uint indexed poolId, uint blocknumber);
event HashGenerated(uint indexed poolId, uint256 hash);
event FeeChanged(uint256 fee);
event OracleChanged(address oracle);
event SignerChanged(address signer);
modifier isPoolExist(uint _poolId) {
require(_poolId < pools.length, "invalid pool");
_;
}
modifier isPoolStarted(uint _poolId) {
require(pools[_poolId].startAt <= block.timestamp, "pool is not started yet");
_;
}
modifier isPoolNotClosed(uint _poolId) {
require(pools[_poolId].closedAt >= block.timestamp, "pool is closed");
_;
}
modifier isPoolClosed(uint _poolId) {
require(pools[_poolId].closedAt < block.timestamp, "pool is not closed yet");
_;
}
function initialize(address owner) public initializer {
_setupRole(DEFAULT_ADMIN_ROLE, owner);
_grantRole(POOL_MANAGER_ROLE, owner);
fee = 3;
}
/* ============ onlyRole(DEFAULT_ADMIN_ROLE) ================== */
/**
* @notice create new pool
* @param _price token per ticket
* @param _sell token to sell
* @param _buy token to buy ticket
*/
function newPool(
uint256 _price,
uint256 _supply,
uint256 _rewardPerTicket,
address _sell,
address _buy,
uint _start,
uint _duration,
address _owner
) external onlyRole(POOL_MANAGER_ROLE) returns (uint256){
// check sell token
require(_sell != address(0), "invalid sell token");
require(_owner != address(0), "invalid owner address");
require(_supply != 0, "invalid token supply");
require(IERC20(_sell).totalSupply() > 0, "sell token didn't mint yet");
// check buy token
if (_buy != address(0)) {
require(IERC20(_buy).totalSupply() > 0, "buy token didn't mint yet");
}
require(IERC20(_sell).transferFrom(msg.sender, address(this), _supply), "insufficient token");
// new pool
Pool memory pool;
pool.ticketPrice = _price;
pool.sellToken = _sell;
pool.supply = _supply;
pool.buyToken = _buy;
pool.startAt = _start;
pool.closedAt = pool.startAt + _duration;
pool.rewardPerTicket = _rewardPerTicket;
pool.owner = _owner;
pools.push(pool);
emit Created(msg.sender, pools.length - 1, pool, pool.startAt);
return pools.length - 1;
}
/**
* @notice set the number of pool
* @param _poolId Index of pools
**/
function lottery(uint256 _poolId) external
isPoolExist(_poolId)
isPoolClosed(_poolId)
onlyRole(POOL_MANAGER_ROLE)
{
Pool storage pool = pools[_poolId];
uint rewardCount = pool.supply / pool.rewardPerTicket;
require(pool.number == 0, "already lotteried");
pool.number = block.number;
emit ClosePool(_poolId, block.number);
if (pool.ticketSold <= rewardCount) {
return;
}
if (rewardCount * 100 / pool.ticketSold > 50) {
poolResult[_poolId].isNeg = true;
} else {
poolResult[_poolId].isNeg = false;
}
IOracle(oracle).requestRandom(_poolId);
}
function calcResult(uint _poolId) external
onlyRole(POOL_MANAGER_ROLE)
{
require(hashes[_poolId] > 0, "waiting for random hash");
require(poolResult[_poolId].list.length == 0, "alrealy generated lucky numbers");
Pool storage pool = pools[_poolId];
uint rewardCount = pool.supply / pool.rewardPerTicket;
if (poolResult[_poolId].isNeg) {
rewardCount = pool.ticketSold - rewardCount;
}
_calcResult(_poolId, hashes[_poolId], pool.ticketSold, rewardCount);
emit Lottery(_poolId, poolResult[_poolId].isNeg, poolResult[_poolId].list);
}
function claimFee(address _tokenAddress) external onlyRole(DEFAULT_ADMIN_ROLE) nonReentrant {
if (_tokenAddress == address(0)) {
payable(msg.sender).transfer(fees[address(0)]);
} else {
require(IERC20(_tokenAddress).transfer(msg.sender, fees[_tokenAddress]), "insufficient fee");
}
emit ClaimFee(msg.sender, _tokenAddress, fees[_tokenAddress]);
fees[_tokenAddress] = 0;
}
function setFee(uint _fee) external onlyRole(DEFAULT_ADMIN_ROLE) {
fee = _fee;
emit FeeChanged(_fee);
}
function setOracle(address _oracle) external onlyRole(DEFAULT_ADMIN_ROLE) {
oracle = _oracle;
emit OracleChanged(_oracle);
}
function setSigner(address _signer) external onlyRole(DEFAULT_ADMIN_ROLE) {
signer = _signer;
emit SignerChanged(_signer);
}
/**
* @notice claim Reward
* @param _poolId index of pools
**/
function claimReward(uint _poolId) external
isPoolExist(_poolId)
isPoolClosed(_poolId)
{
Pool storage pool = pools[_poolId];
require(pool.number > 0, "didn't lottery yet");
require(userClaimed[_poolId][msg.sender] == false, "already claimed reward from this pool");
uint rewardCount = pool.supply / pool.rewardPerTicket;
if (pool.ticketSold > rewardCount) {
require(getPoolResultLength(_poolId) > 0, "waiting calculate lucky number");
}
(uint256 rewardAmount, uint256 refundAmount) = calcReward(msg.sender, _poolId);
userClaimed[_poolId][msg.sender] = true;
if (rewardAmount > 0) {
require(IERC20(pool.sellToken).transfer(msg.sender, rewardAmount), "insufficient token");
}
if (refundAmount > 0) {
if (pool.buyToken == address(0)) {
payable(msg.sender).transfer(refundAmount);
} else {
require(IERC20(pool.buyToken).transferFrom(address(this), msg.sender, refundAmount), "insufficient token");
}
}
emit ClaimReward(msg.sender, _poolId, rewardAmount, refundAmount);
}
function ownerClaim(uint _poolId) external
isPoolExist(_poolId)
isPoolClosed(_poolId)
{
Pool storage pool = pools[_poolId];
require(pool.owner == msg.sender, "only pool owner can claim tokens");
require(poolClaimed[_poolId] == false, "already claimed");
uint rewardCount = pool.supply / pool.rewardPerTicket;
uint sellBalance;
uint buyBalance;
if (rewardCount > pool.tic...
// [truncated — 59728 bytes total]
Read Contract
DEFAULT_ADMIN_ROLE 0xa217fddf → bytes32
POOL_MANAGER_ROLE 0x56d73568 → bytes32
fee 0xddca3f43 → uint256
fees 0xfaaebd21 → uint256
getBought 0x56cec506 → uint256
getClaimable 0xb961cbe1 → bool
getOwnerAvailableClaim 0x8dce1f7c → uint256, uint256
getPool 0x068bcd8d → tuple
getPoolLength 0xb3944d52 → uint256
getPoolNumber 0xea294be3 → uint256
getPoolResult 0x7bca4013 → bool, uint256[]
getPoolResultLength 0x8514ba98 → uint256
getRoleAdmin 0x248a9ca3 → bytes32
getTicket 0xc3149b3a → tuple
getTicketLength 0xf55dd538 → uint256
getTicketReward 0x9dc97e93 → uint256, uint256
hasRole 0x91d14854 → bool
hashes 0x501895ae → uint256
isUserClaimed 0x96826c53 → bool
oracle 0x7dc0d1d0 → address
poolClaimed 0x39c0bd1c → bool
poolResult 0x63429012 → bool
pools 0xac4afa38 → uint256, uint256, uint256, uint256, uint256, address, address, uint256, uint256, address
signer 0x238ac933 → address
supportsInterface 0x01ffc9a7 → bool
ticketBought 0x1a27c649 → uint256
userClaimed 0x3beb9842 → bool
Write Contract 15 functions
These functions modify contract state and require a wallet transaction to execute.
buyTicket 0xf8a0312f
uint256 _poolId
uint256 _quantity
bytes _signature
uint256 _max_quantity
calcResult 0x80bac989
uint256 _poolId
claimFee 0x6ebc51e1
address _tokenAddress
claimReward 0xae169a50
uint256 _poolId
grantRole 0x2f2ff15d
bytes32 role
address account
initialize 0xc4d66de8
address owner
lottery 0xa57d1560
uint256 _poolId
newPool 0x94678f59
uint256 _price
uint256 _supply
uint256 _rewardPerTicket
address _sell
address _buy
uint256 _start
uint256 _duration
address _owner
returns: uint256
ownerClaim 0x434f48c4
uint256 _poolId
renounceRole 0x36568abe
bytes32 role
address account
revokeRole 0xd547741f
bytes32 role
address account
setFee 0x69fe0e2d
uint256 _fee
setHash 0x0e5673b1
uint256 _poolId
uint256 randomness
setOracle 0x7adbf973
address _oracle
setSigner 0x6c19e783
address _signer
Recent Transactions
No transactions found for this address