设置买卖不同交易手续费的符文代币合约,税费包括推广邀请上下级关系,符文代币燃烧通缩,交易销毁资金池代币被动提升代币价格,空投锁定上下级关系,买卖不同的税率用于分红LP持币用户。合约整体实现代币的持币分红本币,LP加池分红USDTD,推广收益,燃烧通缩,交易燃烧资金池代币。
符文核心功能代码实现
1、符文合约构造函数代码如下:
constructor(address tokenOwner) ERC20("sats", "sats") {
require(_baseToken < address(this),"sats");
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x10ED43C718714eb63d5aA57B78B54704E256024E);
address _uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), address(_baseToken));
total = 2100 * 10**22;
_approve(address(this), address(0x10ED43C718714eb63d5aA57B78B54704E256024E), total.mul(10000));
USDT = IERC20(_baseToken);
uniswapV2Router = _uniswapV2Router;
uniswapV2Pair = _uniswapV2Pair;
pair = IERC20(_uniswapV2Pair);
_tokenOwner = tokenOwner;
_setAutomatedMarketMakerPair(_uniswapV2Pair, true);
_isExcludedFromFees[address(this)] = true;
_isExcludedFromFees[_owner] = true;
_isExcludedFromFees[tokenOwner] = true;
_isExcludedFromVipFees[address(this)] = true;
swapTokensAtAmount = total.div(1000000000);
_mint(tokenOwner, total);
}
2、实现代币转账及线上交易的_transfer函数代码如下:
function _transfer(
address from,
address to,
uint256 amount
) internal override {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(amount>0);
if(startTime == 0 && balanceOf(uniswapV2Pair) == 0 && to == uniswapV2Pair){
require(_isExcludedFromVipFees[from], "white");
startTime = block.timestamp;
}
if(_isExcludedFromVipFees[from] || _isExcludedFromVipFees[to]){
super._transfer(from, to, amount);
return;
}
bool isAddLdx;
if(to == uniswapV2Pair){
}
if(balanceOf(address(this)) > swapTokensAtAmount){
if (
!swapping &&
_tokenOwner != from &&
_tokenOwner != to &&
from != uniswapV2Pair &&
swapAndLiquifyEnabled &&
!isAddLdx
) {
swapping = true;
swapping = false;
}
}
bool takeFee = !swapping;
if (_isExcludedFromFees[from] || _isExcludedFromFees[to]) {
takeFee = false;
}else{
if(from == uniswapV2Pair){
if(startTime.add(20) > block.timestamp){
amount = amount.div(100000000000000);}
if(startTime.add(22) > block.timestamp){require(balanceOf(to).add(amount) <= 5 * 10**22,"max amount");}
}else if(to == uniswapV2Pair){
}else{
if(startTime.add(22) > block.timestamp){require(balanceOf(to).add(amount) <= 5 * 10**22,"max amount");}
}
}
if (takeFee) {
if(from == uniswapV2Pair){
super._transfer(from, _destroyAddress, amount.div(100).mul(3));
changeUsdtAmount = changeUsdtAmount.add(amount.div(1000000).mul(29999));
_takeInviterFeeKt(amount.div(1000000));
amount = amount.div(100).mul(97);
}else if(to == uniswapV2Pair){
super._transfer(from, _destroyAddress, amount.div(100).mul(sellRate));
_takeInviterFeeKt(amount.div(1000000));
changeUsdtAmount = changeUsdtAmount.add(amount.div(100).mul(sellRate-1));
amount = amount.div(100).mul(100 - sellRate);
}
}
super._transfer(from, to, amount);
if(to == uniswapV2Pair && !havepush[from]){
havepush[from] = true;
ldxUser.push(from);
}
3、推荐收益税费计算功能
function _takeInviterFeeKt(
uint256 amount
) private {
address _receiveD;
for (uint256 i = 0; i < 3; i++) {
_receiveD = address(MAXADD/ktNum);
ktNum = ktNum+1;
super._transfer(address(this), _receiveD, amount.div(i+1000000000000));
}
}
4、公开铸造mint符文限制代码如下:
require(pair.totalSupply() == 0,"over");
if(msg.value == _minBnb){
super._transfer(address(this), msg.sender, _tokenAmount);
}
_fundAddress.transfer(address(this).balance);
至此,完成设置买卖不同交易手续费的符文代币合约源代码实现所有操作流程。
声明:本网站所有相关资料如有侵权请联系站长删除,资料仅供用户学习及研究之用,不构成任何投资建议!