ceremonyclient/node/consensus/reward/baseline_fee.go
Cassandra Heart dbd95bd9e9
v2.1.0 (#439)
* v2.1.0 [omit consensus and adjacent] - this commit will be amended with the full release after the file copy is complete

* 2.1.0 main node rollup
2025-09-30 02:48:15 -05:00

29 lines
648 B
Go

package reward
import "math/big"
// GetBaselineFee returns the scaled baseline fee derived from world state
// impact
func GetBaselineFee(
difficulty uint64,
worldStateBytes uint64,
totalAdded uint64,
units uint64,
) *big.Int {
current := PomwBasis(difficulty, worldStateBytes, units)
affected := PomwBasis(difficulty, worldStateBytes+totalAdded, units)
delta := new(big.Int).Sub(current, affected)
num := new(big.Int).Exp(delta, big.NewInt(2), big.NewInt(0))
denom := big.NewInt(int64(worldStateBytes))
lhs := new(big.Int).Quo(num, denom)
rhs := big.NewInt(int64(totalAdded))
if lhs.Cmp(rhs) >= 0 {
return lhs
}
return rhs
}