micw/common/burning.go

25 lines
836 B
Go
Raw Normal View History

2024-11-17 21:24:19 +00:00
package common
import "math"
const BurningRate = 0.001
func CalcBurning(trxAmount float64) float64 {
return BurningRate * math.Sqrt(trxAmount)
}
2024-11-24 14:04:52 +00:00
// ValidateBurning doesn't return valid/invalid like usual Validate functions.
// Instead, it returns difference between expected and set values.
// Bcs of a differences in how programming languages might be implemented
// or approach numeric types (yes, JS, I'm about u) we might not get exactly the same burning amount,
// but still it should be a very close value.
// To get boolean value -- use ValidateBurningBool instead
func ValidateBurning(tx *Tx) float64 {
return CalcBurning(tx.Amount) - tx.AmountBurned
}
func ValidateBurningBool(tx *Tx) bool {
// Let's say, that before that count of digits we shouldn't have any mistake
return math.Abs(ValidateBurning(tx)) < 0.1e-10
}