Address Contract Partially Verified
Address
0xC092F8a88F40fF6Fb06704C38683f39Bf3285B05
Balance
0 ETH
Nonce
1
Code Size
13086 bytes
Creator
0x28EC390b...12AE at tx 0xbed94e79...4f8f8b
Indexed Transactions
0
Contract Bytecode
13086 bytes
0x608060405234801561001057600080fd5b50600436106101cf5760003560e01c80639c1454d411610104578063ce4843e9116100a2578063f21c783b11610071578063f21c783b146104c4578063f41322ac146104cc578063fa45aa0014610518578063fc0c546a14610520576101cf565b8063ce4843e91461044c578063d547741f14610454578063eb990c5914610480578063ee172546146104bc576101cf565b8063c0973eed116100de578063c0973eed14610417578063c413d1001461041f578063c7b8981c14610427578063ca15c8731461042f576101cf565b80639c1454d4146103ea578063a217fddf146103f2578063b6b55f25146103fa576101cf565b806354fd4d50116101715780636f4a2cd01161014b5780636f4a2cd01461036f5780638456cb59146103775780639010d07c1461037f57806391d14854146103be576101cf565b806354fd4d50146102b05780635c975abb1461032d5780635e00e67914610349576101cf565b80632f2ff15d116101ad5780632f2ff15d1461024857806336568abe146102745780633f4ba83a146102a05780634d5d0806146102a8576101cf565b806312edde5e146101d4578063248a9ca3146101f357806326a4e8d214610222575b600080fd5b6101f1600480360360208110156101ea57600080fd5b5035610528565b005b6102106004803603602081101561020957600080fd5b50356107a6565b60408051918252519081900360200190f35b6101f16004803603602081101561023857600080fd5b50356001600160a01b03166107bb565b6101f16004803603604081101561025e57600080fd5b50803590602001356001600160a01b031661092a565b6101f16004803603604081101561028a57600080fd5b50803590602001356001600160a01b0316610991565b6101f16109f2565b610210610a63565b6102b8610a69565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102f25781810151838201526020016102da565b50505050905090810190601f16801561031f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610335610a85565b604080519115158252519081900360200190f35b6101f16004803603602081101561035f57600080fd5b50356001600160a01b0316610a8e565b6101f1610bf6565b6101f1610d1b565b6103a26004803603604081101561039557600080fd5b5080359060200135610d8a565b604080516001600160a01b039092168252519081900360200190f35b610335600480360360408110156103d457600080fd5b50803590602001356001600160a01b0316610db1565b610210610dcf565b610210610dd6565b6101f16004803603602081101561041057600080fd5b5035610ddb565b6103a261120c565b61021061121b565b6101f1611222565b6102106004803603602081101561044557600080fd5b503561151e565b610210611535565b6101f16004803603604081101561046a57600080fd5b50803590602001356001600160a01b031661153b565b6101f16004803603608081101561049657600080fd5b506001600160a01b03813581169160208101359091169060408101359060600135611594565b6102106115f5565b6102106115fc565b6104f2600480360360208110156104e257600080fd5b50356001600160a01b0316611602565b604080519485526020850193909352838301919091526060830152519081900360800190f35b6101f1611711565b6103a2611c3c565b60c95460ff1661056d576040805162461bcd60e51b815260206004820152601f6024820152600080516020612b31833981519152604482015290519081900360640190fd5b60c9805460ff1916905560975460ff16156105c2576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b336000908152610104602090815260408083206101059092529091208261061a5760405162461bcd60e51b815260040180806020018281038252602f815260200180612d9c602f913960400191505060405180910390fd5b815483111561065a5760405162461bcd60e51b815260040180806020018281038252603d8152602001806130ac603d913960400191505060405180910390fd5b600582015460ff16801561066e5750815415155b6106a95760405162461bcd60e51b815260040180806020018281038252604081526020018061327a6040913960400191505060405180910390fd5b6002820154156106ea5760405162461bcd60e51b815260040180806020018281038252603f815260200180612c60603f913960400191505060405180910390fd5b60018101541561072b5760405162461bcd60e51b815260040180806020018281038252603f815260200180612c60603f913960400191505060405180910390fd5b426002830181905561010054600484015560018201849055815560fe54610758908463ffffffff611c4b16565b60fe5560408051848152426020820152815133927ff908b12fe0d8dc1ff4fda115e5bace3a7ad1aad889daca8e638ca0b29f806577928290030190a2505060c9805460ff1916600117905550565b60009081526065602052604090206002015490565b806107ce816001600160a01b0316611c8d565b6108095760405162461bcd60e51b8152600401808060200182810382526034815260200180612d476034913960400191505060405180910390fd5b60975460ff16610857576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b60408051694f574e45525f524f4c4560b01b8152905190819003600a01902061088790610882611cc9565b610db1565b6108c25760405162461bcd60e51b8152600401808060200182810382526041815260200180612e366041913960600191505060405180910390fd5b6001600160a01b0382166109075760405162461bcd60e51b8152600401808060200182810382526027815260200180612f5f6027913960400191505060405180910390fd5b5060fb80546001600160a01b0319166001600160a01b0392909216919091179055565b60008281526065602052604090206002015461094890610882611cc9565b6109835760405162461bcd60e51b815260040180806020018281038252602f815260200180612b02602f913960400191505060405180910390fd5b61098d8282611ccd565b5050565b610999611cc9565b6001600160a01b0316816001600160a01b0316146109e85760405162461bcd60e51b815260040180806020018281038252602f8152602001806132ba602f913960400191505060405180910390fd5b61098d8282611d3c565b604080516a5041555345525f524f4c4560a81b8152905190819003600b019020610a1e90610882611cc9565b610a595760405162461bcd60e51b8152600401808060200182810382526035815260200180612c9f6035913960400191505060405180910390fd5b610a61611dab565b565b60fd5481565b6040805180820190915260028152613b1960f11b602082015290565b60975460ff1690565b60975460ff16610adc576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b60408051694f574e45525f524f4c4560b01b8152905190819003600a019020610b0790610882611cc9565b610b425760405162461bcd60e51b8152600401808060200182810382526043815260200180612d046043913960600191505060405180910390fd5b6001600160a01b038116610b875760405162461bcd60e51b8152600401808060200182810382526030815260200180612bc26030913960400191505060405180910390fd5b60fc546001600160a01b0382811691161415610bd45760405162461bcd60e51b815260040180806020018281038252603c815260200180612b86603c913960400191505060405180910390fd5b60fc80546001600160a01b0319166001600160a01b0392909216919091179055565b60c95460ff16610c3b576040805162461bcd60e51b815260206004820152601f6024820152600080516020612b31833981519152604482015290519081900360640190fd5b60c9805460ff1916905560975460ff1615610c90576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6040805177524557415244535f4449535452494255544f525f524f4c4560401b81529051908190036018019020610cc990610882611cc9565b610d045760405162461bcd60e51b815260040180806020018281038252603a815260200180613127603a913960400191505060405180910390fd5b610d0c611e49565b60c9805460ff19166001179055565b604080516a5041555345525f524f4c4560a81b8152905190819003600b019020610d4790610882611cc9565b610d825760405162461bcd60e51b81526004018080602001828103825260338152602001806131946033913960400191505060405180910390fd5b610a616120da565b6000828152606560205260408120610da8908363ffffffff61215b16565b90505b92915050565b6000828152606560205260408120610da8908363ffffffff61216716565b6101015481565b600081565b60c95460ff16610e20576040805162461bcd60e51b815260206004820152601f6024820152600080516020612b31833981519152604482015290519081900360640190fd5b60c9805460ff1916905560975460ff1615610e75576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b33600090815261010460205260409020600281015415610ec65760405162461bcd60e51b81526004018080602001828103825260338152602001806131616033913960400191505060405180910390fd5b80546040805160c081018252828152600184015460208201526002840154918101919091526003830154606082015260048301546080820152600583015460ff16151560a0820152600090610f1a9061217c565b90506000610f3e82610f32858863ffffffff6121ec16565b9063ffffffff6121ec16565b9050828111610f7e5760405162461bcd60e51b8152600401808060200182810382526036815260200180612c2a6036913960400191505060405180910390fd5b6000610fa2610f93838663ffffffff611c4b16565b60fe549063ffffffff6121ec16565b905060fd54811115610fe55760405162461bcd60e51b815260040180806020018281038252603d815260200180612eec603d913960400191505060405180910390fd5b8185554260018087019190915560058601805460ff1916909117905561010054600386015560fe81905560fb54604080516323b872dd60e01b81523360048201523060248201526044810189905290516001600160a01b03909216916323b872dd916064808201926020929091908290030181600087803b15801561106957600080fd5b505af115801561107d573d6000803e3d6000fd5b505050506040513d602081101561109357600080fd5b50516110d05760405162461bcd60e51b81526004018080602001828103825260388152602001806130746038913960400191505060405180910390fd5b82156111b457610102546110ea908463ffffffff6121ec16565b6101025560fb5460fc54604080516323b872dd60e01b81526001600160a01b03928316600482015230602482015260448101879052905191909216916323b872dd9160648083019260209291908290030181600087803b15801561114d57600080fd5b505af1158015611161573d6000803e3d6000fd5b505050506040513d602081101561117757600080fd5b50516111b45760405162461bcd60e51b8152600401808060200182810382526038815260200180612bf26038913960400191505060405180910390fd5b337f0a7bb2e28cc4698aac06db79cf9163bfcc20719286cf59fa7d492ceda1b8edc26111e6888663ffffffff6121ec16565b60408051918252519081900360200190a2505060c9805460ff1916600117905550505050565b60fc546001600160a01b031681565b6101025481565b60c95460ff16611267576040805162461bcd60e51b815260206004820152601f6024820152600080516020612b31833981519152604482015290519081900360640190fd5b60c9805460ff1916905560975460ff16156112bc576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b33600090815261010460205260409020600581015460ff1680156112e05750805415155b61131b5760405162461bcd60e51b815260040180806020018281038252603f8152602001806131c7603f913960400191505060405180910390fd5b60028101541561135c5760405162461bcd60e51b815260040180806020018281038252603e8152602001806130e9603e913960400191505060405180910390fd5b6040805160c08101825282548152600183015460208201526002830154918101919091526003820154606082015260048201546080820152600582015460ff16151560a08201526000906113af9061217c565b9050600081116113f05760405162461bcd60e51b815260040180806020018281038252603e81526020018061323c603e913960400191505060405180910390fd5b6101005460038301556101025461140d908263ffffffff6121ec16565b6101025560fb5460fc54604080516323b872dd60e01b81526001600160a01b03928316600482015233602482015260448101859052905191909216916323b872dd9160648083019260209291908290030181600087803b15801561147057600080fd5b505af1158015611484573d6000803e3d6000fd5b505050506040513d602081101561149a57600080fd5b50516114d75760405162461bcd60e51b815260040180806020018281038252604881526020018061302c6048913960600191505060405180910390fd5b60408051828152905133917f8a43c4352486ec339f487f64af78ca5cbf06cd47833f073d3baf3a193e503161919081900360200190a2505060c9805460ff19166001179055565b6000818152606560205260408120610dab90612246565b60fe5481565b60008281526065602052604090206002015461155990610882611cc9565b6109e85760405162461bcd60e51b8152600401808060200182810382526030815260200180612cd46030913960400191505060405180910390fd5b836115a7816001600160a01b0316611c8d565b6115e25760405162461bcd60e51b8152600401808060200182810382526034815260200180612d476034913960400191505060405180910390fd5b6115ee85858585612251565b5050505050565b6101035481565b60ff5481565b6001600160a01b0381166000908152610104602052604081206005015481908190819060ff16801561164c57506001600160a01b0385166000908152610104602052604090205415155b6116875760405162461bcd60e51b81526004018080602001828103825260368152602001806132066036913960400191505060405180910390fd5b61168f612a61565b506001600160a01b03851660009081526101046020908152604091829020825160c081018452815480825260018301549382018490526002830154948201859052600383015460608301526004830154608083015260059092015460ff16151560a0820152929091906117018461217c565b9450945094509450509193509193565b60c95460ff16611756576040805162461bcd60e51b815260206004820152601f6024820152600080516020612b31833981519152604482015290519081900360640190fd5b60c9805460ff1916905560975460ff16156117ab576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6117b3612a61565b503360009081526101046020908152604091829020825160c08101845281548152600182015492810192909252600281015492820192909252600382015460608201526004820154608082015260059091015460ff16151560a0820152611818612a99565b503360009081526101056020908152604091829020825180840184528154815260019091015491810191909152908201511515806118595750602081015115155b6118945760405162461bcd60e51b815260040180806020018281038252602d815260200180612dcb602d913960400191505060405180910390fd5b8160a0015180156118a55750815115155b6118e05760405162461bcd60e51b8152600401808060200182810382526035815260200180612b516035913960400191505060405180910390fd5b60006201518083604001514203816118f457fe5b0490508060ff5411156119385760405162461bcd60e51b815260040180806020018281038252602c815260200180612ad6602c913960400191505060405180910390fd5b600082602001516000141561194e578351611954565b82602001515b905060006119618561217c565b905081856000015110156119a65760405162461bcd60e51b815260040180806020018281038252604c815260200180612fe0604c913960600191505060405180910390fd5b84518210156119f75733600090815261010460205260409020546119d0908363ffffffff611c4b16565b33600090815261010460205260408120918255600282015561010054600390910155611a33565b336000908152610104602052604081208181556001810182905560028101829055600381018290556004810191909155600501805460ff191690555b60fb546040805163a9059cbb60e01b81523360048201526024810185905290516001600160a01b039092169163a9059cbb916044808201926020929091908290030181600087803b158015611a8757600080fd5b505af1158015611a9b573d6000803e3d6000fd5b505050506040513d6020811015611ab157600080fd5b5051611aee5760405162461bcd60e51b8152600401808060200182810382526047815260200180612ea56047913960600191505060405180910390fd5b8015611bd25761010254611b08908263ffffffff6121ec16565b6101025560fb5460fc54604080516323b872dd60e01b81526001600160a01b03928316600482015233602482015260448101859052905191909216916323b872dd9160648083019260209291908290030181600087803b158015611b6b57600080fd5b505af1158015611b7f573d6000803e3d6000fd5b505050506040513d6020811015611b9557600080fd5b5051611bd25760405162461bcd60e51b815260040180806020018281038252603e815260200180612df8603e913960400191505060405180910390fd5b336000818152610105602090815260408083206001810184905592909255815185815290810184905281517ff6c0fc94edc8fd2a37514f1fb85af88fca386b00a54127b912273e6b83322e08929181900390910190a2505060c9805460ff19166001179055505050565b60fb546001600160a01b031681565b6000610da883836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506123e0565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470818114801590611cc157508115155b949350505050565b3390565b6000828152606560205260409020611ceb908263ffffffff61247716565b1561098d57611cf8611cc9565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000828152606560205260409020611d5a908263ffffffff61248c16565b1561098d57611d67611cc9565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b60975460ff16611df9576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b6097805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa611e2c611cc9565b604080516001600160a01b039092168252519081900360200190a1565b60975460ff1615611e94576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6040805177524557415244535f4449535452494255544f525f524f4c4560401b81529051908190036018019020611ecd90610882611cc9565b611f085760405162461bcd60e51b815260040180806020018281038252603a815260200180613127603a913960400191505060405180910390fd5b600060fe5411611f495760405162461bcd60e51b815260040180806020018281038252602f815260200180612fb1602f913960400191505060405180910390fd5b60fb5460fc54604080516370a0823160e01b81526001600160a01b039283166004820152905160009392909216916370a0823191602480820192602092909190829003018186803b158015611f9d57600080fd5b505afa158015611fb1573d6000803e3d6000fd5b505050506040513d6020811015611fc757600080fd5b50519050806120075760405162461bcd60e51b815260040180806020018281038252602b815260200180612f86602b913960400191505060405180910390fd5b60006120326101015461202661010254856121ec90919063ffffffff16565b9063ffffffff611c4b16565b9050600061206360fe54612057670de0b6b3a7640000856124a190919063ffffffff16565b9063ffffffff6124fa16565b6101005490915061207a908263ffffffff6121ec16565b610100556101018390556000610102556101035461209e908363ffffffff6121ec16565b610103556040805183815290517f6d1c76d614228b523baa4dcd9539e2c713b54ff4ab3ff2d1627e7f6cd32be4429181900360200190a1505050565b60975460ff1615612125576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6097805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611e2c611cc9565b6000610da8838361253c565b6000610da8836001600160a01b0384166125a0565b604081015160009081906121a9576060830151610100546121a29163ffffffff611c4b16565b90506121c5565b606083015160808401516121c29163ffffffff611c4b16565b90505b82516121e590670de0b6b3a764000090612057908463ffffffff6124a116565b9392505050565b600082820183811015610da8576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6000610dab826125b8565b600054610100900460ff168061226a575061226a6125bc565b80612278575060005460ff16155b6122b35760405162461bcd60e51b815260040180806020018281038252602e815260200180612e77602e913960400191505060405180910390fd5b600054610100900460ff161580156122de576000805460ff1961ff0019909116610100171660011790555b6001600160a01b0385166123235760405162461bcd60e51b8152600401808060200182810382526027815260200180612f5f6027913960400191505060405180910390fd5b600083116123625760405162461bcd60e51b8152600401808060200182810382526036815260200180612f296036913960400191505060405180910390fd5b61236a6125c2565b6123726125c2565b61237a612664565b61238261270f565b61238a6127bd565b612392610d1b565b61239b84610a8e565b6123a36109f2565b60fb80546001600160a01b0319166001600160a01b03871617905560fd83905560ff82905580156115ee576000805461ff00191690555050505050565b6000818484111561246f5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561243457818101518382015260200161241c565b50505050905090810190601f1680156124615780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6000610da8836001600160a01b0384166128ec565b6000610da8836001600160a01b038416612936565b6000826124b057506000610dab565b828202828482816124bd57fe5b0414610da85760405162461bcd60e51b8152600401808060200182810382526021815260200180612d7b6021913960400191505060405180910390fd5b6000610da883836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506129fc565b8154600090821061257e5760405162461bcd60e51b8152600401808060200182810382526022815260200180612ab46022913960400191505060405180910390fd5b82600001828154811061258d57fe5b9060005260206000200154905092915050565b60009081526001919091016020526040902054151590565b5490565b303b1590565b600054610100900460ff16806125db57506125db6125bc565b806125e9575060005460ff16155b6126245760405162461bcd60e51b815260040180806020018281038252602e815260200180612e77602e913960400191505060405180910390fd5b600054610100900460ff1615801561264f576000805460ff1961ff0019909116610100171660011790555b8015612661576000805461ff00191690555b50565b600054610100900460ff168061267d575061267d6125bc565b8061268b575060005460ff16155b6126c65760405162461bcd60e51b815260040180806020018281038252602e815260200180612e77602e913960400191505060405180910390fd5b600054610100900460ff161580156126f1576000805460ff1961ff0019909116610100171660011790555b6097805460ff191690558015612661576000805461ff001916905550565b600054610100900460ff168061272857506127286125bc565b80612736575060005460ff16155b6127715760405162461bcd60e51b815260040180806020018281038252602e815260200180612e77602e913960400191505060405180910390fd5b600054610100900460ff1615801561279c576000805460ff1961ff0019909116610100171660011790555b60c9805460ff191660011790558015612661576000805461ff001916905550565b600054610100900460ff16806127d657506127d66125bc565b806127e4575060005460ff16155b61281f5760405162461bcd60e51b815260040180806020018281038252602e815260200180612e77602e913960400191505060405180910390fd5b600054610100900460ff1615801561284a576000805460ff1961ff0019909116610100171660011790555b61285c6000612857611cc9565b610983565b604080516a5041555345525f524f4c4560a81b8152905190819003600b01902061288890612857611cc9565b60408051694f574e45525f524f4c4560b01b8152905190819003600a0190206128b390612857611cc9565b6040805177524557415244535f4449535452494255544f525f524f4c4560401b8152905190819003601801902061264f90612857611cc9565b60006128f883836125a0565b61292e57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610dab565b506000610dab565b600081815260018301602052604081205480156129f2578354600019808301919081019060009087908390811061296957fe5b906000526020600020015490508087600001848154811061298657fe5b6000918252602080832090910192909255828152600189810190925260409020908401905586548790806129b657fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050610dab565b6000915050610dab565b60008183612a4b5760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561243457818101518382015260200161241c565b506000838581612a5757fe5b0495945050505050565b6040518060c0016040528060008152602001600081526020016000815260200160008152602001600081526020016000151581525090565b60405180604001604052806000815260200160008152509056fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e64735b57697468647261775d2054686520756e7374616b696e6720706572696f6420646964206e6f742070617373416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f206772616e745265656e7472616e637947756172643a207265656e7472616e742063616c6c005b57697468647261775d205468657265206973206e6f207374616b65206465706f73697420666f722074686973206163636f756e745b56616c69646174696f6e5d205f726577617264734164647265737320697320616c72656164792073657420746f20676976656e20616464726573735b56616c69646174696f6e5d205f726577617264734164647265737320697320746865207a65726f20616464726573735b4465706f7369745d20536f6d657468696e672077656e742077726f6e67207768696c65207472616e7366657272696e67207265776172645b56616c69646174696f6e5d20546865207374616b65206465706f7369742068617320746f206265206c6172676572207468616e20305b496e697469617465205769746864726177616c5d20596f75206861766520616c726561647920696e6974696174656420746865207769746864726177616c537761705374616b696e67436f6e74726163743a206d75737420686176652070617573657220726f6c6520746f20756e7061757365416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f207265766f6b655b56616c69646174696f6e5d205468652063616c6c6572206d7573742068617665206f776e657220726f6c6520746f20736574207265776172647320616464726573735b56616c69646174696f6e5d20546865206164647265737320646f6573206e6f7420636f6e7461696e206120636f6e7472616374536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775b496e697469617465205769746864726177616c5d20496e76616c6964207769746864726177616c20616d6f756e745b57697468647261775d20576974686472617720616d6f756e74206973206e6f7420696e697469616c697a65645b57697468647261775d20536f6d657468696e672077656e742077726f6e67207768696c65207472616e7366657272696e6720796f7572207265776172645b56616c69646174696f6e5d205468652063616c6c6572206d7573742068617665206f776e657220726f6c6520746f2073657420746f6b656e2061646472657373436f6e747261637420696e7374616e63652068617320616c7265616479206265656e20696e697469616c697a65645b57697468647261775d20536f6d657468696e672077656e742077726f6e67207768696c65207472616e7366657272696e6720796f757220696e697469616c206465706f7369745b4465706f7369745d20596f7572206465706f73697420776f756c6420657863656564207468652063757272656e74207374616b696e67206c696d69745b56616c69646174696f6e5d205f6d61785374616b696e67416d6f756e742068617320746f206265206c6172676572207468616e20305b56616c69646174696f6e5d20496e76616c6964207377617020746f6b656e20616464726573735b56616c69646174696f6e5d206e6f7420656e6f756768207265776172647320616363756d756c617465645b56616c69646174696f6e5d206e6f7420656e6f75676820746f74616c207374616b6520616363756d756c617465645b77697468647261775d2052656d61696e696e67207374616b656465706f73697420616d6f756e74206d75737420626520686967686572207468616e20776974686472617720616d6f756e745b52657761726473205769746864726177616c5d20536f6d657468696e672077656e742077726f6e67207768696c65207472616e7366657272696e6720796f7572207265776172645b4465706f7369745d20536f6d657468696e672077656e742077726f6e6720647572696e672074686520746f6b656e207472616e736665725b496e697469617465205769746864726177616c5d20576974686472617720616d6f756e742065786365656420746865207374616b6520616d6f756e745b52657761726473205769746864726177616c5d20596f7520616c726561647920696e69746961746564207468652066756c6c207769746864726177616c5b56616c69646174696f6e5d205468652063616c6c6572206d75737420686176652072657761726473206469737472696275746f7220726f6c655b4465706f7369745d20596f75206861766520616c726561647920696e6974696174656420746865207769746864726177616c537761705374616b696e67436f6e74726163743a206d75737420686176652070617573657220726f6c6520746f2070617573655b52657761726473205769746864726177616c5d205468657265206973206e6f207374616b65206465706f73697420666f722074686973206163636f756e745b56616c69646174696f6e5d2054686973206163636f756e7420646f65736e277420686176652061207374616b65206465706f7369745b52657761726473205769746864726177616c5d205468652072657761726420616d6f756e742068617320746f206265206c6172676572207468616e20305b496e697469617465205769746864726177616c5d205468657265206973206e6f207374616b65206465706f73697420666f722074686973206163636f756e74416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636520726f6c657320666f722073656c66a2646970667358221220c026ac683a573fad92485832560c4312e5102a3954d107b6ad9cd1142a0dd39c64736f6c63430006020033
Verified Source Code Partial Match
Compiler: v0.6.2+commit.bacdbe57
EVM: istanbul
Optimization: Yes (200 runs)
SwapStakingContract.sol 1432 lines
// File: @openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol
pragma solidity ^0.6.0;
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
// File: @openzeppelin/contracts-ethereum-package/contracts/math/Math.sol
pragma solidity ^0.6.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a >= b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow, so we distribute
return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2);
}
}
// File: @openzeppelin/contracts-ethereum-package/contracts/utils/Address.sol
pragma solidity ^0.6.2;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @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
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @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");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
}
// File: @openzeppelin/contracts-ethereum-package/contracts/utils/Arrays.sol
pragma solidity ^0.6.0;
/**
* @dev Collection of functions related to array types.
*/
library Arrays {
/**
* @dev Searches a sorted `array` and returns the first index that contains
* a value greater or equal to `element`. If no such index exists (i.e. all
* values in the array are strictly less than `element`), the array length is
* returned. Time complexity O(log n).
*
* `array` is expected to be sorted in ascending order, and to contain no
* repeated elements.
*/
function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256) {
if (array.length == 0) {
return 0;
}
uint256 low = 0;
uint256 high = array.length;
while (low < high) {
uint256 mid = Math.average(low, high);
// Note that mid will always be strictly less than high (i.e. it will be a valid array index)
// because Math.average rounds down (it does integer division with truncation).
if (array[mid] > element) {
high = mid;
} else {
low = mid + 1;
}
}
// At this point `low` is the exclusive upper bound. We will return the inclusive upper bound.
if (low > 0 && array[low - 1] == element) {
return low - 1;
} else {
return low;
}
}
}
// File: @openzeppelin/contracts-ethereum-package/contracts/Initializable.sol
pragma solidity >=0.4.24 <0.7.0;
/**
* @title Initializable
*
* @dev Helper contract to support initializer functions. To use it, replace
* the constructor with a function that has the `initializer` modifier.
* WARNING: Unlike constructors, initializer functions must be manually
* invoked. This applies both to deploying an Initializable contract, as well
* as extending an Initializable contract via inheritance.
* WARNING: When used with inheritance, manual care must be taken to not invoke
* a parent initializer twice, or ensure that all initializers are idempotent,
* because this is not dealt with automatically as with constructors.
*/
contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
*/
bool private initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private initializing;
/**
* @dev Modifier to use in the initializer function of a contract.
*/
modifier initializer() {
require(initializing || isConstructor() || !initialized, "Contract instance has already been initialized");
bool isTopLevelCall = !initializing;
if (isTopLevelCall) {
initializing = true;
initialized = true;
}
_;
if (isTopLevelCall) {
initializing = false;
}
}
/// @dev Returns true if and only if the function is running in the constructor
function isConstructor() private view returns (bool) {
// extcodesize checks the size of the code stored in an address, and
// address returns the current address. Since the code is still not
// deployed when running a constructor, any checks on its code size will
// yield zero, making it an effective way to detect if a contract is
// under construction or not.
address self = address(this);
uint256 cs;
assembly { cs := extcodesize(self) }
return cs == 0;
}
// Reserved storage space to allow for layout changes in the future.
uint256[50] private ______gap;
}
// File: @openzeppelin/contracts-ethereum-package/contracts/utils/ReentrancyGuard.sol
pragma solidity ^0.6.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].
*/
contract ReentrancyGuardUpgradeSafe is Initializable {
bool private _notEntered;
function __ReentrancyGuard_init() internal initializer {
__ReentrancyGuard_init_unchained();
}
function __ReentrancyGuard_init_unchained() internal initializer {
// Storing an initial 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 percetange 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.
_notEntered = true;
}
/**
* @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 make it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_notEntered, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_notEntered = false;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_notEntered = true;
}
uint256[49] private __gap;
}
// File: @openzeppelin/contracts-ethereum-package/contracts/GSN/Context.sol
pragma solidity ^0.6.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 GSN 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.
*/
contract ContextUpgradeSafe is Initializable {
// Empty internal constructor, to prevent people from mistakenly deploying
// an instance of this contract, which should be used via inheritance.
function __Context_init() internal initializer {
__Context_init_unchained();
}
function __Context_init_unchained() internal initializer {
}
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
uint256[50] private __gap;
}
// File: @openzeppelin/contracts-ethereum-package/contracts/utils/Pausable.sol
pragma solidity ^0.6.0;
/**
* @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.
*/
contract PausableUpgradeSafe is Initializable, ContextUpgradeSafe {
/**
* @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);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
function __Pausable_init() internal initializer {
__Context_init_unchained();
__Pausable_init_unchained();
}
function __Pausable_init_unchained() internal initializer {
_paused = false;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view returns (bool) {
return _paused;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!_paused, "Pausable: paused");
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(_paused, "Pausable: not paused");
_;
}
/**
* @dev Triggers stopped state.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
uint256[49] private __gap;
}
// File: @openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol
pragma solidity ^0.6.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @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 `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, 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 `sender` to `recipient` 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 sender, address recipient, uint256 amount) external returns (bool);
/**
* @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);
}
// File: @openzeppelin/contracts-ethereum-package/contracts/utils/EnumerableSet.sol
pragma solidity ^0.6.0;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.0.0, only sets of type `address` (`AddressSet`) and `uint256`
* (`UintSet`) are supported.
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping (bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) { // Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
// When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
// so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
bytes32 lastvalue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastvalue;
// Update the index for the moved value
set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
require(set._values.length > index, "EnumerableSet: index out of bounds");
return set._values[index];
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(value)));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint256(_at(set._inner, index)));
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
}
// File: @openzeppelin/contracts-ethereum-package/contracts/access/AccessControl.sol
pragma solidity ^0.6.0;
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms.
*
* 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, _msgSender()));
* ...
* }
* ```
*
* 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}.
*/
abstract contract AccessControlUpgradeSafe is Initializable, ContextUpgradeSafe {
function __AccessControl_init() internal initializer {
__Context_init_unchained();
__AccessControl_init_unchained();
}
function __AccessControl_init_unchained() internal initializer {
}
using EnumerableSet for EnumerableSet.AddressSet;
using Address for address;
struct RoleData {
EnumerableSet.AddressSet members;
bytes32 adminRole;
}
mapping (bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {_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) public view returns (bool) {
return _roles[role].members.contains(account);
}
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) public view returns (uint256) {
return _roles[role].members.length();
}
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
* WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
* you perform all queries on the same block. See the following
* https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
* for more information.
*/
function getRoleMember(bytes32 role, uint256 index) public view returns (address) {
return _roles[role].members.at(index);
}
/**
* @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 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 {
require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant");
_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 {
require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke");
_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 granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) public virtual {
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}.
* ====
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
_roles[role].adminRole = adminRole;
}
function _grantRole(bytes32 role, address account) private {
if (_roles[role].members.add(account)) {
emit RoleGranted(role, account, _msgSender());
}
}
function _revokeRole(bytes32 role, address account) private {
if (_roles[role].members.remove(account)) {
emit RoleRevoked(role, account, _msgSender());
}
}
uint256[49] private __gap;
}
// File: contracts/SwapStakingContract.sol
pragma solidity 0.6.2;
contract SwapStakingContract is Initializable, ContextUpgradeSafe, AccessControlUpgradeSafe, PausableUpgradeSafe, ReentrancyGuardUpgradeSafe {
using SafeMath for uint256;
using Math for uint256;
using Address for address;
using Arrays for uint256[];
bytes32 private constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
bytes32 private constant OWNER_ROLE = keccak256("OWNER_ROLE");
bytes32 private constant REWARDS_DISTRIBUTOR_ROLE = keccak256("REWARDS_DISTRIBUTOR_ROLE");
// EVENTS
event StakeDeposited(address indexed account, uint256 amount);
event WithdrawInitiated(address indexed account, uint256 amount, uint256 initiateDate);
event WithdrawExecuted(address indexed account, uint256 amount, uint256 reward);
event RewardsWithdrawn(address indexed account, uint256 reward);
event RewardsDistributed(uint256 amount);
// STRUCT DECLARATIONS
struct StakeDeposit {
uint256 amount;
uint256 startDate;
uint256 endDate;
uint256 entryRewardPoints;
uint256 exitRewardPoints;
bool exists;
}
// STRUCT WITHDRAWAL
struct WithdrawalState {
uint256 initiateDate;
uint256 amount;
}
// CONTRACT STATE VARIABLES
IERC20 public token;
address public rewardsAddress;
uint256 public maxStakingAmount;
uint256 public currentTotalStake;
uint256 public unstakingPeriod;
//reward calculations
uint256 private totalRewardPoints;
uint256 public rewardsDistributed;
uint256 public rewardsWithdrawn;
uint256 public totalRewardsDistributed;
mapping(address => StakeDeposit) private _stakeDeposits;
mapping(address => WithdrawalState) private _withdrawStates;
// MODIFIERS
modifier guardMaxStakingLimit(uint256 amount)
{
uint256 resultedStakedAmount = currentTotalStake.add(amount);
require(resultedStakedAmount <= maxStakingAmount, "[Deposit] Your deposit would exceed the current staking limit");
_;
}
modifier onlyContract(address account)
{
require(account.isContract(), "[Validation] The address does not contain a contract");
_;
}
// PUBLIC FUNCTIONS
function initialize(address _token, address _rewardsAddress, uint256 _maxStakingAmount, uint256 _unstakingPeriod)
public
onlyContract(_token)
{
__SwapStakingContract_init(_token, _rewardsAddress, _maxStakingAmount, _unstakingPeriod);
}
function __SwapStakingContract_init(address _token, address _rewardsAddress, uint256 _maxStakingAmount, uint256 _unstakingPeriod)
internal
initializer
{
require(
_token != address(0),
"[Validation] Invalid swap token address"
);
require(_maxStakingAmount > 0, "[Validation] _maxStakingAmount has to be larger than 0");
__Context_init_unchained();
__AccessControl_init_unchained();
__Pausable_init_unchained();
__ReentrancyGuard_init_unchained();
__SwapStakingContract_init_unchained();
pause();
setRewardAddress(_rewardsAddress);
unpause();
token = IERC20(_token);
maxStakingAmount = _maxStakingAmount;
unstakingPeriod = _unstakingPeriod;
}
function __SwapStakingContract_init_unchained()
internal
initializer
{
_setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
_setupRole(PAUSER_ROLE, _msgSender());
_setupRole(OWNER_ROLE, _msgSender());
_setupRole(REWARDS_DISTRIBUTOR_ROLE, _msgSender());
}
function pause()
public
{
require(hasRole(PAUSER_ROLE, _msgSender()), "SwapStakingContract: must have pauser role to pause");
_pause();
}
function unpause()
public
{
require(hasRole(PAUSER_ROLE, _msgSender()), "SwapStakingContract: must have pauser role to unpause");
_unpause();
}
function setRewardAddress(address _rewardsAddress)
public
whenPaused
{
require(hasRole(OWNER_ROLE, _msgSender()), "[Validation] The caller must have owner role to set rewards address");
require(_rewardsAddress != address(0), "[Validation] _rewardsAddress is the zero address");
require(_rewardsAddress != rewardsAddress, "[Validation] _rewardsAddress is already set to given address");
rewardsAddress = _rewardsAddress;
}
function setTokenAddress(address _token)
external
onlyContract(_token)
whenPaused
{
require(hasRole(OWNER_ROLE, _msgSender()), "[Validation] The caller must have owner role to set token address");
require(
_token != address(0),
"[Validation] Invalid swap token address"
);
token = IERC20(_token);
}
function deposit(uint256 amount)
external
nonReentrant
whenNotPaused
{
StakeDeposit storage stakeDeposit = _stakeDeposits[msg.sender];
require(stakeDeposit.endDate == 0, "[Deposit] You have already initiated the withdrawal");
uint256 oldPrincipal = stakeDeposit.amount;
uint256 reward = _computeReward(stakeDeposit);
uint256 newPrincipal = oldPrincipal.add(amount).add(reward);
require(newPrincipal > oldPrincipal, "[Validation] The stake deposit has to be larger than 0");
uint256 resultedStakedAmount = currentTotalStake.add(newPrincipal.sub(oldPrincipal));
require(resultedStakedAmount <= maxStakingAmount, "[Deposit] Your deposit would exceed the current staking limit");
stakeDeposit.amount = newPrincipal;
stakeDeposit.startDate = block.timestamp;
stakeDeposit.exists = true;
stakeDeposit.entryRewardPoints = totalRewardPoints;
currentTotalStake = resultedStakedAmount;
// Transfer the Tokens to this contract
require(token.transferFrom(msg.sender, address(this), amount), "[Deposit] Something went wrong during the token transfer");
if( reward > 0 ) {
//calculate withdrawed rewards in single distribution cycle
rewardsWithdrawn = rewardsWithdrawn.add(reward);
require(token.transferFrom(rewardsAddress, address(this), reward), "[Deposit] Something went wrong while transferring reward");
}
emit StakeDeposited(msg.sender, amount.add(reward));
}
function initiateWithdrawal(uint256 withdrawAmount)
external
nonReentrant
whenNotPaused
{
StakeDeposit storage stakeDeposit = _stakeDeposits[msg.sender];
WithdrawalState storage withdrawState = _withdrawStates[msg.sender];
require(withdrawAmount > 0, "[Initiate Withdrawal] Invalid withdrawal amount");
require(withdrawAmount <= stakeDeposit.amount, "[Initiate Withdrawal] Withdraw amount exceed the stake amount");
require(stakeDeposit.exists && stakeDeposit.amount != 0, "[Initiate Withdrawal] There is no stake deposit for this account");
require(stakeDeposit.endDate == 0, "[Initiate Withdrawal] You have already initiated the withdrawal");
require(withdrawState.amount == 0, "[Initiate Withdrawal] You have already initiated the withdrawal");
stakeDeposit.endDate = block.timestamp;
stakeDeposit.exitRewardPoints = totalRewardPoints;
withdrawState.amount = withdrawAmount;
withdrawState.initiateDate = block.timestamp;
currentTotalStake = currentTotalStake.sub(withdrawAmount);
emit WithdrawInitiated(msg.sender, withdrawAmount, block.timestamp);
}
function executeWithdrawal()
external
nonReentrant
whenNotPaused
{
StakeDeposit memory stakeDeposit = _stakeDeposits[msg.sender];
WithdrawalState memory withdrawState = _withdrawStates[msg.sender];
require(stakeDeposit.endDate != 0 || withdrawState.amount != 0, "[Withdraw] Withdraw amount is not initialized");
require(stakeDeposit.exists && stakeDeposit.amount != 0, "[Withdraw] There is no stake deposit for this account");
// validate enough days have passed from initiating the withdrawal
uint256 daysPassed = (block.timestamp - stakeDeposit.endDate) / 1 days;
require(unstakingPeriod <= daysPassed, "[Withdraw] The unstaking period did not pass");
uint256 amount = withdrawState.amount != 0 ? withdrawState.amount : stakeDeposit.amount;
uint256 reward = _computeReward(stakeDeposit);
require(stakeDeposit.amount >= amount, "[withdraw] Remaining stakedeposit amount must be higher than withdraw amount");
if (stakeDeposit.amount > amount) {
_stakeDeposits[msg.sender].amount = _stakeDeposits[msg.sender].amount.sub(amount);
_stakeDeposits[msg.sender].endDate = 0;
_stakeDeposits[msg.sender].entryRewardPoints = totalRewardPoints;
}
else {
delete _stakeDeposits[msg.sender];
}
require(token.transfer(msg.sender, amount), "[Withdraw] Something went wrong while transferring your initial deposit");
if( reward > 0 ) {
//calculate withdrawed rewards in single distribution cycle
rewardsWithdrawn = rewardsWithdrawn.add(reward);
require(token.transferFrom(rewardsAddress, msg.sender, reward), "[Withdraw] Something went wrong while transferring your reward");
}
_withdrawStates[msg.sender].amount = 0;
_withdrawStates[msg.sender].initiateDate = 0;
emit WithdrawExecuted(msg.sender, amount, reward);
}
function withdrawRewards()
external
nonReentrant
whenNotPaused
{
StakeDeposit storage stakeDeposit = _stakeDeposits[msg.sender];
require(stakeDeposit.exists && stakeDeposit.amount != 0, "[Rewards Withdrawal] There is no stake deposit for this account");
require(stakeDeposit.endDate == 0, "[Rewards Withdrawal] You already initiated the full withdrawal");
uint256 reward = _computeReward(stakeDeposit);
require(reward > 0, "[Rewards Withdrawal] The reward amount has to be larger than 0");
stakeDeposit.entryRewardPoints = totalRewardPoints;
//calculate withdrawed rewards in single distribution cycle
rewardsWithdrawn = rewardsWithdrawn.add(reward);
require(token.transferFrom(rewardsAddress, msg.sender, reward), "[Rewards Withdrawal] Something went wrong while transferring your reward");
emit RewardsWithdrawn(msg.sender, reward);
}
// VIEW FUNCTIONS FOR HELPING THE USER AND CLIENT INTERFACE
function getStakeDetails(address account)
external
view
returns (uint256 initialDeposit, uint256 startDate, uint256 endDate, uint256 rewards)
{
require(_stakeDeposits[account].exists && _stakeDeposits[account].amount != 0, "[Validation] This account doesn't have a stake deposit");
StakeDeposit memory s = _stakeDeposits[account];
return (s.amount, s.startDate, s.endDate, _computeReward(s));
}
function _computeReward(StakeDeposit memory stakeDeposit)
private
view
returns (uint256)
{
uint256 rewardsPoints = 0;
if ( stakeDeposit.endDate == 0 )
{
rewardsPoints = totalRewardPoints.sub(stakeDeposit.entryRewardPoints);
}
else
{
//withdrawal is initiated
rewardsPoints = stakeDeposit.exitRewardPoints.sub(stakeDeposit.entryRewardPoints);
}
return stakeDeposit.amount.mul(rewardsPoints).div(10 ** 18);
}
function distributeRewards()
external
nonReentrant
whenNotPaused
{
require(hasRole(REWARDS_DISTRIBUTOR_ROLE, _msgSender()),
"[Validation] The caller must have rewards distributor role");
_distributeRewards();
}
function _distributeRewards()
private
whenNotPaused
{
require(hasRole(REWARDS_DISTRIBUTOR_ROLE, _msgSender()),
"[Validation] The caller must have rewards distributor role");
require(currentTotalStake > 0, "[Validation] not enough total stake accumulated");
uint256 rewardPoolBalance = token.balanceOf(rewardsAddress);
require(rewardPoolBalance > 0, "[Validation] not enough rewards accumulated");
uint256 newlyAdded = rewardPoolBalance.add(rewardsWithdrawn).sub(rewardsDistributed);
uint256 ratio = newlyAdded.mul(10 ** 18).div(currentTotalStake);
totalRewardPoints = totalRewardPoints.add(ratio);
rewardsDistributed = rewardPoolBalance;
rewardsWithdrawn = 0;
totalRewardsDistributed = totalRewardsDistributed.add(newlyAdded);
emit RewardsDistributed(newlyAdded);
}
function version...
// [truncated — 50072 bytes total]
Read Contract
DEFAULT_ADMIN_ROLE 0xa217fddf → bytes32
currentTotalStake 0xce4843e9 → uint256
getRoleAdmin 0x248a9ca3 → bytes32
getRoleMember 0x9010d07c → address
getRoleMemberCount 0xca15c873 → uint256
getStakeDetails 0xf41322ac → uint256, uint256, uint256, uint256
hasRole 0x91d14854 → bool
maxStakingAmount 0x4d5d0806 → uint256
paused 0x5c975abb → bool
rewardsAddress 0xc0973eed → address
rewardsDistributed 0x9c1454d4 → uint256
rewardsWithdrawn 0xc413d100 → uint256
token 0xfc0c546a → address
totalRewardsDistributed 0xee172546 → uint256
unstakingPeriod 0xf21c783b → uint256
version 0x54fd4d50 → string
Write Contract 13 functions
These functions modify contract state and require a wallet transaction to execute.
deposit 0xb6b55f25
uint256 amount
distributeRewards 0x6f4a2cd0
No parameters
executeWithdrawal 0xfa45aa00
No parameters
grantRole 0x2f2ff15d
bytes32 role
address account
initialize 0xeb990c59
address _token
address _rewardsAddress
uint256 _maxStakingAmount
uint256 _unstakingPeriod
initiateWithdrawal 0x12edde5e
uint256 withdrawAmount
pause 0x8456cb59
No parameters
renounceRole 0x36568abe
bytes32 role
address account
revokeRole 0xd547741f
bytes32 role
address account
setRewardAddress 0x5e00e679
address _rewardsAddress
setTokenAddress 0x26a4e8d2
address _token
unpause 0x3f4ba83a
No parameters
withdrawRewards 0xc7b8981c
No parameters
Recent Transactions
No transactions found for this address