Stats
Public Functions
12
Event Types
4
Code Size
40,388 bytes
Library Use
Uses SafeMath for uint.
Events (4)
keyboard_arrow_up
EmergencyWithdrawn
Event
Parameters
help
Event parameters list the data that an event contains.
user |
address help
The type of this value is address, which means it stores an Ethereum address, such as a wallet address.
|
amount |
uint help
The type of this value is uint, which stands for unsigned integer. Integer means it's a whole number (such as 1, 12, 52) without fractions or decimals. Unsigned means it can't have a negative or positive sign, so it's always a positive number.
|
OwnershipTransferred
Event
Parameters
help
Event parameters list the data that an event contains.
previousOwner |
address help
The type of this value is address, which means it stores an Ethereum address, such as a wallet address.
|
newOwner |
address help
The type of this value is address, which means it stores an Ethereum address, such as a wallet address.
|
Staked
Event
Parameters
help
Event parameters list the data that an event contains.
user |
address help
The type of this value is address, which means it stores an Ethereum address, such as a wallet address.
|
amount |
uint help
The type of this value is uint, which stands for unsigned integer. Integer means it's a whole number (such as 1, 12, 52) without fractions or decimals. Unsigned means it can't have a negative or positive sign, so it's always a positive number.
|
Withdrawn
Event
Parameters
help
Event parameters list the data that an event contains.
user |
address help
The type of this value is address, which means it stores an Ethereum address, such as a wallet address.
|
amount |
uint help
The type of this value is uint, which stands for unsigned integer. Integer means it's a whole number (such as 1, 12, 52) without fractions or decimals. Unsigned means it can't have a negative or positive sign, so it's always a positive number.
|
fee |
uint help
The type of this value is uint, which stands for unsigned integer. Integer means it's a whole number (such as 1, 12, 52) without fractions or decimals. Unsigned means it can't have a negative or positive sign, so it's always a positive number.
|
Structs (1)
keyboard_arrow_up
UserInfo
Struct
Members
staked |
uint help
The type of this value is uint, which stands for unsigned integer. Integer means it's a whole number (such as 1, 12, 52) without fractions or decimals. Unsigned means it can't have a negative or positive sign, so it's always a positive number.
|
stakedTime |
uint help
The type of this value is uint, which stands for unsigned integer. Integer means it's a whole number (such as 1, 12, 52) without fractions or decimals. Unsigned means it can't have a negative or positive sign, so it's always a positive number.
|
Constants (3)
keyboard_arrow_up
MAX_NUM_TIERS
Constant
uint
help
The type of this value is uint, which stands for unsigned integer. Integer means it's a whole number (such as 1, 12, 52) without fractions or decimals. Unsigned means it can't have a negative or positive sign, so it's always a positive number.
10
_NOT_ENTERED
Constant
uint256
help
The type of this value is uint, which stands for unsigned integer. Integer means it's a whole number (such as 1, 12, 52) without fractions or decimals. Unsigned means it can't have a negative or positive sign, so it's always a positive number.
1
_ENTERED
Constant
uint256
help
The type of this value is uint, which stands for unsigned integer. Integer means it's a whole number (such as 1, 12, 52) without fractions or decimals. Unsigned means it can't have a negative or positive sign, so it's always a positive number.
2
State Variables (8)
keyboard_arrow_up
DUCK
Variable
address
help
The type of this value is address, which means it stores an Ethereum address, such as a wallet address.
canEmergencyWithdraw
Variable
bool
help
The type of this value is other.
currentMaxTier
Variable
uint8
help
The type of this value is uint, which stands for unsigned integer. Integer means it's a whole number (such as 1, 12, 52) without fractions or decimals. Unsigned means it can't have a negative or positive sign, so it's always a positive number.
userInfo
Variable
mapping(address => UserInfo)
help
The type of this value is other.
tierPrice
Variable
uint[]
help
The type of this value is uint, which stands for unsigned integer. Integer means it's a whole number (such as 1, 12, 52) without fractions or decimals. Unsigned means it can't have a negative or positive sign, so it's always a positive number. Because the type ends with '[]', that means it is an array. An array is just a list of values, rather than a single value.
withdrawFeePercent
Variable
uint[]
help
The type of this value is uint, which stands for unsigned integer. Integer means it's a whole number (such as 1, 12, 52) without fractions or decimals. Unsigned means it can't have a negative or positive sign, so it's always a positive number. Because the type ends with '[]', that means it is an array. An array is just a list of values, rather than a single value.
_owner
Variable
address
help
The type of this value is address, which means it stores an Ethereum address, such as a wallet address.
_status
Variable
uint256
help
The type of this value is uint, which stands for unsigned integer. Integer means it's a whole number (such as 1, 12, 52) without fractions or decimals. Unsigned means it can't have a negative or positive sign, so it's always a positive number.
owner
keyboard_arrow_up
Parameters
help
Function parameters list what input the function expects from the user. Each
parameter must be given a value.
This function has no parameters.
Properties
Visibility
help
Visibility determines if the function is visible to users and other contracts.
Only functions that are public can be used.
public
Mutability
help
Mutability tells you if a function can make changes on the blockchain.
View means the function can be called by anyone without
a wallet and without submitting a transaction.
view
Source Code
function owner() public view returns (address) {
return _owner;
}
renounceOwnership
keyboard_arrow_up
Parameters
help
Function parameters list what input the function expects from the user. Each
parameter must be given a value.
This function has no parameters.
Properties
Visibility
help
Visibility determines if the function is visible to users and other contracts.
Only functions that are public can be used.
public
Mutability
help
Mutability tells you if a function can make changes on the blockchain.
View means the function can be called by anyone without
a wallet and without submitting a transaction.
transaction
Modifiers
help
Modifiers are additions to a function that typically make various checks before
the function is run.
onlyOwner
checks for the following:
Source Code
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
transferOwnership
keyboard_arrow_up
Parameters
help
Function parameters list what input the function expects from the user. Each
parameter must be given a value.
Name |
Type |
newOwner |
address help
The type of this value is address, which means it stores an Ethereum address, such as a wallet address.
|
Properties
Visibility
help
Visibility determines if the function is visible to users and other contracts.
Only functions that are public can be used.
public
Mutability
help
Mutability tells you if a function can make changes on the blockchain.
View means the function can be called by anyone without
a wallet and without submitting a transaction.
transaction
Modifiers
help
Modifiers are additions to a function that typically make various checks before
the function is run.
onlyOwner
checks for the following:
Requirements
help
Requirements are checks that the function makes when it runs, and give you
insight on what conditions are required for the function to succeed.
Source Code
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
deposit
keyboard_arrow_up
Parameters
help
Function parameters list what input the function expects from the user. Each
parameter must be given a value.
Name |
Type |
_amount |
uint help
The type of this value is uint, which stands for unsigned integer. Integer means it's a whole number (such as 1, 12, 52) without fractions or decimals. Unsigned means it can't have a negative or positive sign, so it's always a positive number.
|
Properties
Visibility
help
Visibility determines if the function is visible to users and other contracts.
Only functions that are public can be used.
public
Mutability
help
Mutability tells you if a function can make changes on the blockchain.
View means the function can be called by anyone without
a wallet and without submitting a transaction.
transaction
Modifiers
help
Modifiers are additions to a function that typically make various checks before
the function is run.
nonReentrant
checks for the following:
Source Code
function deposit(uint256 _amount) external nonReentrant() {
DUCK.transferFrom(msg.sender, address(this), _amount);
userInfo[msg.sender].staked = userInfo[msg.sender].staked.add(_amount);
userInfo[msg.sender].stakedTime = block.timestamp;
emit Staked(msg.sender, _amount);
}
withdraw
keyboard_arrow_up
Parameters
help
Function parameters list what input the function expects from the user. Each
parameter must be given a value.
Name |
Type |
_amount |
uint help
The type of this value is uint, which stands for unsigned integer. Integer means it's a whole number (such as 1, 12, 52) without fractions or decimals. Unsigned means it can't have a negative or positive sign, so it's always a positive number.
|
Properties
Visibility
help
Visibility determines if the function is visible to users and other contracts.
Only functions that are public can be used.
public
Mutability
help
Mutability tells you if a function can make changes on the blockchain.
View means the function can be called by anyone without
a wallet and without submitting a transaction.
transaction
Modifiers
help
Modifiers are additions to a function that typically make various checks before
the function is run.
nonReentrant
checks for the following:
Requirements
help
Requirements are checks that the function makes when it runs, and give you
insight on what conditions are required for the function to succeed.
Source Code
function withdraw(uint256 _amount) external nonReentrant() {
UserInfo storage user = userInfo[msg.sender];
require(user.staked >= _amount, "not enough amount to withdraw");
uint256 toBurn = calculateWithdrawFee(msg.sender, _amount);
user.staked = user.staked.sub(_amount);
if (toBurn > 0) {
DUCK.burn(toBurn);
}
DUCK.transfer(msg.sender, _amount.sub(toBurn));
emit Withdrawn(msg.sender, _amount, toBurn);
}
updateEmergencyWithdrawStatus
keyboard_arrow_up
Parameters
help
Function parameters list what input the function expects from the user. Each
parameter must be given a value.
Name |
Type |
_status |
bool help
The type of this value is other.
|
Properties
Visibility
help
Visibility determines if the function is visible to users and other contracts.
Only functions that are public can be used.
public
Mutability
help
Mutability tells you if a function can make changes on the blockchain.
View means the function can be called by anyone without
a wallet and without submitting a transaction.
transaction
Modifiers
help
Modifiers are additions to a function that typically make various checks before
the function is run.
onlyOwner
checks for the following:
Source Code
function updateEmergencyWithdrawStatus(bool _status) external onlyOwner {
canEmergencyWithdraw = _status;
}
emergencyWithdraw
keyboard_arrow_up
Parameters
help
Function parameters list what input the function expects from the user. Each
parameter must be given a value.
This function has no parameters.
Properties
Visibility
help
Visibility determines if the function is visible to users and other contracts.
Only functions that are public can be used.
public
Mutability
help
Mutability tells you if a function can make changes on the blockchain.
View means the function can be called by anyone without
a wallet and without submitting a transaction.
transaction
Requirements
help
Requirements are checks that the function makes when it runs, and give you
insight on what conditions are required for the function to succeed.
Source Code
function emergencyWithdraw() external {
require(canEmergencyWithdraw, "function disabled");
UserInfo storage user = userInfo[msg.sender];
require(user.staked > 0, "nothing to withdraw");
uint256 _amount = user.staked;
user.staked = 0;
DUCK.transfer(msg.sender, _amount);
emit EmergencyWithdrawn(msg.sender, _amount);
}
updateTier
keyboard_arrow_up
Parameters
help
Function parameters list what input the function expects from the user. Each
parameter must be given a value.
Name |
Type |
_tierId |
uint8 help
The type of this value is uint, which stands for unsigned integer. Integer means it's a whole number (such as 1, 12, 52) without fractions or decimals. Unsigned means it can't have a negative or positive sign, so it's always a positive number.
|
_amount |
uint help
The type of this value is uint, which stands for unsigned integer. Integer means it's a whole number (such as 1, 12, 52) without fractions or decimals. Unsigned means it can't have a negative or positive sign, so it's always a positive number.
|
Properties
Visibility
help
Visibility determines if the function is visible to users and other contracts.
Only functions that are public can be used.
public
Mutability
help
Mutability tells you if a function can make changes on the blockchain.
View means the function can be called by anyone without
a wallet and without submitting a transaction.
transaction
Modifiers
help
Modifiers are additions to a function that typically make various checks before
the function is run.
onlyOwner
checks for the following:
Requirements
help
Requirements are checks that the function makes when it runs, and give you
insight on what conditions are required for the function to succeed.
Source Code
function updateTier(uint8 _tierId, uint256 _amount) external onlyOwner {
require(_tierId > 0 && _tierId <= MAX_NUM_TIERS, "invalid _tierId");
tierPrice[_tierId] = _amount;
if (_tierId > currentMaxTier) {
currentMaxTier = _tierId;
}
}
updateWithdrawFee
keyboard_arrow_up
Parameters
help
Function parameters list what input the function expects from the user. Each
parameter must be given a value.
Name |
Type |
_key |
uint help
The type of this value is uint, which stands for unsigned integer. Integer means it's a whole number (such as 1, 12, 52) without fractions or decimals. Unsigned means it can't have a negative or positive sign, so it's always a positive number.
|
_percent |
uint help
The type of this value is uint, which stands for unsigned integer. Integer means it's a whole number (such as 1, 12, 52) without fractions or decimals. Unsigned means it can't have a negative or positive sign, so it's always a positive number.
|
Properties
Visibility
help
Visibility determines if the function is visible to users and other contracts.
Only functions that are public can be used.
public
Mutability
help
Mutability tells you if a function can make changes on the blockchain.
View means the function can be called by anyone without
a wallet and without submitting a transaction.
transaction
Modifiers
help
Modifiers are additions to a function that typically make various checks before
the function is run.
onlyOwner
checks for the following:
Requirements
help
Requirements are checks that the function makes when it runs, and give you
insight on what conditions are required for the function to succeed.
Source Code
function updateWithdrawFee(uint256 _key, uint256 _percent) external onlyOwner {
require(_percent < 100, "too high percent");
withdrawFeePercent[_key] = _percent;
}
getUserTier
keyboard_arrow_up
Parameters
help
Function parameters list what input the function expects from the user. Each
parameter must be given a value.
Name |
Type |
_userAddress |
address help
The type of this value is address, which means it stores an Ethereum address, such as a wallet address.
|
Properties
Visibility
help
Visibility determines if the function is visible to users and other contracts.
Only functions that are public can be used.
public
Mutability
help
Mutability tells you if a function can make changes on the blockchain.
View means the function can be called by anyone without
a wallet and without submitting a transaction.
view
Source Code
function getUserTier(address _userAddress) external view returns (uint8 res) {
for (uint8 i = 1; i <= MAX_NUM_TIERS; i++) {
if (tierPrice[i] == 0 || userInfo[_userAddress].staked < tierPrice[i]) {
return res;
}
res = i;
}
}
calculateWithdrawFee
keyboard_arrow_up
Parameters
help
Function parameters list what input the function expects from the user. Each
parameter must be given a value.
Name |
Type |
_userAddress |
address help
The type of this value is address, which means it stores an Ethereum address, such as a wallet address.
|
_amount |
uint help
The type of this value is uint, which stands for unsigned integer. Integer means it's a whole number (such as 1, 12, 52) without fractions or decimals. Unsigned means it can't have a negative or positive sign, so it's always a positive number.
|
Properties
Visibility
help
Visibility determines if the function is visible to users and other contracts.
Only functions that are public can be used.
public
Mutability
help
Mutability tells you if a function can make changes on the blockchain.
View means the function can be called by anyone without
a wallet and without submitting a transaction.
view
Requirements
help
Requirements are checks that the function makes when it runs, and give you
insight on what conditions are required for the function to succeed.
Source Code
function calculateWithdrawFee(address _userAddress, uint256 _amount)
public
view
returns (uint256)
{
UserInfo storage user = userInfo[_userAddress];
require(user.staked >= _amount, "not enough amount to withdraw");
if (block.timestamp < user.stakedTime.add(10 days)) {
return _amount.mul(withdrawFeePercent[0]).div(100); //30%
}
if (block.timestamp < user.stakedTime.add(20 days)) {
return _amount.mul(withdrawFeePercent[1]).div(100); //25%
}
if (block.timestamp < user.stakedTime.add(30 days)) {
return _amount.mul(withdrawFeePercent[2]).div(100); //20%
}
if (block.timestamp < user.stakedTime.add(60 days)) {
return _amount.mul(withdrawFeePercent[3]).div(100); //10%
}
if (block.timestamp < user.stakedTime.add(90 days)) {
return _amount.mul(withdrawFeePercent[4]).div(100); //5%
}
return _amount.mul(withdrawFeePercent[5]).div(100);
}
getTiers
keyboard_arrow_up
Parameters
help
Function parameters list what input the function expects from the user. Each
parameter must be given a value.
This function has no parameters.
Properties
Visibility
help
Visibility determines if the function is visible to users and other contracts.
Only functions that are public can be used.
public
Mutability
help
Mutability tells you if a function can make changes on the blockchain.
View means the function can be called by anyone without
a wallet and without submitting a transaction.
view
Source Code
function getTiers() external view returns (uint256[MAX_NUM_TIERS] memory buf) {
for (uint8 i = 1; i < MAX_NUM_TIERS; i++) {
if (tierPrice[i] == 0) {
return buf;
}
buf[i - 1] = tierPrice[i];
}
return buf;
}
Internal functions are parts of the contract that can't be used directly, but instead are used by
the public functions listed above.
internal Ownable.constructor
keyboard_arrow_up
Parameters
help
Function parameters list what input the function expects from the user. Each
parameter must be given a value.
This function has no parameters.
Properties
Visibility
help
Visibility determines if the function is visible to users and other contracts.
Only functions that are public can be used.
internal
Mutability
help
Mutability tells you if a function can make changes on the blockchain.
View means the function can be called by anyone without
a wallet and without submitting a transaction.
transaction
Source Code
constructor() internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
internal Context._msgSender
keyboard_arrow_up
Parameters
help
Function parameters list what input the function expects from the user. Each
parameter must be given a value.
This function has no parameters.
Properties
Visibility
help
Visibility determines if the function is visible to users and other contracts.
Only functions that are public can be used.
internal
Mutability
help
Mutability tells you if a function can make changes on the blockchain.
View means the function can be called by anyone without
a wallet and without submitting a transaction.
view
Source Code
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
internal Context._msgData
keyboard_arrow_up
Parameters
help
Function parameters list what input the function expects from the user. Each
parameter must be given a value.
This function has no parameters.
Properties
Visibility
help
Visibility determines if the function is visible to users and other contracts.
Only functions that are public can be used.
internal
Mutability
help
Mutability tells you if a function can make changes on the blockchain.
View means the function can be called by anyone without
a wallet and without submitting a transaction.
view
Source Code
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;
}
internal ReentrancyGuard.constructor
keyboard_arrow_up
Parameters
help
Function parameters list what input the function expects from the user. Each
parameter must be given a value.
This function has no parameters.
Properties
Visibility
help
Visibility determines if the function is visible to users and other contracts.
Only functions that are public can be used.
internal
Mutability
help
Mutability tells you if a function can make changes on the blockchain.
View means the function can be called by anyone without
a wallet and without submitting a transaction.
transaction
Source Code
constructor() internal {
_status = _NOT_ENTERED;
}