From 5857f2fa869a44601bb68dedbeee3be7f12c1e7c Mon Sep 17 00:00:00 2001 From: Ares <75481906+ice-ares@users.noreply.github.com> Date: Thu, 20 Jun 2024 12:04:32 +0300 Subject: [PATCH] made the mining boost price decimals randomized for each request --- tokenomics/mining_boost.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tokenomics/mining_boost.go b/tokenomics/mining_boost.go index ada51dd..2fbc843 100644 --- a/tokenomics/mining_boost.go +++ b/tokenomics/mining_boost.go @@ -100,10 +100,12 @@ func (r *repository) InitializeMiningBoostUpgrade(ctx context.Context, miningBoo previousLevelPrice = (*r.cfg.MiningBoost.levels.Load())[*res[0].MiningBoostLevelIndex].icePrice } upgradePrice := (*r.cfg.MiningBoost.levels.Load())[miningBoostLevelIndex].icePrice - previousLevelPrice + randomizedPrice, err := strconv.ParseFloat(fmt.Sprint(uint64(upgradePrice))+"."+fmt.Sprint(random(4)), 64) + log.Panic(err) + upgradePrice = randomizedPrice storedPrice := strconv.FormatFloat(upgradePrice, 'f', miningBoostPricePrecision, 64) key := fmt.Sprintf("mining_boost_upgrades:%v", id) - randomPart := fmt.Sprint(random(4)) - val := fmt.Sprintf("%v:%v", miningBoostLevelIndex, storedPrice+randomPart) + val := fmt.Sprintf("%v:%v", miningBoostLevelIndex, storedPrice) result, err := r.db.Set(ctx, key, val, r.cfg.MiningBoost.SessionLength).Result() if err != nil { return nil, errors.Wrapf(err, "failed to set new mining_boost_upgrade for userID:%v", userID) @@ -114,7 +116,7 @@ func (r *repository) InitializeMiningBoostUpgrade(ctx context.Context, miningBoo icePrice := strconv.FormatFloat(upgradePrice*(1+(float64(r.cfg.MiningBoost.PriceDelta)/100)), 'f', miningBoostPricePrecision, 64) return &PendingMiningBoostUpgrade{ ExpiresAt: time.New(stdlibtime.Now().Add(r.cfg.MiningBoost.SessionLength)), - ICEPrice: icePrice + randomPart, + ICEPrice: icePrice, PaymentAddress: r.cfg.MiningBoost.PaymentAddress, }, nil }