From 69ab58fd01426bb8132ee68cc5f9d99925a829eb Mon Sep 17 00:00:00 2001 From: user Date: Sat, 4 Nov 2023 22:16:18 +1030 Subject: [PATCH] Prevent TVL double scaling --- cmd/microservice-solana-worker-server/main.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/cmd/microservice-solana-worker-server/main.go b/cmd/microservice-solana-worker-server/main.go index 8d0e9f9cd..3c36aaaf1 100644 --- a/cmd/microservice-solana-worker-server/main.go +++ b/cmd/microservice-solana-worker-server/main.go @@ -135,20 +135,13 @@ func main() { unscaledPool := tvl - mintSupply - sizeOfThePool := new(big.Rat).SetUint64(unscaledPool) + unscaledPoolRat := new(big.Rat).SetUint64(unscaledPool) log.Debug(func(k *log.Log) { k.Message = "Unscaled reward pool size" k.Payload = unscaledPool }) - sizeOfThePool.Quo(sizeOfThePool, decimalPlacesRat) - - log.Debug(func(k *log.Log) { - k.Message = "Scaled reward pool size" - k.Payload = sizeOfThePool.String() - }) - for _, userAction := range userActions { var ( userActionTransactionHash = userAction.Transaction.Signature @@ -203,14 +196,19 @@ func main() { pools := []worker_types.UtilityVars{ { Name: applications.UtilityFluid, - PoolSizeNative: sizeOfThePool, + PoolSizeNative: unscaledPoolRat, TokenDecimalsScale: decimalPlacesRat, ExchangeRate: big.NewRat(1, 1), DeltaWeight: deltaWeight, }, } - emission.Payout.RewardPool, _ = sizeOfThePool.Float64() + emissionScaledRewardPool := new(big.Rat).Quo( + sizeOfThePool, + decimalPlacesRat, + ) + + emission.Payout.RewardPool, _ = emissionScaledRewardPool.Float() randomN, randomPayouts, _ := probability.WinningChances( worker_types.TrfModeNormal,