// Blitz Finance-Theta (BFI-T) Token is 1 of 4 index tokens aims to lay the
// foundation for a novel monetary regime that does not act under a monetary
// authority or require oversight, yet still is able to sustain macroeconomic
// stability.
// BFI-T can be considered as the triggering layer of the ecosystem. Price of
// BFI-T Token sets the parameters of a chain reaction towards each token. Price
// of BFI-T Token determines how BFI-Alpha Token supply will be adjusted dynamically.
// A drop in BFI-Theta Token’s price triggers the burn of a fraction of BFI-Alpha
// Token supply. In addition, BFI-T Token is inherently deflationary where 1% of
// each transaction is burned and deducted from the supply.
pragma solidity ^0.5.13;
interface Callable {
function tokenCallback(address _from, uint256 _tokens, bytes calldata _data) external returns (bool);
}
// Price of BFI-Theta Token has a regulatory role on the supply of BFI-Alpha Token, that is the staking token of
// the Blitz Genesis Index, where a price drop in BFI-Theta Token triggers supply reduction in BFI-Alpha Token as a
// stability measure in BFI-Alpha Token price in order to protect BFI-Alpha Token Stakers. However the burn function
// does not affect the staked supply. BFI-Theta has trading pairs with ETH and all the other tokens in the Blitz Genesis Index.
contract BFI_Theta {
uint256 constant private Constant = 2**64;
uint256 constant private Total_BFIT = 96500000000000000000;
uint256 constant private Burn_Ratio = 1;
uint256 constant private Burn_Threshold = 2;
uint256 constant private Freeze_Size = 1e20;
string constant public name = "BFI-Theta";
string constant public symbol = "BFI-T";
uint8 constant public decimals = 12;
struct User {
bool whitelisted;
uint256 balance;
uint256 frozen;
mapping(address => uint256) allowance;
int256 scaledPayout;
}
struct Info {
uint256 totalSupply;
uint256 totalFrozen;
mapping(address => User) users;
uint256 scaledPayoutPerToken;
address admin;
}
Info private info;
event Transfer(address indexed from, address indexed to, uint256 tokens);
event Approval(address indexed owner, address indexed spender, uint256 tokens);
event Whitelist(address indexed user, bool status);
event Freeze(address indexed owner, uint256 tokens);
event Unfreeze(address indexed owner, uint256 tokens);
event Collect(address indexed owner, uint256 tokens);
event Burn(uint256 tokens);
// BFI-Theta Token’s secondary regulatory task is to adjust the supply of BFI-Beta Token that is
// the staking reward token of the Blitz Genesis Index. If price of BFI-Theta Token drops, it results
// in minting of BFI-Beta Token. Purpose of the connection is to ensure the stability in the staking
// reward price, so to assure stakers about the amount of staking reward they will receive despite
// drastic market volatility. BFI-Beta has a single trading pair that is with BFI-Theta.
constructor() public {
info.admin = msg.sender;
info.totalSupply = Total_BFIT;
info.users[msg.sender].balance = Total_BFIT;
emit Transfer(address(0x0), msg.sender, Total_BFIT);
whitelist(msg.sender, true);
}
function freeze(uint256 _tokens) external {
_freeze(_tokens);
}
function unfreeze(uint256 _tokens) external {
_unfreeze(_tokens);
}
function collect() external returns (uint256) {
uint256 _dividends = dividendsOf(msg.sender);
require(_dividends >= 0);
info.users[msg.sender].scaledPayout += int256(_dividends * Constant);
info.users[msg.sender].balance += _dividends;
emit Transfer(address(this), msg.sender, _dividends);
emit Collect(msg.sender, _dividends);
return _dividends;
}
function burn(uint256 _tokens) external {
require(balanceOf(msg.sender) >= _tokens);
info.users[msg.sender].balance -= _tokens;
uint256 _burnedAmount = _tokens;
if (info.totalFrozen > 0) {
_burnedAmount /= 2;
info.scaledPayoutPerToken += _burnedAmount * Constant / info.totalFrozen;
emit Transfer(msg.sender, address(this), _burnedAmount);
}
info.totalSupply -= _burnedAmount;
emit Transfer(msg.sender, address(0x0), _burnedAmount);
emit Burn(_burnedAmount);
}
function distribute(uint256 _tokens) external {
require(info.totalFrozen > 0);
require(balanceOf(msg.sender) >= _tokens);
info.users[msg.sender].balance -= _tokens;
info.scaledPayoutPerToken += _tokens * Constant / info.totalFrozen;
emit Transfer(msg.sender, address(this), _tokens);
}
function transfer(address _to, uint256 _tokens) external returns (bool) {
_transfer(msg.sender, _to, _tokens);
return true;
}
function approve(address _spender, uint256 _tokens) external returns (bool) {
info.users[msg.sender].allowance[_spender] = _tokens;
emit Approval(msg.sender, _spender, _tokens);
return true;
}
function transferFrom(address _from, address _to, uint256 _tokens) external returns (bool) {
require(info.users[_from].allowance[msg.sender] >= _tokens);
info.users[_from].allowance[msg.sender] -= _tokens;
_transfer(_from, _to, _tokens);
return true;
}
function transferAndCall(address _to, uint256 _tokens, bytes calldata _data) external returns (bool) {
uint256 _transferred = _transfer(msg.sender, _to, _tokens);
uint32 _size;
assembly {
_size := extcodesize(_to)
}
if (_size > 0) {
require(Callable(_to).tokenCallback(msg.sender, _transferred, _data));
}
return true;
}
function bulkTransfer(address[] calldata _receivers, uint256[] calldata _amounts) external {
require(_receivers.length == _amounts.length);
for (uint256 i = 0; i < _receivers.length; i++) {
_transfer(msg.sender, _receivers[i], _amounts[i]);
}
}
function whitelist(address _user, bool _status) public {
require(msg.sender == info.admin);
info.users[_user].whitelisted = _status;
emit Whitelist(_user, _status);
}
function totalSupply() public view returns (uint256) {
return info.totalSupply;
}
function totalFrozen() public view returns (uint256) {
return info.totalFrozen;
}
function balanceOf(address _user) public view returns (uint256) {
return info.users[_user].balance - frozenOf(_user);
}
function frozenOf(address _user) public view returns (uint256) {
return info.users[_user].frozen;
}
function dividendsOf(address _user) public view returns (uint256) {
return uint256(int256(info.scaledPayoutPerToken * info.users[_user].frozen) - info.users[_user].scaledPayout) / Constant;
}
function allowance(address _user, address _spender) public view returns (uint256) {
return info.users[_user].allowance[_spender];
}
function isWhitelisted(address _user) public view returns (bool) {
return info.users[_user].whitelisted;
}
function allInfoFor(address _user) public view returns (uint256 totalTokenSupply, uint256 totalTokensFrozen, uint256 userBalance, uint256 userFrozen, uint256 userDividends) {
return (totalSupply(), totalFrozen(), balanceOf(_user), frozenOf(_user), dividendsOf(_user));
}
function _transfer(address _from, address _to, uint256 _tokens) internal returns (uint256) {
require(balanceOf(_from) >= _tokens);
info.users[_from].balance -= _tokens;
uint256 _burnedAmount = _tokens * Burn_Ratio / 100;
if (totalSupply() - _burnedAmount < Total_BFIT * Burn_Threshold / 100 || isWhitelisted(_from)) {
_burnedAmount = 0;
}
uint256 _transferred = _tokens - _burnedAmount;
info.users[_to].balance += _transferred;
emit Transfer(_from, _to, _transferred);
if (_burnedAmount > 0) {
if (info.totalFrozen > 0) {
_burnedAmount /= 2;
info.scaledPayoutPerToken += _burnedAmount * Constant / info.totalFrozen;
emit Transfer(_from, address(this), _burnedAmount);
}
info.totalSupply -= _burnedAmount;
emit Transfer(_from, address(0x0), _burnedAmount);
emit Burn(_burnedAmount);
}
return _transferred;
}
function _freeze(uint256 _amount) internal {
require(balanceOf(msg.sender) >= _amount);
require(frozenOf(msg.sender) + _amount >= Freeze_Size);
info.totalFrozen += _amount;
info.users[msg.sender].frozen += _amount;
info.users[msg.sender].scaledPayout += int256(_amount * info.scaledPayoutPerToken);
emit Transfer(msg.sender, address(this), _amount);
emit Freeze(msg.sender, _amount);
}
function _unfreeze(uint256 _amount) internal {
require(frozenOf(msg.sender) >= _amount);
uint256 _burnedAmount = _amount * Burn_Ratio / 100;
info.scaledPayoutPerToken += _burnedAmount * Constant / info.totalFrozen;
info.totalFrozen -= _amount;
info.users[msg.sender].balance -= _burnedAmount;
info.users[msg.sender].frozen -= _amount;
info.users[msg.sender].scaledPayout -= int256(_amount * info.scaledPayoutPerToken);
emit Transfer(address(this), msg.sender, _amount - _burnedAmount);
emit Unfreeze(msg.sender, _amount);
}
}
{
"compilationTarget": {
"BFI_Theta.sol": "BFI_Theta"
},
"evmVersion": "petersburg",
"libraries": {},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}
[{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokens","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"tokens","type":"uint256"}],"name":"Burn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokens","type":"uint256"}],"name":"Collect","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokens","type":"uint256"}],"name":"Freeze","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokens","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokens","type":"uint256"}],"name":"Unfreeze","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"bool","name":"status","type":"bool"}],"name":"Whitelist","type":"event"},{"constant":true,"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"allInfoFor","outputs":[{"internalType":"uint256","name":"totalTokenSupply","type":"uint256"},{"internalType":"uint256","name":"totalTokensFrozen","type":"uint256"},{"internalType":"uint256","name":"userBalance","type":"uint256"},{"internalType":"uint256","name":"userFrozen","type":"uint256"},{"internalType":"uint256","name":"userDividends","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"address","name":"_spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"_tokens","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address[]","name":"_receivers","type":"address[]"},{"internalType":"uint256[]","name":"_amounts","type":"uint256[]"}],"name":"bulkTransfer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_tokens","type":"uint256"}],"name":"burn","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"collect","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_tokens","type":"uint256"}],"name":"distribute","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"dividendsOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_tokens","type":"uint256"}],"name":"freeze","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"frozenOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"isWhitelisted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalFrozen","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_tokens","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_tokens","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"transferAndCall","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_tokens","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_tokens","type":"uint256"}],"name":"unfreeze","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"bool","name":"_status","type":"bool"}],"name":"whitelist","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]