Skip to content

Commit

Permalink
feat: oracle split as per governance (#495)
Browse files Browse the repository at this point in the history
Co-authored-by: expertdicer <[email protected]>
  • Loading branch information
fragwuerdig and expertdicer authored Jul 10, 2024
1 parent 383a96d commit 2db4512
Show file tree
Hide file tree
Showing 19 changed files with 269 additions and 70 deletions.
14 changes: 13 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import (
v7 "github.com/classic-terra/core/v3/app/upgrades/v7"
v7_1 "github.com/classic-terra/core/v3/app/upgrades/v7_1"
v8 "github.com/classic-terra/core/v3/app/upgrades/v8"
v8_1 "github.com/classic-terra/core/v3/app/upgrades/v8_1"

customante "github.com/classic-terra/core/v3/custom/auth/ante"
custompost "github.com/classic-terra/core/v3/custom/auth/post"
Expand All @@ -75,7 +76,18 @@ var (
DefaultNodeHome string

// Upgrades defines upgrades to be applied to the network
Upgrades = []upgrades.Upgrade{v2.Upgrade, v3.Upgrade, v4.Upgrade, v5.Upgrade, v6.Upgrade, v6_1.Upgrade, v7.Upgrade, v7_1.Upgrade, v8.Upgrade}
Upgrades = []upgrades.Upgrade{
v2.Upgrade,
v3.Upgrade,
v4.Upgrade,
v5.Upgrade,
v6.Upgrade,
v6_1.Upgrade,
v7.Upgrade,
v7_1.Upgrade,
v8.Upgrade,
v8_1.Upgrade,
}

// Forks defines forks to be applied to the network
Forks = []upgrades.Fork{}
Expand Down
2 changes: 0 additions & 2 deletions app/legacy/pubkey_replacement.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ func loadKeydataFromFile(clientCtx client.Context, replacementrJSON string, genD
var replacementKeys replacementConfigs

err = json.Unmarshal(jsonReplacementBlob, &replacementKeys)

if err != nil {
log.Fatal(errors.Wrap(err, "Could not unmarshal replacement keys "))
}
Expand Down Expand Up @@ -112,7 +111,6 @@ func loadKeydataFromFile(clientCtx client.Context, replacementrJSON string, genD
state[slashing.ModuleName] = clientCtx.Codec.MustMarshalJSON(&slashingGenesis)

genDoc.AppState, err = json.Marshal(state)

if err != nil {
log.Fatal("Could not marshal App State")
}
Expand Down
13 changes: 13 additions & 0 deletions app/upgrades/v8_1/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//nolint:revive
package v8_1

import (
"github.com/classic-terra/core/v3/app/upgrades"
)

const UpgradeName = "v8_1"

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateV81UpgradeHandler,
}
25 changes: 25 additions & 0 deletions app/upgrades/v8_1/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//nolint:revive
package v8_1

import (
"github.com/classic-terra/core/v3/app/keepers"
"github.com/classic-terra/core/v3/app/upgrades"
treasurykeeper "github.com/classic-terra/core/v3/x/treasury/keeper"
treasurytypes "github.com/classic-terra/core/v3/x/treasury/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

func CreateV81UpgradeHandler(
mm *module.Manager,
cfg module.Configurator,
_ upgrades.BaseAppParamManager,
keepers *keepers.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
// set default oracle split
mm.Modules[treasurytypes.ModuleName].(*treasurykeeper.Keeper).SetOracleSplitRate(ctx, treasurytypes.DefaultOracleSplit)
return mm.RunMigrations(ctx, cfg, fromVM)
}
}
4 changes: 2 additions & 2 deletions contrib/updates/Dockerfile.old
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ RUN --mount=type=cache,target=/root/.cache/go-build \

# Cosmwasm - Download correct libwasmvm version and verify checksum
RUN set -eux &&\
WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | cut -d ' ' -f 5) && \
WASMVM_DOWNLOADS="https://github.com/classic-terra/wasmvm/releases/download/${WASMVM_VERSION}"; \
WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | cut -d ' ' -f 2) && \
WASMVM_DOWNLOADS="https://github.com/CosmWasm/wasmvm/releases/download/${WASMVM_VERSION}"; \
wget ${WASMVM_DOWNLOADS}/checksums.txt -O /tmp/checksums.txt; \
if [ ${BUILDPLATFORM} = "linux/amd64" ]; then \
WASMVM_URL="${WASMVM_DOWNLOADS}/libwasmvm_muslc.x86_64.a"; \
Expand Down
2 changes: 1 addition & 1 deletion contrib/updates/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,4 @@ networks:
driver: default
config:
-
subnet: 192.168.10.0/16
subnet: 192.168.10.0/24
2 changes: 1 addition & 1 deletion contrib/updates/prepare_cosmovisor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# These fields should be fetched automatically in the future
# Need to do more upgrade to see upgrade patterns
OLD_VERSION=v2.4.2
OLD_VERSION=v3.0.3
# this command will retrieve the folder with the largest number in format v<number>
SOFTWARE_UPGRADE_NAME=$(ls -d -- ./app/upgrades/v* | sort -Vr | head -n 1 | xargs basename)
BUILDDIR=$1
Expand Down
Empty file modified contrib/updates/upgrade-test.sh
100644 → 100755
Empty file.
1 change: 1 addition & 0 deletions custom/auth/ante/expected_keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type TreasuryKeeper interface {
HasBurnTaxExemptionAddress(ctx sdk.Context, addresses ...string) bool
HasBurnTaxExemptionContract(ctx sdk.Context, address string) bool
GetMinInitialDepositRatio(ctx sdk.Context) sdk.Dec
GetOracleSplitRate(ctx sdk.Context) sdk.Dec
}

// OracleKeeper for feeder validation
Expand Down
23 changes: 22 additions & 1 deletion custom/auth/ante/fee_burntax.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@ import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/types"

oracle "github.com/classic-terra/core/v3/x/oracle/types"
treasury "github.com/classic-terra/core/v3/x/treasury/types"
)

// BurnTaxSplit splits
func (fd FeeDecorator) BurnTaxSplit(ctx sdk.Context, taxes sdk.Coins) (err error) {
burnSplitRate := fd.treasuryKeeper.GetBurnSplitRate(ctx)
oracleSplitRate := fd.treasuryKeeper.GetOracleSplitRate(ctx)
distributionDeltaCoins := sdk.NewCoins()
oracleSplitCoins := sdk.NewCoins()

if burnSplitRate.IsPositive() {
distributionDeltaCoins := sdk.NewCoins()

for _, taxCoin := range taxes {
splitcoinAmount := burnSplitRate.MulInt(taxCoin.Amount).RoundInt()
Expand All @@ -24,6 +27,24 @@ func (fd FeeDecorator) BurnTaxSplit(ctx sdk.Context, taxes sdk.Coins) (err error
taxes = taxes.Sub(distributionDeltaCoins...)
}

if oracleSplitRate.IsPositive() {
for _, distrCoin := range distributionDeltaCoins {
oracleCoinAmnt := oracleSplitRate.MulInt(distrCoin.Amount).RoundInt()
oracleSplitCoins = oracleSplitCoins.Add(sdk.NewCoin(distrCoin.Denom, oracleCoinAmnt))
}
}

if !oracleSplitCoins.IsZero() {
if err = fd.bankKeeper.SendCoinsFromModuleToModule(
ctx,
types.FeeCollectorName,
oracle.ModuleName,
oracleSplitCoins,
); err != nil {
return errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, err.Error())
}
}

if !taxes.IsZero() {
if err = fd.bankKeeper.SendCoinsFromModuleToModule(
ctx,
Expand Down
44 changes: 36 additions & 8 deletions custom/auth/ante/fee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -687,9 +687,12 @@ func (s *AnteTestSuite) TestTaxExemption() {
ak := s.app.AccountKeeper
bk := s.app.BankKeeper
burnSplitRate := sdk.NewDecWithPrec(5, 1)
oracleSplitRate := sdk.ZeroDec()

// Set burn split rate to 50%
// oracle split to 0% (oracle split is covered in another test)
tk.SetBurnSplitRate(s.ctx, burnSplitRate)
tk.SetOracleSplitRate(s.ctx, oracleSplitRate)

fmt.Printf("CASE = %s \n", c.name)
s.txBuilder = s.clientCtx.TxConfig.NewTxBuilder()
Expand Down Expand Up @@ -732,14 +735,26 @@ func (s *AnteTestSuite) TestTaxExemption() {

// go test -v -run ^TestAnteTestSuite/TestBurnSplitTax$ github.com/classic-terra/core/v3/custom/auth/ante
func (s *AnteTestSuite) TestBurnSplitTax() {
s.runBurnSplitTaxTest(sdk.NewDecWithPrec(1, 0)) // 100%
s.runBurnSplitTaxTest(sdk.NewDecWithPrec(1, 1)) // 10%
s.runBurnSplitTaxTest(sdk.NewDecWithPrec(1, 2)) // 0.1%
s.runBurnSplitTaxTest(sdk.NewDecWithPrec(0, 0)) // 0% burn all taxes (old burn tax behavior)
s.runBurnSplitTaxTest(sdk.NewDecWithPrec(-1, 1)) // -10% invalid rate
s.runBurnSplitTaxTest(sdk.NewDecWithPrec(1, 0), sdk.ZeroDec()) // 100% distribute, 0% to oracle
s.runBurnSplitTaxTest(sdk.NewDecWithPrec(1, 1), sdk.ZeroDec()) // 10% distribute, 0% to oracle
s.runBurnSplitTaxTest(sdk.NewDecWithPrec(1, 2), sdk.ZeroDec()) // 0.1% distribute, 0% to oracle
s.runBurnSplitTaxTest(sdk.NewDecWithPrec(0, 0), sdk.ZeroDec()) // 0% distribute, 0% to oracle
s.runBurnSplitTaxTest(sdk.NewDecWithPrec(1, 0), sdk.NewDecWithPrec(5, 1)) // 100% distribute, 50% to oracle
s.runBurnSplitTaxTest(sdk.NewDecWithPrec(1, 1), sdk.NewDecWithPrec(5, 1)) // 10% distribute, 50% to oracle
s.runBurnSplitTaxTest(sdk.NewDecWithPrec(1, 2), sdk.NewDecWithPrec(5, 1)) // 0.1% distribute, 50% to oracle
s.runBurnSplitTaxTest(sdk.NewDecWithPrec(0, 0), sdk.NewDecWithPrec(5, 1)) // 0% distribute, 50% to oracle
s.runBurnSplitTaxTest(sdk.NewDecWithPrec(1, 0), sdk.ZeroDec()) // 100% distribute, 0% to oracle
s.runBurnSplitTaxTest(sdk.NewDecWithPrec(1, 1), sdk.ZeroDec()) // 10% distribute, 0% to oracle
s.runBurnSplitTaxTest(sdk.NewDecWithPrec(1, 2), sdk.ZeroDec()) // 0.1% distribute, 0% to oracle
s.runBurnSplitTaxTest(sdk.NewDecWithPrec(0, 0), sdk.ZeroDec()) // 0% distribute, 0% to oracle
s.runBurnSplitTaxTest(sdk.NewDecWithPrec(1, 0), sdk.OneDec()) // 100% distribute, 100% to oracle
s.runBurnSplitTaxTest(sdk.NewDecWithPrec(1, 1), sdk.OneDec()) // 10% distribute, 100% to oracle
s.runBurnSplitTaxTest(sdk.NewDecWithPrec(1, 2), sdk.OneDec()) // 0.1% distribute, 100% to oracle
s.runBurnSplitTaxTest(sdk.NewDecWithPrec(0, 0), sdk.OneDec()) // 0% distribute, 100% to oracle
s.runBurnSplitTaxTest(sdk.NewDecWithPrec(-1, 1), sdk.ZeroDec()) // -10% distribute - invalid rate
}

func (s *AnteTestSuite) runBurnSplitTaxTest(burnSplitRate sdk.Dec) {
func (s *AnteTestSuite) runBurnSplitTaxTest(burnSplitRate sdk.Dec, oracleSplitRate sdk.Dec) {
s.SetupTest(true) // setup
require := s.Require()
s.txBuilder = s.clientCtx.TxConfig.NewTxBuilder()
Expand All @@ -752,6 +767,7 @@ func (s *AnteTestSuite) runBurnSplitTaxTest(burnSplitRate sdk.Dec) {

// Set burn split tax
tk.SetBurnSplitRate(s.ctx, burnSplitRate)
tk.SetOracleSplitRate(s.ctx, oracleSplitRate)

// keys and addresses
priv1, _, addr1 := testdata.KeyTestPubAddr()
Expand Down Expand Up @@ -804,15 +820,27 @@ func (s *AnteTestSuite) runBurnSplitTaxTest(burnSplitRate sdk.Dec) {
tk.BurnCoinsFromBurnAccount(s.ctx)

feeCollectorAfter := sdk.NewDecCoinsFromCoins(bk.GetAllBalances(s.ctx, ak.GetModuleAddress(authtypes.FeeCollectorName))...)
oracleAfter := sdk.NewDecCoinsFromCoins(bk.GetAllBalances(s.ctx, ak.GetModuleAddress(oracletypes.ModuleName))...)
taxes := ante.FilterMsgAndComputeTax(s.ctx, tk, msg)
burnTax := sdk.NewDecCoinsFromCoins(taxes...)

if burnSplitRate.IsPositive() {
distributionDeltaCoins := burnTax.MulDec(burnSplitRate)
expectedOracleCoins := distributionDeltaCoins.MulDec(oracleSplitRate)
expectedDistrCoins := distributionDeltaCoins.Sub(expectedOracleCoins)

if expectedOracleCoins == nil {
expectedOracleCoins = sdk.NewDecCoins()
}

if expectedDistrCoins == nil {
expectedDistrCoins = sdk.NewDecCoins()
}

// expected: community pool 50%
fmt.Printf("BurnSplitRate %v, DistributionDeltaCoins %v\n", burnSplitRate, distributionDeltaCoins)
require.Equal(feeCollectorAfter, distributionDeltaCoins)
fmt.Printf("-- BurnSplitRate %+v, OracleSplitRate %+v, OracleCoins %+v, DistrCoins %+v\n", burnSplitRate, oracleSplitRate, expectedOracleCoins, expectedDistrCoins)
require.Equal(feeCollectorAfter, expectedDistrCoins)
require.Equal(oracleAfter, expectedOracleCoins)
burnTax = burnTax.Sub(distributionDeltaCoins)
}

Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ require (
github.com/moby/term v0.0.0-20220808134915-39b0c02b01ae // indirect
github.com/opencontainers/image-spec v1.1.0-rc2 // indirect
github.com/opencontainers/runc v1.1.12 // indirect
github.com/regen-network/cosmos-proto v0.3.1 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,8 @@ github.com/rakyll/statik v0.1.7/go.mod h1:AlZONWzMtEnMs7W4e/1LURLiI49pIMmp6V9Ung
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM=
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/regen-network/cosmos-proto v0.3.1 h1:rV7iM4SSFAagvy8RiyhiACbWEGotmqzywPxOvwMdxcg=
github.com/regen-network/cosmos-proto v0.3.1/go.mod h1:jO0sVX6a1B36nmE8C9xBFXpNwWejXC7QqCOnH3O0+YM=
github.com/regen-network/protobuf v1.3.3-alpha.regen.1 h1:OHEc+q5iIAXpqiqFKeLpu5NwTIkVXUs48vFMwzqpqY4=
github.com/regen-network/protobuf v1.3.3-alpha.regen.1/go.mod h1:2DjTFR1HhMQhiWC5sZ4OhQ3+NtdbZ6oBDKQwq5Ou+FI=
github.com/retailnext/hllpp v1.0.1-0.20180308014038-101a6d2f8b52/go.mod h1:RDpi1RftBQPUCDRw6SmxeaREsAaRKnOclghuzp/WRzc=
Expand Down
6 changes: 6 additions & 0 deletions proto/terra/treasury/v1beta1/treasury.proto
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ message Params {
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string oracle_split = 10 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.moretags) = "yaml:\"oracle_split\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}

// PolicyConstraints - defines policy constraints can be applied in tax & reward policies
Expand Down
5 changes: 4 additions & 1 deletion tests/e2e/configurer/chain/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (n *NodeConfig) InstantiateWasmContract(codeID, initMsg, amount, from strin
n.LogActionF("successfully initialized")
}

func (n *NodeConfig) Instantiate2WasmContract(codeID, initMsg, salt, amount, fee, from string) {
func (n *NodeConfig) Instantiate2WasmContract(codeID, initMsg, salt, amount, fee, gas, from string) {
n.LogActionF("instantiating wasm contract %s with %s", codeID, initMsg)
encodedSalt := make([]byte, hex.EncodedLen(len([]byte(salt))))
hex.Encode(encodedSalt, []byte(salt))
Expand All @@ -56,6 +56,9 @@ func (n *NodeConfig) Instantiate2WasmContract(codeID, initMsg, salt, amount, fee
if fee != "" {
cmd = append(cmd, fmt.Sprintf("--fees=%s", fee))
}
if gas != "" {
cmd = append(cmd, fmt.Sprintf("--gas=%s", gas))
}
n.LogActionF(strings.Join(cmd, " "))
_, _, err := n.containerManager.ExecTxCmd(n.t, n.chainID, n.Name, cmd)
require.NoError(n.t, err)
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func (s *IntegrationTestSuite) TestFeeTaxWasm() {
strconv.Itoa(chain.LatestCodeID),
`{"count": "0"}`, "salt",
transferCoin.String(),
fmt.Sprintf("%duluna", stabilityFee), "test")
fmt.Sprintf("%duluna", stabilityFee), "300000", "test")

contracts, err = node.QueryContractsFromID(chain.LatestCodeID)
s.Require().NoError(err)
Expand Down
9 changes: 9 additions & 0 deletions x/treasury/keeper/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ func (k Keeper) SetMinInitialDepositRatio(ctx sdk.Context, minInitialDepositRati
k.paramSpace.Set(ctx, types.KeyMinInitialDepositRatio, minInitialDepositRatio)
}

func (k Keeper) GetOracleSplitRate(ctx sdk.Context) (res sdk.Dec) {
k.paramSpace.Get(ctx, types.KeyOracleSplit, &res)
return
}

func (k Keeper) SetOracleSplitRate(ctx sdk.Context, oracleSplit sdk.Dec) {
k.paramSpace.Set(ctx, types.KeyOracleSplit, oracleSplit)
}

// GetParams returns the total set of treasury parameters.
func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) {
k.paramSpace.GetParamSetIfExists(ctx, &params)
Expand Down
29 changes: 29 additions & 0 deletions x/treasury/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ var (
KeyWindowProbation = []byte("WindowProbation")
KeyBurnTaxSplit = []byte("BurnTaxSplit")
KeyMinInitialDepositRatio = []byte("MinInitialDepositRatio")
KeyOracleSplit = []byte("OracleSplit")
)

// Default parameter values
Expand All @@ -47,6 +48,7 @@ var (
DefaultRewardWeight = sdk.NewDecWithPrec(5, 2) // 5%
DefaultBurnTaxSplit = sdk.NewDecWithPrec(1, 1) // 10% goes to community pool, 90% burn
DefaultMinInitialDepositRatio = sdk.ZeroDec() // 0% min initial deposit
DefaultOracleSplit = sdk.NewDecWithPrec(5, 1) // 50% oracle, 50% community pool
)

var _ paramstypes.ParamSet = &Params{}
Expand All @@ -63,6 +65,7 @@ func DefaultParams() Params {
WindowProbation: DefaultWindowProbation,
BurnTaxSplit: DefaultBurnTaxSplit,
MinInitialDepositRatio: DefaultMinInitialDepositRatio,
OracleSplit: DefaultOracleSplit,
}
}

Expand Down Expand Up @@ -90,6 +93,7 @@ func (p *Params) ParamSetPairs() paramstypes.ParamSetPairs {
paramstypes.NewParamSetPair(KeyWindowProbation, &p.WindowProbation, validateWindowProbation),
paramstypes.NewParamSetPair(KeyBurnTaxSplit, &p.BurnTaxSplit, validateBurnTaxSplit),
paramstypes.NewParamSetPair(KeyMinInitialDepositRatio, &p.MinInitialDepositRatio, validateMinInitialDepositRatio),
paramstypes.NewParamSetPair(KeyOracleSplit, &p.OracleSplit, validateOraceSplit),
}
}

Expand Down Expand Up @@ -137,6 +141,14 @@ func (p Params) Validate() error {
return fmt.Errorf("treasury parameter WindowLong must be bigger than WindowShort: (%d, %d)", p.WindowLong, p.WindowShort)
}

if p.OracleSplit.IsNegative() {
return fmt.Errorf("treasury parameter OracleSplit must be positive: %s", p.OracleSplit)
}

if p.OracleSplit.GT(sdk.OneDec()) {
return fmt.Errorf("treasury parameter OracleSplit must be less than or equal to 1.0: %s", p.OracleSplit)
}

return nil
}

Expand Down Expand Up @@ -268,3 +280,20 @@ func validateMinInitialDepositRatio(i interface{}) error {

return nil
}

func validateOraceSplit(i interface{}) error {
v, ok := i.(sdk.Dec)
if !ok {
return fmt.Errorf("invalid paramater type: %T", i)
}

if v.IsNegative() {
return fmt.Errorf("oracle split must be positive: %s", v)
}

if v.GT(sdk.OneDec()) {
return fmt.Errorf("oracle split must be less than or equal to 1.0: %s", v)
}

return nil
}
Loading

0 comments on commit 2db4512

Please sign in to comment.