Address Contract Partially Verified
Address
0xD4f2249dd6c26446F1413f6d97F14fcaa7792545
Balance
17.8512 ETH
Nonce
1
Code Size
19251 bytes
Creator
0x8696BDE5...C007 at tx 0x07238d96...48fcd3
Indexed Transactions
0
Contract Bytecode
19251 bytes
0x60806040526004361061021a5760003560e01c806370a0823111610123578063bc197c81116100ab578063dd62ed3e1161006f578063dd62ed3e14610e7a578063e3a7c90314610eff578063ee7a116314610f2a578063f23a6e6114610f55578063fa89401a146110625761021a565b8063bc197c8114610bc4578063c45a015514610d67578063c79045cb14610da8578063cfa84dfe14610dd3578063d383f64614610e635761021a565b806395d89b41116100f257806395d89b41146109c25780639d13fb2414610a52578063a457c2d714610ab7578063a9059cbb14610b28578063af58e6f014610b995761021a565b806370a08231146107fc5780637e067a60146108615780637f3c81601461095c5780637fc6bb3d146109875761021a565b8063265aa621116101a6578063379607f511610175578063379607f51461067457806339509351146106af5780634423c5f114610720578063454a2ab314610793578063525d02b8146107c15761021a565b8063265aa621146105305780632788aeb2146105ac578063313ce5671461061b578063355274ea146106495761021a565b80630e4cfe97116101ed5780630e4cfe97146103bd57806318160ddd146103f85780631d1438481461042357806322a250821461046457806323b872dd1461049f5761021a565b806301ffc9a71461021f57806302fb0c5e1461028f57806306fdde03146102bc578063095ea7b31461034c575b600080fd5b34801561022b57600080fd5b506102776004803603602081101561024257600080fd5b8101908080357bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690602001909291905050506110b3565b60405180821515815260200191505060405180910390f35b34801561029b57600080fd5b506102a461111b565b60405180821515815260200191505060405180910390f35b3480156102c857600080fd5b506102d161112e565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103115780820151818401526020810190506102f6565b50505050905090810190601f16801561033e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561035857600080fd5b506103a56004803603604081101561036f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506111d0565b60405180821515815260200191505060405180910390f35b3480156103c957600080fd5b506103f6600480360360208110156103e057600080fd5b81019080803590602001909291905050506111ee565b005b34801561040457600080fd5b5061040d6117ac565b6040518082815260200191505060405180910390f35b34801561042f57600080fd5b506104386117b6565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561047057600080fd5b5061049d6004803603602081101561048757600080fd5b81019080803590602001909291905050506117dc565b005b3480156104ab57600080fd5b50610518600480360360608110156104c257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506118c0565b60405180821515815260200191505060405180910390f35b34801561053c57600080fd5b506105696004803603602081101561055357600080fd5b8101908080359060200190929190505050611999565b604051808573ffffffffffffffffffffffffffffffffffffffff168152602001848152602001838152602001821515815260200194505050505060405180910390f35b3480156105b857600080fd5b50610605600480360360408110156105cf57600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506119f6565b6040518082815260200191505060405180910390f35b34801561062757600080fd5b50610630611a1b565b604051808260ff16815260200191505060405180910390f35b34801561065557600080fd5b5061065e611a32565b6040518082815260200191505060405180910390f35b34801561068057600080fd5b506106ad6004803603602081101561069757600080fd5b8101908080359060200190929190505050611a38565b005b3480156106bb57600080fd5b50610708600480360360408110156106d257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611fe3565b60405180821515815260200191505060405180910390f35b34801561072c57600080fd5b506107596004803603602081101561074357600080fd5b8101908080359060200190929190505050612096565b604051808473ffffffffffffffffffffffffffffffffffffffff168152602001838152602001828152602001935050505060405180910390f35b6107bf600480360360208110156107a957600080fd5b81019080803590602001909291905050506120e0565b005b3480156107cd57600080fd5b506107fa600480360360208110156107e457600080fd5b8101908080359060200190929190505050612513565b005b34801561080857600080fd5b5061084b6004803603602081101561081f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506127b8565b6040518082815260200191505060405180910390f35b34801561086d57600080fd5b5061095a6004803603606081101561088457600080fd5b81019080803590602001906401000000008111156108a157600080fd5b8201836020820111156108b357600080fd5b803590602001918460208302840111640100000000831117156108d557600080fd5b9091929391929390803590602001906401000000008111156108f657600080fd5b82018360208201111561090857600080fd5b8035906020019184602083028401116401000000008311171561092a57600080fd5b9091929391929390803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612800565b005b34801561096857600080fd5b50610971612f15565b6040518082815260200191505060405180910390f35b34801561099357600080fd5b506109c0600480360360208110156109aa57600080fd5b8101908080359060200190929190505050612f1b565b005b3480156109ce57600080fd5b506109d7613097565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610a175780820151818401526020810190506109fc565b50505050905090810190601f168015610a445780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b348015610a5e57600080fd5b50610aa160048036036020811015610a7557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050613139565b6040518082815260200191505060405180910390f35b348015610ac357600080fd5b50610b1060048036036040811015610ada57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050613151565b60405180821515815260200191505060405180910390f35b348015610b3457600080fd5b50610b8160048036036040811015610b4b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061321e565b60405180821515815260200191505060405180910390f35b348015610ba557600080fd5b50610bae61323c565b6040518082815260200191505060405180910390f35b348015610bd057600080fd5b50610d32600480360360a0811015610be757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190640100000000811115610c4457600080fd5b820183602082011115610c5657600080fd5b80359060200191846020830284011164010000000083111715610c7857600080fd5b909192939192939080359060200190640100000000811115610c9957600080fd5b820183602082011115610cab57600080fd5b80359060200191846020830284011164010000000083111715610ccd57600080fd5b909192939192939080359060200190640100000000811115610cee57600080fd5b820183602082011115610d0057600080fd5b80359060200191846001830284011164010000000083111715610d2257600080fd5b9091929391929390505050613242565b60405180827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200191505060405180910390f35b348015610d7357600080fd5b50610d7c6132c2565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b348015610db457600080fd5b50610dbd6132e8565b6040518082815260200191505060405180910390f35b348015610ddf57600080fd5b50610de86132ef565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610e28578082015181840152602081019050610e0d565b50505050905090810190601f168015610e555780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b348015610e6f57600080fd5b50610e7861338d565b005b348015610e8657600080fd5b50610ee960048036036040811015610e9d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050613619565b6040518082815260200191505060405180910390f35b348015610f0b57600080fd5b50610f146136a0565b6040518082815260200191505060405180910390f35b348015610f3657600080fd5b50610f3f6136a6565b6040518082815260200191505060405180910390f35b348015610f6157600080fd5b5061102d600480360360a0811015610f7857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035906020019092919080359060200190640100000000811115610fe957600080fd5b820183602082011115610ffb57600080fd5b8035906020019184600183028401116401000000008311171561101d57600080fd5b90919293919293905050506136ac565b60405180827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200191505060405180910390f35b34801561106e57600080fd5b506110b16004803603602081101561108557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061372a565b005b600060066000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060009054906101000a900460ff169050919050565b600960009054906101000a900460ff1681565b606060038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156111c65780601f1061119b576101008083540402835291602001916111c6565b820191906000526020600020905b8154815290600101906020018083116111a957829003601f168201915b5050505050905090565b60006111e46111dd613bcf565b8484613bd7565b6001905092915050565b6111f6614769565b601260008381526020019081526020016000206040518060600160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200160018201548152602001600282015481525050905060003373ffffffffffffffffffffffffffffffffffffffff16826000015173ffffffffffffffffffffffffffffffffffffffff16149050600c54600b541061131a578015611319576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603d815260200180614958603d913960400191505060405180910390fd5b5b80156115a357611328613dce565b6203f480836040015101106113a5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f436f6e7665727465723a20546f7020626964206c6f636b65640000000000000081525060200191505060405180910390fd5b8160200151600a600082825403925050819055506040518060600160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600081526020016113f0613dce565b8152506012600085815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506020820151816001015560408201518160020155905050600060603373ffffffffffffffffffffffffffffffffffffffff16846020015160405180600001905060006040518083038185875af1925050503d80600081146114ca576040519150601f19603f3d011682016040523d82523d6000602084013e6114cf565b606091505b509150915081611547576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f436f6e7665727465723a204661696c656420746f2073656e642045746865720081525060200191505060405180910390fd5b7f7fd2c6472e4a5cf47dd45d6e616062bb6b2a25c19206eaa78f5ac8ea80cd5f973386604051808373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a150506117a7565b60006013600085815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490506000811161166e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f436f6e7665727465723a206e6f2062696420666f756e6400000000000000000081525060200191505060405180910390fd5b60006013600086815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600060603373ffffffffffffffffffffffffffffffffffffffff168360405180600001905060006040518083038185875af1925050503d8060008114611726576040519150601f19603f3d011682016040523d82523d6000602084013e61172b565b606091505b5091509150816117a3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f436f6e7665727465723a204661696c656420746f2073656e642045746865720081525060200191505060405180910390fd5b5050505b505050565b6000600254905090565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600c54600b5410611855576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f436f6e7665727465723a205468726573686f6c6420726561636865640000000081525060200191505060405180910390fd5b611860333083613dd6565b80601060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555080600b6000828254019250508190555050565b60006118cd848484613dd6565b61198e846118d9613bcf565b611989856040518060600160405280602881526020016149d760289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061193f613bcf565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546140979092919063ffffffff16565b613bd7565b600190509392505050565b60076020528060005260406000206000915090508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060010154908060020154908060030160009054906101000a900460ff16905084565b6013602052816000526040600020602052806000526040600020600091509150505481565b6000600560009054906101000a900460ff16905090565b600f5481565b600c54600b541015611ab2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f436f6e7665727465723a205468726573686f6c64206e6f74206d65740000000081525060200191505060405180910390fd5b6007600082815260200190815260200160002060030160009054906101000a900460ff1615611b49576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f436f6e7665727465723a20416c726561647920636c61696d656400000000000081525060200191505060405180910390fd5b611b51614769565b601260008381526020019081526020016000206040518060600160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001600182015481526020016002820154815250509050806000015173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611c80576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f436f6e7665727465723a204f6e6c792077696e6e65722063616e20636c61696d81525060200191505060405180910390fd5b60016007600084815260200190815260200160002060030160006101000a81548160ff021916908315150217905550611cb76147a0565b600760008481526020019081526020016000206040518060800160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200160018201548152602001600282015481526020016003820160009054906101000a900460ff1615151515815250509050611d71816000015163d9b67a2660e01b614157565b15611eaa576060816000015173ffffffffffffffffffffffffffffffffffffffff1663f242432a30856000015185602001518660400151866040518663ffffffff1660e01b8152600401808673ffffffffffffffffffffffffffffffffffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff16815260200184815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015611e3c578082015181840152602081019050611e21565b50505050905090810190601f168015611e695780820380516001836020036101000a031916815260200191505b509650505050505050600060405180830381600087803b158015611e8c57600080fd5b505af1158015611ea0573d6000803e3d6000fd5b5050505050611f79565b611ebf81600001516380ac58cd60e01b614157565b15611f7857806000015173ffffffffffffffffffffffffffffffffffffffff166342842e0e30846000015184602001516040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050600060405180830381600087803b158015611f5f57600080fd5b505af1158015611f73573d6000803e3d6000fd5b505050505b5b7feeca06d3fb2f51c15539b63d32d639ef54c363f311045a0cbec5971f7fd355328260000151848360200151604051808473ffffffffffffffffffffffffffffffffffffffff168152602001838152602001828152602001935050505060405180910390a1505050565b600061208c611ff0613bcf565b846120878560016000612001613bcf565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461417c90919063ffffffff16565b613bd7565b6001905092915050565b60126020528060005260406000206000915090508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060010154908060020154905083565b600c54600b541061213c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603f815260200180614890603f913960400191505060405180910390fd5b612144614769565b601260008381526020019081526020016000206040518060600160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016001820154815260200160028201548152505090503373ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff161415612257576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806148cf6021913960400191505060405180910390fd5b348160200151106122d0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f436f6e7665727465723a2042696420746f6f206c6f770000000000000000000081525060200191505060405180910390fd5b60006013600084815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414612396576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f436f6e7665727465723a20436f6c6c6563742062696420726566756e6400000081525060200191505060405180910390fd5b60405180606001604052803373ffffffffffffffffffffffffffffffffffffffff1681526020013481526020016123cb613dce565b8152506012600084815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160010155604082015181600201559050508060200151601360008481526020019081526020016000206000836000015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555080602001513403600a600082825401925050819055507fbc13236afe4f10fc8d44c86b16e9e6695b2758938a2bedf6ceef72157259447b338334604051808473ffffffffffffffffffffffffffffffffffffffff168152602001838152602001828152602001935050505060405180910390a15050565b600c54600b54101561258d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f436f6e7665727465723a205468726573686f6c64206e6f74206d65740000000081525060200191505060405180910390fd5b60008111156125a2576125a1333083613dd6565b5b6000601060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054820190506000601060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600060603373ffffffffffffffffffffffffffffffffffffffff166126ef3073ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561269157600080fd5b505afa1580156126a5573d6000803e3d6000fd5b505050506040513d60208110156126bb57600080fd5b81019080805190602001909291905050506126e186600a5461420490919063ffffffff16565b61428a90919063ffffffff16565b60405180600001905060006040518083038185875af1925050503d8060008114612735576040519150601f19603f3d011682016040523d82523d6000602084013e61273a565b606091505b5091509150816127b2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f436f6e7665727465723a204661696c656420746f2073656e642045746865720081525060200191505060405180910390fd5b50505050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146128a6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806148486022913960400191505060405180910390fd5b6032858590501115612903576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603c81526020018061491c603c913960400191505060405180910390fd5b6000858590501161295f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526031815260200180614a246031913960400191505060405180910390fd5b6129708163d9b67a2660e01b614157565b15612c5e578073ffffffffffffffffffffffffffffffffffffffff16632eb2c2d63330888888886040518060400160405280600481526020017f4a434d59000000000000000000000000000000000000000000000000000000008152506040518863ffffffff1660e01b8152600401808873ffffffffffffffffffffffffffffffffffffffff1681526020018773ffffffffffffffffffffffffffffffffffffffff1681526020018060200180602001806020018481038452898982818152602001925060200280828437600081840152601f19601f8201169050808301925050508481038352878782818152602001925060200280828437600081840152601f19601f820116905080830192505050848103825285818151815260200191508051906020019080838360005b83811015612ab8578082015181840152602081019050612a9d565b50505050905090810190601f168015612ae55780820380516001836020036101000a031916815260200191505b509a5050505050505050505050600060405180830381600087803b158015612b0c57600080fd5b505af1158015612b20573d6000803e3d6000fd5b5050505060005b60328160ff161015612c58578060ff16868690501415612b4657612c58565b60405180608001604052808373ffffffffffffffffffffffffffffffffffffffff16815260200187878460ff16818110612b7c57fe5b90506020020135815260200185858460ff16818110612b9757fe5b90506020020135815260200160001515815250600760006008600081548092919060010191905055815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550602082015181600101556040820151816002015560608201518160030160006101000a81548160ff0219169083151502179055509050508080600101915050612b27565b50612e53565b612c6f816380ac58cd60e01b614157565b15612e525760005b60328160ff161015612e50578060ff16868690501415612c9657612e50565b8173ffffffffffffffffffffffffffffffffffffffff166323b872dd333089898660ff16818110612cc357fe5b905060200201356040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050600060405180830381600087803b158015612d3a57600080fd5b505af1158015612d4e573d6000803e3d6000fd5b5050505060405180608001604052808373ffffffffffffffffffffffffffffffffffffffff16815260200187878460ff16818110612d8857fe5b9050602002013581526020016001815260200160001515815250600760006008600081548092919060010191905055815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550602082015181600101556040820151816002015560608201518160030160006101000a81548160ff0219169083151502179055509050508080600101915050612c77565b505b5b7fa483e688f75a9865537d84843ea1c4d1c5f25f6f00565268e91430c4d75cc01b85858585856040518080602001806020018473ffffffffffffffffffffffffffffffffffffffff1681526020018381038352888882818152602001925060200280828437600081840152601f19601f8201169050808301925050508381038252868682818152602001925060200280828437600081840152601f19601f82011690508083019250505097505050505050505060405180910390a15050505050565b600c5481565b600c54600b5410612f94576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f436f6e7665727465723a205468726573686f6c6420726561636865640000000081525060200191505060405180910390fd5b80601060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561302c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c8152602001806148f0602c913960400191505060405180910390fd5b80600b6000828254039250508190555080601060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550613094303383613dd6565b50565b606060048054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561312f5780601f106131045761010080835404028352916020019161312f565b820191906000526020600020905b81548152906001019060200180831161311257829003601f168201915b5050505050905090565b60106020528060005260406000206000915090505481565b600061321461315e613bcf565b8461320f85604051806060016040528060258152602001614ad96025913960016000613188613bcf565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546140979092919063ffffffff16565b613bd7565b6001905092915050565b600061323261322b613bcf565b8484613dd6565b6001905092915050565b60085481565b60006040518060400160405280600481526020017f4a434d5900000000000000000000000000000000000000000000000000000000815250805190602001208383604051808383808284378083019250505092505050604051809103902014156132b55763bc197c8160e01b90506132b6565b5b98975050505050505050565b601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6203f48081565b600e8054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156133855780601f1061335a57610100808354040283529160200191613385565b820191906000526020600020905b81548152906001019060200180831161336857829003601f168201915b505050505081565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614613433576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602b815260200180614aae602b913960400191505060405180910390fd5b60001515600960009054906101000a900460ff1615151461349f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806148046022913960400191505060405180910390fd5b6001600960006101000a81548160ff0219169083151502179055506000601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663017e7e586040518163ffffffff1660e01b815260040160206040518083038186803b15801561352457600080fd5b505afa158015613538573d6000803e3d6000fd5b505050506040513d602081101561354e57600080fd5b8101908080519060200190929190505050905060008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16146135b9576135ac60c8600f5461428a90919063ffffffff16565b90506135b882826142d4565b5b6135e9600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682600f54036142d4565b7fee1d8c0a784b4733dc46e6e61233f85c6b4e41244a61fe29f41a84d3f8a3d01c60405160405180910390a15050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600b5481565b600a5481565b60006040518060400160405280600481526020017f4a434d59000000000000000000000000000000000000000000000000000000008152508051906020012083836040518083838082843780830192505050925050506040518091039020141561371f5763f23a6e6160e01b9050613720565b5b9695505050505050565b600960009054906101000a900460ff1615613790576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526035815260200180614a556035913960400191505060405180910390fd5b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614613836576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806149b66021913960400191505060405180910390fd5b600080600854905060605b600082118015613854575060328360ff16105b15613b96576138616147a0565b600760006001850381526020019081526020016000206040518060800160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200160018201548152602001600282015481526020016003820160009054906101000a900460ff161515151581525050905061391e816000015163d9b67a2660e01b614157565b15613a5057806000015173ffffffffffffffffffffffffffffffffffffffff1663f242432a308784602001518560400151876040518663ffffffff1660e01b8152600401808673ffffffffffffffffffffffffffffffffffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff16815260200184815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b838110156139e35780820151818401526020810190506139c8565b50505050905090810190601f168015613a105780820380516001836020036101000a031916815260200191505b509650505050505050600060405180830381600087803b158015613a3357600080fd5b505af1158015613a47573d6000803e3d6000fd5b50505050613b1b565b613a6581600001516380ac58cd60e01b614157565b15613b1a57806000015173ffffffffffffffffffffffffffffffffffffffff166342842e0e308784602001516040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050600060405180830381600087803b158015613b0157600080fd5b505af1158015613b15573d6000803e3d6000fd5b505050505b5b60076000600185038152602001908152602001600020600080820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055600182016000905560028201600090556003820160006101000a81549060ff02191690555050828060019003935050838060010194505050613841565b816008819055507f8616bbbbad963e4e65b1366f1d75dfb63f9e9704bbbf91fb01bec70849906cf760405160405180910390a150505050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415613c5d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180614a8a6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415613ce3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806148266022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600042905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415613e5c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806149ff6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415613ee2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806147e16023913960400191505060405180910390fd5b613eed83838361449b565b613f588160405180606001604052806026815260200161486a602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546140979092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550613feb816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461417c90919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290614144576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156141095780820151818401526020810190506140ee565b50505050905090810190601f1680156141365780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b6000614162836144a0565b8015614174575061417383836144d4565b5b905092915050565b6000808284019050838110156141fa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b6000808314156142175760009050614284565b600082840290508284828161422857fe5b041461427f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806149956021913960400191505060405180910390fd5b809150505b92915050565b60006142cc83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506144fb565b905092915050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415614377576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f45524332303a206d696e7420746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b6143836000838361449b565b6143988160025461417c90919063ffffffff16565b6002819055506143ef816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461417c90919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b505050565b60006144b3826301ffc9a760e01b6144d4565b80156144cd57506144cb8263ffffffff60e01b6144d4565b155b9050919050565b60008060006144e385856145c1565b915091508180156144f15750805b9250505092915050565b600080831182906145a7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561456c578082015181840152602081019050614551565b50505050905090810190601f1680156145995780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385816145b357fe5b049050809150509392505050565b60008060606301ffc9a760e01b8460405160240180827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152602001915050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050509050600060608673ffffffffffffffffffffffffffffffffffffffff16617530846040518082805190602001908083835b602083106146af578051825260208201915060208101905060208303925061468c565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303818686fa925050503d8060008114614710576040519150601f19603f3d011682016040523d82523d6000602084013e614715565b606091505b50915091506020815110156147335760008094509450505050614762565b8181806020019051602081101561474957600080fd5b8101908080519060200190929190505050945094505050505b9250929050565b6040518060600160405280600073ffffffffffffffffffffffffffffffffffffffff16815260200160008152602001600081525090565b6040518060800160405280600073ffffffffffffffffffffffffffffffffffffffff1681526020016000815260200160008152602001600015158152509056fe45524332303a207472616e7366657220746f20746865207a65726f2061646472657373436f6e7665727465723a20546f6b656e20697320616c72656164792061637469766545524332303a20617070726f766520746f20746865207a65726f2061646472657373436f6e7665727465723a204f6e6c79206973737565722063616e206465706f73697445524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365436f6e7665727465723a2052656c65617365207468726573686f6c6420686173206265656e206d65742c206e6f206d6f7265206269647320616c6c6f776564436f6e7665727465723a20596f75206861766520616e2061637469766520626964436f6e7665727465723a204e6f7420656e6f7567682075546f6b656e73206c6f636b65642062792075736572436f6e7665727465723a2041206d6178696d756d206f6620353020746f6b656e732063616e206265206465706f736974656420696e206f6e6520676f436f6e7665727465723a2052656c65617365207468726573686f6c6420686173206265656e206d65742c2077696e6e65722063616e277420756e626964536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77436f6e7665727465723a204f6e6c79206973737565722063616e20726566756e6445524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f2061646472657373436f6e7665727465723a20596f75206d7573742073706563696679206174206c65617374206f6e6520746f6b656e204944436f6e7665727465723a20436f6e747261637420697320616c726561647920616374697665202d2063616e6e6f7420726566756e6445524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373436f6e7665727465723a204f6e6c79206973737565722063616e2069737375652074686520746f6b656e7345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220162a98375b9a0d32bad20ab3a262d9d279ef87b720c6b243dbb155c10a8de98564736f6c634300060c0033
Verified Source Code Partial Match
Compiler: v0.6.12+commit.27d51765
EVM: istanbul
Optimization: No
Converter.sol 1373 lines
// File: @openzeppelin/contracts/introspection/ERC165Checker.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.2 <0.8.0;
/**
* @dev Library used to query support of an interface declared via {IERC165}.
*
* Note that these functions return the actual result of the query: they do not
* `revert` if an interface is not supported. It is up to the caller to decide
* what to do in these cases.
*/
library ERC165Checker {
// As per the EIP-165 spec, no interface should ever match 0xffffffff
bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff;
/*
* bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7
*/
bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;
/**
* @dev Returns true if `account` supports the {IERC165} interface,
*/
function supportsERC165(address account) internal view returns (bool) {
// Any contract that implements ERC165 must explicitly indicate support of
// InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid
return _supportsERC165Interface(account, _INTERFACE_ID_ERC165) &&
!_supportsERC165Interface(account, _INTERFACE_ID_INVALID);
}
/**
* @dev Returns true if `account` supports the interface defined by
* `interfaceId`. Support for {IERC165} itself is queried automatically.
*
* See {IERC165-supportsInterface}.
*/
function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) {
// query support of both ERC165 as per the spec and support of _interfaceId
return supportsERC165(account) &&
_supportsERC165Interface(account, interfaceId);
}
/**
* @dev Returns true if `account` supports all the interfaces defined in
* `interfaceIds`. Support for {IERC165} itself is queried automatically.
*
* Batch-querying can lead to gas savings by skipping repeated checks for
* {IERC165} support.
*
* See {IERC165-supportsInterface}.
*/
function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) {
// query support of ERC165 itself
if (!supportsERC165(account)) {
return false;
}
// query support of each interface in _interfaceIds
for (uint256 i = 0; i < interfaceIds.length; i++) {
if (!_supportsERC165Interface(account, interfaceIds[i])) {
return false;
}
}
// all interfaces supported
return true;
}
/**
* @notice Query if a contract implements an interface, does not check ERC165 support
* @param account The address of the contract to query for support of an interface
* @param interfaceId The interface identifier, as specified in ERC-165
* @return true if the contract at account indicates support of the interface with
* identifier interfaceId, false otherwise
* @dev Assumes that account contains a contract that supports ERC165, otherwise
* the behavior of this method is undefined. This precondition can be checked
* with {supportsERC165}.
* Interface identification is specified in ERC-165.
*/
function _supportsERC165Interface(address account, bytes4 interfaceId) private view returns (bool) {
// success determines whether the staticcall succeeded and result determines
// whether the contract at account indicates support of _interfaceId
(bool success, bool result) = _callERC165SupportsInterface(account, interfaceId);
return (success && result);
}
/**
* @notice Calls the function with selector 0x01ffc9a7 (ERC165) and suppresses throw
* @param account The address of the contract to query for support of an interface
* @param interfaceId The interface identifier, as specified in ERC-165
* @return success true if the STATICCALL succeeded, false otherwise
* @return result true if the STATICCALL succeeded and the contract at account
* indicates support of the interface with identifier interfaceId, false otherwise
*/
function _callERC165SupportsInterface(address account, bytes4 interfaceId)
private
view
returns (bool, bool)
{
bytes memory encodedParams = abi.encodeWithSelector(_INTERFACE_ID_ERC165, interfaceId);
(bool success, bytes memory result) = account.staticcall{ gas: 30000 }(encodedParams);
if (result.length < 32) return (false, false);
return (success, abi.decode(result, (bool)));
}
}
// File: @openzeppelin/contracts/GSN/Context.sol
pragma solidity >=0.6.0 <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 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.
*/
abstract contract Context {
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;
}
}
// File: @openzeppelin/contracts/token/ERC20/IERC20.sol
pragma solidity >=0.6.0 <0.8.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/math/SafeMath.sol
pragma solidity >=0.6.0 <0.8.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) {
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/token/ERC20/ERC20.sol
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name_, string memory symbol_) public {
_name = name_;
_symbol = symbol_;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
}
// File: @openzeppelin/contracts/introspection/IERC165.sol
pragma solidity >=0.6.0 <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 IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
// File: @openzeppelin/contracts/token/ERC721/IERC721.sol
pragma solidity >=0.6.2 <0.8.0;
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
}
// File: @openzeppelin/contracts/token/ERC1155/IERC1155.sol
pragma solidity >=0.6.2 <0.8.0;
/**
* @dev Required interface of an ERC1155 compliant contract, as defined in the
* https://eips.ethereum.org/EIPS/eip-1155[EIP].
*
* _Available since v3.1._
*/
interface IERC1155 is IERC165 {
/**
* @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
*/
event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);
/**
* @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
* transfers.
*/
event TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values);
/**
* @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
* `approved`.
*/
event ApprovalForAll(address indexed account, address indexed operator, bool approved);
/**
* @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
*
* If an {URI} event was emitted for `id`, the standard
* https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
* returned by {IERC1155MetadataURI-uri}.
*/
event URI(string value, uint256 indexed id);
/**
* @dev Returns the amount of tokens of token type `id` owned by `account`.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function balanceOf(address account, uint256 id) external view returns (uint256);
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory);
/**
* @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
*
* Emits an {ApprovalForAll} event.
*
* Requirements:
*
* - `operator` cannot be the caller.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
*
* See {setApprovalForAll}.
*/
function isApprovedForAll(address account, address operator) external view returns (bool);
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}.
* - `from` must have a balance of tokens of type `id` of at least `amount`.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external;
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function safeBatchTransferFrom(address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data) external;
}
// File: @openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol
pragma solidity >=0.6.0 <0.8.0;
/**
* _Available since v3.1._
*/
interface IERC1155Receiver is IERC165 {
/**
@dev Handles the receipt of a single ERC1155 token type. This function is
called at the end of a `safeTransferFrom` after the balance has been updated.
To accept the transfer, this must return
`bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
(i.e. 0xf23a6e61, or its own function selector).
@param operator The address which initiated the transfer (i.e. msg.sender)
@param from The address which previously owned the token
@param id The ID of the token being transferred
@param value The amount of tokens being transferred
@param data Additional data with no specified format
@return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
*/
function onERC1155Received(
address operator,
address from,
uint256 id,
uint256 value,
bytes calldata data
)
external
returns(bytes4);
/**
@dev Handles the receipt of a multiple ERC1155 token types. This function
is called at the end of a `safeBatchTransferFrom` after the balances have
been updated. To accept the transfer(s), this must return
`bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
(i.e. 0xbc197c81, or its own function selector).
@param operator The address which initiated the batch transfer (i.e. msg.sender)
@param from The address which previously owned the token
@param ids An array containing ids of each token being transferred (order and length must match values array)
@param values An array containing amounts of each token being transferred (order and length must match ids array)
@param data Additional data with no specified format
@return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
*/
function onERC1155BatchReceived(
address operator,
address from,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
)
external
returns(bytes4);
}
// File: @openzeppelin/contracts/introspection/ERC165.sol
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts may inherit from this and call {_registerInterface} to declare
* their support of an interface.
*/
abstract contract ERC165 is IERC165 {
/*
* bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7
*/
bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;
/**
* @dev Mapping of interface ids to whether or not it's supported.
*/
mapping(bytes4 => bool) private _supportedInterfaces;
constructor () internal {
// Derived contracts need only register support for their own interfaces,
// we register support for ERC165 itself here
_registerInterface(_INTERFACE_ID_ERC165);
}
/**
* @dev See {IERC165-supportsInterface}.
*
* Time complexity O(1), guaranteed to always use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) public view override returns (bool) {
return _supportedInterfaces[interfaceId];
}
/**
* @dev Registers the contract as an implementer of the interface defined by
* `interfaceId`. Support of the actual ERC165 interface is automatic and
* registering its interface id is not required.
*
* See {IERC165-supportsInterface}.
*
* Requirements:
*
* - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`).
*/
function _registerInterface(bytes4 interfaceId) internal virtual {
require(interfaceId != 0xffffffff, "ERC165: invalid interface id");
_supportedInterfaces[interfaceId] = true;
}
}
// File: @openzeppelin/contracts/token/ERC1155/ERC1155Receiver.sol
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev _Available since v3.1._
*/
abstract contract ERC1155Receiver is ERC165, IERC1155Receiver {
constructor() internal {
_registerInterface(
ERC1155Receiver(0).onERC1155Received.selector ^
ERC1155Receiver(0).onERC1155BatchReceived.selector
);
}
}
// File: contracts/interfaces/IUnicFactory.sol
pragma solidity >=0.5.0;
interface IUnicFactory {
event TokenCreated(address indexed caller, address indexed uToken);
function feeTo() external view returns (address);
function feeToSetter() external view returns (address);
function getUToken(address uToken) external view returns (uint);
function uTokens(uint) external view returns (address);
function uTokensLength() external view returns (uint);
function createUToken(uint256 totalSupply, uint8 decimals, string calldata name, string calldata symbol, uint256 threshold, string calldata description) external returns (address);
function setFeeTo(address) external;
function setFeeToSetter(address) external;
}
// File: contracts/Converter.sol
pragma solidity 0.6.12;
contract Converter is ERC20, ERC1155Receiver {
using SafeMath for uint;
// List of NFTs that have been deposited
struct NFT {
address contractAddr;
uint256 tokenId;
uint256 amount;
bool claimed;
}
struct Bid {
address bidder;
uint256 amount;
uint time;
}
mapping(uint256 => NFT) public nfts;
// Current index and length of nfts
uint256 public currentNFTIndex = 0;
// If active, NFTs can’t be withdrawn
bool public active = false;
uint256 public totalBidAmount = 0;
uint256 public unlockVotes = 0;
uint256 public _threshold;
address public issuer;
string public _description;
uint256 public cap;
// Amount of uTokens each user has voted to unlock collection
mapping(address => uint256) public unlockApproved;
IUnicFactory public factory;
// NFT index to Bid
mapping(uint256 => Bid) public bids;
// NFT index to address to amount
mapping(uint256 => mapping(address => uint256)) public bidRefunds;
uint public constant TOP_BID_LOCK_TIME = 3 days;
event Deposited(uint256[] tokenIDs, uint256[] amounts, address contractAddr);
event Refunded();
event Issued();
event BidCreated(address sender, uint256 nftIndex, uint256 bidAmount);
event BidRemoved(address sender, uint256 nftIndex);
event ClaimedNFT(address winner, uint256 nftIndex, uint256 tokenId);
bytes private constant VALIDATOR = bytes('JCMY');
constructor (uint256 totalSupply, uint8 decimals, string memory name, string memory symbol, uint256 threshold, string memory description, address _issuer, IUnicFactory _factory)
public
ERC20(name, symbol)
{
_setupDecimals(decimals);
issuer = _issuer;
_description = description;
_threshold = threshold;
factory = _factory;
cap = totalSupply;
}
// deposits an nft using the transferFrom action of the NFT contractAddr
function deposit(uint256[] calldata tokenIDs, uint256[] calldata amounts, address contractAddr) external {
require(msg.sender == issuer, "Converter: Only issuer can deposit");
require(tokenIDs.length <= 50, "Converter: A maximum of 50 tokens can be deposited in one go");
require(tokenIDs.length > 0, "Converter: You must specify at least one token ID");
if (ERC165Checker.supportsInterface(contractAddr, 0xd9b67a26)){
IERC1155(contractAddr).safeBatchTransferFrom(msg.sender, address(this), tokenIDs, amounts, VALIDATOR);
for (uint8 i = 0; i < 50; i++){
if (tokenIDs.length == i){
break;
}
nfts[currentNFTIndex++] = NFT(contractAddr, tokenIDs[i], amounts[i], false);
}
}
else if (ERC165Checker.supportsInterface(contractAddr, 0x80ac58cd)){
for (uint8 i = 0; i < 50; i++){
if (tokenIDs.length == i){
break;
}
IERC721(contractAddr).transferFrom(msg.sender, address(this), tokenIDs[i]);
nfts[currentNFTIndex++] = NFT(contractAddr, tokenIDs[i], 1, false);
}
}
emit Deposited(tokenIDs, amounts, contractAddr);
}
// Function that locks NFT collateral and issues the uTokens to the issuer
function issue() external {
require(msg.sender == issuer, "Converter: Only issuer can issue the tokens");
require(active == false, "Converter: Token is already active");
active = true;
address feeTo = factory.feeTo();
uint256 feeAmount = 0;
if (feeTo != address(0)) {
// 0.5% of uToken supply is sent to feeToAddress if fee is on
feeAmount = cap.div(200);
_mint(feeTo, feeAmount);
}
_mint(issuer, cap - feeAmount);
emit Issued();
}
// Function that allows NFTs to be refunded (prior to issue being called)
function refund(address _to) external {
require(!active, "Converter: Contract is already active - cannot refund");
require(msg.sender == issuer, "Converter: Only issuer can refund");
// Only transfer maximum of 50 at a time to limit gas per call
uint8 _i = 0;
uint256 _index = currentNFTIndex;
bytes memory data;
while (_index > 0 && _i < 50){
NFT memory nft = nfts[_index - 1];
if (ERC165Checker.supportsInterface(nft.contractAddr, 0xd9b67a26)){
IERC1155(nft.contractAddr).safeTransferFrom(address(this), _to, nft.tokenId, nft.amount, data);
}
else if (ERC165Checker.supportsInterface(nft.contractAddr, 0x80ac58cd)){
IERC721(nft.contractAddr).safeTransferFrom(address(this), _to, nft.tokenId);
}
delete nfts[_index - 1];
_index--;
_i++;
}
currentNFTIndex = _index;
emit Refunded();
}
function bid(uint256 nftIndex) external payable {
require(unlockVotes < _threshold, "Converter: Release threshold has been met, no more bids allowed");
Bid memory topBid = bids[nftIndex];
require(topBid.bidder != msg.sender, "Converter: You have an active bid");
require(topBid.amount < msg.value, "Converter: Bid too low");
require(bidRefunds[nftIndex][msg.sender] == 0, "Converter: Collect bid refund");
bids[nftIndex] = Bid(msg.sender, msg.value, getBlockTimestamp());
bidRefunds[nftIndex][topBid.bidder] = topBid.amount;
totalBidAmount += msg.value - topBid.amount;
emit BidCreated(msg.sender, nftIndex, msg.value);
}
function unbid(uint256 nftIndex) external {
Bid memory topBid = bids[nftIndex];
bool isTopBidder = topBid.bidder == msg.sender;
if (unlockVotes >= _threshold) {
require(!isTopBidder, "Converter: Release threshold has been met, winner can't unbid");
}
if (isTopBidder) {
require(topBid.time + TOP_BID_LOCK_TIME < getBlockTimestamp(), "Converter: Top bid locked");
totalBidAmount -= topBid.amount;
bids[nftIndex] = Bid(address(0), 0, getBlockTimestamp());
(bool sent, bytes memory data) = msg.sender.call{value: topBid.amount}("");
require(sent, "Converter: Failed to send Ether");
emit BidRemoved(msg.sender, nftIndex);
}
else {
uint256 refundAmount = bidRefunds[nftIndex][msg.sender];
require(refundAmount > 0, "Converter: no bid found");
bidRefunds[nftIndex][msg.sender] = 0;
(bool sent, bytes memory data) = msg.sender.call{value: refundAmount}("");
require(sent, "Converter: Failed to send Ether");
}
}
// Claim NFT if address is winning bidder
function claim(uint256 nftIndex) external {
require(unlockVotes >= _threshold, "Converter: Threshold not met");
require(!nfts[nftIndex].claimed, "Converter: Already claimed");
Bid memory topBid = bids[nftIndex];
require(msg.sender == topBid.bidder, "Converter: Only winner can claim");
nfts[nftIndex].claimed = true;
NFT memory winningNFT = nfts[nftIndex];
if (ERC165Checker.supportsInterface(winningNFT.contractAddr, 0xd9b67a26)){
bytes memory data;
IERC1155(winningNFT.contractAddr).safeTransferFrom(address(this), topBid.bidder, winningNFT.tokenId, winningNFT.amount, data);
}
else if (ERC165Checker.supportsInterface(winningNFT.contractAddr, 0x80ac58cd)){
IERC721(winningNFT.contractAddr).safeTransferFrom(address(this), topBid.bidder, winningNFT.tokenId);
}
emit ClaimedNFT(topBid.bidder, nftIndex, winningNFT.tokenId);
}
// Approve collection unlock
function approveUnlock(uint256 amount) external {
require(unlockVotes < _threshold, "Converter: Threshold reached");
_transfer(msg.sender, address(this), amount);
unlockApproved[msg.sender] += amount;
unlockVotes += amount;
}
// Unapprove collection unlock
function unapproveUnlock(uint256 amount) external {
require(unlockVotes < _threshold, "Converter: Threshold reached");
require(unlockApproved[msg.sender] >= amount, "Converter: Not enough uTokens locked by user");
unlockVotes -= amount;
unlockApproved[msg.sender] -= amount;
_transfer(address(this), msg.sender, amount);
}
// Claim ETH function
function redeemETH(uint256 amount) external {
require(unlockVotes >= _threshold, "Converter: Threshold not met");
// Deposit uTokens
if (amount > 0) {
_transfer(msg.sender, address(this), amount);
}
// Combine approved balance + newly deposited balance
uint256 finalBalance = amount + unlockApproved[msg.sender];
// Remove locked uTokens tracked for user
unlockApproved[msg.sender] = 0;
// Redeem ETH corresponding to uToken amount
(bool sent, bytes memory data) = msg.sender.call{value: totalBidAmount.mul(finalBalance).div(this.totalSupply())}("");
require(sent, "Converter: Failed to send Ether");
}
function getBlockTimestamp() internal view returns (uint) {
// solium-disable-next-line security/no-block-members
return block.timestamp;
}
/**
* ERC1155 Token ERC1155Receiver
*/
function onERC1155Received(address _operator, address _from, uint256 _id, uint256 _value, bytes calldata _data) override external returns(bytes4) {
if(keccak256(_data) == keccak256(VALIDATOR)){
return 0xf23a6e61;
}
}
function onERC1155BatchReceived(address _operator, address _from, uint256[]...
// [truncated — 50211 bytes total]
Read Contract
TOP_BID_LOCK_TIME 0xc79045cb → uint256
_description 0xcfa84dfe → string
_threshold 0x7f3c8160 → uint256
active 0x02fb0c5e → bool
allowance 0xdd62ed3e → uint256
balanceOf 0x70a08231 → uint256
bidRefunds 0x2788aeb2 → uint256
bids 0x4423c5f1 → address, uint256, uint256
cap 0x355274ea → uint256
currentNFTIndex 0xaf58e6f0 → uint256
decimals 0x313ce567 → uint8
factory 0xc45a0155 → address
issuer 0x1d143848 → address
name 0x06fdde03 → string
nfts 0x265aa621 → address, uint256, uint256, bool
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
totalBidAmount 0xee7a1163 → uint256
totalSupply 0x18160ddd → uint256
unlockApproved 0x9d13fb24 → uint256
unlockVotes 0xe3a7c903 → uint256
Write Contract 16 functions
These functions modify contract state and require a wallet transaction to execute.
approve 0x095ea7b3
address spender
uint256 amount
returns: bool
approveUnlock 0x22a25082
uint256 amount
bid 0x454a2ab3
uint256 nftIndex
claim 0x379607f5
uint256 nftIndex
decreaseAllowance 0xa457c2d7
address spender
uint256 subtractedValue
returns: bool
deposit 0x7e067a60
uint256[] tokenIDs
uint256[] amounts
address contractAddr
increaseAllowance 0x39509351
address spender
uint256 addedValue
returns: bool
issue 0xd383f646
No parameters
onERC1155BatchReceived 0xbc197c81
address _operator
address _from
uint256[] _ids
uint256[] _values
bytes _data
returns: bytes4
onERC1155Received 0xf23a6e61
address _operator
address _from
uint256 _id
uint256 _value
bytes _data
returns: bytes4
redeemETH 0x525d02b8
uint256 amount
refund 0xfa89401a
address _to
transfer 0xa9059cbb
address recipient
uint256 amount
returns: bool
transferFrom 0x23b872dd
address sender
address recipient
uint256 amount
returns: bool
unapproveUnlock 0x7fc6bb3d
uint256 amount
unbid 0x0e4cfe97
uint256 nftIndex
Token Balances (1)
View Transfers →Recent Transactions
No transactions found for this address