所以我要分叉一个ethereum令牌合同,我想增加一个功能,如果你24小时卖东西,你会比平时多交税,我就是用这个逻辑来实现的。
if(takeFee){
// bot/sniper penalty.
if(earlyBuyPenaltyInEffect() && automatedMarketMakerPairs[from] && !automatedMarketMakerPairs[to] && buyTotalFees > 0){
if(!boughtEarly[to]){
boughtEarly[to] = true;
botsCaught += 1;
}
fees = amount * 99 / 100;
tokensForLiquidity += fees * buyLiquidityFee / buyTotalFees;
tokensForOperations += fees * buyOperationsFee / buyTotalFees;
tokensForDev += fees * buyDevFee / buyTotalFees;
tokensForBurn += fees * buyBurnFee / buyTotalFees;
}
// on early sell
else if (automatedMarketMakerPairs[to] && sellTotalFees > 0 && ((_buyMap[from] + (24 hours)) >= block.timestamp)) {
fees = amount * sellTotalFeesEarly / 100;
tokensForLiquidity += fees * sellLiquidityFeeEarly / sellTotalFeesEarly;
tokensForOperations += fees * sellOperationsFeeEarly / sellTotalFeesEarly;
tokensForDev += fees * sellDevFeeEarly / sellTotalFeesEarly;
tokensForBurn += fees * sellBurnFeeEarly / sellTotalFeesEarly;
}
// on sell
else if (automatedMarketMakerPairs[to] && sellTotalFees > 0){
fees = amount * sellTotalFees / 100;
tokensForLiquidity += fees * sellLiquidityFee / sellTotalFees;
tokensForOperations += fees * sellOperationsFee / sellTotalFees;
tokensForDev += fees * sellDevFee / sellTotalFees;
tokensForBurn += fees * sellBurnFee / sellTotalFees;
}
// on buy
else if(automatedMarketMakerPairs[from] && buyTotalFees > 0) {
if (_buyMap[to] == 0) {
_buyMap[to] = block.timestamp;
}
fees = amount * buyTotalFees / 100;
tokensForLiquidity += fees * buyLiquidityFee / buyTotalFees;
tokensForOperations += fees * buyOperationsFee / buyTotalFees;
tokensForDev += fees * buyDevFee / buyTotalFees;
tokensForBurn += fees * buyBurnFee / buyTotalFees;
}
if(fees > 0){
super._transfer(from, address(this), fees);
}
amount -= fees;
}我的问题是,当用户购买时,这一切都能工作,但如果他想要出售,他甚至不能只被征税,而不是阻止他出售,这是负责早期销售征税的代码块:
// on early sell
else if (automatedMarketMakerPairs[to] && sellTotalFees > 0 && ((_buyMap[from] + (24 hours)) >= block.timestamp)) {
fees = amount * sellTotalFeesEarly / 100;
tokensForLiquidity += fees * sellLiquidityFeeEarly / sellTotalFeesEarly;
tokensForOperations += fees * sellOperationsFeeEarly / sellTotalFeesEarly;
tokensForDev += fees * sellDevFeeEarly / sellTotalFeesEarly;
tokensForBurn += fees * sellBurnFeeEarly / sellTotalFeesEarly;
}如果我把它拿出来买卖工作,但如果我把它放回去,它就卖了,停止工作,还有什么我遗漏了吗?
发布于 2022-10-27 07:06:30
修正后,错误是"((_buyMap从… + (24小时))“应该是"((_buyMap从… + (24 *1小时))”
差点就放弃了,我很喜欢编码。
https://ethereum.stackexchange.com/questions/138241
复制相似问题