Banker Token
ERC20
This contract is an ERC20 token.
Name
Banker Token
Symbol
BNK
Decimals
8
Total Supply
25,000,000,000 BNK
About link
Bankera (BNK) is a cryptocurrency and operates on the Ethereum platform. Bankera has a current supply of 25,000,000,000 with 24,798,912,107.742558 in circulation. The last known price of Bankera is 0.00054319 USD and is up 0.02 over the last 24 hours. It is currently trading on 4 active market(s) with $5,019.84 traded over the last 24 hours. More information can be found at https://bankera.com/.
Stats
Public Functions
34
Event Types
3
Code Size
22,670 bytes
Events (3) keyboard_arrow_up
Structs (2) keyboard_arrow_up
State Variables (14) keyboard_arrow_up
Functions
safeMul keyboard_arrow_up
Requirements help
Source Code
function safeMul(uint256 a, uint256 b) public pure returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
safeDiv keyboard_arrow_up
Source Code
function safeDiv(uint256 a, uint256 b) public pure returns (uint256) {
//assert(a > 0);// Solidity automatically throws when dividing by 0
//assert(b > 0);// Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
safeSub keyboard_arrow_up
safeAdd keyboard_arrow_up
Source Code
function safeAdd(uint256 a, uint256 b) public pure returns (uint256) {
uint256 c = a + b;
assert(c >= a && c >= b);
return c;
}
totalSupply keyboard_arrow_up
balanceOf keyboard_arrow_up
transfer keyboard_arrow_up
Modifiers help
notSelf checks for the following:
whenNotPaused checks for the following:
Source Code
function transfer(address _to, uint256 _value)
public
notSelf(_to)
whenNotPaused
returns (bool success)
{
require(_to != address(0));
//added due to backwards compatibility reasons
bytes memory empty;
if (isContract(_to)) {
return transferToContract(msg.sender, _to, _value, empty);
} else {
return transferToAddress(msg.sender, _to, _value, empty);
}
}
transferFrom keyboard_arrow_up
Requirements help
Source Code
function transferFrom(
address _from,
address _to,
uint256 _value
) public whenNotPaused returns (bool) {
require(_to != address(0));
require(_value <= allowed[_from][msg.sender]);
//added due to backwards compatibility reasons
bytes memory empty;
if (isContract(_to)) {
require(transferToContract(_from, _to, _value, empty));
} else {
require(transferToAddress(_from, _to, _value, empty));
}
allowed[_from][msg.sender] = safeSub(allowed[_from][msg.sender], _value);
return true;
}
approve keyboard_arrow_up
Source Code
function approve(address _spender, uint256 _value)
public
whenNotPaused
returns (bool)
{
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
allowance keyboard_arrow_up
Source Code
function allowance(address _owner, address _spender)
public
view
whenNotPaused
returns (uint256)
{
return allowed[_owner][_spender];
}
transfer keyboard_arrow_up
Modifiers help
whenNotPaused checks for the following:
notSelf checks for the following:
Source Code
function transfer(
address _to,
uint256 _value,
bytes _data
) public whenNotPaused notSelf(_to) returns (bool success) {
require(_to != address(0));
if (isContract(_to)) {
return transferToContract(msg.sender, _to, _value, _data);
} else {
return transferToAddress(msg.sender, _to, _value, _data);
}
}
transfer keyboard_arrow_up
Parameters help
Modifiers help
whenNotPaused checks for the following:
notSelf checks for the following:
Source Code
function transfer(
address _to,
uint256 _value,
bytes _data,
string _custom_fallback
) public whenNotPaused notSelf(_to) returns (bool success) {
require(_to != address(0));
if (isContract(_to)) {
if (accountBalances[msg.sender].addressBalance < _value) {
// Check if the sender has enough
revert();
}
if (
safeAdd(accountBalances[_to].addressBalance, _value) <
accountBalances[_to].addressBalance
) {
// Check for overflows
revert();
}
isNewRound();
subFromAddressBalancesInfo(msg.sender, _value); // Subtract from the sender
addToAddressBalancesInfo(_to, _value); // Add the same to the recipient
assert(
_to.call.value(0)(
bytes4(keccak256(_custom_fallback)),
msg.sender,
_value,
_data
)
);
/* Notify anyone listening that this transfer took place */
Transfer(msg.sender, _to, _value, _data);
Transfer(msg.sender, _to, _value);
return true;
} else {
return transferToAddress(msg.sender, _to, _value, _data);
}
}
constructor keyboard_arrow_up
tokenFallback keyboard_arrow_up
Source Code
function tokenFallback(
address _from,
uint256 _value,
bytes _data
) public view whenNotPaused {
revert();
}
setReward keyboard_arrow_up
Modifiers help
whenNotPaused checks for the following:
onlyRewardManager checks for the following:
Requirements help
Source Code
function setReward(uint64 _roundNumber, uint256 _roundRewardInWei)
public
whenNotPaused
onlyRewardManager
{
isNewRound();
Reward storage rewardInfo = reward[_roundNumber];
//validations
assert(rewardInfo.roundNumber == _roundNumber);
assert(!rewardInfo.isConfigured); //allow just not configured reward configuration
rewardInfo.rewardInWei = _roundRewardInWei;
if (_roundRewardInWei > 0) {
rewardInfo.rewardRate = safeDiv(
_roundRewardInWei,
issuedTokensInRound[_roundNumber]
);
}
rewardInfo.isConfigured = true;
}
changeContractOwner keyboard_arrow_up
Modifiers help
onlyContractOwner checks for the following:
Source Code
function changeContractOwner(address _newContractOwner)
public
onlyContractOwner
{
isNewRound();
if (_newContractOwner != contractOwner) {
contractOwner = _newContractOwner;
} else {
revert();
}
}
changeRewardManager keyboard_arrow_up
Modifiers help
onlyContractOwner checks for the following:
Source Code
function changeRewardManager(address _newRewardManager)
public
onlyContractOwner
{
isNewRound();
if (_newRewardManager != rewardManager) {
rewardManager = _newRewardManager;
} else {
revert();
}
}
changeRoundManager keyboard_arrow_up
Modifiers help
onlyContractOwner checks for the following:
Source Code
function changeRoundManager(address _newRoundManager) public onlyContractOwner {
isNewRound();
if (_newRoundManager != roundManager) {
roundManager = _newRoundManager;
} else {
revert();
}
}
changeIssueManager keyboard_arrow_up
Modifiers help
onlyContractOwner checks for the following:
Source Code
function changeIssueManager(address _newIssueManager) public onlyContractOwner {
isNewRound();
if (_newIssueManager != issueManager) {
issueManager = _newIssueManager;
} else {
revert();
}
}
setBlocksPerRound keyboard_arrow_up
Modifiers help
whenNotPaused checks for the following:
onlyRoundManager checks for the following:
Source Code
function setBlocksPerRound(uint64 _newBlocksPerRound)
public
whenNotPaused
onlyRoundManager
{
blocksPerRound = _newBlocksPerRound;
}
pause keyboard_arrow_up
resume keyboard_arrow_up
getRoundBalance keyboard_arrow_up
isModifiedInRound keyboard_arrow_up
getBalanceModificationRounds keyboard_arrow_up
issueTokens keyboard_arrow_up
Modifiers help
whenNotPaused checks for the following:
onlyIssueManager checks for the following:
Source Code
function issueTokens(address _receiver, uint256 _tokenAmount)
public
whenNotPaused
onlyIssueManager
{
isNewRound();
issue(_receiver, _tokenAmount);
}
withdrawEther keyboard_arrow_up
increaseApproval keyboard_arrow_up
Source Code
function increaseApproval(address _spender, uint256 _addedValue)
public
returns (bool)
{
allowed[msg.sender][_spender] = safeAdd(
allowed[msg.sender][_spender],
_addedValue
);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
decreaseApproval keyboard_arrow_up
Source Code
function decreaseApproval(address _spender, uint256 _subtractedValue)
public
returns (bool)
{
uint256 oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = safeSub(oldValue, _subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
claimReward keyboard_arrow_up
Parameters help
This function has no parameters.
Source Code
function claimReward()
public
whenNotPaused
returns (uint256 rewardAmountInWei)
{
isNewRound();
return claimRewardTillRound(currentRound);
}
claimRewardTillRound keyboard_arrow_up
Source Code
function claimRewardTillRound(uint64 _claimTillRound)
public
whenNotPaused
returns (uint256 rewardAmountInWei)
{
isNewRound();
rewardAmountInWei = calculateClaimableRewardTillRound(
msg.sender,
_claimTillRound
);
accountBalances[msg.sender].claimedRewardTillRound = _claimTillRound;
if (rewardAmountInWei > 0) {
accountBalances[msg.sender].totalClaimedReward = safeAdd(
accountBalances[msg.sender].totalClaimedReward,
rewardAmountInWei
);
msg.sender.transfer(rewardAmountInWei);
}
return rewardAmountInWei;
}
calculateClaimableReward keyboard_arrow_up
calculateClaimableRewardTillRound keyboard_arrow_up
Source Code
function calculateClaimableRewardTillRound(
address _address,
uint64 _claimTillRound
) public constant returns (uint256) {
uint256 rewardAmountInWei = 0;
if (_claimTillRound > currentRound) {
revert();
}
if (currentRound < 1) {
revert();
}
AddressBalanceInfoStructure storage accountBalanceInfo = accountBalances[
_address
];
if (accountBalanceInfo.mapKeys.length == 0) {
revert();
}
uint64 userLastClaimedRewardRound = accountBalanceInfo.claimedRewardTillRound;
if (_claimTillRound < userLastClaimedRewardRound) {
revert();
}
for (
uint64 workRound = userLastClaimedRewardRound;
workRound < _claimTillRound;
workRound++
) {
Reward storage rewardInfo = reward[workRound];
assert(rewardInfo.isConfigured); //don't allow to withdraw reward if affected reward is not configured
if (accountBalanceInfo.wasModifiedInRoundMap[workRound]) {
rewardAmountInWei = safeAdd(
rewardAmountInWei,
safeMul(
accountBalanceInfo.roundBalanceMap[workRound],
rewardInfo.rewardRate
)
);
} else {
uint64 lastBalanceModifiedRound = 0;
for (uint256 i = accountBalanceInfo.mapKeys.length; i > 0; i--) {
uint64 modificationInRound = accountBalanceInfo.mapKeys[i - 1];
if (modificationInRound <= workRound) {
lastBalanceModifiedRound = modificationInRound;
break;
}
}
rewardAmountInWei = safeAdd(
rewardAmountInWei,
safeMul(
accountBalanceInfo.roundBalanceMap[lastBalanceModifiedRound],
rewardInfo.rewardRate
)
);
}
}
return rewardAmountInWei;
}
createRounds keyboard_arrow_up
Source Code
function createRounds(uint256 maxRounds) public {
uint256 blocksAfterLastRound = safeSub(block.number, lastBlockNumberInRound); //current block number - last round block number = blocks after last round
if (blocksAfterLastRound >= blocksPerRound) {
// need to increase reward round if blocks after last round is greater or equal blocks per round
uint256 roundsNeedToCreate = safeDiv(blocksAfterLastRound, blocksPerRound); //calculate how many rounds need to create
if (roundsNeedToCreate > maxRounds) {
roundsNeedToCreate = maxRounds;
}
lastBlockNumberInRound = safeAdd(
lastBlockNumberInRound,
safeMul(roundsNeedToCreate, blocksPerRound)
);
for (uint256 i = 0; i < roundsNeedToCreate; i++) {
updateRoundInformation();
}
}
}
Internal Functions
Internal functions are parts of the contract that can't be used directly, but instead are used by the public functions listed above.
internal BankeraToken.isContract keyboard_arrow_up
Source Code
function isContract(address _address) private view returns (bool is_contract) {
uint256 length;
assembly {
//retrieve the size of the code on target address, this needs assembly
length := extcodesize(_address)
}
return (length > 0);
}
internal BankeraToken.isNewRound keyboard_arrow_up
Parameters help
This function has no parameters.
Source Code
function isNewRound() private {
uint256 blocksAfterLastRound = safeSub(block.number, lastBlockNumberInRound); //current block number - last round block number = blocks after last round
if (blocksAfterLastRound >= blocksPerRound) {
// need to increase reward round if blocks after last round is greater or equal blocks per round
updateRoundsInformation(blocksAfterLastRound);
}
}
internal BankeraToken.updateRoundsInformation keyboard_arrow_up
Source Code
function updateRoundsInformation(uint256 _blocksAfterLastRound) private {
uint256 roundsNeedToCreate = safeDiv(_blocksAfterLastRound, blocksPerRound); //calculate how many rounds need to create
lastBlockNumberInRound = safeAdd(
lastBlockNumberInRound,
safeMul(roundsNeedToCreate, blocksPerRound)
); //calculate last round creation block number
for (uint256 i = 0; i < roundsNeedToCreate; i++) {
updateRoundInformation();
}
}
internal BankeraToken.updateRoundInformation keyboard_arrow_up
Parameters help
This function has no parameters.
Source Code
function updateRoundInformation() private {
issuedTokensInRound[currentRound] = issued;
Reward storage rewardInfo = reward[currentRound];
rewardInfo.roundNumber = currentRound;
currentRound = currentRound + 1;
}
internal BankeraToken.issue keyboard_arrow_up
Source Code
function issue(address _receiver, uint256 _tokenAmount) private {
if (_tokenAmount == 0) {
revert();
}
uint256 newIssuedAmount = safeAdd(_tokenAmount, issued);
if (newIssuedAmount > totalTokens) {
revert();
}
addToAddressBalancesInfo(_receiver, _tokenAmount);
issued = newIssuedAmount;
bytes memory empty;
if (isContract(_receiver)) {
ContractReceiver receiverContract = ContractReceiver(_receiver);
receiverContract.tokenFallback(msg.sender, _tokenAmount, empty);
}
/* Notify anyone listening that this transfer took place */
Transfer(msg.sender, _receiver, _tokenAmount, empty);
Transfer(msg.sender, _receiver, _tokenAmount);
}
internal BankeraToken.addToAddressBalancesInfo keyboard_arrow_up
Source Code
function addToAddressBalancesInfo(address _receiver, uint256 _tokenAmount)
private
{
AddressBalanceInfoStructure storage accountBalance = accountBalances[
_receiver
];
if (!accountBalance.wasModifiedInRoundMap[currentRound]) {
//allow just push one time per round
// If user first time get update balance set user claimed reward round to round before.
if (accountBalance.mapKeys.length == 0 && currentRound > 0) {
accountBalance.claimedRewardTillRound = currentRound;
}
accountBalance.mapKeys.push(currentRound);
accountBalance.wasModifiedInRoundMap[currentRound] = true;
}
accountBalance.addressBalance = safeAdd(
accountBalance.addressBalance,
_tokenAmount
);
accountBalance.roundBalanceMap[currentRound] = accountBalance.addressBalance;
}
internal BankeraToken.subFromAddressBalancesInfo keyboard_arrow_up
Source Code
function subFromAddressBalancesInfo(address _adr, uint256 _tokenAmount)
private
{
AddressBalanceInfoStructure storage accountBalance = accountBalances[_adr];
if (!accountBalance.wasModifiedInRoundMap[currentRound]) {
//allow just push one time per round
accountBalance.mapKeys.push(currentRound);
accountBalance.wasModifiedInRoundMap[currentRound] = true;
}
accountBalance.addressBalance = safeSub(
accountBalance.addressBalance,
_tokenAmount
);
accountBalance.roundBalanceMap[currentRound] = accountBalance.addressBalance;
}
internal BankeraToken.transferToAddress keyboard_arrow_up
Source Code
function transferToAddress(
address _from,
address _to,
uint256 _value,
bytes _data
) private returns (bool success) {
if (accountBalances[_from].addressBalance < _value) {
// Check if the sender has enough
revert();
}
if (
safeAdd(accountBalances[_to].addressBalance, _value) <
accountBalances[_to].addressBalance
) {
// Check for overflows
revert();
}
isNewRound();
subFromAddressBalancesInfo(_from, _value); // Subtract from the sender
addToAddressBalancesInfo(_to, _value); // Add the same to the recipient
/* Notify anyone listening that this transfer took place */
Transfer(_from, _to, _value, _data);
Transfer(_from, _to, _value);
return true;
}
internal BankeraToken.transferToContract keyboard_arrow_up
Source Code
function transferToContract(
address _from,
address _to,
uint256 _value,
bytes _data
) private returns (bool success) {
if (accountBalances[_from].addressBalance < _value) {
// Check if the sender has enough
revert();
}
if (
safeAdd(accountBalances[_to].addressBalance, _value) <
accountBalances[_to].addressBalance
) {
// Check for overflows
revert();
}
isNewRound();
subFromAddressBalancesInfo(_from, _value); // Subtract from the sender
addToAddressBalancesInfo(_to, _value); // Add the same to the recipient
ContractReceiver receiver = ContractReceiver(_to);
receiver.tokenFallback(_from, _value, _data);
/* Notify anyone listening that this transfer took place */
Transfer(_from, _to, _value, _data);
Transfer(_from, _to, _value);
return true;
}