Address Contract Partially Verified
Address
0x70acf0475645F71F2cdd21D47E17b0336f0F7543
Balance
0 ETH
Nonce
1
Code Size
9422 bytes
Creator
0xB1A23356...A52e at tx 0x0c2026a5...24ef66
Indexed Transactions
0
Contract Bytecode
9422 bytes
0x608060405234801561001057600080fd5b506004361061018e5760003560e01c80637b0472f0116100de578063b3d9799c11610097578063e8f5fb1c11610071578063e8f5fb1c146105a8578063f2fde38b146105c6578063f446c1d01461060a578063fcc77c18146106285761018e565b8063b3d9799c14610500578063c4590d3f1461052e578063da8abf24146105665761018e565b80637b0472f0146103f6578063817b1cd21461042e57806383dfe5fd1461044c5780638da5cb5b1461046a5780639251a708146104b4578063a4dee155146104e25761018e565b806332e7c5bf1161014b5780635eff82db116101255780635eff82db14610348578063677a68e11461038a57806369f8ef0c146103e2578063715018a6146103ec5761018e565b806332e7c5bf146103025780634e71d92d146103205780635aa9892e1461032a5761018e565b80630e15561a1461019357806313ed0846146101b157806316934fc4146101fd578063212c5fea1461026a57806329ad27d71461029a57806329fef69d146102b8575b600080fd5b61019b61068a565b6040518082815260200191505060405180910390f35b6101e7600480360360408110156101c757600080fd5b810190808035906020019092919080359060200190929190505050610690565b6040518082815260200191505060405180910390f35b61023f6004803603602081101561021357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506106d5565b6040518085815260200184815260200183815260200182815260200194505050505060405180910390f35b6102986004803603602081101561028057600080fd5b81019080803515159060200190929190505050610705565b005b6102a26107eb565b6040518082815260200191505060405180910390f35b6102c06107f1565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61030a610817565b6040518082815260200191505060405180910390f35b61032861081d565b005b610332610d34565b6040518082815260200191505060405180910390f35b6103886004803603606081101561035e57600080fd5b81019080803590602001909291908035906020019092919080359060200190929190505050610d52565b005b6103cc600480360360208110156103a057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e35565b6040518082815260200191505060405180910390f35b6103ea610ed5565b005b6103f4611000565b005b61042c6004803603604081101561040c57600080fd5b810190808035906020019092919080359060200190929190505050611188565b005b6104366118a6565b6040518082815260200191505060405180910390f35b6104546118ac565b6040518082815260200191505060405180910390f35b6104726118b2565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6104e0600480360360208110156104ca57600080fd5b81019080803590602001909291905050506118db565b005b6104ea611bf3565b6040518082815260200191505060405180910390f35b61052c6004803603602081101561051657600080fd5b8101908080359060200190929190505050611bf9565b005b6105646004803603604081101561054457600080fd5b810190808035906020019092919080359060200190929190505050611d4f565b005b6105926004803603602081101561057c57600080fd5b8101908080359060200190929190505050611e2a565b6040518082815260200191505060405180910390f35b6105b0611ea5565b6040518082815260200191505060405180910390f35b610608600480360360208110156105dc57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611eab565b005b6106126120b8565b6040518082815260200191505060405180910390f35b6106746004803603604081101561063e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506120be565b6040518082815260200191505060405180910390f35b60085481565b60008061069c83611e2a565b905060006106b3828661212590919063ffffffff16565b90506106cb62989680826121c890919063ffffffff16565b9250505092915050565b600a6020528060005260406000206000915090508060000154908060010154908060020154908060030154905084565b61070d612212565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146107ce576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600160146101000a81548160ff02191690831515021790555050565b60055481565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60035481565b600061082833610e35565b1161089b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f6e6f7468696e6720746f20636c61696d0000000000000000000000000000000081525060200191505060405180910390fd5b6108f2600954600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206002015461221a90919063ffffffff16565b4211610966576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260098152602001807f746f6f206561726c79000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60006109ff600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010154600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000015461226490919063ffffffff16565b9050610a58600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001015460075461221a90919063ffffffff16565b600781905550610ab5600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000015460085461221a90919063ffffffff16565b6008819055506000600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101819055506000600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001819055506000600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600201819055506000600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060030181905550600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33836040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b158015610c8457600080fd5b505af1158015610c98573d6000803e3d6000fd5b505050506040513d6020811015610cae57600080fd5b8101908080519060200190929190505050610d31576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600f8152602001807f7472616e73666572206661696c6564000000000000000000000000000000000081525060200191505060405180910390fd5b50565b6000610d4d60085460075461226490919063ffffffff16565b905090565b610d5a612212565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610e1b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b826002819055508160038190555080600481905550505050565b6000610ece600a60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000154600a60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001015461226490919063ffffffff16565b9050919050565b610edd612212565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610f9e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6000610fb460014761221a90919063ffffffff16565b90503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610ffc573d6000803e3d6000fd5b5050565b611008612212565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146110c9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60065481116111ff576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f6c657373207468616e206d696e696d756d207374616b696e6720706572696f6481525060200191505060405180910390fd5b6005548110611276576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f6d6f7265207468616e206d6178696d756d207374616b696e6720706572696f6481525060200191505060405180910390fd5b6000600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600201541461132e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f616c7265616479207374616b656400000000000000000000000000000000000081525060200191505060405180910390fd5b606482116113a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600f8152602001807f616d6f756e7420746f20736d616c6c000000000000000000000000000000000081525060200191505060405180910390fd5b600160149054906101000a900460ff1615611427576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260118152602001807f7374616b696e6720697320636c6f73656400000000000000000000000000000081525060200191505060405180910390fd5b60006114338383610690565b90506114618361145383611445610d34565b61226490919063ffffffff16565b61226490919063ffffffff16565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561150057600080fd5b505afa158015611514573d6000803e3d6000fd5b505050506040513d602081101561152a57600080fd5b8101908080519060200190929190505050116115ae576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f696e73756666696369656e7420636f6e74726163742062616c0000000000000081525060200191505060405180910390fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3330866040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b15801561168b57600080fd5b505af115801561169f573d6000803e3d6000fd5b505050506040513d60208110156116b557600080fd5b8101908080519060200190929190505050611738576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600f8152602001807f7472616e73666572206661696c6564000000000000000000000000000000000081525060200191505060405180910390fd5b6117506201518083024261226490919063ffffffff16565b600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206002018190555080600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018190555042600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206003018190555082600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101819055506118808360075461226490919063ffffffff16565b60078190555061189b8160085461226490919063ffffffff16565b600881905550505050565b60075481565b60045481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6118e3612212565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146119a4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b611a976119af610d34565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015611a4e57600080fd5b505afa158015611a62573d6000803e3d6000fd5b505050506040513d6020811015611a7857600080fd5b810190808051906020019092919050505061221a90919063ffffffff16565b8110611b0b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f63616e6e6f74207769746864726177206f7765642066756e647300000000000081525060200191505060405180910390fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33836040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b158015611bb457600080fd5b505af1158015611bc8573d6000803e3d6000fd5b505050506040513d6020811015611bde57600080fd5b81019080805190602001909291905050505050565b60095481565b611c01612212565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611cc2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b635fa032c68110611d3b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260078152602001807f746f6f206269670000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b611d456001610705565b8060098190555050565b611d57612212565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611e18576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b81600681905550806005819055505050565b600080611e426003548461212590919063ffffffff16565b90506000611e59848561212590919063ffffffff16565b90506000611e728260045461212590919063ffffffff16565b9050611e9b81611e8d8560025461226490919063ffffffff16565b61226490919063ffffffff16565b9350505050919050565b60065481565b611eb3612212565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611f74576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611ffa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806124736026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60025481565b600081600a60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600201541115612113576000905061211f565b61211c83610e35565b90505b92915050565b60008083141561213857600090506121c2565b600082840290508284828161214957fe5b04146121bd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f6d756c3a202a000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b809150505b92915050565b600061220a83836040518060400160405280600681526020017f6469763a202f00000000000000000000000000000000000000000000000000008152506122ec565b905092915050565b600033905090565b600061225c83836040518060400160405280600681526020017f7375623a202d00000000000000000000000000000000000000000000000000008152506123b2565b905092915050565b6000808284019050838110156122e2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f6164643a202b000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b8091505092915050565b60008083118290612398576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561235d578082015181840152602081019050612342565b50505050905090810190601f16801561238a5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385816123a457fe5b049050809150509392505050565b600083831115829061245f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612424578082015181840152602081019050612409565b50505050905090810190601f1680156124515780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838503905080915050939250505056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373a2646970667358221220827998613f33bb5eb2084317f094a3e486069960cd506299e709c88effd1094564736f6c63430006060033
Verified Source Code Partial Match
Compiler: v0.6.6+commit.6c089d02
EVM: istanbul
Optimization: No
StakeContract.sol 414 lines
/* Experimental Keeper staking contract – for the distribution of unsold presale tokens to
buyer */
pragma solidity 0.6.6;
interface IERC20 {
function totalSupply() external view returns (uint);
function balanceOf(address account) external view returns (uint);
function transfer(address recipient, uint amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint amount) external returns (bool);
function transferFrom(address sender, address recipient, uint amount) external returns (bool);
event Transfer(address indexed from, address indexed to, uint value);
event Approval(address indexed owner, address indexed spender, uint value);
}
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint a, uint b) internal pure returns (uint) {
uint c = a + b;
require(c >= a, "add: +");
return c;
}
/**
* @dev Returns the addition of two unsigned integers, reverting with custom message on overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint a, uint b, string memory errorMessage) internal pure returns (uint) {
uint c = a + b;
require(c >= a, errorMessage);
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on underflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot underflow.
*/
function sub(uint a, uint b) internal pure returns (uint) {
return sub(a, b, "sub: -");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on underflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot underflow.
*/
function sub(uint a, uint b, string memory errorMessage) internal pure returns (uint) {
require(b <= a, errorMessage);
uint 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(uint a, uint b) internal pure returns (uint) {
// 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;
}
uint c = a * b;
require(c / a == b, "mul: *");
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint a, uint b, string memory errorMessage) internal pure returns (uint) {
// 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;
}
uint c = a * b;
require(c / a == b, errorMessage);
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(uint a, uint b) internal pure returns (uint) {
return div(a, b, "div: /");
}
/**
* @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(uint a, uint b, string memory errorMessage) internal pure returns (uint) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, errorMessage);
uint 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(uint a, uint b) internal pure returns (uint) {
return mod(a, b, "mod: %");
}
/**
* @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(uint a, uint b, string memory errorMessage) internal pure returns (uint) {
require(b != 0, errorMessage);
return a % b;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with GSN meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
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;
}
}
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 () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view 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 {
emit OwnershipTransferred(_owner, address(0));
_owner = 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");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
// y = f(x)
// 5 = f(10)
// 185 = f(365)
//y = A^x - X
//y = 1.87255 + 0.2985466*x + 0.001419838*x^2
interface StakingInterface {
function votingPowerOf(address acc, uint256 until) external view returns(uint256);
}
contract StakeContract is Ownable, StakingInterface {
using SafeMath for uint256;
IERC20 public kp4r;
bool isClosed = false;
// quadratic reward curve constants
// a + b*x + c*x^2
uint256 public A = 187255; // 1.87255
uint256 public B = 29854; // 0.2985466*x
uint256 public C = 141; // 0.001419838*x^2
uint256 constant BP = 10000;
uint256 public maxDays = 365;
uint256 public minDays = 10;
uint256 public totalStaked = 0;
uint256 public totalRewards = 0;
uint256 public earlyExit = 0;
struct StakeInfo {
uint256 reward;
uint256 initial;
uint256 payday;
uint256 startday;
}
mapping (address=>StakeInfo) public stakes;
constructor(address _kp4r) public {
kp4r = IERC20(_kp4r);
}
function stake(uint256 _amount, uint256 _days) public {
require(_days > minDays, "less than minimum staking period");
require(_days < maxDays, "more than maximum staking period");
require(stakes[msg.sender].payday == 0, "already staked");
require(_amount > 100, "amount to small");
require(!isClosed, "staking is closed");
// calculate reward
uint256 _reward = calculateReward(_amount, _days);
// contract must have funds to keep this commitment
require(kp4r.balanceOf(address(this)) > totalOwedValue().add(_reward).add(_amount), "insufficient contract bal");
require(kp4r.transferFrom(msg.sender, address(this), _amount), "transfer failed");
stakes[msg.sender].payday = block.timestamp.add(_days * (1 days));
stakes[msg.sender].reward = _reward;
stakes[msg.sender].startday = block.timestamp;
stakes[msg.sender].initial = _amount;
// update stats
totalStaked = totalStaked.add(_amount);
totalRewards = totalRewards.add(_reward);
}
function claim() public {
require(owedBalance(msg.sender) > 0, "nothing to claim");
require(block.timestamp > stakes[msg.sender].payday.sub(earlyExit), "too early");
uint256 owed = stakes[msg.sender].reward.add(stakes[msg.sender].initial);
// update stats
totalStaked = totalStaked.sub(stakes[msg.sender].initial);
totalRewards = totalRewards.sub(stakes[msg.sender].reward);
stakes[msg.sender].initial = 0;
stakes[msg.sender].reward = 0;
stakes[msg.sender].payday = 0;
stakes[msg.sender].startday = 0;
require(kp4r.transfer(msg.sender, owed), "transfer failed");
}
function calculateReward(uint256 _amount, uint256 _days) public view returns (uint256) {
uint256 _multiplier = _quadraticRewardCurveY(_days);
uint256 _AY = _amount.mul(_multiplier);
return _AY.div(10000000);
}
// a + b*x + c*x^2
function _quadraticRewardCurveY(uint256 _x) public view returns (uint256) {
uint256 _bx = _x.mul(B);
uint256 _x2 = _x.mul(_x);
uint256 _cx2 = C.mul(_x2);
return A.add(_bx).add(_cx2);
}
// helpers:
function totalOwedValue() public view returns (uint256) {
return totalStaked.add(totalRewards);
}
function owedBalance(address acc) public view returns(uint256) {
return stakes[acc].initial.add(stakes[acc].reward);
}
function votingPowerOf(address acc, uint256 until) external override view returns(uint256) {
if (stakes[acc].payday > until) {
return 0;
}
return owedBalance(acc);
}
// owner functions:
function setLimits(uint256 _minDays, uint256 _maxDays) public onlyOwner {
minDays = _minDays;
maxDays = _maxDays;
}
function setCurve(uint256 _A, uint256 _B, uint256 _C) public onlyOwner {
A = _A;
B = _B;
C = _C;
}
function setEarlyExit(uint256 _earlyExit) public onlyOwner {
require(_earlyExit < 1604334278, "too big");
close(true);
earlyExit = _earlyExit;
}
function close(bool closed) public onlyOwner {
isClosed = closed;
}
function ownerReclaim(uint256 _amount) public onlyOwner {
require(_amount < kp4r.balanceOf(address(this)).sub(totalOwedValue()), "cannot withdraw owed funds");
kp4r.transfer(msg.sender, _amount);
}
function flushETH() public onlyOwner {
uint256 bal = address(this).balance.sub(1);
msg.sender.transfer(bal);
}
}
Read Contract
A 0xf446c1d0 → uint256
B 0x32e7c5bf → uint256
C 0x83dfe5fd → uint256
_quadraticRewardCurveY 0xda8abf24 → uint256
calculateReward 0x13ed0846 → uint256
earlyExit 0xa4dee155 → uint256
kp4r 0x29fef69d → address
maxDays 0x29ad27d7 → uint256
minDays 0xe8f5fb1c → uint256
owedBalance 0x677a68e1 → uint256
owner 0x8da5cb5b → address
stakes 0x16934fc4 → uint256, uint256, uint256, uint256
totalOwedValue 0x5aa9892e → uint256
totalRewards 0x0e15561a → uint256
totalStaked 0x817b1cd2 → uint256
votingPowerOf 0xfcc77c18 → uint256
Write Contract 10 functions
These functions modify contract state and require a wallet transaction to execute.
claim 0x4e71d92d
No parameters
close 0x212c5fea
bool closed
flushETH 0x69f8ef0c
No parameters
ownerReclaim 0x9251a708
uint256 _amount
renounceOwnership 0x715018a6
No parameters
setCurve 0x5eff82db
uint256 _A
uint256 _B
uint256 _C
setEarlyExit 0xb3d9799c
uint256 _earlyExit
setLimits 0xc4590d3f
uint256 _minDays
uint256 _maxDays
stake 0x7b0472f0
uint256 _amount
uint256 _days
transferOwnership 0xf2fde38b
address newOwner
Recent Transactions
No transactions found for this address