This commit is contained in:
2022-09-22 13:05:04 +03:00
parent efadddcde6
commit b8793df4f8
15 changed files with 342 additions and 175 deletions

14
contracts/ERC.sol Normal file
View File

@@ -0,0 +1,14 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity ^0.8.15;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract ERC is ERC20 {
constructor(string memory name, string memory symbol) ERC20(name, symbol) {
}
function mint(address to, uint256 amount) public {
_mint(to, amount);
}
}

View File

@@ -18,6 +18,8 @@ contract Marketplace is Initializable {
address payable seller;
uint256 tokenId;
uint256 price;
bool bought;
bool cancelled;
}
mapping(uint256 => Sale) saleIdToSale;
@@ -48,22 +50,22 @@ contract Marketplace is Initializable {
//modifiers
modifier isExistingSale(uint256 saleId) {
require(saleIdToSale[saleId].price != 0);
require(saleIdToSale[saleId].price != 0, "!exists");
_;
}
modifier onlySaleOwner(uint256 saleId) {
require(saleIdToSale[saleId].seller == msg.sender);
require(saleIdToSale[saleId].seller == msg.sender, "!seller");
_;
}
modifier onlyValidPrice(uint256 price) {
require(price > 0);
require(price > 0, "!price");
_;
}
modifier onlyAdmin() {
require(treasury.isAdmin(msg.sender));
require(treasury.isAdmin(msg.sender), "!admin");
_;
}
@@ -105,7 +107,7 @@ contract Marketplace is Initializable {
onlyValidPrice(price)
{
currentSaleId++;
Sale memory sale = saleIdToSale[currentSaleId];
Sale storage sale = saleIdToSale[currentSaleId];
sale.seller = payable(msg.sender);
sale.price = price;
sale.tokenId = tokenId;
@@ -114,9 +116,11 @@ contract Marketplace is Initializable {
}
function cancelSale(uint256 saleId) public onlySaleOwner(saleId) {
Sale memory sale = saleIdToSale[saleId];
Sale storage sale = saleIdToSale[saleId];
require(!sale.bought, "bought");
require(!sale.cancelled, "cancelled");
nft.transferFrom(address(this), msg.sender, sale.tokenId);
delete sale;
sale.cancelled = true;
emit SaleCancelled(saleId);
}
@@ -126,22 +130,27 @@ contract Marketplace is Initializable {
onlyValidPrice(price)
isExistingSale(saleId)
{
Sale memory sale = saleIdToSale[saleId];
Sale storage sale = saleIdToSale[saleId];
require(!sale.bought, "bought");
require(!sale.cancelled, "cancelled");
uint256 oldPrice = sale.price;
sale.price = price;
emit SaleUpdated(saleId, oldPrice, price);
}
function buyToken(uint256 saleId) public isExistingSale(saleId) {
Sale memory sale = saleIdToSale[saleId];
Sale storage sale = saleIdToSale[saleId];
require(!sale.bought, "bought");
require(!sale.cancelled, "cancelled");
nft.transferFrom(address(this), msg.sender, sale.tokenId);
_distributeFunds(sale.price, sale.seller);
sale.bought = true;
emit TokenBought(saleId, msg.sender, sale.tokenId, sale.price);
}
//admin functions
function changeFees(uint256 _fee) public onlyAdmin {
require(_fee > 0 && _fee < 2000);
require(_fee > 0 && _fee < 2000, "wrong arg");
emit FeesChanged(msg.sender, fee, _fee);
fee = _fee;
}

View File

@@ -7,8 +7,9 @@ import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeab
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/Base64Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "./interfaces/ITreasury.sol";
import "./interfaces/IPancake.sol";
import "./interfaces/IPancakeSwapPair.sol";
import "./mixins/signature-control.sol";
contract NFT is ERC721EnumerableUpgradeable, SignatureControl {
@@ -16,7 +17,7 @@ contract NFT is ERC721EnumerableUpgradeable, SignatureControl {
using SafeERC20Upgradeable for IERC20Upgradeable;
//variables
bool pause = true;
bool pause;
uint256 nonce;
ITreasury treasury;
IERC20Upgradeable BoM;
@@ -40,7 +41,8 @@ contract NFT is ERC721EnumerableUpgradeable, SignatureControl {
//mint prices, caps, addresses of reward tokens(shiba,floki,doggy,doge)
uint256[4] prices = [
300 * 10**18,
.001 ether,
// 300 * 10**18,
250 * 10**18,
200 * 10**18,
250 * 10**18
@@ -51,9 +53,9 @@ contract NFT is ERC721EnumerableUpgradeable, SignatureControl {
uint256[4] nftCaps = [1000, 1500, 2000, 1500];
address[4] public rewardTokens = [
0x0000000000000000000000000000000000000000,
0x0000000000000000000000000000000000000000,
0x0000000000000000000000000000000000000000,
0x0000000000000000000000000000000000000000
0x0000000000000000000000000000000000000001,
0x0000000000000000000000000000000000000002,
0x0000000000000000000000000000000000000003
];
mapping(address => uint256) addressToType;
mapping(address => uint256) totalRatesForType;
@@ -123,43 +125,43 @@ contract NFT is ERC721EnumerableUpgradeable, SignatureControl {
//modifiers
modifier onlyAdmin() {
require(treasury.isAdmin(msg.sender));
require(treasury.isAdmin(msg.sender), "!admin");
_;
}
modifier isUnpaused() {
require(!pause);
require(!pause, "paused");
_;
}
modifier isValidWhitelistMint(uint256 amount, uint256 tokenType) {
require(isPresale);
require(isWhitelisted[msg.sender]);
require(isPresale, "!presale");
require(isWhitelisted[msg.sender], "!whitelisted");
require(
mintedOnWhitelist[msg.sender] + amount <=
maxMintPerAddressDuringWhitelist
maxMintPerAddressDuringWhitelist, "maxMint exceeded"
);
require(tokenType <= 3);
require(tokenType <= 3, "!tokenType");
require(
whitelistMintCapOfToken[tokenType] + amount <=
whitelistMintCapPerType
whitelistMintCapPerType, "mintCap exceeded"
);
_;
}
modifier isValidMint(uint256 amount, uint256 tokenType) {
require(!isPresale);
require(tokenType <= 3);
require(!isPresale, "(mint) presale");
require(tokenType <= 3, "!tokenType");
require(mintCapOfToken[tokenType] + amount <= nftCaps[tokenType]);
_;
}
modifier isValidCombine(uint256[] memory tokenIds) {
require(tokenIds.length > 1 && tokenIds.length <= 4);
require(tokenIds.length > 1 && tokenIds.length <= 4, "wrong tokenIds length");
bool hasDupes;
for (uint256 i = 0; i < tokenIds.length; i++) {
require(ownerOf(tokenIds[i]) == msg.sender);
require(tokenIdToType[tokenIds[i]].length == 1);
require(ownerOf(tokenIds[i]) == msg.sender, "!owner");
require(tokenIdToType[tokenIds[i]].length == 1, "!tokenIdToType");
for (uint256 index = i; index < tokenIds.length; index++) {
if (
index != i &&
@@ -169,7 +171,7 @@ contract NFT is ERC721EnumerableUpgradeable, SignatureControl {
hasDupes = true;
}
}
require(!hasDupes);
require(!hasDupes, "dupes");
}
_;
}
@@ -230,9 +232,10 @@ contract NFT is ERC721EnumerableUpgradeable, SignatureControl {
{
for (uint256 i = 0; i < amount; i++) {
supply++;
_mint(msg.sender, supply);
tokenIdToInfo[supply].tokens.push(rewardTokens[tokenType]);
tokenIdToType[supply].push(rewardTokens[tokenType]);
uint256 rate = createTokenStats(supply);
_mint(msg.sender, supply);
emit TokenMinted(msg.sender, supply, rewardTokens[tokenType], rate);
}
mintedOnWhitelist[msg.sender] += amount;
@@ -249,9 +252,10 @@ contract NFT is ERC721EnumerableUpgradeable, SignatureControl {
{
for (uint256 i = 0; i < amount; i++) {
supply++;
_mint(msg.sender, supply);
tokenIdToInfo[supply].tokens.push(rewardTokens[tokenType]);
tokenIdToType[supply].push(rewardTokens[tokenType]);
uint256 rate = createTokenStats(supply);
_mint(msg.sender, supply);
emit TokenMinted(msg.sender, supply, rewardTokens[tokenType], rate);
}
mintCapOfToken[tokenType] += amount;
@@ -264,15 +268,15 @@ contract NFT is ERC721EnumerableUpgradeable, SignatureControl {
payable
isUnpaused
{
require(msg.value == 0.05 ether);
require(msg.value == 0.05 ether, "!value");
supply++;
uint256 price;
_mint(msg.sender, supply);
address[] memory tokens = new address[](tokenIds.length);
for (uint256 i = 0; i < tokenIds.length; i++) {
TokenInfo storage token = tokenIdToInfo[tokenIds[i]];
TokenInfo memory token = tokenIdToInfo[tokenIds[i]];
address intermediateStorageForToken = tokenIdToType[tokenIds[i]][0];
tokenIdToInfo[supply].tokens.push(intermediateStorageForToken);
tokenIdToType[supply].push(intermediateStorageForToken);
tokens[i] = intermediateStorageForToken;
_burn(tokenIds[i]);
price += tokenToPrices[tokenIdToType[tokenIds[i]][0]] / 4;
@@ -281,7 +285,9 @@ contract NFT is ERC721EnumerableUpgradeable, SignatureControl {
}
}
uint256 rate = createTokenStats(supply);
_mint(msg.sender, supply);
emit TokenCombined(msg.sender, tokenIds, tokens, supply, rate);
//TBD: calculate price with usd in mind
_distributeFunds(price);
}
@@ -455,7 +461,7 @@ contract NFT is ERC721EnumerableUpgradeable, SignatureControl {
address path0,
address path1
) internal view returns (uint256[] memory) {
address[] memory path;
address[] memory path = new address[](2);
path[0] = path0;
path[1] = path1;
return swapRouter.getAmountsIn(price, path);
@@ -467,7 +473,8 @@ contract NFT is ERC721EnumerableUpgradeable, SignatureControl {
address path0,
address path1
) internal returns (uint256[] memory) {
address[] memory path;
IERC20(path0).approve(address(swapRouter), 2**256-1);
address[] memory path = new address[](2);
path[0] = path0;
path[1] = path1;
return
@@ -606,10 +613,11 @@ contract NFT is ERC721EnumerableUpgradeable, SignatureControl {
function _addToPool(uint256 amount) internal {
uint256 lotteryPoolAmount = amount / 10;
address[] memory path;
address[] memory path = new address[](2);
path[0] = address(BoM);
path[1] = address(BUSD);
IERC20(address(BoM)).approve(address(swapRouter), amount);
uint256 swappedFor = swapRouter.swapExactTokensForTokens(
lotteryPoolAmount, // 10% to lottery
0,
@@ -637,38 +645,38 @@ contract NFT is ERC721EnumerableUpgradeable, SignatureControl {
emit RewardPoolRaised(swappedFor);
}
function _afterTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual override {
super._afterTokenTransfer(from, to, tokenId);
TokenInfo memory info = tokenIdToInfo[tokenId];
if (from != address(0)) {
if (ERC721Upgradeable.balanceOf(from) == 0) {
_holders.remove(from);
}
if (info.tokens.length > 1) {
totalShares[4] -= info.rate;
accountShares[from][4] -= info.rate;
} else {
uint256 idx = addressToType[info.tokens[0]];
totalShares[idx] -= info.rate;
accountShares[from][idx] -= info.rate;
}
}
if (to != address(0)) {
_holders.add(to);
if (info.tokens.length > 1) {
totalShares[4] += info.rate;
accountShares[to][4] += info.rate;
} else {
uint256 idx = addressToType[info.tokens[0]];
totalShares[idx] += info.rate;
accountShares[from][idx] += info.rate;
}
}
}
// function _afterTokenTransfer(
// address from,
// address to,
// uint256 tokenId
// ) internal virtual override {
// super._afterTokenTransfer(from, to, tokenId);
// TokenInfo memory info = tokenIdToInfo[tokenId];
// if (from != address(0)) {
// if (ERC721Upgradeable.balanceOf(from) == 0) {
// _holders.remove(from);
// }
// if (info.tokens.length > 1) {
// totalShares[4] -= info.rate;
// accountShares[from][4] -= info.rate;
// } else {
// uint256 idx = addressToType[info.tokens[0]];
// totalShares[idx] -= info.rate;
// accountShares[from][idx] -= info.rate;
// }
// }
// if (to != address(0)) {
// _holders.add(to);
// if (info.tokens.length > 1) {
//// totalShares[4] += info.rate;
//// accountShares[to][4] += info.rate;
// } else {
//// uint256 idx = addressToType[info.tokens[0]];
//// totalShares[idx] += info.rate;
//// accountShares[to][idx] += info.rate;
// }
// }
// }
function pendingReward(uint256 idx, address account) public view returns (uint256) {
return accountShares[account][idx] + (_rewardPerShare(idx) - accountRewardsPerTokenPaid[account][idx]) / 1e18 + accountRewards[account][idx];
@@ -697,7 +705,8 @@ contract NFT is ERC721EnumerableUpgradeable, SignatureControl {
require(reward > 0, "nothing to claim");
accountRewards[msg.sender][idx] = 0;
address[] memory path;
IERC20(address(WETH)).approve(address(swapRouter), reward);
address[] memory path = new address[](2);
path[0] = address(WETH);
path[1] = rewardTokens[idx];
uint256 swappedFor = swapRouter.swapExactTokensForTokens(
@@ -708,4 +717,13 @@ contract NFT is ERC721EnumerableUpgradeable, SignatureControl {
block.timestamp
)[0];
}
function togglePause() external onlyAdmin {
pause = !pause;
}
function finishPresale() external onlyAdmin {
require(isPresale, "!presale");
isPresale = false;
}
}

View File

@@ -25,4 +25,4 @@ contract Treasury is RoleControl {
emit TokenWithdraw(to, address(token), amount);
}
}
}

View File

@@ -3,15 +3,12 @@
pragma solidity ^0.8.15;
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import "./interfaces/IPancake.sol";
import "./interfaces/IPancakeSwapPair.sol";
import "./mixins/SafeMathInt.sol";
import "./interfaces/ITreasury.sol";
import "./interfaces/INFT.sol";
contract BabiesOfMars is ERC20Upgradeable {
using SafeMathUpgradeable for uint256;
using SafeMathInt for int256;
event LogRebase(uint256 indexed epoch, uint256 totalSupply);
string public _name = "BabiesOfMars";
@@ -22,12 +19,12 @@ contract BabiesOfMars is ERC20Upgradeable {
mapping(address => bool) _isFeeExempt;
modifier validRecipient(address to) {
require(to != address(0x0));
require(to != address(0x0), "!recipient");
_;
}
modifier onlyAdmin() {
require(treasury.isAdmin(msg.sender));
require(treasury.isAdmin(msg.sender), "!admin");
_;
}
@@ -62,10 +59,9 @@ contract BabiesOfMars is ERC20Upgradeable {
inSwap = false;
}
uint256 private constant TOTAL_GONS =
MAX_UINT256 - (MAX_UINT256 % INITIAL_FRAGMENTS_SUPPLY);
uint256 private constant INITIAL_FRAGMENTS_SUPPLY = 50_000 * 10**DECIMALS;
uint256 private constant INITIAL_FRAGMENTS_SUPPLY = 150_000 * 10**DECIMALS; // should be 50
uint256 private constant MAX_SUPPLY = 500_000 * 10**DECIMALS;
uint256 private constant TOTAL_GONS = MAX_UINT256 - (MAX_UINT256 % INITIAL_FRAGMENTS_SUPPLY);
bool public _autoRebase;
bool public _autoAddLiquidity;
@@ -87,16 +83,25 @@ contract BabiesOfMars is ERC20Upgradeable {
ITreasury _treasury,
address _redTrustWallet,
INFT _nftRewardPool,
address _redFurnace
address _redFurnace,
address _BUSD
) public initializer {
__ERC20_init(_name, _symbol);
router = IPancakeSwapRouter(_router);
address factoryAddress = router.factory();
IPancakeSwapFactory factory = IPancakeSwapFactory(factoryAddress);
pair = IPancakeSwapPair(
IPancakeSwapFactory(router.factory()).createPair(
factory.createPair(
router.WETH(),
address(this)
)
);
IPancakeSwapPair(
factory.createPair(
_BUSD,
address(this)
)
);
autoLiquidityReceiver = DEAD;
treasury = _treasury;
@@ -108,8 +113,10 @@ contract BabiesOfMars is ERC20Upgradeable {
pairContract = IPancakeSwapPair(pair);
_totalSupply = INITIAL_FRAGMENTS_SUPPLY;
_gonBalances[_owner] = TOTAL_GONS;
_gonsPerFragment = TOTAL_GONS.div(_totalSupply);
_gonBalances[_owner] = TOTAL_GONS / 3;
_gonBalances[address(_nftRewardPool)] = TOTAL_GONS / 3; // TODO: remove after test
_gonBalances[0x62F650c0eE84E3a1998A2EEe042a12D9E9728843] = TOTAL_GONS / 3; // TODO: remove after test
_gonsPerFragment = TOTAL_GONS / _totalSupply;
_initRebaseStartTime = block.timestamp;
_lastRebasedTime = block.timestamp;
_autoRebase = false;
@@ -130,8 +137,8 @@ contract BabiesOfMars is ERC20Upgradeable {
uint256 rebaseRate;
uint256 deltaTimeFromInit = block.timestamp - _initRebaseStartTime;
uint256 deltaTime = block.timestamp - _lastRebasedTime;
uint256 times = deltaTime.div(rebaseInterval);
uint256 epoch = times.mul(15);
uint256 times = deltaTime / rebaseInterval;
uint256 epoch = times * 15;
if (deltaTimeFromInit < (365 days)) {
rebaseRate = 2731;
@@ -144,13 +151,11 @@ contract BabiesOfMars is ERC20Upgradeable {
}
for (uint256 i = 0; i < times; i++) {
_totalSupply = _totalSupply
.mul((10**RATE_DECIMALS).add(rebaseRate))
.div(10**RATE_DECIMALS);
_totalSupply = _totalSupply * (10**RATE_DECIMALS + rebaseRate) / 10**RATE_DECIMALS;
}
_gonsPerFragment = TOTAL_GONS.div(_totalSupply);
_lastRebasedTime = _lastRebasedTime.add(times.mul(rebaseInterval));
_gonsPerFragment = TOTAL_GONS / _totalSupply;
_lastRebasedTime += times * rebaseInterval;
pairContract.sync();
@@ -172,10 +177,9 @@ contract BabiesOfMars is ERC20Upgradeable {
address to,
uint256 value
) public override validRecipient(to) returns (bool) {
if (_allowedFragments[from][msg.sender] != type(uint256).max) {
_allowedFragments[from][msg.sender] = _allowedFragments[from][
msg.sender
].sub(value, "Insufficient Allowance");
if (from != msg.sender && _allowedFragments[from][msg.sender] != type(uint256).max) {
require(value <= _allowedFragments[from][msg.sender], "Insufficient Allowance");
_allowedFragments[from][msg.sender] -= (value);
}
_transferFrom(from, to, value);
return true;
@@ -186,9 +190,9 @@ contract BabiesOfMars is ERC20Upgradeable {
address to,
uint256 amount
) internal returns (bool) {
uint256 gonAmount = amount.mul(_gonsPerFragment);
_gonBalances[from] = _gonBalances[from].sub(gonAmount);
_gonBalances[to] = _gonBalances[to].add(gonAmount);
uint256 gonAmount = amount * _gonsPerFragment;
_gonBalances[from] -= gonAmount;
_gonBalances[to] += gonAmount;
return true;
}
@@ -210,19 +214,17 @@ contract BabiesOfMars is ERC20Upgradeable {
addLiquidity();
}
uint256 gonAmount = amount.mul(_gonsPerFragment);
_gonBalances[sender] = _gonBalances[sender].sub(gonAmount);
uint256 gonAmount = amount * _gonsPerFragment;
_gonBalances[sender] -= gonAmount;
uint256 gonAmountReceived = shouldTakeFee(sender, recipient)
? takeFee(sender, recipient, gonAmount)
: gonAmount;
_gonBalances[recipient] = _gonBalances[recipient].add(
gonAmountReceived
);
_gonBalances[recipient] += gonAmountReceived;
emit Transfer(
sender,
recipient,
gonAmountReceived.div(_gonsPerFragment)
gonAmountReceived / _gonsPerFragment
);
return true;
}
@@ -240,7 +242,7 @@ contract BabiesOfMars is ERC20Upgradeable {
if (rdStatus == true) {
if (block.timestamp - defenderTimer > 1 hours) {
rdStatus = false;
defenderTimer = block.timestamp.sub(1);
defenderTimer = block.timestamp - (1);
accumulatedImpact = 1;
}
}
@@ -252,7 +254,7 @@ contract BabiesOfMars is ERC20Upgradeable {
if (recipient == address(pair)) {
if (block.timestamp - defenderTimer < 1 hours) {
// add impact to accumulator
accumulatedImpact = accumulatedImpact.add(impact);
accumulatedImpact += impact;
} else {
// window has passed, reset accumulator
accumulatedImpact = impact;
@@ -282,35 +284,27 @@ contract BabiesOfMars is ERC20Upgradeable {
}
}
return gonAmount.sub(feeAmount);
return gonAmount - (feeAmount);
}
function distributeFees(uint256 liquidityFee, uint256 rtfFee, uint256 rtFee, uint256 rfFee, uint256 rewardFee, uint256 gonAmount) private returns (uint256) {
uint256 _totalFee = liquidityFee.add(rtfFee);
_totalFee = _totalFee.add(rtFee);
_totalFee = _totalFee.add(rfFee);
_totalFee = _totalFee.add(rewardFee);
uint256 feeAmount = gonAmount.mul(_totalFee).div(feeDenominator);
uint256 _totalFee = liquidityFee + rtfFee;
_totalFee += rtFee;
_totalFee += rfFee;
_totalFee += rewardFee;
uint256 feeAmount = gonAmount * _totalFee / feeDenominator;
_gonBalances[redFurnace] = _gonBalances[redFurnace].add(
gonAmount.mul(rfFee).div(feeDenominator)
);
_gonBalances[address(treasury)] = _gonBalances[address(treasury)].add(
gonAmount.mul(rtFee).div(feeDenominator)
);
_gonBalances[redTrustWallet] = _gonBalances[redTrustWallet].add(
gonAmount.mul(rtfFee).div(feeDenominator)
);
_gonBalances[autoLiquidityReceiver] = _gonBalances[
autoLiquidityReceiver
].add(gonAmount.mul(liquidityFee).div(feeDenominator));
_gonBalances[redFurnace] += gonAmount * rfFee / feeDenominator;
_gonBalances[address(treasury)] += gonAmount * rtFee / feeDenominator;
_gonBalances[redTrustWallet] += gonAmount * rtfFee / feeDenominator;
_gonBalances[autoLiquidityReceiver] += gonAmount * liquidityFee / feeDenominator;
approve(address(nftRewardPool), rewardFee);
nftRewardPool.raiseRewardPool(rewardFee);
emit Transfer(msg.sender, address(treasury), rtFee.div(_gonsPerFragment));
emit Transfer(msg.sender, redTrustWallet, rtfFee.div(_gonsPerFragment));
emit Transfer(msg.sender, redFurnace, rfFee.div(_gonsPerFragment));
emit Transfer(msg.sender, autoLiquidityReceiver, liquidityFee.div(_gonsPerFragment));
emit Transfer(msg.sender, address(treasury), rtFee / _gonsPerFragment);
emit Transfer(msg.sender, redTrustWallet, rtfFee / _gonsPerFragment);
emit Transfer(msg.sender, redFurnace, rfFee / _gonsPerFragment);
emit Transfer(msg.sender, autoLiquidityReceiver, liquidityFee / _gonsPerFragment);
return feeAmount;
}
@@ -336,15 +330,13 @@ contract BabiesOfMars is ERC20Upgradeable {
}
function addLiquidity() internal swapping {
uint256 autoLiquidityAmount = _gonBalances[autoLiquidityReceiver].div(
uint256 autoLiquidityAmount = _gonBalances[autoLiquidityReceiver] / (
_gonsPerFragment
);
_gonBalances[address(this)] = _gonBalances[address(this)].add(
_gonBalances[autoLiquidityReceiver]
);
_gonBalances[address(this)] += _gonBalances[autoLiquidityReceiver];
_gonBalances[autoLiquidityReceiver] = 0;
uint256 amountToLiquify = autoLiquidityAmount.div(2);
uint256 amountToSwap = autoLiquidityAmount.sub(amountToLiquify);
uint256 amountToLiquify = autoLiquidityAmount / 2;
uint256 amountToSwap = autoLiquidityAmount - amountToLiquify;
if (amountToSwap == 0) {
return;
@@ -363,7 +355,7 @@ contract BabiesOfMars is ERC20Upgradeable {
block.timestamp
);
uint256 amountETHLiquidity = address(this).balance.sub(balanceBefore);
uint256 amountETHLiquidity = address(this).balance - (balanceBefore);
if (amountToLiquify > 0 && amountETHLiquidity > 0) {
router.addLiquidityETH{value: amountETHLiquidity}(
@@ -379,7 +371,7 @@ contract BabiesOfMars is ERC20Upgradeable {
}
function withdrawAllToTreasury() public swapping onlyAdmin {
uint256 amountToSwap = _gonBalances[address(this)].div(
uint256 amountToSwap = _gonBalances[address(this)] / (
_gonsPerFragment
);
require(
@@ -466,7 +458,7 @@ contract BabiesOfMars is ERC20Upgradeable {
if (subtractedValue >= oldValue) {
_allowedFragments[msg.sender][spender] = 0;
} else {
_allowedFragments[msg.sender][spender] = oldValue.sub(
_allowedFragments[msg.sender][spender] = oldValue - (
subtractedValue
);
}
@@ -483,9 +475,7 @@ contract BabiesOfMars is ERC20Upgradeable {
override
returns (bool)
{
_allowedFragments[msg.sender][spender] = _allowedFragments[msg.sender][
spender
].add(addedValue);
_allowedFragments[msg.sender][spender] += addedValue;
emit Approval(
msg.sender,
spender,
@@ -509,10 +499,7 @@ contract BabiesOfMars is ERC20Upgradeable {
}
function getCirculatingSupply() public view returns (uint256) {
return
(TOTAL_GONS.sub(_gonBalances[DEAD]).sub(_gonBalances[ZERO])).div(
_gonsPerFragment
);
return (TOTAL_GONS - _gonBalances[DEAD] - _gonBalances[ZERO]) / _gonsPerFragment;
}
function isNotInSwap() public view returns (bool) {
@@ -538,11 +525,9 @@ contract BabiesOfMars is ERC20Upgradeable {
view
returns (uint256)
{
uint256 liquidityBalance = _gonBalances[address(pair)].div(
_gonsPerFragment
);
uint256 liquidityBalance = _gonBalances[address(pair)] / _gonsPerFragment;
return
accuracy.mul(liquidityBalance.mul(2)).div(getCirculatingSupply());
accuracy * liquidityBalance * 2 / getCirculatingSupply();
}
function setWhitelist(address _addr) public onlyAdmin {
@@ -562,7 +547,7 @@ contract BabiesOfMars is ERC20Upgradeable {
}
function balanceOf(address who) public view override returns (uint256) {
return _gonBalances[who].div(_gonsPerFragment);
return _gonBalances[who] / _gonsPerFragment;
}
function isContract(address addr) internal view returns (bool) {