Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go-kosu: update scaling methods to be consistent #243

Merged
merged 7 commits into from Aug 29, 2019

go-kosu: update scaleBalance to not use Rat

  • Loading branch information
hrharder committed Aug 28, 2019
commit cf6a4b2c27b7546bc722d0224a6a4315bb9c9e3b
@@ -102,15 +102,16 @@ func scaleBalance(balance *big.Int) int64 {
return int64(0)
}

scaled := &big.Rat{}
divisor := &big.Int{}
scaled := &big.Int{}
ether := &big.Int{}
scaled.Set(balance)

// scale balance by 10**18 (base units for KOSU)
// nolint:gosec
divisor = divisor.Exp(big.NewInt(10), big.NewInt(18), nil)
scaled.SetFrac(balance, divisor)
ether.Exp(big.NewInt(10), big.NewInt(18), big.NewInt(0))
scaled.Div(balance, ether)

res, _ := scaled.Float64()
power := math.Floor(res)
return int64(power)
if scaled.IsInt64() {
return scaled.Int64()
}
return math.MaxInt64
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.