0g-chain/x/cdp/simulation/utils.go
Federico Kunze a573625df8
[R4R] bump SDK version to v0.38.3 (#421)
* bump SDK version to v0.38.3

Co-authored-by: Denali Marsh <denali@kava.io>
Co-authored-by: Kevin Davis <kjydavis3@gmail.com>
Co-authored-by: Kevin Davis <karzak@users.noreply.github.com>
Co-authored-by: denalimarsh <denalimarsh@gmail.com>
Co-authored-by: rhuairahrighairigh <ruaridh.odonnell@gmail.com>
2020-04-23 12:35:58 -04:00

27 lines
441 B
Go

package simulation
import (
sdk "github.com/cosmos/cosmos-sdk/types"
)
func ShiftDec(x sdk.Dec, places sdk.Int) sdk.Dec {
neg := places.IsNegative()
for i := 0; i < int(abs(places.Int64())); i++ {
if neg {
x = x.Mul(sdk.MustNewDecFromStr("0.1"))
} else {
x = x.Mul(sdk.NewDecFromInt(sdk.NewInt(10)))
}
}
return x
}
// abs returns the absolute value of x.
func abs(x int64) int64 {
if x < 0 {
return -x
}
return x
}