Codgo Fonte PTC
Codgo Fonte PTC
1
pragma solidity 0.8.25;
/**
* @title PonzioTheCat
* @notice Implementation of the PONZIO token.
* @dev PONZIO is a rebasable token, which means that the total supply can be
updated. Its particularity is that
* every 4 days the supply is divided by 2, and in between the supply is constantly
decreasing linearly. The balances
* stays fixed for 34 minutes. Then every 34 minutes, the supply is updated, and
the balances are updated
* proportionally.
* At each rebase, 13.37% of the debased supply is sent to the feesCollector.
*/
contract PonzioTheCat is IPonzioTheCat, ERC20Rebasable, Ownable {
using Math for uint256;
using SafeCast for uint256;
using SafeERC20 for IERC20;
/* --------------------------------------------------------------------------
*/
/* external functions
*/
/* --------------------------------------------------------------------------
*/
emit FeesCollectorSet(feeCollector);
}
_initialized = true;
_uniswapV2Pair = IUniswapV2Pair(uniV2PoolAddr);
emit UniV2PoolPairSet(uniV2PoolAddr);
_blacklistForUpdateSupply[uniV2PoolAddr] = true;
emit BlacklistForUpdateSupplySet(uniV2PoolAddr, true);
_feesCollector = feeCollector;
emit FeesCollectorSet(feeCollector);
}
/* --------------------------------------------------------------------------
*/
/* public functions
*/
/* --------------------------------------------------------------------------
*/
/// @dev This check prevents revert in case the feesCollector is an EOA
if (address(feeCollector).code.length != 0) {
/// @dev This try/catch prevents revert in case of feesCollector
does not implement sync()
try IStake(feeCollector).sync() { } catch { }
}
_uniswapV2Pair.sync();
}
}
if (previousTotalSupply != MINIMUM_TOTAL_SUPPLY) {
uint256 _timeSinceDeploy = block.timestamp - DEPLOYED_TIME;
uint256 _tsLastHalving = INITIAL_SUPPLY / (2 ** (_timeSinceDeploy /
HALVING_EVERY));
// slither-disable-next-line weak-prng
totalSupply_ = _tsLastHalving
- (_tsLastHalving * ((_timeSinceDeploy % HALVING_EVERY) /
DEBASE_EVERY)) / NB_DEBASE_PER_HALVING / 2;
uint256 newShares;
if (fees_ >= totalSupply_) {
// if fees are greater than the total supply, we mint totalShares of
shares, so we double the supply of the
// shares, the fees will be equal to half of the total supply
newShares = totalShares;
fees_ = totalSupply_ / 2;
} else {
newShares = totalShares.mulDiv(fees_, totalSupply_ - fees_);
}
bool success;
(success, totalShares_) = totalShares.tryAdd(newShares);
if (!success) {
totalShares_ = type(uint256).max;
fees_ = sharesToToken((type(uint256).max - totalShares), totalShares_,
totalSupply_);
}
}
/// @inheritdoc IERC20
function balanceOf(address account) public view override(ERC20Rebasable,
IERC20) returns (uint256) {
return _sharesOf[account].mulDiv(_previousTotalSupply, _totalShares);
}
/* --------------------------------------------------------------------------
*/
/* internal functions
*/
/* --------------------------------------------------------------------------
*/
/**
* @notice Mint shares to an account.
* @param account The account to mint the shares to.
* @param shares The number of shares to mint.
*/
function _mintShares(address account, uint256 shares) internal override {
uint256 totalShares = _totalShares;
(bool success,) = totalShares.tryAdd(shares);
if (!success) {
super._mintShares(account, type(uint256).max - totalShares);
_maxSharesReached = true;
emit MaxSharesReached(block.timestamp);
} else {
super._mintShares(account, shares);
}
}
}