Skip to content

Commit

Permalink
fix balance sum
Browse files Browse the repository at this point in the history
  • Loading branch information
grkamil committed Mar 25, 2021
1 parent 5666b8a commit 5390ff1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions address/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ type Resource struct {
}

type Params struct {
TotalBalanceSum *big.Float
TotalBalanceSum *big.Int
TotalBalanceSumUSD *big.Float
StakeBalanceSum *big.Float
StakeBalanceSum *big.Int
StakeBalanceSumUSD *big.Float
}

Expand Down
12 changes: 6 additions & 6 deletions balance/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func NewService(baseCoin string, marketService *market.Service) *Service {
return &Service{baseCoin, marketService}
}

func (s *Service) GetTotalBalance(address *models.Address) *big.Float {
func (s *Service) GetTotalBalance(address *models.Address) *big.Int {
sum := big.NewInt(0)
for _, balance := range address.Balances {
if balance.Coin.Crr == 0 {
Expand All @@ -39,10 +39,10 @@ func (s *Service) GetTotalBalance(address *models.Address) *big.Float {
))
}

return new(big.Float).SetInt(sum)
return sum
}

func (s *Service) GetStakeBalance(stakes []models.Stake) *big.Float {
func (s *Service) GetStakeBalance(stakes []models.Stake) *big.Int {
sum := big.NewInt(0)

for _, stake := range stakes {
Expand All @@ -65,9 +65,9 @@ func (s *Service) GetStakeBalance(stakes []models.Stake) *big.Float {
))
}

return new(big.Float).SetInt(sum)
return sum
}

func (s *Service) GetTotalBalanceInUSD(sumInBasecoin *big.Float) *big.Float {
return new(big.Float).Mul(sumInBasecoin, big.NewFloat(s.marketService.PriceChange.Price))
func (s *Service) GetTotalBalanceInUSD(sumInBasecoin *big.Int) *big.Float {
return new(big.Float).Mul(new(big.Float).SetInt(sumInBasecoin), big.NewFloat(s.marketService.PriceChange.Price))
}

0 comments on commit 5390ff1

Please sign in to comment.