25 lines
836 B
Go
25 lines
836 B
Go
package common
|
|
|
|
import "math"
|
|
|
|
const BurningRate = 0.001
|
|
|
|
func CalcBurning(trxAmount float64) float64 {
|
|
return BurningRate * math.Sqrt(trxAmount)
|
|
}
|
|
|
|
// 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
|
|
}
|