Address Contract Partially Verified
Address
0x8981c60ff02CDBbF2A6AC1a9F150814F9cF68f62
Balance
0 ETH
Nonce
1
Code Size
13534 bytes
Creator
0x3E8aE53D...E744 at tx 0xf39e5628...41747a
Indexed Transactions
0
Contract Bytecode
13534 bytes
0x6080604052600436106101ac5760003560e01c806389d6517f116100ec578063bd3507da1161008a578063d1c924a511610064578063d1c924a5146105dd578063d62dd3a614610609578063e2bbb15814610629578063f2fde38b1461064957600080fd5b8063bd3507da1461057d578063cd785a5e1461059d578063d004b036146105bd57600080fd5b80639ac8eebc116100c65780639ac8eebc146104c5578063ac9650d8146104db578063b01ce31f146104fb578063b36b9fa31461055d57600080fd5b806389d6517f146104175780638da5cb5b146104915780639a174591146104af57600080fd5b806331d7a2621161015957806366666aa91161013357806366666aa91461036c57806370bb45b3146103cd578063715018a6146103e257806378b0013d146103f757600080fd5b806331d7a2621461030857806338d07436146103285780634d3402381461034857600080fd5b8063150b7a021161018a578063150b7a02146102515780632d6730db146102c65780632e0c5ca2146102e857600080fd5b8063025e7c27146101b157806309ca27561461020457806312f7086c14610224575b600080fd5b3480156101bd57600080fd5b506101e76101cc366004612f4d565b600b602052600090815260409020546001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561021057600080fd5b50600e546101e7906001600160a01b031681565b34801561023057600080fd5b5061024461023f366004612f4d565b610669565b6040516101fb9190613261565b34801561025d57600080fd5b5061029561026c366004612db0565b7f150b7a0200000000000000000000000000000000000000000000000000000000949350505050565b6040517fffffffff0000000000000000000000000000000000000000000000000000000090911681526020016101fb565b3480156102d257600080fd5b506102e66102e1366004612fb8565b61087d565b005b3480156102f457600080fd5b506102e6610303366004612f65565b610990565b34801561031457600080fd5b50610244610323366004612d78565b610aa2565b34801561033457600080fd5b506102e6610343366004612f94565b610c35565b34801561035457600080fd5b5061035e600f5481565b6040519081526020016101fb565b34801561037857600080fd5b506003546004546103a2916001600160a01b039081169190811690600160a01b900462ffffff1683565b604080516001600160a01b03948516815293909216602084015262ffffff16908201526060016101fb565b3480156103d957600080fd5b506102e6610e4f565b3480156103ee57600080fd5b506102e6610f56565b34801561040357600080fd5b50610244610412366004612f4d565b610fbc565b34801561042357600080fd5b50610466610432366004612f4d565b60096020526000908152604090208054600182015460028301546003909301546001600160a01b0392831693919092169184565b604080516001600160a01b0395861681529490931660208501529183015260608201526080016101fb565b34801561049d57600080fd5b506000546001600160a01b03166101e7565b3480156104bb57600080fd5b5061035e600a5481565b3480156104d157600080fd5b5061035e60105481565b6104ee6104e9366004612e57565b611137565b6040516101fb9190613200565b34801561050757600080fd5b5061053d610516366004612f4d565b600d6020526000908152604090208054600182015460028301546003909301549192909184565b6040805194855260208501939093529183015260608201526080016101fb565b34801561056957600080fd5b506102e6610578366004612fb8565b6112b2565b34801561058957600080fd5b506102e6610598366004612f4d565b611519565b3480156105a957600080fd5b506102e66105b8366004612f4d565b6115e7565b3480156105c957600080fd5b506102446105d8366004612d78565b61179f565b3480156105e957600080fd5b506105f261186f565b6040516101fb9b9a99989796959493929190613110565b34801561061557600080fd5b506102e6610624366004612f4d565b611a47565b34801561063557600080fd5b5061035e610644366004612fb8565b611b37565b34801561065557600080fd5b506102e6610664366004612d78565b61200b565b60606000600d60008481526020019081526020016000206040518060a0016040529081600082015481526020016001820154815260200160028201548152602001600382015481526020016004820180548060200260200160405190810160405280929190818152602001828054801561070257602002820191906000526020600020905b8154815260200190600101908083116106ee575b50505050508152505090506000600a5467ffffffffffffffff81111561073857634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015610761578160200160208202803683370190505b50905060005b600a5481101561087557600061077f600654436120ed565b6000838152600960205260408120600301549192509061079f9083613395565b90506000601054600160801b836107b69190613395565b6107c09190613375565b6000858152600960205260409020600201546107dc919061335d565b9050600160801b8660800151858151811061080757634e487b7160e01b600052603260045260246000fd5b60200260200101518261081a91906133fb565b87602001516108299190613395565b6108339190613375565b85858151811061085357634e487b7160e01b600052603260045260246000fd5b602002602001018181525050505050808061086d9061343e565b915050610767565b509392505050565b6000546001600160a01b031633146108dc5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b600a54821061092d5760405162461bcd60e51b815260206004820152601860248201527f4f5554204f462052455741524420494e464f2052414e4745000000000000000060448201526064016108d3565b610935612138565b600082815260096020908152604091829020600381018490555491518381526001600160a01b03909216917fd9a745381d3899e0a1380f3c7f56ea1bf0fb8331482527ff4984296da9580fab91015b60405180910390a25050565b6000546001600160a01b031633146109ea5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016108d3565b600a548210610a3b5760405162461bcd60e51b815260206004820152601860248201527f4f5554204f462052455741524420494e464f2052414e4745000000000000000060448201526064016108d3565b6000828152600960209081526040918290206001810180546001600160a01b0319166001600160a01b038681169182179092559154935191825292909216917fda608212a78120f0e323cf82e77003c28512aa6eae3747c062c459901d7930159101610984565b60606000600a5467ffffffffffffffff811115610acf57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015610af8578160200160208202803683370190505b50905060005b600a54811015610b47576000828281518110610b2a57634e487b7160e01b600052603260045260246000fd5b602090810291909101015280610b3f8161343e565b915050610afe565b5060005b6001600160a01b0384166000908152600c60205260409020610b6c9061220b565b811015610c2e576001600160a01b0384166000908152600c60205260408120610b999061023f9084612215565b905060005b600a54811015610c1957818181518110610bc857634e487b7160e01b600052603260045260246000fd5b6020026020010151848281518110610bf057634e487b7160e01b600052603260045260246000fd5b60200260200101818151610c04919061335d565b90525080610c118161343e565b915050610b9e565b50508080610c269061343e565b915050610b4b565b5092915050565b60026001541415610c885760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016108d3565b60026001556000828152600b60205260409020546001600160a01b03163314610cf35760405162461bcd60e51b815260206004820152601660248201527f4e4f54204f574e4552204f52204e4f542045584953540000000000000000000060448201526064016108d3565b8015610d0657610d01612138565b610d0f565b610d0f82612228565b6000828152600d602052604081205490610d2a908290612412565b6000838152600d60205260409020600201548015610d6457610d4d81600061249a565b600e54610d64906001600160a01b031633836124c3565b600254604051632142170760e11b8152306004820152336024820152604481018690526001600160a01b03909116906342842e0e90606401600060405180830381600087803b158015610db657600080fd5b505af1158015610dca573d6000803e3d6000fd5b5050506000858152600b6020908152604080832080546001600160a01b0319169055338352600c9091528120909150610e039086612558565b905080610e0f57600080fd5b60405185815233907f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a94243649060200160405180910390a2505060018055505050565b60026001541415610ea25760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016108d3565b6002600155336000908152600c60205260408120905b610ec18261220b565b811015610f4e5733600b6000610ed78585612215565b81526020810191909152604001600020546001600160a01b031614610f2a5760405162461bcd60e51b81526020600482015260096024820152682727aa1027aba722a960b91b60448201526064016108d3565b610f3c610f378383612215565b612228565b80610f468161343e565b915050610eb8565b505060018055565b6000546001600160a01b03163314610fb05760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016108d3565b610fba6000612564565b565b60606000600d60008481526020019081526020016000206040518060a0016040529081600082015481526020016001820154815260200160028201548152602001600382015481526020016004820180548060200260200160405190810160405280929190818152602001828054801561105557602002820191906000526020600020905b815481526020019060010190808311611041575b505050919092525050506080810151519091508067ffffffffffffffff81111561108f57634e487b7160e01b600052604160045260246000fd5b6040519080825280602002602001820160405280156110b8578160200160208202803683370190505b50925060005b8181101561112f57826080015181815181106110ea57634e487b7160e01b600052603260045260246000fd5b602002602001015184828151811061111257634e487b7160e01b600052603260045260246000fd5b6020908102919091010152806111278161343e565b9150506110be565b505050919050565b60608167ffffffffffffffff81111561116057634e487b7160e01b600052604160045260246000fd5b60405190808252806020026020018201604052801561119357816020015b606081526020019060019003908161117e5790505b50905060005b82811015610c2e57600080308686858181106111c557634e487b7160e01b600052603260045260246000fd5b90506020028101906111d791906132b8565b6040516111e59291906130e4565b600060405180830381855af49150503d8060008114611220576040519150601f19603f3d011682016040523d82523d6000602084013e611225565b606091505b5091509150816112715760448151101561123e57600080fd5b600481019050808060200190518101906112589190612ee3565b60405162461bcd60e51b81526004016108d391906132a5565b8084848151811061129257634e487b7160e01b600052603260045260246000fd5b6020026020010181905250505080806112aa9061343e565b915050611199565b600260015414156113055760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016108d3565b60026001556000828152600b60205260409020546001600160a01b031633146113705760405162461bcd60e51b815260206004820152601660248201527f4e4f54204f574e4552204f52204e4f542045584953540000000000000000000060448201526064016108d3565b600e546001600160a01b03166113c85760405162461bcd60e51b815260206004820152600960248201527f4e4f5420424f4f5354000000000000000000000000000000000000000000000060448201526064016108d3565b600081116114185760405162461bcd60e51b815260206004820152601c60248201527f4445504f53495420495a49204d55535420424520504f5349544956450000000060448201526064016108d3565b61142182612228565b6000828152600d60209081526040808320815160a08101835281548152600182015481850152600282015481840152600382015460608201526004820180548451818702810187019095528085529194929360808601939092908301828280156114aa57602002820191906000526020600020905b815481526020019060010190808311611496575b50505050508152505090506114c082600161249a565b60008282604001516114d2919061335d565b905060006114e48360000151836125b4565b90506114f68584600001518385612625565b600e5461150e906001600160a01b03163330876126b4565b505060018055505050565b6002600154141561156c5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016108d3565b60026001556000818152600b60205260409020546001600160a01b031633146115d75760405162461bcd60e51b815260206004820152601660248201527f4e4f54204f574e4552204f52204e4f542045584953540000000000000000000060448201526064016108d3565b6115e081612228565b5060018055565b6000546001600160a01b031633146116415760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016108d3565b6000818152600b60205260409020546001600160a01b03168061166357600080fd5b6002546000838152600b602052604090819020549051632142170760e11b81523060048201526001600160a01b039182166024820152604481018590529116906342842e0e90606401600060405180830381600087803b1580156116c657600080fd5b505af11580156116da573d6000803e3d6000fd5b5050506000838152600d60205260409020600201549050801561177f57600e5460405163a9059cbb60e01b81526001600160a01b038481166004830152602482018490529091169063a9059cbb90604401602060405180830381600087803b15801561174557600080fd5b505af1158015611759573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061177d9190612ec7565b505b50506000908152600b6020526040902080546001600160a01b0319169055565b6001600160a01b0381166000908152600c602052604081206060916117c38261220b565b67ffffffffffffffff8111156117e957634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611812578160200160208202803683370190505b50905060005b6118218361220b565b811015610875576118328382612215565b82828151811061185257634e487b7160e01b600052603260045260246000fd5b6020908102919091010152806118678161343e565b915050611818565b600080600060606000806000806000806000600a5467ffffffffffffffff8111156118aa57634e487b7160e01b600052604160045260246000fd5b6040519080825280602002602001820160405280156118fc57816020015b6040805160808101825260008082526020808301829052928201819052606082015282526000199092019101816118c85790505b50975060005b600a5481101561199957600081815260096020908152604091829020825160808101845281546001600160a01b03908116825260018301541692810192909252600281015492820192909252600390910154606082015289518a908390811061197b57634e487b7160e01b600052603260045260246000fd5b602002602001018190525080806119919061343e565b915050611902565b50600360000160009054906101000a90046001600160a01b0316600360010160009054906101000a90046001600160a01b0316600360010160149054906101000a900462ffffff168a600e60009054906101000a90046001600160a01b0316600560009054906101000a900460020b600560039054906101000a900460020b6006546010546007546008549a509a509a509a509a509a509a509a509a509a509a50909192939495969798999a565b6000546001600160a01b03163314611aa15760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016108d3565b438111611af05760405162461bcd60e51b815260206004820152600b60248201527f4f5554204f46204441544500000000000000000000000000000000000000000060448201526064016108d3565b611af8612138565b4360065560088190556040518181527f6861e667f4625c666d8000dd2fe6b7dde9a3d46381327f9e1330df56969f15be9060200160405180910390a150565b6002546040517f6352211e0000000000000000000000000000000000000000000000000000000081526004810184905260009182916001600160a01b0390911690636352211e9060240160206040518083038186803b158015611b9957600080fd5b505afa158015611bad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bd19190612d94565b90506001600160a01b0381163314611c175760405162461bcd60e51b81526020600482015260096024820152682727aa1027aba722a960b91b60448201526064016108d3565b6002546040517f99fbab8800000000000000000000000000000000000000000000000000000000815260048101869052600091829182918291829182916001600160a01b03909116906399fbab88906024016101806040518083038186803b158015611c8257600080fd5b505afa158015611c96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cba9190612fd9565b5050600354979f50959d50939b509199509750955050506001600160a01b03808a169116149150611d2f90505760405162461bcd60e51b815260206004820152601060248201527f544f454b4e30204e4f54204d415443480000000000000000000000000000000060448201526064016108d3565b6004546001600160a01b03868116911614611d8c5760405162461bcd60e51b815260206004820152601060248201527f544f4b454e31204e4f54204d415443480000000000000000000000000000000060448201526064016108d3565b60045462ffffff858116600160a01b9092041614611dec5760405162461bcd60e51b815260206004820152600d60248201527f464545204e4f54204d415443480000000000000000000000000000000000000060448201526064016108d3565b611df7838383612705565b975060008811611e495760405162461bcd60e51b815260206004820152600d60248201527f494e56414c494420544f4b454e0000000000000000000000000000000000000060448201526064016108d3565b600254604051632142170760e11b8152336004820152306024820152604481018c90526001600160a01b03909116906342842e0e90606401600060405180830381600087803b158015611e9b57600080fd5b505af1158015611eaf573d6000803e3d6000fd5b50505060008b8152600b6020908152604080832080546001600160a01b031916339081179091558352600c9091528120909150611eec908c6127f0565b905080611ef857600080fd5b611f00612138565b611f0b896001612412565b600e546001600160a01b0316611f2057600099505b611f2b8a600161249a565b6000611f378a8c6125b4565b9050611f486006600160801b613375565b8b10611f965760405162461bcd60e51b815260206004820152600660248201527f4e495a49204f000000000000000000000000000000000000000000000000000060448201526064016108d3565b611fa28c8b838e6127fc565b8a15611fc057600e54611fc0906001600160a01b031633308e6126b4565b604080518d8152602081018d905233917f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a15910160405180910390a25050505050505050505b92915050565b6000546001600160a01b031633146120655760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016108d3565b6001600160a01b0381166120e15760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016108d3565b6120ea81612564565b50565b6000818311156120ff57506000612005565b60085482116121195761211283836133fb565b9050612005565b600854831061212a57506000612005565b8260085461211291906133fb565b600654431161214357565b6008546006541061215057565b600061215e436008546128ee565b90506010546000141561217057600655565b60005b600a548110156122055760008181526009602052604081206003015460065461219c90856133fb565b6121a69190613395565b6010549091506121ba600160801b83613395565b6121c49190613375565b6000838152600960205260409020600201546121e0919061335d565b60008381526009602052604090206002015550806121fd8161343e565b915050612173565b50600655565b6000612005825490565b60006122218383612904565b9392505050565b6000818152600d60209081526040808320815160a08101835281548152600182015481850152600282015481840152600382015460608201526004820180548451818702810187019095528085529194929360808601939092908301828280156122b157602002820191906000526020600020905b81548152602001906001019080831161229d575b50505050508152505090506122c4612138565b60005b600a548110156123e5576000600160801b836080015183815181106122fc57634e487b7160e01b600052603260045260246000fd5b6020026020010151600960008581526020019081526020016000206002015461232591906133fb565b84602001516123349190613395565b61233e9190613375565b9050801561237357600082815260096020526040902060018101549054612373916001600160a01b03918216911633846126b4565b6000828152600960209081526040918290205482518781526001600160a01b039091169181019190915290810182905233907fbc96baf3023d0b9ea3a899e000f15d5f0f7a8b064774c1eed6b4cc63fcbd1b199060600160405180910390a250806123dd8161343e565b9150506122c7565b50604081015181516000906123fa90836125b4565b905061240c8484600001518385612625565b50505050565b801561242e5781601054612426919061335d565b601055612440565b8160105461243c91906133fb565b6010555b600160801b60105411156124965760405162461bcd60e51b815260206004820152601960248201527f544f4f204d554348204c4951554944495459205354414b45440000000000000060448201526064016108d3565b5050565b80156124b55781600f546124ae919061335d565b600f555050565b81600f546124ae91906133fb565b6040516001600160a01b03831660248201526044810182905261255390849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915261293c565b505050565b60006122218383612a21565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000600f54600014156125c8575081612005565b6000600a600f54846010546125dd9190613395565b6125e8906006613395565b6125f29190613375565b6125fd866004613395565b612607919061335d565b6126119190613375565b905061261d81856128ee565b949350505050565b6000848152600d6020526040812084815560018101849055600281018390556006546003820155905b600a548110156126ac576000818152600960205260409020600201546004830180548390811061268e57634e487b7160e01b600052603260045260246000fd5b600091825260209091200155806126a48161343e565b91505061264e565b505050505050565b6040516001600160a01b038085166024830152831660448201526064810182905261240c9085907f23b872dd00000000000000000000000000000000000000000000000000000000906084016124ef565b6000620f4240826fffffffffffffffffffffffffffffffff16101561276c5760405162461bcd60e51b815260206004820152601360248201527f4c495155494449545920544f4f20534d414c4c0000000000000000000000000060448201526064016108d3565b6005546000906127ab9061278a906301000000900460020b87612b3e565b60055461279a9060020b87612b54565b6127a491906133b4565b6000612b3e565b62ffffff169050620f42406fffffffffffffffffffffffffffffffff84166127d38380613395565b6127dd9190613395565b6127e79190613375565b95945050505050565b60006122218383612b69565b6000848152600d6020526040902083815560018101839055600281018290556006546003820155600a5467ffffffffffffffff81111561284c57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015612875578160200160208202803683370190505b50805161288c916004840191602090910190612cc3565b5060005b600a548110156126ac57600081815260096020526040902060020154600483018054839081106128d057634e487b7160e01b600052603260045260246000fd5b600091825260209091200155806128e68161343e565b915050612890565b60008183106128fd5781612221565b5090919050565b600082600001828154811061292957634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905092915050565b6000612991826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612bb89092919063ffffffff16565b80519091501561255357808060200190518101906129af9190612ec7565b6125535760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016108d3565b60008181526001830160205260408120548015612b34576000612a456001836133fb565b8554909150600090612a59906001906133fb565b9050818114612ada576000866000018281548110612a8757634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905080876000018481548110612ab857634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910192909255918252600188019052604090208390555b8554869080612af957634e487b7160e01b600052603160045260246000fd5b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050612005565b6000915050612005565b60008160020b8360020b12156128fd5781612221565b60008160020b8360020b126128fd5781612221565b6000818152600183016020526040812054612bb057508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155612005565b506000612005565b606061261d848460008585843b612c115760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016108d3565b600080866001600160a01b03168587604051612c2d91906130f4565b60006040518083038185875af1925050503d8060008114612c6a576040519150601f19603f3d011682016040523d82523d6000602084013e612c6f565b606091505b5091509150612c7f828286612c8a565b979650505050505050565b60608315612c99575081612221565b825115612ca95782518084602001fd5b8160405162461bcd60e51b81526004016108d391906132a5565b828054828255906000526020600020908101928215612cfe579160200282015b82811115612cfe578251825591602001919060010190612ce3565b50612d0a929150612d0e565b5090565b5b80821115612d0a5760008155600101612d0f565b8051612d2e81613485565b919050565b8051600281900b8114612d2e57600080fd5b80516fffffffffffffffffffffffffffffffff81168114612d2e57600080fd5b805162ffffff81168114612d2e57600080fd5b600060208284031215612d89578081fd5b813561222181613485565b600060208284031215612da5578081fd5b815161222181613485565b60008060008060808587031215612dc5578283fd5b8435612dd081613485565b93506020850135612de081613485565b925060408501359150606085013567ffffffffffffffff811115612e02578182fd5b8501601f81018713612e12578182fd5b8035612e25612e2082613335565b613304565b818152886020838501011115612e39578384fd5b81602084016020830137908101602001929092525092959194509250565b60008060208385031215612e69578182fd5b823567ffffffffffffffff80821115612e80578384fd5b818501915085601f830112612e93578384fd5b813581811115612ea1578485fd5b8660208260051b8501011115612eb5578485fd5b60209290920196919550909350505050565b600060208284031215612ed8578081fd5b81516122218161349a565b600060208284031215612ef4578081fd5b815167ffffffffffffffff811115612f0a578182fd5b8201601f81018413612f1a578182fd5b8051612f28612e2082613335565b818152856020838501011115612f3c578384fd5b6127e7826020830160208601613412565b600060208284031215612f5e578081fd5b5035919050565b60008060408385031215612f77578182fd5b823591506020830135612f8981613485565b809150509250929050565b60008060408385031215612fa6578182fd5b823591506020830135612f898161349a565b60008060408385031215612fca578182fd5b50508035926020909101359150565b6000806000806000806000806000806000806101808d8f031215612ffb578788fd5b8c516bffffffffffffffffffffffff81168114613016578889fd5b9b5061302460208e01612d23565b9a5061303260408e01612d23565b995061304060608e01612d23565b985061304e60808e01612d65565b975061305c60a08e01612d33565b965061306a60c08e01612d33565b955061307860e08e01612d45565b94506101008d015193506101208d015192506130976101408e01612d45565b91506130a66101608e01612d45565b90509295989b509295989b509295989b565b600081518084526130d0816020860160208601613412565b601f01601f19169290920160200192915050565b8183823760009101908152919050565b60008251613106818460208701613412565b9190910192915050565b600061016082016001600160a01b03808f168452808e16602085015262ffffff8d1660408501526101606060850152818c518084526101808601915060208e019350845b8181101561319c578451848151168452846020820151166020850152604081015160408501526060810151606085015250608083019250602085019450600181019050613154565b50506001600160a01b038c16608086015292506131b7915050565b6131c660a083018960020b9052565b6131d560c083018860020b9052565b8560e08301528461010083015283610120830152826101408301529c9b505050505050505050505050565b6000602080830181845280855180835260408601915060408160051b8701019250838701855b8281101561325457603f198886030184526132428583516130b8565b94509285019290850190600101613226565b5092979650505050505050565b6020808252825182820181905260009190848201906040850190845b818110156132995783518352928401929184019160010161327d565b50909695505050505050565b60208152600061222160208301846130b8565b6000808335601e198436030181126132ce578283fd5b83018035915067ffffffffffffffff8211156132e8578283fd5b6020019150368190038213156132fd57600080fd5b9250929050565b604051601f8201601f1916810167ffffffffffffffff8111828210171561332d5761332d61346f565b604052919050565b600067ffffffffffffffff82111561334f5761334f61346f565b50601f01601f191660200190565b6000821982111561337057613370613459565b500190565b60008261339057634e487b7160e01b81526012600452602481fd5b500490565b60008160001904831182151516156133af576133af613459565b500290565b60008160020b8360020b82811281627fffff19018312811516156133da576133da613459565b81627fffff0183138116156133f1576133f1613459565b5090039392505050565b60008282101561340d5761340d613459565b500390565b60005b8381101561342d578181015183820152602001613415565b8381111561240c5750506000910152565b600060001982141561345257613452613459565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146120ea57600080fd5b80151581146120ea57600080fdfea264697066735822122041a4cedc7c6e8e0820818f9d40998df4fe1136663cf3db3a87d22b4990d2f7d764736f6c63430008040033
Verified Source Code Partial Match
Compiler: v0.8.4+commit.c7e474f2
EVM: istanbul
Optimization: Yes (1000 runs)
multicall.sol 24 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.4;
/// @title Multicall
/// @notice Enables calling multiple methods in a single call to the contract
abstract contract Multicall {
function multicall(bytes[] calldata data) external payable returns (bytes[] memory results) {
results = new bytes[](data.length);
for (uint256 i = 0; i < data.length; i++) {
(bool success, bytes memory result) = address(this).delegatecall(data[i]);
if (!success) {
// Next 5 lines from https://ethereum.stackexchange.com/a/83577
if (result.length < 68) revert();
assembly {
result := add(result, 0x04)
}
revert(abi.decode(result, (string)));
}
results[i] = result;
}
}
}
Address.sol 217 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)
pragma solidity ^0.8.0;
/**
* @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) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
Ownable.sol 76 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
IERC20.sol 82 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol)
pragma solidity ^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);
}
ReentrancyGuard.sol 63 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}
miningFixRangeBoost.sol 654 lines
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.4;
// Uncomment if needed.
// import "hardhat/console.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import "../multicall.sol";
/// @title Simple math library for Max and Min.
library Math {
function max(int24 a, int24 b) internal pure returns (int24) {
return a >= b ? a : b;
}
function min(int24 a, int24 b) internal pure returns (int24) {
return a < b ? a : b;
}
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a >= b ? a : b;
}
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
}
/// @title Uniswap V3 Nonfungible Position Manager Interface
interface PositionManagerV3 {
function positions(uint256 tokenId)
external
view
returns (
uint96 nonce,
address operator,
address token0,
address token1,
uint24 fee,
int24 tickLower,
int24 tickUpper,
uint128 liquidity,
uint256 feeGrowthInside0LastX128,
uint256 feeGrowthInside1LastX128,
uint128 tokensOwed0,
uint128 tokensOwed1
);
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
function ownerOf(uint256 tokenId) external view returns (address);
}
/// @title Uniswap V3 Liquidity Mining Main Contract
contract MiningFixRangeBoost is Ownable, Multicall, ReentrancyGuard, IERC721Receiver {
using Math for int24;
using SafeERC20 for IERC20;
using EnumerableSet for EnumerableSet.UintSet;
struct PoolInfo {
address token0;
address token1;
uint24 fee;
}
/// @dev Contract of the uniV3 Nonfungible Position Manager.
PositionManagerV3 uniV3NFTManager;
PoolInfo public rewardPool;
/// @dev The reward range of this mining contract.
int24 rewardUpperTick;
int24 rewardLowerTick;
/// @dev Last block number that the accRewardRerShare is touched.
uint256 lastTouchBlock;
/// @dev The block number when NFT mining rewards starts/ends.
uint256 startBlock;
uint256 endBlock;
struct RewardInfo {
/// @dev Contract of the reward erc20 token.
address rewardToken;
/// @dev who provides reward
address provider;
/// @dev Accumulated Reward Tokens per share, times 1e128.
uint256 accRewardPerShare;
/// @dev Reward amount for each block.
uint256 rewardPerBlock;
}
mapping(uint256 => RewardInfo) public rewardInfos;
uint256 public rewardInfosLen;
/// @dev Store the owner of the NFT token
mapping(uint256 => address) public owners;
/// @dev The inverse mapping of owners.
mapping(address => EnumerableSet.UintSet) private tokenIds;
/// @dev Record the status for a certain token for the last touched time.
struct TokenStatus {
uint256 vLiquidity;
uint256 validVLiquidity;
uint256 nIZI;
uint256 lastTouchBlock;
uint256[] lastTouchAccRewardPerShare;
}
mapping(uint256 => TokenStatus) public tokenStatus;
function lastTouchAccRewardPerShare(uint256 tokenId)
external
view
returns (uint256[] memory lta)
{
TokenStatus memory t = tokenStatus[tokenId];
uint256 len = t.lastTouchAccRewardPerShare.length;
lta = new uint256[](len);
for (uint256 i = 0; i < len; i++) {
lta[i] = t.lastTouchAccRewardPerShare[i];
}
return lta;
}
/// @dev token to lock, 0 for not boost
IERC20 public iziToken;
/// @dev current total nIZI.
uint256 public totalNIZI;
/// @dev Current total virtual liquidity.
uint256 public totalVLiquidity;
/// @dev 2 << 128
uint256 internal constant Q128 = 0x100000000000000000000000000000000;
// Events
event Deposit(address indexed user, uint256 tokenId, uint256 nIZI);
event Withdraw(address indexed user, uint256 tokenId);
event CollectReward(address indexed user, uint256 tokenId, address token, uint256 amount);
event ModifyEndBlock(uint256 endBlock);
event ModifyRewardPerBlock(address indexed rewardToken, uint256 rewardPerBlock);
event ModifyProvider(address indexed rewardToken, address provider);
constructor(
address _uniV3NFTManager,
address token0,
address token1,
uint24 fee,
RewardInfo[] memory _rewardInfos,
address iziTokenAddr,
int24 _rewardUpperTick,
int24 _rewardLowerTick,
uint256 _startBlock,
uint256 _endBlock
) {
uniV3NFTManager = PositionManagerV3(_uniV3NFTManager);
require(_rewardLowerTick < _rewardUpperTick, "L<U");
require(token0 < token1, "TOKEN0 < TOKEN1 NOT MATCH");
rewardPool.token0 = token0;
rewardPool.token1 = token1;
rewardPool.fee = fee;
rewardInfosLen = _rewardInfos.length;
require(rewardInfosLen > 0, "NO REWARD");
require(rewardInfosLen < 3, "AT MOST 2 REWARDS");
for (uint256 i = 0; i < rewardInfosLen; i++) {
rewardInfos[i] = _rewardInfos[i];
rewardInfos[i].accRewardPerShare = 0;
}
// iziTokenAddr == 0 means not boost
iziToken = IERC20(iziTokenAddr);
rewardUpperTick = _rewardUpperTick;
rewardLowerTick = _rewardLowerTick;
startBlock = _startBlock;
endBlock = _endBlock;
lastTouchBlock = startBlock;
totalVLiquidity = 0;
totalNIZI = 0;
}
/// @notice Used for ERC721 safeTransferFrom
function onERC721Received(address, address, uint256, bytes memory)
public
virtual
override
returns (bytes4)
{
return this.onERC721Received.selector;
}
/// @notice Get the overall info for the mining contract.
function getMiningContractInfo()
external
view
returns (
address token0_,
address token1_,
uint24 fee_,
RewardInfo[] memory rewardInfos_,
address iziTokenAddr_,
int24 rewardUpperTick_,
int24 rewardLowerTick_,
uint256 lastTouchBlock_,
uint256 totalVLiquidity_,
uint256 startBlock_,
uint256 endBlock_
)
{
rewardInfos_ = new RewardInfo[](rewardInfosLen);
for (uint256 i = 0; i < rewardInfosLen; i++) {
rewardInfos_[i] = rewardInfos[i];
}
return (
rewardPool.token0,
rewardPool.token1,
rewardPool.fee,
rewardInfos_,
address(iziToken),
rewardUpperTick,
rewardLowerTick,
lastTouchBlock,
totalVLiquidity,
startBlock,
endBlock
);
}
/// @notice Compute the virtual liquidity from a position's parameters.
/// @param tickLower The lower tick of a position.
/// @param tickUpper The upper tick of a position.
/// @param liquidity The liquidity of a a position.
/// @dev vLiquidity = liquidity * validRange^2 / 1e6, where the validRange is the tick amount of the
/// intersection between the position and the reward range.
/// We divided it by 1e6 to keep vLiquidity smaller than Q128 in most cases. This is safe since liqudity is usually a large number.
function _getVLiquidityForNFT(
int24 tickLower,
int24 tickUpper,
uint128 liquidity
) internal view returns (uint256 vLiquidity) {
// liquidity is roughly equals to sqrt(amountX*amountY)
require(liquidity >= 1e6, "LIQUIDITY TOO SMALL");
uint256 validRange = uint24(
Math.max(
Math.min(rewardUpperTick, tickUpper) - Math.max(rewardLowerTick, tickLower),
0
)
);
vLiquidity = (validRange * validRange * uint256(liquidity)) / 1e6;
return vLiquidity;
}
/// @notice new a token status when touched.
function _newTokenStatus(
uint256 tokenId,
uint256 vLiquidity,
uint256 validVLiquidity,
uint256 nIZI
) internal {
TokenStatus storage t = tokenStatus[tokenId];
t.vLiquidity = vLiquidity;
t.validVLiquidity = validVLiquidity;
t.nIZI = nIZI;
t.lastTouchBlock = lastTouchBlock;
t.lastTouchAccRewardPerShare = new uint256[](rewardInfosLen);
for (uint256 i = 0; i < rewardInfosLen; i++) {
t.lastTouchAccRewardPerShare[i] = rewardInfos[i].accRewardPerShare;
}
}
/// @notice update a token status when touched
function _updateTokenStatus(
uint256 tokenId,
uint256 vLiquidity,
uint256 validVLiquidity,
uint256 nIZI
) internal {
TokenStatus storage t = tokenStatus[tokenId];
t.vLiquidity = vLiquidity;
// when not boost, validVL == vL
t.validVLiquidity = validVLiquidity;
t.nIZI = nIZI;
t.lastTouchBlock = lastTouchBlock;
for (uint256 i = 0; i < rewardInfosLen; i++) {
t.lastTouchAccRewardPerShare[i] = rewardInfos[i].accRewardPerShare;
}
}
/// @notice Update reward variables to be up-to-date.
function _updateVLiquidity(uint256 vLiquidity, bool isAdd) internal {
if (isAdd) {
totalVLiquidity = totalVLiquidity + vLiquidity;
} else {
totalVLiquidity = totalVLiquidity - vLiquidity;
}
// Q128 is enough for 10^5 * 10^5 * 10^18 * 10^10
require(totalVLiquidity <= Q128, "TOO MUCH LIQUIDITY STAKED");
}
function _updateNIZI(uint256 nIZI, bool isAdd) internal {
if (isAdd) {
totalNIZI = totalNIZI + nIZI;
} else {
totalNIZI = totalNIZI - nIZI;
}
// totalNIZI is always < Q96
}
/// @notice Update the global status.
function _updateGlobalStatus() internal {
if (block.number <= lastTouchBlock) {
return;
}
if (lastTouchBlock >= endBlock) {
return;
}
uint256 currBlockNumber = Math.min(block.number, endBlock);
if (totalVLiquidity == 0) {
lastTouchBlock = currBlockNumber;
return;
}
for (uint256 i = 0; i < rewardInfosLen; i++) {
uint256 tokenReward = (currBlockNumber - lastTouchBlock) * rewardInfos[i].rewardPerBlock;
rewardInfos[i].accRewardPerShare = rewardInfos[i].accRewardPerShare + ((tokenReward * Q128) / totalVLiquidity);
}
lastTouchBlock = currBlockNumber;
}
function _computeValidVLiquidity(uint256 vLiquidity, uint256 nIZI)
internal
view
returns (uint256)
{
if (totalNIZI == 0) {
return vLiquidity;
}
uint256 iziVLiquidity = (vLiquidity * 4 + (totalVLiquidity * nIZI * 6) / totalNIZI) / 10;
return Math.min(iziVLiquidity, vLiquidity);
}
/// @notice Deposit a single position.
/// @param tokenId The related position id.
/// @param nIZI the amount of izi to lock
function deposit(uint256 tokenId, uint256 nIZI)
external
returns (uint256 vLiquidity)
{
address owner = uniV3NFTManager.ownerOf(tokenId);
require(owner == msg.sender, "NOT OWNER");
(
,
,
address token0,
address token1,
uint24 fee,
int24 tickLower,
int24 tickUpper,
uint128 liquidity,
,
,
,
) = uniV3NFTManager.positions(tokenId);
// alternatively we can compute the pool address with tokens and fee and compare the address directly
require(token0 == rewardPool.token0, "TOEKN0 NOT MATCH");
require(token1 == rewardPool.token1, "TOKEN1 NOT MATCH");
require(fee == rewardPool.fee, "FEE NOT MATCH");
// require the NFT token has interaction with [rewardLowerTick, rewardUpperTick]
vLiquidity = _getVLiquidityForNFT(tickLower, tickUpper, liquidity);
require(vLiquidity > 0, "INVALID TOKEN");
uniV3NFTManager.safeTransferFrom(msg.sender, address(this), tokenId);
owners[tokenId] = msg.sender;
bool res = tokenIds[msg.sender].add(tokenId);
require(res);
// the execution order for the next three lines is crutial
_updateGlobalStatus();
_updateVLiquidity(vLiquidity, true);
if (address(iziToken) == address(0)) {
// boost is not enabled
nIZI = 0;
}
_updateNIZI(nIZI, true);
uint256 validVLiquidity = _computeValidVLiquidity(vLiquidity, nIZI);
require(nIZI < Q128 / 6, "NIZI O");
_newTokenStatus(tokenId, vLiquidity, validVLiquidity, nIZI);
if (nIZI > 0) {
// lock izi in this contract
iziToken.safeTransferFrom(msg.sender, address(this), nIZI);
}
emit Deposit(msg.sender, tokenId, nIZI);
return vLiquidity;
}
/// @notice deposit iZi to an nft token
/// @param tokenId nft already deposited
/// @param deltaNIZI amount of izi to deposit
function depositIZI(uint256 tokenId, uint256 deltaNIZI)
external
nonReentrant
{
require(owners[tokenId] == msg.sender, "NOT OWNER OR NOT EXIST");
require(address(iziToken) != address(0), "NOT BOOST");
require(deltaNIZI > 0, "DEPOSIT IZI MUST BE POSITIVE");
_collectReward(tokenId);
TokenStatus memory t = tokenStatus[tokenId];
_updateNIZI(deltaNIZI, true);
uint256 nIZI = t.nIZI + deltaNIZI;
// update validVLiquidity
uint256 validVLiquidity = _computeValidVLiquidity(t.vLiquidity, nIZI);
_updateTokenStatus(tokenId, t.vLiquidity, validVLiquidity, nIZI);
// transfer iZi from user
iziToken.safeTransferFrom(msg.sender, address(this), deltaNIZI);
}
/// @notice withdraw a single position.
/// @param tokenId The related position id.
/// @param noReward true if donot collect reward
function withdraw(uint256 tokenId, bool noReward) external nonReentrant {
require(owners[tokenId] == msg.sender, "NOT OWNER OR NOT EXIST");
if (noReward) {
_updateGlobalStatus();
} else {
_collectReward(tokenId);
}
uint256 vLiquidity = tokenStatus[tokenId].vLiquidity;
_updateVLiquidity(vLiquidity, false);
uint256 nIZI = tokenStatus[tokenId].nIZI;
if (nIZI > 0) {
_updateNIZI(nIZI, false);
// refund iZi to user
iziToken.safeTransfer(msg.sender, nIZI);
}
uniV3NFTManager.safeTransferFrom(address(this), msg.sender, tokenId);
owners[tokenId] = address(0);
bool res = tokenIds[msg.sender].remove(tokenId);
require(res);
emit Withdraw(msg.sender, tokenId);
}
/// @notice Collect pending reward for a single position.
/// @param tokenId The related position id.
function _collectReward(uint256 tokenId) internal {
TokenStatus memory t = tokenStatus[tokenId];
_updateGlobalStatus();
for (uint256 i = 0; i < rewardInfosLen; i++) {
uint256 _reward = (t.validVLiquidity * (rewardInfos[i].accRewardPerShare - t.lastTouchAccRewardPerShare[i])) / Q128;
if (_reward > 0) {
IERC20(rewardInfos[i].rewardToken).safeTransferFrom(
rewardInfos[i].provider,
msg.sender,
_reward
);
}
emit CollectReward(
msg.sender,
tokenId,
rewardInfos[i].rewardToken,
_reward
);
}
uint256 nIZI = t.nIZI;
// update validVLiquidity
uint256 validVLiquidity = _computeValidVLiquidity(t.vLiquidity, nIZI);
_updateTokenStatus(tokenId, t.vLiquidity, validVLiquidity, nIZI);
}
/// @notice Collect pending reward for a single position.
/// @param tokenId The related position id.
function collectReward(uint256 tokenId) external nonReentrant {
require(owners[tokenId] == msg.sender, "NOT OWNER OR NOT EXIST");
_collectReward(tokenId);
}
/// @notice Collect all pending rewards.
function collectRewards() external nonReentrant {
EnumerableSet.UintSet storage ids = tokenIds[msg.sender];
for (uint256 i = 0; i < ids.length(); i++) {
require(owners[ids.at(i)] == msg.sender, "NOT OWNER");
_collectReward(ids.at(i));
}
}
/// @notice View function to get position ids staked here for an user.
/// @param _user The related address.
function getTokenIds(address _user)
external
view
returns (uint256[] memory)
{
EnumerableSet.UintSet storage ids = tokenIds[_user];
// push could not be used in memory array
// we set the tokenIdList into a fixed-length array rather than dynamic
uint256[] memory tokenIdList = new uint256[](ids.length());
for (uint256 i = 0; i < ids.length(); i++) {
tokenIdList[i] = ids.at(i);
}
return tokenIdList;
}
/// @notice Return reward multiplier over the given _from to _to block.
/// @param _from The start block.
/// @param _to The end block.
function _getMultiplier(uint256 _from, uint256 _to)
internal
view
returns (uint256)
{
if (_from > _to) {
return 0;
}
if (_to <= endBlock) {
return _to - _from;
} else if (_from >= endBlock) {
return 0;
} else {
return endBlock - _from;
}
}
/// @notice View function to see pending Reward for a single position.
/// @param tokenId The related position id.
function pendingReward(uint256 tokenId)
public
view
returns (uint256[] memory)
{
TokenStatus memory t = tokenStatus[tokenId];
uint256[] memory _reward = new uint256[](rewardInfosLen);
for (uint256 i = 0; i < rewardInfosLen; i++) {
uint256 multiplier = _getMultiplier(lastTouchBlock, block.number);
uint256 tokenReward = multiplier * rewardInfos[i].rewardPerBlock;
uint256 rewardPerShare = rewardInfos[i].accRewardPerShare + (tokenReward * Q128) / totalVLiquidity;
// l * (currentAcc - lastAcc)
_reward[i] = (t.validVLiquidity * (rewardPerShare - t.lastTouchAccRewardPerShare[i])) / Q128;
}
return _reward;
}
/// @notice View function to see pending Rewards for an address.
/// @param _user The related address.
function pendingRewards(address _user)
external
view
returns (uint256[] memory)
{
uint256[] memory _reward = new uint256[](rewardInfosLen);
for (uint256 j = 0; j < rewardInfosLen; j++) {
_reward[j] = 0;
}
for (uint256 i = 0; i < tokenIds[_user].length(); i++) {
uint256[] memory r = pendingReward(tokenIds[_user].at(i));
for (uint256 j = 0; j < rewardInfosLen; j++) {
_reward[j] += r[j];
}
}
return _reward;
}
// Control fuctions for the contract owner and operators.
/// @notice If something goes wrong, we can send back user's nft and locked iZi
/// @param tokenId The related position id.
function emergenceWithdraw(uint256 tokenId) external onlyOwner {
address owner = owners[tokenId];
require(owner != address(0));
uniV3NFTManager.safeTransferFrom(
address(this),
owners[tokenId],
tokenId
);
uint256 nIZI = tokenStatus[tokenId].nIZI;
if (nIZI > 0) {
// we should ensure nft refund to user
// omit the case when transfer() returns false unexpectedly
iziToken.transfer(owner, nIZI);
}
// make sure user cannot withdraw/depositIZI or collect reward on this nft
owners[tokenId] = address(0);
}
/// @notice Set new reward end block.
/// @param _endBlock New end block.
function modifyEndBlock(uint256 _endBlock) external onlyOwner {
require(_endBlock > block.number, "OUT OF DATE");
_updateGlobalStatus();
// jump if origin endBlock < block.number
lastTouchBlock = block.number;
endBlock = _endBlock;
emit ModifyEndBlock(endBlock);
}
/// @notice Set new reward per block.
/// @param rewardIdx which rewardInfo to modify
/// @param _rewardPerBlock new reward per block
function modifyRewardPerBlock(uint256 rewardIdx, uint256 _rewardPerBlock)
external
onlyOwner
{
require(rewardIdx < rewardInfosLen, "OUT OF REWARD INFO RANGE");
_updateGlobalStatus();
rewardInfos[rewardIdx].rewardPerBlock = _rewardPerBlock;
emit ModifyRewardPerBlock(
rewardInfos[rewardIdx].rewardToken,
_rewardPerBlock
);
}
/// @notice Set new reward provider.
/// @param rewardIdx which rewardInfo to modify
/// @param provider New provider
function modifyProvider(uint256 rewardIdx, address provider)
external
onlyOwner
{
require(rewardIdx < rewardInfosLen, "OUT OF REWARD INFO RANGE");
rewardInfos[rewardIdx].provider = provider;
emit ModifyProvider(rewardInfos[rewardIdx].rewardToken, provider);
}
}
SafeERC20.sol 99 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
function safeTransfer(
IERC20 token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(
IERC20 token,
address spender,
uint256 value
) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
// Return data is optional
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
EnumerableSet.sol 357 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/structs/EnumerableSet.sol)
pragma solidity ^0.8.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.3.0, sets of type `bytes32` (`Bytes32Set`), `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;
if (lastIndex != toDeleteIndex) {
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] = valueIndex; // Replace lastvalue's index to valueIndex
}
// 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) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
// Bytes32Set
struct Bytes32Set {
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(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, 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(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set 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(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
return _values(set._inner);
}
// 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(uint160(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(uint160(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(uint160(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(uint160(uint256(_at(set._inner, index))));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
assembly {
result := store
}
return result;
}
// 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));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
assembly {
result := store
}
return result;
}
}
IERC721Receiver.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
Read Contract
getMiningContractInfo 0xd1c924a5 → address, address, uint24, tuple[], address, int24, int24, uint256, uint256, uint256, uint256
getTokenIds 0xd004b036 → uint256[]
iziToken 0x09ca2756 → address
lastTouchAccRewardPerShare 0x78b0013d → uint256[]
owner 0x8da5cb5b → address
owners 0x025e7c27 → address
pendingReward 0x12f7086c → uint256[]
pendingRewards 0x31d7a262 → uint256[]
rewardInfos 0x89d6517f → address, address, uint256, uint256
rewardInfosLen 0x9a174591 → uint256
rewardPool 0x66666aa9 → address, address, uint24
tokenStatus 0xb01ce31f → uint256, uint256, uint256, uint256
totalNIZI 0x4d340238 → uint256
totalVLiquidity 0x9ac8eebc → uint256
Write Contract 13 functions
These functions modify contract state and require a wallet transaction to execute.
collectReward 0xbd3507da
uint256 tokenId
collectRewards 0x70bb45b3
No parameters
deposit 0xe2bbb158
uint256 tokenId
uint256 nIZI
returns: uint256
depositIZI 0xb36b9fa3
uint256 tokenId
uint256 deltaNIZI
emergenceWithdraw 0xcd785a5e
uint256 tokenId
modifyEndBlock 0xd62dd3a6
uint256 _endBlock
modifyProvider 0x2e0c5ca2
uint256 rewardIdx
address provider
modifyRewardPerBlock 0x2d6730db
uint256 rewardIdx
uint256 _rewardPerBlock
multicall 0xac9650d8
bytes[] data
returns: bytes[]
onERC721Received 0x150b7a02
address
address
uint256
bytes
returns: bytes4
renounceOwnership 0x715018a6
No parameters
transferOwnership 0xf2fde38b
address newOwner
withdraw 0x38d07436
uint256 tokenId
bool noReward
Recent Transactions
No transactions found for this address