commit inicial do projeto

This commit is contained in:
Júnior
2025-05-23 10:44:32 -03:00
commit 8f04473c0b
106 changed files with 5673 additions and 0 deletions

View File

@ -0,0 +1,19 @@
package staking
import (
"math"
"time"
)
// CalculateRewards calcula as recompensas baseadas em tempo e APR.
// Exemplo: APR 12% ao ano = 0.01 ao mês, 0.00033 ao dia.
func CalculateRewards(amount uint64, startTime int64, apr float64) uint64 {
daysStaked := float64(time.Now().Unix()-startTime) / (60 * 60 * 24)
if daysStaked <= 0 {
return 0
}
// Fórmula de juros simples: R = P * i * t
interest := float64(amount) * (apr / 365.0) * daysStaked
return uint64(math.Floor(interest))
}