首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当签入if else语句中的映射时,Solidity契约函数停止工作。

当签入if else语句中的映射时,Solidity契约函数停止工作。
EN

Ethereum用户
提问于 2022-10-27 05:25:30
回答 1查看 43关注 0票数 0

所以我要分叉一个ethereum令牌合同,我想增加一个功能,如果你24小时卖东西,你会比平时多交税,我就是用这个逻辑来实现的。

代码语言:javascript
复制
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;
}

我的问题是,当用户购买时,这一切都能工作,但如果他想要出售,他甚至不能只被征税,而不是阻止他出售,这是负责早期销售征税的代码块:

代码语言:javascript
复制
// 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;
            }

如果我把它拿出来买卖工作,但如果我把它放回去,它就卖了,停止工作,还有什么我遗漏了吗?

EN

回答 1

Ethereum用户

发布于 2022-10-27 07:06:30

修正后,错误是"((_buyMap从… + (24小时))“应该是"((_buyMap从… + (24 *1小时))”

差点就放弃了,我很喜欢编码。

票数 0
EN
页面原文内容由Ethereum提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://ethereum.stackexchange.com/questions/138241

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档