Bonding Token
ERC20
This contract is an ERC20 token.
Name
Bonding Token
Symbol
BONT
Decimals
18
Total Supply
100,000 BONT
About
Stats
Public Functions
19
Event Types
5
Code Size
43,172 bytes
Library Use
Uses SafeMath for uint256.
Events (5) keyboard_arrow_up
Constants (12) keyboard_arrow_up
State Variables (12) keyboard_arrow_up
Functions
totalSupply keyboard_arrow_up
balanceOf keyboard_arrow_up
allowance keyboard_arrow_up
transfer keyboard_arrow_up
Requirements help
Source Code
function transfer(address to, uint256 value) public returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
approve keyboard_arrow_up
Source Code
function approve(address spender, uint256 value) public returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
transferFrom keyboard_arrow_up
Requirements help
Source Code
function transferFrom(
address from,
address to,
uint256 value
) public returns (bool) {
require(value <= _allowed[from][msg.sender]);
_allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
_transfer(from, to, value);
return true;
}
increaseAllowance keyboard_arrow_up
Source Code
function increaseAllowance(address spender, uint256 addedValue)
public
returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (
_allowed[msg.sender][spender].add(addedValue)
);
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
decreaseAllowance keyboard_arrow_up
Source Code
function decreaseAllowance(address spender, uint256 subtractedValue)
public
returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (
_allowed[msg.sender][spender].sub(subtractedValue)
);
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
owner keyboard_arrow_up
isOwner keyboard_arrow_up
renounceOwnership keyboard_arrow_up
transferOwnership keyboard_arrow_up
Modifiers help
onlyOwner checks for the following:
null
Source Code
function transferOwnership(address newOwner) public onlyOwner {
_transferOwnership(newOwner);
}
calculatePurchaseReturn keyboard_arrow_up
Parameters help
Requirements help
Source Code
function calculatePurchaseReturn(
uint256 _supply,
uint256 _reserveBalance,
uint32 _reserveRatio,
uint256 _depositAmount
) public constant returns (uint256) {
// validate input
require(
_supply > 0 &&
_reserveBalance > 0 &&
_reserveRatio > 0 &&
_reserveRatio <= MAX_RESERVE_RATIO
);
// special case for 0 deposit amount
if (_depositAmount == 0) {
return 0;
}
// special case if the ratio = 100%
if (_reserveRatio == MAX_RESERVE_RATIO) {
return _supply.mul(_depositAmount).div(_reserveBalance);
}
uint256 result;
uint8 precision;
uint256 baseN = _depositAmount.add(_reserveBalance);
(result, precision) = power(
baseN,
_reserveBalance,
_reserveRatio,
MAX_RESERVE_RATIO
);
uint256 newTokenSupply = _supply.mul(result) >> precision;
return newTokenSupply - _supply;
}
calculateSaleReturn keyboard_arrow_up
Parameters help
Requirements help
Source Code
function calculateSaleReturn(
uint256 _supply,
uint256 _reserveBalance,
uint32 _reserveRatio,
uint256 _sellAmount
) public constant returns (uint256) {
// validate input
require(
_supply > 0 &&
_reserveBalance > 0 &&
_reserveRatio > 0 &&
_reserveRatio <= MAX_RESERVE_RATIO &&
_sellAmount <= _supply
);
// special case for 0 sell amount
if (_sellAmount == 0) {
return 0;
}
// special case for selling the entire supply
if (_sellAmount == _supply) {
return _reserveBalance;
}
// special case if the ratio = 100%
if (_reserveRatio == MAX_RESERVE_RATIO) {
return _reserveBalance.mul(_sellAmount).div(_supply);
}
uint256 result;
uint8 precision;
uint256 baseD = _supply - _sellAmount;
(result, precision) = power(_supply, baseD, MAX_RESERVE_RATIO, _reserveRatio);
uint256 oldBalance = _reserveBalance.mul(result);
uint256 newBalance = _reserveBalance << precision;
return oldBalance.sub(newBalance).div(result);
}
mint keyboard_arrow_up
burn keyboard_arrow_up
constructor keyboard_arrow_up
calculateContinuousMintReturn keyboard_arrow_up
Requirements help
UNKNOWN VALUE
must be greater than
0
Source Code
function calculateContinuousMintReturn(uint256 _amount)
public
view
returns (uint256 mintAmount)
{
return
calculatePurchaseReturn(
totalSupply(),
reserveBalance,
uint32(reserveRatio),
_amount
);
}
calculateContinuousBurnReturn keyboard_arrow_up
Requirements help
UNKNOWN VALUE
must be greater than
0
Source Code
function calculateContinuousBurnReturn(uint256 _amount)
public
view
returns (uint256 burnAmount)
{
return
calculateSaleReturn(
totalSupply(),
reserveBalance,
uint32(reserveRatio),
_amount
);
}
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 ContinuousToken._continuousMint keyboard_arrow_up
Requirements help
Source Code
function _continuousMint(uint256 _deposit) internal returns (uint256) {
require(_deposit > 0, "Deposit must be non-zero.");
uint256 amount = calculateContinuousMintReturn(_deposit);
_mint(msg.sender, amount);
reserveBalance = reserveBalance.add(_deposit);
emit ContinuousMint(msg.sender, amount, _deposit);
return amount;
}
internal ContinuousToken._continuousBurn keyboard_arrow_up
Requirements help
Source Code
function _continuousBurn(uint256 _amount) internal returns (uint256) {
require(_amount > 0, "Amount must be non-zero.");
require(balanceOf(msg.sender) >= _amount, "Insufficient tokens to burn.");
uint256 reimburseAmount = calculateContinuousBurnReturn(_amount);
reserveBalance = reserveBalance.sub(reimburseAmount);
_burn(msg.sender, _amount);
emit ContinuousBurn(msg.sender, _amount, reimburseAmount);
return reimburseAmount;
}
internal Power.power keyboard_arrow_up
Parameters help
Source Code
function power(
uint256 _baseN,
uint256 _baseD,
uint32 _expN,
uint32 _expD
) internal view returns (uint256, uint8) {
require(_baseN < MAX_NUM, "baseN exceeds max value.");
require(_baseN >= _baseD, "Bases < 1 are not supported.");
uint256 baseLog;
uint256 base = (_baseN * FIXED_1) / _baseD;
if (base < OPT_LOG_MAX_VAL) {
baseLog = optimalLog(base);
} else {
baseLog = generalLog(base);
}
uint256 baseLogTimesExp = (baseLog * _expN) / _expD;
if (baseLogTimesExp < OPT_EXP_MAX_VAL) {
return (optimalExp(baseLogTimesExp), MAX_PRECISION);
} else {
uint8 precision = findPositionInMaxExpArray(baseLogTimesExp);
return (
generalExp(baseLogTimesExp >> (MAX_PRECISION - precision), precision),
precision
);
}
}
internal Power.generalLog keyboard_arrow_up
Source Code
function generalLog(uint256 _x) internal pure returns (uint256) {
uint256 res = 0;
uint256 x = _x;
// If x >= 2, then we compute the integer part of log2(x), which is larger than 0.
if (x >= FIXED_2) {
uint8 count = floorLog2(x / FIXED_1);
x >>= count; // now x < 2
res = count * FIXED_1;
}
// If x > 1, then we compute the fraction part of log2(x), which is larger than 0.
if (x > FIXED_1) {
for (uint8 i = MAX_PRECISION; i > 0; --i) {
x = (x * x) / FIXED_1; // now 1 < x < 4
if (x >= FIXED_2) {
x >>= 1; // now 1 < x < 2
res += ONE << (i - 1);
}
}
}
return (res * LN2_NUMERATOR) / LN2_DENOMINATOR;
}
internal Power.floorLog2 keyboard_arrow_up
Source Code
function floorLog2(uint256 _n) internal pure returns (uint8) {
uint8 res = 0;
uint256 n = _n;
if (n < 256) {
// At most 8 iterations
while (n > 1) {
n >>= 1;
res += 1;
}
} else {
// Exactly 8 iterations
for (uint8 s = 128; s > 0; s >>= 1) {
if (n >= (ONE << s)) {
n >>= s;
res |= s;
}
}
}
return res;
}
internal Power.findPositionInMaxExpArray keyboard_arrow_up
Source Code
function findPositionInMaxExpArray(uint256 _x) internal view returns (uint8) {
uint8 lo = MIN_PRECISION;
uint8 hi = MAX_PRECISION;
while (lo + 1 < hi) {
uint8 mid = (lo + hi) / 2;
if (maxExpArray[mid] >= _x) lo = mid;
else hi = mid;
}
if (maxExpArray[hi] >= _x) return hi;
if (maxExpArray[lo] >= _x) return lo;
assert(false);
return 0;
}
internal Power.generalExp keyboard_arrow_up
Source Code
function generalExp(uint256 _x, uint8 _precision)
internal
pure
returns (uint256)
{
uint256 xi = _x;
uint256 res = 0;
xi = (xi * _x) >> _precision;
res += xi * 0x3442c4e6074a82f1797f72ac0000000; // add x^02 * (33! / 02!)
xi = (xi * _x) >> _precision;
res += xi * 0x116b96f757c380fb287fd0e40000000; // add x^03 * (33! / 03!)
xi = (xi * _x) >> _precision;
res += xi * 0x045ae5bdd5f0e03eca1ff4390000000; // add x^04 * (33! / 04!)
xi = (xi * _x) >> _precision;
res += xi * 0x00defabf91302cd95b9ffda50000000; // add x^05 * (33! / 05!)
xi = (xi * _x) >> _precision;
res += xi * 0x002529ca9832b22439efff9b8000000; // add x^06 * (33! / 06!)
xi = (xi * _x) >> _precision;
res += xi * 0x00054f1cf12bd04e516b6da88000000; // add x^07 * (33! / 07!)
xi = (xi * _x) >> _precision;
res += xi * 0x0000a9e39e257a09ca2d6db51000000; // add x^08 * (33! / 08!)
xi = (xi * _x) >> _precision;
res += xi * 0x000012e066e7b839fa050c309000000; // add x^09 * (33! / 09!)
xi = (xi * _x) >> _precision;
res += xi * 0x000001e33d7d926c329a1ad1a800000; // add x^10 * (33! / 10!)
xi = (xi * _x) >> _precision;
res += xi * 0x0000002bee513bdb4a6b19b5f800000; // add x^11 * (33! / 11!)
xi = (xi * _x) >> _precision;
res += xi * 0x00000003a9316fa79b88eccf2a00000; // add x^12 * (33! / 12!)
xi = (xi * _x) >> _precision;
res += xi * 0x0000000048177ebe1fa812375200000; // add x^13 * (33! / 13!)
xi = (xi * _x) >> _precision;
res += xi * 0x0000000005263fe90242dcbacf00000; // add x^14 * (33! / 14!)
xi = (xi * _x) >> _precision;
res += xi * 0x000000000057e22099c030d94100000; // add x^15 * (33! / 15!)
xi = (xi * _x) >> _precision;
res += xi * 0x0000000000057e22099c030d9410000; // add x^16 * (33! / 16!)
xi = (xi * _x) >> _precision;
res += xi * 0x00000000000052b6b54569976310000; // add x^17 * (33! / 17!)
xi = (xi * _x) >> _precision;
res += xi * 0x00000000000004985f67696bf748000; // add x^18 * (33! / 18!)
xi = (xi * _x) >> _precision;
res += xi * 0x000000000000003dea12ea99e498000; // add x^19 * (33! / 19!)
xi = (xi * _x) >> _precision;
res += xi * 0x00000000000000031880f2214b6e000; // add x^20 * (33! / 20!)
xi = (xi * _x) >> _precision;
res += xi * 0x000000000000000025bcff56eb36000; // add x^21 * (33! / 21!)
xi = (xi * _x) >> _precision;
res += xi * 0x000000000000000001b722e10ab1000; // add x^22 * (33! / 22!)
xi = (xi * _x) >> _precision;
res += xi * 0x0000000000000000001317c70077000; // add x^23 * (33! / 23!)
xi = (xi * _x) >> _precision;
res += xi * 0x00000000000000000000cba84aafa00; // add x^24 * (33! / 24!)
xi = (xi * _x) >> _precision;
res += xi * 0x00000000000000000000082573a0a00; // add x^25 * (33! / 25!)
xi = (xi * _x) >> _precision;
res += xi * 0x00000000000000000000005035ad900; // add x^26 * (33! / 26!)
xi = (xi * _x) >> _precision;
res += xi * 0x000000000000000000000002f881b00; // add x^27 * (33! / 27!)
xi = (xi * _x) >> _precision;
res += xi * 0x0000000000000000000000001b29340; // add x^28 * (33! / 28!)
xi = (xi * _x) >> _precision;
res += xi * 0x00000000000000000000000000efc40; // add x^29 * (33! / 29!)
xi = (xi * _x) >> _precision;
res += xi * 0x0000000000000000000000000007fe0; // add x^30 * (33! / 30!)
xi = (xi * _x) >> _precision;
res += xi * 0x0000000000000000000000000000420; // add x^31 * (33! / 31!)
xi = (xi * _x) >> _precision;
res += xi * 0x0000000000000000000000000000021; // add x^32 * (33! / 32!)
xi = (xi * _x) >> _precision;
res += xi * 0x0000000000000000000000000000001; // add x^33 * (33! / 33!)
return res / 0x688589cc0e9505e2f2fee5580000000 + _x + (ONE << _precision); // divide by 33! and then add x^1 / 1! + x^0 / 0!
}
internal Power.optimalLog keyboard_arrow_up
Source Code
function optimalLog(uint256 x) internal pure returns (uint256) {
uint256 res = 0;
uint256 y;
uint256 z;
uint256 w;
if (x >= 0xd3094c70f034de4b96ff7d5b6f99fcd8) {
res += 0x40000000000000000000000000000000;
x = (x * FIXED_1) / 0xd3094c70f034de4b96ff7d5b6f99fcd8;
}
if (x >= 0xa45af1e1f40c333b3de1db4dd55f29a7) {
res += 0x20000000000000000000000000000000;
x = (x * FIXED_1) / 0xa45af1e1f40c333b3de1db4dd55f29a7;
}
if (x >= 0x910b022db7ae67ce76b441c27035c6a1) {
res += 0x10000000000000000000000000000000;
x = (x * FIXED_1) / 0x910b022db7ae67ce76b441c27035c6a1;
}
if (x >= 0x88415abbe9a76bead8d00cf112e4d4a8) {
res += 0x08000000000000000000000000000000;
x = (x * FIXED_1) / 0x88415abbe9a76bead8d00cf112e4d4a8;
}
if (x >= 0x84102b00893f64c705e841d5d4064bd3) {
res += 0x04000000000000000000000000000000;
x = (x * FIXED_1) / 0x84102b00893f64c705e841d5d4064bd3;
}
if (x >= 0x8204055aaef1c8bd5c3259f4822735a2) {
res += 0x02000000000000000000000000000000;
x = (x * FIXED_1) / 0x8204055aaef1c8bd5c3259f4822735a2;
}
if (x >= 0x810100ab00222d861931c15e39b44e99) {
res += 0x01000000000000000000000000000000;
x = (x * FIXED_1) / 0x810100ab00222d861931c15e39b44e99;
}
if (x >= 0x808040155aabbbe9451521693554f733) {
res += 0x00800000000000000000000000000000;
x = (x * FIXED_1) / 0x808040155aabbbe9451521693554f733;
}
z = y = x - FIXED_1;
w = (y * y) / FIXED_1;
res +=
(z * (0x100000000000000000000000000000000 - y)) /
0x100000000000000000000000000000000;
z = (z * w) / FIXED_1;
res +=
(z * (0x0aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - y)) /
0x200000000000000000000000000000000;
z = (z * w) / FIXED_1;
res +=
(z * (0x099999999999999999999999999999999 - y)) /
0x300000000000000000000000000000000;
z = (z * w) / FIXED_1;
res +=
(z * (0x092492492492492492492492492492492 - y)) /
0x400000000000000000000000000000000;
z = (z * w) / FIXED_1;
res +=
(z * (0x08e38e38e38e38e38e38e38e38e38e38e - y)) /
0x500000000000000000000000000000000;
z = (z * w) / FIXED_1;
res +=
(z * (0x08ba2e8ba2e8ba2e8ba2e8ba2e8ba2e8b - y)) /
0x600000000000000000000000000000000;
z = (z * w) / FIXED_1;
res +=
(z * (0x089d89d89d89d89d89d89d89d89d89d89 - y)) /
0x700000000000000000000000000000000;
z = (z * w) / FIXED_1;
res +=
(z * (0x088888888888888888888888888888888 - y)) /
0x800000000000000000000000000000000;
return res;
}
internal Power.optimalExp keyboard_arrow_up
Source Code
function optimalExp(uint256 x) internal pure returns (uint256) {
uint256 res = 0;
uint256 y;
uint256 z;
z = y = x % 0x10000000000000000000000000000000;
z = (z * y) / FIXED_1;
res += z * 0x10e1b3be415a0000; // add y^02 * (20! / 02!)
z = (z * y) / FIXED_1;
res += z * 0x05a0913f6b1e0000; // add y^03 * (20! / 03!)
z = (z * y) / FIXED_1;
res += z * 0x0168244fdac78000; // add y^04 * (20! / 04!)
z = (z * y) / FIXED_1;
res += z * 0x004807432bc18000; // add y^05 * (20! / 05!)
z = (z * y) / FIXED_1;
res += z * 0x000c0135dca04000; // add y^06 * (20! / 06!)
z = (z * y) / FIXED_1;
res += z * 0x0001b707b1cdc000; // add y^07 * (20! / 07!)
z = (z * y) / FIXED_1;
res += z * 0x000036e0f639b800; // add y^08 * (20! / 08!)
z = (z * y) / FIXED_1;
res += z * 0x00000618fee9f800; // add y^09 * (20! / 09!)
z = (z * y) / FIXED_1;
res += z * 0x0000009c197dcc00; // add y^10 * (20! / 10!)
z = (z * y) / FIXED_1;
res += z * 0x0000000e30dce400; // add y^11 * (20! / 11!)
z = (z * y) / FIXED_1;
res += z * 0x000000012ebd1300; // add y^12 * (20! / 12!)
z = (z * y) / FIXED_1;
res += z * 0x0000000017499f00; // add y^13 * (20! / 13!)
z = (z * y) / FIXED_1;
res += z * 0x0000000001a9d480; // add y^14 * (20! / 14!)
z = (z * y) / FIXED_1;
res += z * 0x00000000001c6380; // add y^15 * (20! / 15!)
z = (z * y) / FIXED_1;
res += z * 0x000000000001c638; // add y^16 * (20! / 16!)
z = (z * y) / FIXED_1;
res += z * 0x0000000000001ab8; // add y^17 * (20! / 17!)
z = (z * y) / FIXED_1;
res += z * 0x000000000000017c; // add y^18 * (20! / 18!)
z = (z * y) / FIXED_1;
res += z * 0x0000000000000014; // add y^19 * (20! / 19!)
z = (z * y) / FIXED_1;
res += z * 0x0000000000000001; // add y^20 * (20! / 20!)
res = res / 0x21c3677c82b40000 + y + FIXED_1; // divide by 20! and then add y^1 / 1! + y^0 / 0!
if ((x & 0x010000000000000000000000000000000) != 0)
res =
(res * 0x1c3d6a24ed82218787d624d3e5eba95f9) /
0x18ebef9eac820ae8682b9793ac6d1e776;
if ((x & 0x020000000000000000000000000000000) != 0)
res =
(res * 0x18ebef9eac820ae8682b9793ac6d1e778) /
0x1368b2fc6f9609fe7aceb46aa619baed4;
if ((x & 0x040000000000000000000000000000000) != 0)
res =
(res * 0x1368b2fc6f9609fe7aceb46aa619baed5) /
0x0bc5ab1b16779be3575bd8f0520a9f21f;
if ((x & 0x080000000000000000000000000000000) != 0)
res =
(res * 0x0bc5ab1b16779be3575bd8f0520a9f21e) /
0x0454aaa8efe072e7f6ddbab84b40a55c9;
if ((x & 0x100000000000000000000000000000000) != 0)
res =
(res * 0x0454aaa8efe072e7f6ddbab84b40a55c5) /
0x00960aadc109e7a3bf4578099615711ea;
if ((x & 0x200000000000000000000000000000000) != 0)
res =
(res * 0x00960aadc109e7a3bf4578099615711d7) /
0x0002bf84208204f5977f9a8cf01fdce3d;
if ((x & 0x400000000000000000000000000000000) != 0)
res =
(res * 0x0002bf84208204f5977f9a8cf01fdc307) /
0x0000003c6ab775dd0b95b4cbee7e65d11;
return res;
}
internal Ownable.constructor keyboard_arrow_up
internal Ownable._transferOwnership keyboard_arrow_up
Source Code
function _transferOwnership(address newOwner) internal {
require(newOwner != address(0));
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
internal ERC20._transfer keyboard_arrow_up
Requirements help
Source Code
function _transfer(
address from,
address to,
uint256 value
) internal {
require(value <= _balances[from]);
require(to != address(0));
_balances[from] = _balances[from].sub(value);
_balances[to] = _balances[to].add(value);
emit Transfer(from, to, value);
}
internal ERC20._mint keyboard_arrow_up
Requirements help
Source Code
function _mint(address account, uint256 value) internal {
require(account != 0);
_totalSupply = _totalSupply.add(value);
_balances[account] = _balances[account].add(value);
emit Transfer(address(0), account, value);
}
internal ERC20._burn keyboard_arrow_up
Requirements help
Source Code
function _burn(address account, uint256 value) internal {
require(account != 0);
require(value <= _balances[account]);
_totalSupply = _totalSupply.sub(value);
_balances[account] = _balances[account].sub(value);
emit Transfer(account, address(0), value);
}
internal ERC20._burnFrom keyboard_arrow_up
Requirements help
Source Code
function _burnFrom(address account, uint256 value) internal {
require(value <= _allowed[account][msg.sender]);
// Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,
// this function needs to emit an event with the updated approval.
_allowed[account][msg.sender] = _allowed[account][msg.sender].sub(value);
_burn(account, value);
}