From 99a7a0fde2b24e46b6b92fc1861c69e8ed0f1dfd Mon Sep 17 00:00:00 2001 From: Unique Divine <51418232+Unique-Divine@users.noreply.github.com> Date: Fri, 29 Sep 2023 07:25:22 -0500 Subject: [PATCH] refactor(app)!: Remove x/stablecoin module (#1609) * refactor: rm x/stablecoin * changelog * change log number --- CHANGELOG.md | 5 + app/app.go | 18 +- app/keepers.go | 15 +- x/stablecoin/README.md | 108 - x/stablecoin/abci.go | 30 - x/stablecoin/abci_test.go | 169 -- x/stablecoin/client/cli/cli_test.go | 289 --- x/stablecoin/client/cli/flags.go | 17 - x/stablecoin/client/cli/query.go | 149 -- x/stablecoin/client/cli/tx.go | 189 -- x/stablecoin/genesis.go | 28 - x/stablecoin/genesis_test.go | 31 - x/stablecoin/keeper/balance.go | 35 - x/stablecoin/keeper/collateral_ratio.go | 499 ---- x/stablecoin/keeper/collateral_ratio_test.go | 1220 ---------- x/stablecoin/keeper/grpc_query.go | 80 - x/stablecoin/keeper/grpc_query_test.go | 25 - x/stablecoin/keeper/hooks.go | 46 - x/stablecoin/keeper/keeper.go | 84 - x/stablecoin/keeper/keeper_test.go | 59 - x/stablecoin/keeper/mint_burn_stable.go | 367 --- x/stablecoin/keeper/mint_burn_stable_test.go | 608 ----- x/stablecoin/keeper/msg_server.go | 70 - x/stablecoin/keeper/msg_server_test.go | 37 - x/stablecoin/keeper/needed.go | 49 - x/stablecoin/keeper/needed_test.go | 130 - x/stablecoin/keeper/params_test.go | 92 - x/stablecoin/keeper/supply.go | 74 - x/stablecoin/keeper/supply_test.go | 118 - x/stablecoin/mock/dex_keeper.go | 25 - x/stablecoin/module.go | 167 -- x/stablecoin/module_simulation.go | 56 - x/stablecoin/simulation/msg.go | 39 - x/stablecoin/simulation/sim.go | 15 - x/stablecoin/types/codec.go | 24 - x/stablecoin/types/errors.go | 14 - x/stablecoin/types/events.pb.go | 1749 -------------- x/stablecoin/types/expected_keepers.go | 46 - x/stablecoin/types/expected_keepers_test.go | 54 - x/stablecoin/types/genesis.go | 24 - x/stablecoin/types/genesis.pb.go | 383 --- x/stablecoin/types/genesis_test.go | 79 - x/stablecoin/types/keys.go | 21 - x/stablecoin/types/messages.go | 165 -- x/stablecoin/types/messages_test.go | 103 - x/stablecoin/types/params.go | 308 --- x/stablecoin/types/params.pb.go | 631 ----- x/stablecoin/types/query.pb.go | 2225 ----------------- x/stablecoin/types/query.pb.gw.go | 348 --- x/stablecoin/types/tx.pb.go | 2228 ------------------ x/stablecoin/types/tx.pb.gw.go | 420 ---- x/stablecoin/types/types.go | 1 - 52 files changed, 11 insertions(+), 13755 deletions(-) delete mode 100644 x/stablecoin/README.md delete mode 100644 x/stablecoin/abci.go delete mode 100644 x/stablecoin/abci_test.go delete mode 100644 x/stablecoin/client/cli/cli_test.go delete mode 100644 x/stablecoin/client/cli/flags.go delete mode 100644 x/stablecoin/client/cli/query.go delete mode 100644 x/stablecoin/client/cli/tx.go delete mode 100644 x/stablecoin/genesis.go delete mode 100644 x/stablecoin/genesis_test.go delete mode 100644 x/stablecoin/keeper/balance.go delete mode 100644 x/stablecoin/keeper/collateral_ratio.go delete mode 100644 x/stablecoin/keeper/collateral_ratio_test.go delete mode 100644 x/stablecoin/keeper/grpc_query.go delete mode 100644 x/stablecoin/keeper/grpc_query_test.go delete mode 100644 x/stablecoin/keeper/hooks.go delete mode 100644 x/stablecoin/keeper/keeper.go delete mode 100644 x/stablecoin/keeper/keeper_test.go delete mode 100644 x/stablecoin/keeper/mint_burn_stable.go delete mode 100644 x/stablecoin/keeper/mint_burn_stable_test.go delete mode 100644 x/stablecoin/keeper/msg_server.go delete mode 100644 x/stablecoin/keeper/msg_server_test.go delete mode 100644 x/stablecoin/keeper/needed.go delete mode 100644 x/stablecoin/keeper/needed_test.go delete mode 100644 x/stablecoin/keeper/params_test.go delete mode 100644 x/stablecoin/keeper/supply.go delete mode 100644 x/stablecoin/keeper/supply_test.go delete mode 100644 x/stablecoin/mock/dex_keeper.go delete mode 100644 x/stablecoin/module.go delete mode 100644 x/stablecoin/module_simulation.go delete mode 100644 x/stablecoin/simulation/msg.go delete mode 100644 x/stablecoin/simulation/sim.go delete mode 100644 x/stablecoin/types/codec.go delete mode 100644 x/stablecoin/types/errors.go delete mode 100644 x/stablecoin/types/events.pb.go delete mode 100644 x/stablecoin/types/expected_keepers.go delete mode 100644 x/stablecoin/types/expected_keepers_test.go delete mode 100644 x/stablecoin/types/genesis.go delete mode 100644 x/stablecoin/types/genesis.pb.go delete mode 100644 x/stablecoin/types/genesis_test.go delete mode 100644 x/stablecoin/types/keys.go delete mode 100644 x/stablecoin/types/messages.go delete mode 100644 x/stablecoin/types/messages_test.go delete mode 100644 x/stablecoin/types/params.go delete mode 100644 x/stablecoin/types/params.pb.go delete mode 100644 x/stablecoin/types/query.pb.go delete mode 100644 x/stablecoin/types/query.pb.gw.go delete mode 100644 x/stablecoin/types/tx.pb.go delete mode 100644 x/stablecoin/types/tx.pb.gw.go delete mode 100644 x/stablecoin/types/types.go diff --git a/CHANGELOG.md b/CHANGELOG.md index e0cd2774e..b4985578f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,9 +41,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Features + * [#xxx](https://github.com/NibiruChain/nibiru/pull/xxx) - epic(tokenfactory): State transitions, collections, genesis import and export, and app wiring +### State Breaking + +* [#1609](https://github.com/NibiruChain/nibiru/pull/1609) - refactor(app)!: Remove x/stablecoin module. + ## [v0.21.10] ### Features diff --git a/app/app.go b/app/app.go index 4821aa4d3..c2c338283 100644 --- a/app/app.go +++ b/app/app.go @@ -114,9 +114,6 @@ import ( "github.com/NibiruChain/nibiru/x/spot" spotkeeper "github.com/NibiruChain/nibiru/x/spot/keeper" spottypes "github.com/NibiruChain/nibiru/x/spot/types" - "github.com/NibiruChain/nibiru/x/stablecoin" - stablecoinkeeper "github.com/NibiruChain/nibiru/x/stablecoin/keeper" - stablecointypes "github.com/NibiruChain/nibiru/x/stablecoin/types" "github.com/NibiruChain/nibiru/x/sudo" "github.com/NibiruChain/nibiru/x/sudo/keeper" sudotypes "github.com/NibiruChain/nibiru/x/sudo/types" @@ -168,7 +165,6 @@ var ( spot.AppModuleBasic{}, oracle.AppModuleBasic{}, epochs.AppModuleBasic{}, - stablecoin.AppModuleBasic{}, perpv2.AppModuleBasic{}, inflation.AppModuleBasic{}, sudo.AppModuleBasic{}, @@ -191,19 +187,17 @@ var ( oracletypes.ModuleName: {}, ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, ibcfeetypes.ModuleName: {}, - stablecointypes.ModuleName: {authtypes.Minter, authtypes.Burner}, perptypesv2.ModuleName: {}, perptypesv2.VaultModuleAccount: {}, perptypesv2.PerpEFModuleAccount: {}, perptypesv2.FeePoolModuleAccount: {}, - epochstypes.ModuleName: {}, - stablecointypes.StableEFModuleAccount: {authtypes.Burner}, - sudotypes.ModuleName: {}, - common.TreasuryPoolModuleAccount: {}, - wasm.ModuleName: {authtypes.Burner}, - tokenfactorytypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + epochstypes.ModuleName: {}, + sudotypes.ModuleName: {}, + common.TreasuryPoolModuleAccount: {}, + wasm.ModuleName: {authtypes.Burner}, + tokenfactorytypes.ModuleName: {authtypes.Minter, authtypes.Burner}, } ) @@ -278,7 +272,6 @@ type NibiruApp struct { PerpKeeperV2 perpkeeperv2.Keeper SpotKeeper spotkeeper.Keeper OracleKeeper oraclekeeper.Keeper - StablecoinKeeper stablecoinkeeper.Keeper InflationKeeper inflationkeeper.Keeper SudoKeeper keeper.Keeper DevGasKeeper devgaskeeper.Keeper @@ -628,7 +621,6 @@ func initParamsKeeper( // Nibiru core params keepers | x/ paramsKeeper.Subspace(spottypes.ModuleName) paramsKeeper.Subspace(epochstypes.ModuleName) - paramsKeeper.Subspace(stablecointypes.ModuleName) paramsKeeper.Subspace(inflationtypes.ModuleName) // ibc params keepers paramsKeeper.Subspace(ibctransfertypes.ModuleName) diff --git a/app/keepers.go b/app/keepers.go index 7de11338d..5de5af006 100644 --- a/app/keepers.go +++ b/app/keepers.go @@ -95,9 +95,6 @@ import ( "github.com/NibiruChain/nibiru/x/spot" spotkeeper "github.com/NibiruChain/nibiru/x/spot/keeper" spottypes "github.com/NibiruChain/nibiru/x/spot/types" - "github.com/NibiruChain/nibiru/x/stablecoin" - stablecoinkeeper "github.com/NibiruChain/nibiru/x/stablecoin/keeper" - stablecointypes "github.com/NibiruChain/nibiru/x/stablecoin/types" "github.com/NibiruChain/nibiru/x/sudo" "github.com/NibiruChain/nibiru/x/sudo/keeper" sudotypes "github.com/NibiruChain/nibiru/x/sudo/types" @@ -135,7 +132,6 @@ func initStoreKeys() ( // nibiru x/ keys spottypes.StoreKey, - stablecointypes.StoreKey, oracletypes.StoreKey, epochstypes.StoreKey, perpv2types.StoreKey, @@ -146,7 +142,7 @@ func initStoreKeys() ( tokenfactorytypes.StoreKey, ) tkeys = sdk.NewTransientStoreKeys(paramstypes.TStoreKey) - memKeys = sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey, stablecointypes.MemStoreKey) + memKeys = sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) return keys, tkeys, memKeys } @@ -283,12 +279,6 @@ func (app *NibiruApp) InitKeepers( app.AccountKeeper, app.BankKeeper, app.DistrKeeper, app.stakingKeeper, distrtypes.ModuleName, ) - app.StablecoinKeeper = stablecoinkeeper.NewKeeper( - appCodec, keys[stablecointypes.StoreKey], memKeys[stablecointypes.MemStoreKey], - app.GetSubspace(stablecointypes.ModuleName), - app.AccountKeeper, app.BankKeeper, app.OracleKeeper, app.SpotKeeper, - ) - app.EpochsKeeper = epochskeeper.NewKeeper( appCodec, keys[epochstypes.StoreKey], ) @@ -309,7 +299,6 @@ func (app *NibiruApp) InitKeepers( app.EpochsKeeper.SetHooks( epochstypes.NewMultiEpochHooks( - app.StablecoinKeeper.Hooks(), app.PerpKeeperV2.Hooks(), app.InflationKeeper.Hooks(), app.OracleKeeper.Hooks(), @@ -520,7 +509,6 @@ func (app *NibiruApp) initAppModules( // Nibiru modules spot.NewAppModule(appCodec, app.SpotKeeper, app.AccountKeeper, app.BankKeeper), - stablecoin.NewAppModule(appCodec, app.StablecoinKeeper, app.AccountKeeper, app.BankKeeper, app.OracleKeeper), oracle.NewAppModule(appCodec, app.OracleKeeper, app.AccountKeeper, app.BankKeeper), epochs.NewAppModule(appCodec, app.EpochsKeeper), perpv2.NewAppModule(appCodec, app.PerpKeeperV2, app.AccountKeeper, app.BankKeeper, app.OracleKeeper), @@ -590,7 +578,6 @@ func orderedModuleNames() []string { // -------------------------------------------------------------------- // Native x/ Modules epochstypes.ModuleName, - stablecointypes.ModuleName, spottypes.ModuleName, oracletypes.ModuleName, perpv2types.ModuleName, diff --git a/x/stablecoin/README.md b/x/stablecoin/README.md deleted file mode 100644 index d06b610a9..000000000 --- a/x/stablecoin/README.md +++ /dev/null @@ -1,108 +0,0 @@ -# `x/stablecoin` - -******* - -The `stablecoin` module is responsible for minting and burning NUSD, maintenance of NUSD's price stability, and orchestration of Nibiru Protocol's collateral ratio. - -- [Docs - NUSD Stablecoin](https://docs.nibiru.fi/ecosystem/nusd-stablecoin.html) - -#### Table of Contents - -- **[CLI Usage Guide](#cli-usage-guide)** - - [Minting Stablecoins](#minting-stablecoins) -- **[Concepts](#concepts)** - - [Recollateralize](#recollateralize): Recollateralize is a function that incentivizes the caller to add up to the amount of collateral needed to reach some **target collateral ratio** (`collRatioTarget`). - - [Buybacks](#buybacks): A user can call `Buyback` when there's too much collateral in the protocol according to the target collateral ratio. The user swaps NIBI for UST at a 0% transaction fee and the protocol burns the NIBI it buys from the user. -- **Messages and Events**: [description] -- **Keepers and Parameters**: [description] -- **Module Accounts of `x/stablecoin`**: [description] - ---- - -# CLI Usage Guide - -## Minting Stablecoins - -In a new terminal, run the following command: - -```bash -// send a transaction to mint stablecoin -$ nibid tx stablecoin mint 1000validatortoken --from validator --home data/localnet --chain-id localnet - -// query the balance -$ nibid q bank balances cosmos1zaavvzxez0elundtn32qnk9lkm8kmcszzsv80v -``` - - - -# Concepts - -## Recollateralize - -**Recollateralize** is a function that incentivizes the caller to add up to the amount of collateral needed to reach some **target collateral ratio** (`collRatioTarget`). Recollateralize checks if the USD value of collateral in the protocol is below the required amount defined by the current collateral ratio. Here, Nibiru's NUSD stablecoin is taken to be the dollar that determines USD value. - -**`collRatio`**: The collateral ratio, or 'collRatio' (sdk.Dec), is a value beteween 0 and 1 that determines what proportion of collateral and governance token is used during stablecoin mints and burns. - -#### How much collateral is needed to reach a certain `collRatio`? - -Suppose an amount `supplyNUSD` of NUSD is in circulation at $1 at some inital collateral ratio, `collRatioStart`. The total USD value of the collateral in Nibiru is denoted `collUSDVal`. If NUSD falls in price below the lower band, the collateral ratio will increase to `collRatioTarget`, which is the target ratio. - -In order to reach the target `collRatioTarget` with a constant `supplyNUSD`, more collateral needs to be added to the system. This amount can be given by: -```go -collUSDValEnd := supplyNUSD * collRatioEnd -collNeeded := collUSDValEnd - collUSDVal -``` - -#### Incentives for the caller of `Recollateralize` - -The caller is given bonus NIBI for bringing the value of the protocol's collateral up to the appropriate value as defined by `collRatioTarget`. This bonus rate is some percentage of the collateral value provided. - -Let: -- `collNeeded` (sdk.Int): Amount of collateral needed to reach the target `collRatio`. -- `priceColl` (sdk.Dec): USD price of the collateral -- `priceNIBI` (sdk.Dec): USD price of NIBI. -- `bonusRate` (sdk.Dec): Defaults to 0.2% (20 bps). The bonus rate gives the caller an incentive to recollateralize Nibiru to the target `collRatioTarget`. - -Thus, the caller receives an amount of NIBI, `nibiOut`: -```go -nibiOut * priceNIBI = (collNeeded * priceColl) * (1 + bonusRate) -nibiOut = (collNeeded * priceColl) * (1 + bonusRate) / priceNIBI -``` - -#### Implementation - -See [[collateral_ratio.go]](../keeper/collateral_ratio.go) - - -#### References: -- https://github.com/NibiruChain/nibiru/issues/118 - - -## Buybacks - -**TLDR**: A user can call `Buyback` when there's too much collateral in the protocol according to the target collateral ratio. The user swaps NIBI for UST at a 0% transaction fee and the protocol burns the NIBI it buys from the user. - -**`collRatio`**: The collateral ratio, or `collRatio` (sdk.Dec), is a value beteween 0 and 1 that determines what proportion of collateral and governance token is used during stablecoin mints and burns. - -**`liqRatio`**: The liquidity ratio, or `liqRatio` (sdk.Dec), is a the proportion of the circulating NIBI liquidity relvative to the NUSD (stable) value. - -#### When is a "buyback" possible? - -The protocol has too much collateral. Here, "protocol" refers to the module account of the `x/stablecoin` module, and "too much" refers to the difference between the `collRatio` and `liqRatio`. - -For example, if there's 10M NUSD in circulation, the price of UST collateral is 0.99 NUSD per UST, and the protocol has 5M UST, the `liqRatio` would be (5M * 0.99) / 10M = 0.495. -Thus, if the collateral ratio, or `collRatio`, is less than 0.495, the an address with sufficient funds can call `Buyback`. - -#### How does a buyback work? - -The protocol has an excess of collateral. Buybacks allow users to sell NIBI to the protocol in exchange for NUSD, meaning that Nibiru Chain is effectively buying back its shares. After this transfer, the NIBI purchased by protocol is burned. This raises the value of the NIBI token for all of its hodlers. - -- Unlike `Recollateralize`, there is no bonus rate for this transaction. - - -#### Related Issues: -- https://github.com/NibiruChain/nibiru/issues/117 diff --git a/x/stablecoin/abci.go b/x/stablecoin/abci.go deleted file mode 100644 index 3dd9130a1..000000000 --- a/x/stablecoin/abci.go +++ /dev/null @@ -1,30 +0,0 @@ -package stablecoin - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/NibiruChain/nibiru/x/common/asset" - "github.com/NibiruChain/nibiru/x/common/denoms" - "github.com/NibiruChain/nibiru/x/stablecoin/keeper" -) - -// EndBlocker updates the current oracle -func EndBlocker(ctx sdk.Context, k keeper.Keeper) { - if !k.GetParams(ctx).IsCollateralRatioValid { - // Try to re-start the collateral ratio updates - err := k.EvaluateCollRatio(ctx) - - params := k.GetParams(ctx) - params.IsCollateralRatioValid = (err == nil) - - k.SetParams(ctx, params) - } - - _, err := k.OracleKeeper.GetExchangeRateTwap(ctx, asset.Registry.Pair(denoms.USDC, denoms.NUSD)) - if err != nil { - params := k.GetParams(ctx) - params.IsCollateralRatioValid = false - - k.SetParams(ctx, params) - } -} diff --git a/x/stablecoin/abci_test.go b/x/stablecoin/abci_test.go deleted file mode 100644 index 888d3e7bd..000000000 --- a/x/stablecoin/abci_test.go +++ /dev/null @@ -1,169 +0,0 @@ -package stablecoin_test - -import ( - "testing" - "time" - - "github.com/NibiruChain/nibiru/app" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" - - "github.com/NibiruChain/nibiru/x/common/asset" - "github.com/NibiruChain/nibiru/x/common/denoms" - "github.com/NibiruChain/nibiru/x/common/testutil/testapp" - "github.com/NibiruChain/nibiru/x/epochs" - otypes "github.com/NibiruChain/nibiru/x/oracle/types" -) - -type test struct { - Name string - InCollRatio sdk.Dec - ExpectedCollRatio sdk.Dec - price sdk.Dec - fn func() -} - -func TestEpochInfoChangesBeginBlockerAndInitGenesis(t *testing.T) { - var app *app.NibiruApp - var ctx sdk.Context - var price sdk.Dec - - tests := []test{ - { - Name: "Collateral price higher than stable, wait for correct amount of time", - InCollRatio: sdk.MustNewDecFromStr("0.8"), - price: sdk.MustNewDecFromStr("0.9"), - ExpectedCollRatio: sdk.MustNewDecFromStr("0.7975"), - fn: func() { - ctx = ctx.WithBlockHeight(2).WithBlockTime(ctx.BlockTime().Add(time.Second)) - epochs.BeginBlocker(ctx, app.EpochsKeeper) - - ctx = ctx.WithBlockHeight(3).WithBlockTime(ctx.BlockTime().Add(time.Second * 60 * 16)) - app.OracleKeeper.SetPrice(ctx, asset.Registry.Pair(denoms.USDC, denoms.NUSD), price) - epochs.BeginBlocker(ctx, app.EpochsKeeper) - }, - }, - { - Name: "Price at peg, coll ratio should be the same", - InCollRatio: sdk.MustNewDecFromStr("0.8"), - price: sdk.OneDec(), - ExpectedCollRatio: sdk.MustNewDecFromStr("0.8"), - fn: func() { - ctx = ctx.WithBlockHeight(2).WithBlockTime(ctx.BlockTime().Add(time.Second)) - epochs.BeginBlocker(ctx, app.EpochsKeeper) - - ctx = ctx.WithBlockHeight(3).WithBlockTime(ctx.BlockTime().Add(time.Second * 60 * 16)) - app.OracleKeeper.SetPrice(ctx, asset.Registry.Pair(denoms.USDC, denoms.NUSD), price) - epochs.BeginBlocker(ctx, app.EpochsKeeper) - }, - }, - { - Name: "Price higher than peg, but we don't wait for enough time, coll ratio should be the same", - InCollRatio: sdk.MustNewDecFromStr("0.8"), - price: sdk.MustNewDecFromStr("0.9"), - ExpectedCollRatio: sdk.MustNewDecFromStr("0.8"), - fn: func() { - ctx = ctx.WithBlockHeight(2).WithBlockTime(ctx.BlockTime().Add(time.Second)) - epochs.BeginBlocker(ctx, app.EpochsKeeper) - - ctx = ctx.WithBlockHeight(3).WithBlockTime(ctx.BlockTime().Add(time.Second * 2)) - epochs.BeginBlocker(ctx, app.EpochsKeeper) - - ctx = ctx.WithBlockHeight(3).WithBlockTime(ctx.BlockTime().Add(time.Second * 3)) - epochs.BeginBlocker(ctx, app.EpochsKeeper) - }, - }, - { - Name: "Collateral price higher than stable, and we wait for 2 updates, coll ratio should be updated twice", - InCollRatio: sdk.MustNewDecFromStr("0.8"), - price: sdk.MustNewDecFromStr("1.1"), - ExpectedCollRatio: sdk.MustNewDecFromStr("0.805"), - fn: func() { - ctx = ctx.WithBlockHeight(2).WithBlockTime(ctx.BlockTime().Add(time.Second)) - epochs.BeginBlocker(ctx, app.EpochsKeeper) - - ctx = ctx.WithBlockHeight(3).WithBlockTime(ctx.BlockTime().Add(time.Second + time.Minute*15)) - app.OracleKeeper.SetPrice(ctx, asset.Registry.Pair(denoms.USDC, denoms.NUSD), price) - epochs.BeginBlocker(ctx, app.EpochsKeeper) - - ctx = ctx.WithBlockHeight(3).WithBlockTime(ctx.BlockTime().Add(time.Second + time.Minute*30)) - app.OracleKeeper.SetPrice(ctx, asset.Registry.Pair(denoms.USDC, denoms.NUSD), price) - epochs.BeginBlocker(ctx, app.EpochsKeeper) - }, - }, - { - Name: "Collateral price higher than stable, and we wait for 2 updates but the last one is too close for update, coll ratio should be updated once", - InCollRatio: sdk.MustNewDecFromStr("0.8"), - price: sdk.MustNewDecFromStr("1.1"), - ExpectedCollRatio: sdk.MustNewDecFromStr("0.8025"), - fn: func() { - ctx = ctx.WithBlockHeight(2).WithBlockTime(ctx.BlockTime().Add(time.Second)) - epochs.BeginBlocker(ctx, app.EpochsKeeper) - - ctx = ctx.WithBlockHeight(3).WithBlockTime(ctx.BlockTime().Add(time.Second + time.Minute*14)) - app.OracleKeeper.SetPrice(ctx, asset.Registry.Pair(denoms.USDC, denoms.NUSD), price) - epochs.BeginBlocker(ctx, app.EpochsKeeper) - - ctx = ctx.WithBlockHeight(3).WithBlockTime(ctx.BlockTime().Add(time.Second + time.Minute*16)) - app.OracleKeeper.SetPrice(ctx, asset.Registry.Pair(denoms.USDC, denoms.NUSD), price) - epochs.BeginBlocker(ctx, app.EpochsKeeper) - }, - }, - } - - for _, tc := range tests { - tc := tc - t.Run(tc.Name, func(t *testing.T) { - app, ctx = testapp.NewNibiruTestAppAndContext() - - ctx = ctx.WithBlockHeight(1) - price = tc.price - - require.NoError(t, app.StablecoinKeeper.SetCollRatio(ctx, tc.InCollRatio)) - - tc.fn() - - currCollRatio := app.StablecoinKeeper.GetCollRatio(ctx) - require.Equal(t, tc.ExpectedCollRatio, currCollRatio) - }) - } -} - -func TestEpochInfoChangesCollateralValidity(t *testing.T) { - app, ctx := testapp.NewNibiruTestAppAndContext() - - runBlock := func(duration time.Duration) { - ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1).WithBlockTime(ctx.BlockTime().Add(duration)) - epochs.BeginBlocker(ctx, app.EpochsKeeper) - } - - // start at t=1sec with blockheight 1 - ctx = ctx.WithBlockHeight(1).WithBlockTime(time.Now()) - epochs.BeginBlocker(ctx, app.EpochsKeeper) - - pairs := []asset.Pair{ - asset.Registry.Pair(denoms.USDC, denoms.NUSD), - } - params := otypes.DefaultParams() - params.TwapLookbackWindow = 1 * time.Hour - app.OracleKeeper.Params.Set(ctx, params) - app.OracleKeeper.SetPrice(ctx, pairs[0], sdk.MustNewDecFromStr("0.9")) - - require.NoError(t, app.StablecoinKeeper.SetCollRatio(ctx, sdk.MustNewDecFromStr("0.8"))) - - // Mint block #2 - runBlock(time.Minute * 15) - require.True(t, app.StablecoinKeeper.GetParams(ctx).IsCollateralRatioValid) - - // Mint block #3, collateral should be not valid because price are expired - runBlock(time.Hour) // Collateral ratio is set to invalid at the beginning of this block - require.False(t, app.StablecoinKeeper.GetParams(ctx).IsCollateralRatioValid) - - // Post price, collateral should be valid again - app.OracleKeeper.SetPrice(ctx, pairs[0], sdk.MustNewDecFromStr("0.9")) - - // Mint block #4, median price and TWAP are computed again at the end of a new block - runBlock(15 * time.Minute) // Collateral ratio is set to valid at the next epoch - require.True(t, app.StablecoinKeeper.GetParams(ctx).IsCollateralRatioValid) -} diff --git a/x/stablecoin/client/cli/cli_test.go b/x/stablecoin/client/cli/cli_test.go deleted file mode 100644 index 68998ffb0..000000000 --- a/x/stablecoin/client/cli/cli_test.go +++ /dev/null @@ -1,289 +0,0 @@ -package cli_test - -import ( - "fmt" - "testing" - - sdkmath "cosmossdk.io/math" - - "github.com/cosmos/cosmos-sdk/client/flags" - clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth/types" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - "github.com/cosmos/gogoproto/proto" - "github.com/stretchr/testify/suite" - - "github.com/NibiruChain/nibiru/app" - "github.com/NibiruChain/nibiru/x/common" - "github.com/NibiruChain/nibiru/x/common/asset" - "github.com/NibiruChain/nibiru/x/common/denoms" - testutilcli "github.com/NibiruChain/nibiru/x/common/testutil/cli" - "github.com/NibiruChain/nibiru/x/common/testutil/genesis" - oracletypes "github.com/NibiruChain/nibiru/x/oracle/types" - "github.com/NibiruChain/nibiru/x/stablecoin/client/cli" - stabletypes "github.com/NibiruChain/nibiru/x/stablecoin/types" -) - -type IntegrationTestSuite struct { - suite.Suite - - cfg testutilcli.Config - network *testutilcli.Network -} - -func (s *IntegrationTestSuite) SetupSuite() { - /* Make test skip if -short is not used: - All tests: `go test ./...` - Unit tests only: `go test ./... -short` - Integration tests only: `go test ./... -run Integration` - https://stackoverflow.com/a/41407042/13305627 */ - if testing.Short() { - s.T().Skip("skipping integration test suite") - } - - s.T().Log("setting up integration test suite") - app.SetPrefixes(app.AccountAddressPrefix) - - encodingConfig := app.MakeEncodingConfigAndRegister() - genesisState := genesis.NewTestGenesisState(encodingConfig) - - // x/stablecoin genesis state - stableGen := stabletypes.DefaultGenesis() - stableGen.Params.IsCollateralRatioValid = true - stableGen.ModuleAccountBalance = sdk.NewCoin(denoms.USDC, sdk.NewInt(10000*common.TO_MICRO)) - genesisState[stabletypes.ModuleName] = encodingConfig.Marshaler.MustMarshalJSON(stableGen) - - oracleGenesis := oracletypes.DefaultGenesisState() - oracleGenesis.ExchangeRates = []oracletypes.ExchangeRateTuple{ - {Pair: asset.Registry.Pair(denoms.NIBI, denoms.NUSD), ExchangeRate: sdk.NewDec(10)}, - {Pair: asset.Registry.Pair(denoms.USDC, denoms.NUSD), ExchangeRate: sdk.OneDec()}, - } - oracleGenesis.Params.VotePeriod = 1_000 - - genesisState[oracletypes.ModuleName] = encodingConfig.Marshaler.MustMarshalJSON(oracleGenesis) - - homeDir := s.T().TempDir() - s.cfg = testutilcli.BuildNetworkConfig(genesisState) - - network, err := testutilcli.New(s.T(), homeDir, s.cfg) - s.Require().NoError(err) - - s.network = network - _, err = s.network.WaitForHeight(1) - s.NoError(err) -} - -func (s *IntegrationTestSuite) TearDownSuite() { - s.T().Log("tearing down integration test suite") - s.network.Cleanup() -} - -func (s IntegrationTestSuite) TestMintStableCmd() { - val := s.network.Validators[0] - minter := testutilcli.NewAccount(s.network, "minter2") - - s.NoError(testutilcli.FillWalletFromValidator( - minter, - sdk.NewCoins( - sdk.NewInt64Coin(denoms.NIBI, 100*common.TO_MICRO), - sdk.NewInt64Coin(denoms.USDC, 100*common.TO_MICRO), - ), - val, - s.cfg.BondDenom, - )) - - commonArgs := []string{ - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(denoms.NIBI, sdk.NewInt(10))).String()), - } - s.Require().NoError(s.network.WaitForNextBlock()) - - testCases := []struct { - name string - args []string - - expectedStable sdkmath.Int - expectErr bool - respType proto.Message - expectedCode uint32 - }{ - { - name: "Mint correct amount", - args: append([]string{ - "1000000unusd", - fmt.Sprintf("--%s=%s", flags.FlagFrom, "minter2"), - }, commonArgs...), - expectedStable: sdk.NewInt(1 * common.TO_MICRO), - expectErr: false, - respType: &sdk.TxResponse{}, - expectedCode: 0, - }, - } - - for _, tc := range testCases { - tc := tc - - s.Run(tc.name, func() { - cmd := cli.MintStableCmd() - clientCtx := val.ClientCtx - - out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) - s.Require().NoError(s.network.WaitForNextBlock()) - if tc.expectErr { - s.Require().Error(err) - } else { - s.NoError(err, out.String()) - s.NoError( - clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) - - txResp := tc.respType.(*sdk.TxResponse) - tx, err := testutilcli.QueryTx(val.ClientCtx, txResp.TxHash) - s.NoError(err) - - s.Require().Equal(tc.expectedCode, tx.Code, out.String()) - - resp, err := clitestutil.QueryBalancesExec(clientCtx, minter) - s.NoError(err) - - var balRes banktypes.QueryAllBalancesResponse - err = val.ClientCtx.Codec.UnmarshalJSON(resp.Bytes(), &balRes) - s.NoError(err) - - s.Require().Equal( - balRes.Balances.AmountOf(denoms.NUSD), tc.expectedStable) - } - }) - } -} - -func (s IntegrationTestSuite) TestBurnStableCmd() { - val := s.network.Validators[0] - burner := testutilcli.NewAccount(s.network, "burn") - s.NoError(testutilcli.FillWalletFromValidator( - burner, - sdk.NewCoins( - sdk.NewInt64Coin(s.cfg.BondDenom, 20_000), - sdk.NewInt64Coin(denoms.NUSD, 50*common.TO_MICRO), - ), - val, - s.cfg.BondDenom, - )) - s.NoError(s.network.WaitForNextBlock()) - - defaultBondCoinsString := sdk.NewCoins(sdk.NewCoin(denoms.NIBI, sdk.NewInt(10))).String() - commonArgs := []string{ - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, defaultBondCoinsString), - } - - testCases := []struct { - name string - args []string - - expectedStable sdkmath.Int - expectedColl sdkmath.Int - expectedGov sdkmath.Int - expectedTreasury sdk.Coins - expectedEf sdk.Coins - expectErr bool - respType proto.Message - expectedCode uint32 - }{ - { - name: "Burn at 100% collRatio", - args: append([]string{ - "50000000unusd", - fmt.Sprintf("--%s=%s", flags.FlagFrom, "burn"), - }, commonArgs...), - expectedStable: sdk.ZeroInt(), - expectedColl: sdk.NewInt(50*common.TO_MICRO - 100_000), // Collateral minus 0,02% fees - expectedGov: sdk.NewInt(19_990), - expectedTreasury: sdk.NewCoins(sdk.NewInt64Coin(denoms.USDC, 50_000)), - expectedEf: sdk.NewCoins(sdk.NewInt64Coin(denoms.USDC, 50_000)), - expectErr: false, - respType: &sdk.TxResponse{}, - expectedCode: 0, - }, - // { - // name: "Burn at 90% collRatio", - // args: append([]string{ - // "100000000unusd", - // fmt.Sprintf("--%s=%s", flags.FlagFrom, "burn")}, commonArgs...), - // expectedStable: sdk.ZeroInt(), - // expectedColl: sdk.NewInt(90 * common.TO_MICRO), - // expectedGov: sdk.NewInt(1 * common.TO_MICRO), - // expectErr: false, - // respType: &sdk.TxResponse{}, - // expectedCode: 0, - // }, - } - - for _, tc := range testCases { - tc := tc - - s.Run(tc.name, func() { - cmd := cli.BurnStableCmd() - clientCtx := val.ClientCtx - - out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) - s.Require().NoError(s.network.WaitForNextBlock()) - - if tc.expectErr { - s.Require().Error(err) - } else { - s.NoError(err, out.String()) - s.NoError( - clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), - out.String(), - ) - - txResp := tc.respType.(*sdk.TxResponse) - tx, err := testutilcli.QueryTx(val.ClientCtx, txResp.TxHash) - s.NoError(err) - s.Require().Equal(tc.expectedCode, tx.Code, out.String()) - - resp, err := clitestutil.QueryBalancesExec(clientCtx, burner) - s.NoError(err) - - var balRes banktypes.QueryAllBalancesResponse - err = val.ClientCtx.Codec.UnmarshalJSON(resp.Bytes(), &balRes) - s.NoError(err) - - s.Require().Equal( - tc.expectedColl, balRes.Balances.AmountOf(denoms.USDC)) - s.Require().Equal( - tc.expectedGov, balRes.Balances.AmountOf(denoms.NIBI)) - s.Require().Equal( - tc.expectedStable, balRes.Balances.AmountOf(denoms.NUSD)) - - // Query treasury pool balance - resp, err = clitestutil.QueryBalancesExec( - clientCtx, types.NewModuleAddress(common.TreasuryPoolModuleAccount)) - s.NoError(err) - err = val.ClientCtx.Codec.UnmarshalJSON(resp.Bytes(), &balRes) - s.NoError(err) - - s.Require().Equal( - tc.expectedTreasury, balRes.Balances) - - // Query ecosystem fund balance - resp, err = clitestutil.QueryBalancesExec( - clientCtx, - types.NewModuleAddress(stabletypes.StableEFModuleAccount)) - s.NoError(err) - err = val.ClientCtx.Codec.UnmarshalJSON(resp.Bytes(), &balRes) - s.NoError(err) - - s.Require().Equal( - tc.expectedEf, balRes.Balances) - } - }) - } -} - -func TestIntegrationTestSuite(t *testing.T) { - suite.Run(t, new(IntegrationTestSuite)) -} diff --git a/x/stablecoin/client/cli/flags.go b/x/stablecoin/client/cli/flags.go deleted file mode 100644 index 3d28191e9..000000000 --- a/x/stablecoin/client/cli/flags.go +++ /dev/null @@ -1,17 +0,0 @@ -package cli - -import ( - flag "github.com/spf13/pflag" -) - -const ( - // Will be parsed to []string. - MintDenoms = "swap-route-denoms" -) - -func FlagSetSwapAmountOutRoutes() *flag.FlagSet { - fs := flag.NewFlagSet("", flag.ContinueOnError) - - fs.StringArray(MintDenoms, []string{""}, "mint denoms") - return fs -} diff --git a/x/stablecoin/client/cli/query.go b/x/stablecoin/client/cli/query.go deleted file mode 100644 index 4deedbc0e..000000000 --- a/x/stablecoin/client/cli/query.go +++ /dev/null @@ -1,149 +0,0 @@ -package cli - -import ( - "context" - "fmt" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - - "github.com/NibiruChain/nibiru/x/stablecoin/types" - - "github.com/spf13/cobra" -) - -// GetQueryCmd returns the cli query commands for this module -func GetQueryCmd() *cobra.Command { - // Group stablecoin queries under a subcommand - stablecoinQueryCmd := &cobra.Command{ - Use: types.ModuleName, - Short: fmt.Sprintf( - "Querying commands for the %s module", types.ModuleName), - DisableFlagParsing: true, - SuggestionsMinimumDistance: 2, - RunE: client.ValidateCmd, - } - - cmds := []*cobra.Command{ - CmdQueryParams(), - CmdQueryModuleAccountBalances(), - CmdQueryCirculatingSupplies(), - CmdQueryLiquidityRatioInfo(), - } - for _, cmd := range cmds { - stablecoinQueryCmd.AddCommand(cmd) - } - - return stablecoinQueryCmd -} - -func CmdQueryParams() *cobra.Command { - cmd := &cobra.Command{ - Use: "params", - Short: "shows the parameters of the module", - Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } - - queryClient := types.NewQueryClient(clientCtx) - - res, err := queryClient.Params(context.Background(), &types.QueryParamsRequest{}) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - -func CmdQueryModuleAccountBalances() *cobra.Command { - cmd := &cobra.Command{ - Use: "module-acc", - Short: "account balances of the x/stablecoin module", - Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } - - queryClient := types.NewQueryClient(clientCtx) - - res, err := queryClient.ModuleAccountBalances( - context.Background(), &types.QueryModuleAccountBalances{}) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - -func CmdQueryCirculatingSupplies() *cobra.Command { - cmd := &cobra.Command{ - Use: "circulating-supplies", - Short: "circulating supply of both NIBI and NUSD", - Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } - - queryClient := types.NewQueryClient(clientCtx) - - res, err := queryClient.CirculatingSupplies( - context.Background(), &types.QueryCirculatingSupplies{}) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - -func CmdQueryLiquidityRatioInfo() *cobra.Command { - cmd := &cobra.Command{ - Use: "liqratio-info", - Short: "liqRatio and the liqRatio bands", - Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } - - queryClient := types.NewQueryClient(clientCtx) - - res, err := queryClient.LiquidityRatioInfo( - context.Background(), &types.QueryLiquidityRatioInfoRequest{}) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} diff --git a/x/stablecoin/client/cli/tx.go b/x/stablecoin/client/cli/tx.go deleted file mode 100644 index c46984524..000000000 --- a/x/stablecoin/client/cli/tx.go +++ /dev/null @@ -1,189 +0,0 @@ -package cli - -import ( - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/client/tx" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/spf13/cobra" - - "github.com/NibiruChain/nibiru/x/stablecoin/types" -) - -func GetTxCmd() *cobra.Command { - txCmd := &cobra.Command{ - Use: types.ModuleName, - Short: "Generalized automated market maker transaction subcommands", - DisableFlagParsing: true, - SuggestionsMinimumDistance: 2, - RunE: client.ValidateCmd, - } - - txCmd.AddCommand( - MintStableCmd(), - BurnStableCmd(), - BuybackCmd(), - RecollateralizeCmd(), - ) - - return txCmd -} - -/* -MintStableCmd is a CLI command that mints Nibiru stablecoins. -Example: "mint-sc 100unusd" -*/ -func MintStableCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "mint-sc [token-in]", - Short: "Mint Nibiru stablecoin", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - txf, err := tx.NewFactoryCLI(clientCtx, cmd.Flags()) - if err != nil { - return err - } - - txf = txf.WithTxConfig( - clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) - - inCoin, err := sdk.ParseCoinNormalized(args[0]) - if err != nil { - return err - } - msg := &types.MsgMintStable{ - Creator: clientCtx.GetFromAddress().String(), - Stable: inCoin, - } - - return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -func BurnStableCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "burn-sc [token-in]", - Short: "Burn Nibiru stablecoin commands", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - txf, err := tx.NewFactoryCLI(clientCtx, cmd.Flags()) - if err != nil { - return err - } - txf.WithTxConfig(clientCtx.TxConfig). - WithAccountRetriever(clientCtx.AccountRetriever) - - inCoin, err := sdk.ParseCoinNormalized(args[0]) - if err != nil { - return err - } - msg := &types.MsgBurnStable{ - Creator: clientCtx.GetFromAddress().String(), - Stable: inCoin, - } - return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -func BuybackCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "buyback [token-in]", - Short: "sell shares to the protocol in exchange for collateral (UST)", - Long: `A user can call 'buyback' when there's too much collateral in the - protocol according to the target collateral ratio. The user swaps NIBI - for UST at a 0% transaction fee and the protocol burns the NIBI it - buys from the user.`, - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - txf, err := tx.NewFactoryCLI(clientCtx, cmd.Flags()) - if err != nil { - return err - } - - txf = txf.WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) - - inCoin, err := sdk.ParseCoinNormalized(args[0]) - if err != nil { - return err - } - msg := &types.MsgBuyback{ - Creator: clientCtx.GetFromAddress().String(), - Gov: inCoin, - } - - return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -// TODO: test -func RecollateralizeCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "recoll [token-in]", - Short: "sell UST to the protocol in exchange for bonus value in NIBI", - Long: `Recollateralize is a function that incentivizes the caller to add up to - the amount of collateral needed to reach some target collateral ratio. - Recollateralize checks if the USD value of collateral in the protocol is - below the required amount defined by the current collateral ratio. - Nibiru's NUSD stablecoin is taken to be the dollar that determines USD value.`, - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - txf, err := tx.NewFactoryCLI(clientCtx, cmd.Flags()) - if err != nil { - return err - } - - txf = txf.WithTxConfig( - clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) - - inCoin, err := sdk.ParseCoinNormalized(args[0]) - if err != nil { - return err - } - msg := &types.MsgRecollateralize{ - Creator: clientCtx.GetFromAddress().String(), - Coll: inCoin, - } - - return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} diff --git a/x/stablecoin/genesis.go b/x/stablecoin/genesis.go deleted file mode 100644 index 1984fcd81..000000000 --- a/x/stablecoin/genesis.go +++ /dev/null @@ -1,28 +0,0 @@ -package stablecoin - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/NibiruChain/nibiru/x/stablecoin/keeper" - "github.com/NibiruChain/nibiru/x/stablecoin/types" -) - -// InitGenesis initializes the capability module's state from a provided genesis -// state. -func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { - if genState.ModuleAccountBalance.Amount.GT(sdk.ZeroInt()) { - if err := k.BankKeeper.MintCoins(ctx, types.ModuleName, sdk.NewCoins(genState.ModuleAccountBalance)); err != nil { - panic(err) - } - } - k.SetParams(ctx, genState.Params) -} - -// ExportGenesis returns the capability module's exported genesis. -func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { - genesis := types.DefaultGenesis() - genesis.Params = k.GetParams(ctx) - genesis.ModuleAccountBalance = k.GetModuleAccountBalance(ctx) - - return genesis -} diff --git a/x/stablecoin/genesis_test.go b/x/stablecoin/genesis_test.go deleted file mode 100644 index 63ecc5e1f..000000000 --- a/x/stablecoin/genesis_test.go +++ /dev/null @@ -1,31 +0,0 @@ -package stablecoin_test - -import ( - "testing" - - "github.com/NibiruChain/nibiru/x/common/denoms" - "github.com/NibiruChain/nibiru/x/common/testutil" - "github.com/NibiruChain/nibiru/x/common/testutil/testapp" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" - - "github.com/NibiruChain/nibiru/x/stablecoin" - "github.com/NibiruChain/nibiru/x/stablecoin/types" -) - -func TestGenesis(t *testing.T) { - genesisState := types.GenesisState{ - Params: types.DefaultParams(), - ModuleAccountBalance: sdk.NewCoin(denoms.USDC, sdk.ZeroInt()), - } - - nibiruApp, ctx := testapp.NewNibiruTestAppAndContext() - k := nibiruApp.StablecoinKeeper - stablecoin.InitGenesis(ctx, k, genesisState) - got := stablecoin.ExportGenesis(ctx, k) - require.NotNil(t, got) - - testutil.Fill(&genesisState) - testutil.Fill(got) -} diff --git a/x/stablecoin/keeper/balance.go b/x/stablecoin/keeper/balance.go deleted file mode 100644 index d251635f1..000000000 --- a/x/stablecoin/keeper/balance.go +++ /dev/null @@ -1,35 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/NibiruChain/nibiru/x/stablecoin/types" -) - -// checkEnoughBalance -func (k Keeper) checkEnoughBalance(ctx sdk.Context, coinToSpend sdk.Coin, acc sdk.AccAddress) error { - accCoins := k.BankKeeper.SpendableCoins(ctx, acc) - for _, coin := range accCoins { - if coin.Denom == coinToSpend.Denom { - hasEnoughBalance := coin.Amount.GTE(coinToSpend.Amount) - if hasEnoughBalance { - return nil - } else { - break - } - } - } - return types.NotEnoughBalance.Wrap(coinToSpend.String()) -} - -// CheckEnoughBalances checks if account address has enough balance of coins. -func (k Keeper) CheckEnoughBalances(ctx sdk.Context, coins sdk.Coins, account sdk.AccAddress) error { - for _, coin := range coins { - err := k.checkEnoughBalance(ctx, coin, account) - if err != nil { - return err - } - } - - return nil -} diff --git a/x/stablecoin/keeper/collateral_ratio.go b/x/stablecoin/keeper/collateral_ratio.go deleted file mode 100644 index b45396ffe..000000000 --- a/x/stablecoin/keeper/collateral_ratio.go +++ /dev/null @@ -1,499 +0,0 @@ -package keeper - -import ( - "context" - "fmt" - - sdkmath "cosmossdk.io/math" - - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/NibiruChain/nibiru/x/common" - "github.com/NibiruChain/nibiru/x/common/asset" - "github.com/NibiruChain/nibiru/x/common/denoms" - "github.com/NibiruChain/nibiru/x/stablecoin/types" -) - -// --------------------------------------------------------------------------- -// Collateral Ratio Getters and Setters -// --------------------------------------------------------------------------- - -/* -The collateral ratio, or 'collRatio' (sdk.Dec), is a value beteween 0 and 1 that -determines what proportion of collateral and governance token is used during -stablecoin mints and burns. -*/ - -// GetCollRatio queries the 'collRatio'. -func (k *Keeper) GetCollRatio(ctx sdk.Context) (collRatio sdk.Dec) { - return sdk.NewDec(k.GetParams(ctx).CollRatio).QuoInt64(1 * common.TO_MICRO) -} - -/* -SetCollRatio manually sets the 'collRatio'. This method is mainly used for -testing. when the chain is live, the collateral ratio cannot be manually set, only -adjusted by a fixed amount (e.g. 0.25%). -*/ -func (k *Keeper) SetCollRatio(ctx sdk.Context, collRatio sdk.Dec) (err error) { - collRatioTooHigh := collRatio.GT(sdk.OneDec()) - collRatioTooLow := collRatio.IsNegative() - if collRatioTooHigh { - return fmt.Errorf("input 'collRatio', %d, is higher than 1", collRatio) - } else if collRatioTooLow { - return fmt.Errorf("input 'collRatio', %d, is negative", collRatio) - } - - params := k.GetParams(ctx) - million := sdk.NewDec(1 * common.TO_MICRO) - collRatioInt := collRatio.Mul(million).RoundInt().Int64() - - params.CollRatio = collRatioInt - k.ParamSubspace.SetParamSet(ctx, ¶ms) - - return err -} - -// --------------------------------------------------------------------------- -// Recollateralize -// --------------------------------------------------------------------------- - -/* -updateCollRatio updates the value of the target collateral ratio based on -whether the price of NUSD is above or below peg -*/ -func (k *Keeper) updateCollRatio(ctx sdk.Context, isPriceUp bool) (err error) { - params := k.GetParams(ctx) - nibiruStep := params.GetAdjustmentStepAsDec() - var adjustment sdk.Dec - - if !isPriceUp { - adjustment = nibiruStep - } else { - adjustment = nibiruStep.Mul(sdk.MustNewDecFromStr("-1")) - } - currCollRatio := k.GetCollRatio(ctx) - err = k.SetCollRatio(ctx, currCollRatio.Add(adjustment)) - if err != nil { - return err - } - - return nil -} - -/* -Evaluate Coll ratio updates the collateral ratio if the price is out of the bounds. -*/ -func (k *Keeper) EvaluateCollRatio(ctx sdk.Context) (err error) { - params := k.GetParams(ctx) - - lowerBound := params.GetPriceLowerBoundAsDec() - upperBound := params.GetPriceUpperBoundAsDec() - - stablePrice, err := k.OracleKeeper.GetExchangeRateTwap( - ctx, asset.Registry.Pair(denoms.USDC, denoms.NUSD)) - if err != nil { - return err - } - - if stablePrice.LTE(lowerBound) { - err = k.updateCollRatio(ctx, true) - } else if stablePrice.GTE(upperBound) { - err = k.updateCollRatio(ctx, false) - } - if err != nil { - return err - } - return nil -} - -/* -StableRequiredForTargetCollRatio is the collateral value in USD needed to reach -a target collateral ratio. -*/ -func (k *Keeper) StableRequiredForTargetCollRatio( - ctx sdk.Context, -) (neededStable sdk.Dec, err error) { - stableSupply := k.GetSupplyNUSD(ctx) - targetCollRatio := k.GetCollRatio(ctx) - moduleAddr := k.AccountKeeper.GetModuleAddress(types.ModuleName) - moduleCoins := k.BankKeeper.SpendableCoins(ctx, moduleAddr) - collDenoms := []string{denoms.USDC} - - currentTotalCollUSD := sdk.ZeroDec() - - for _, collDenom := range collDenoms { - amtColl := moduleCoins.AmountOf(collDenom) - priceColl, err := k.OracleKeeper.GetExchangeRate( - ctx, asset.Registry.Pair(denoms.USDC, denoms.NUSD)) - if err != nil { - return sdk.ZeroDec(), err - } - collUSD := priceColl.MulInt(amtColl) - currentTotalCollUSD = currentTotalCollUSD.Add(collUSD) - } - - targetCollUSD := targetCollRatio.MulInt(stableSupply.Amount) - neededStable = targetCollUSD.Sub(currentTotalCollUSD) - return neededStable, err -} - -func (k *Keeper) RecollateralizeCollAmtForTargetCollRatio( - ctx sdk.Context, -) (neededCollAmount sdkmath.Int, err error) { - neededUSDForRecoll, _ := k.StableRequiredForTargetCollRatio(ctx) - priceCollStable, err := k.OracleKeeper.GetExchangeRate( - ctx, asset.Registry.Pair(denoms.USDC, denoms.NUSD)) - if err != nil { - return sdkmath.Int{}, err - } - - neededCollAmountDec := neededUSDForRecoll.Quo(priceCollStable) - return neededCollAmountDec.Ceil().TruncateInt(), err -} - -/* -Recollateralize is a function that incentivizes the caller to add up to the -amount of collateral needed to reach some target collateral ratio -(`collRatioTarget`). Recollateralize checks if the USD value of collateral in -the protocol is below the required amount defined by the current collateral ratio. -Nibiru's NUSD stablecoin is taken to be the dollar that determines USD value. - -Args: - - msg (MsgRecollateralize) { - Creator (string): Caller of 'Recollateralize' - Coll (sdk.Coin): Input collateral that will be sold to the protocol. - } - -Returns: - - response (MsgRecollateralizeResponse) { - Gov (sdk.Coin): Governance received as a reward for recollateralizing Nibiru. - } - err: Error condition for if the function succeeds or fails. -*/ -func (k Keeper) Recollateralize( - goCtx context.Context, msg *types.MsgRecollateralize, -) (response *types.MsgRecollateralizeResponse, err error) { - ctx := sdk.UnwrapSDKContext(goCtx) - caller, err := sdk.AccAddressFromBech32(msg.Creator) - if err != nil { - return response, err - } - - params := k.GetParams(ctx) - targetCollRatio := params.GetCollRatioAsDec() - - neededCollAmt, err := k.RecollateralizeCollAmtForTargetCollRatio(ctx) - if err != nil { - return response, err - } else if neededCollAmt.LTE(sdk.ZeroInt()) { - return response, fmt.Errorf( - "protocol has sufficient COLL, so 'Recollateralize' is not needed") - } - - // The caller doesn't need to be put in the full amount, - // just a positive amount that is at most the 'neededCollAmount'. - inColl := sdk.NewCoin(msg.Coll.Denom, sdk.ZeroInt()) - if msg.Coll.Amount.GT(neededCollAmt) { - inColl.Amount = neededCollAmt - } else if msg.Coll.Amount.LTE(sdk.ZeroInt()) { - return response, fmt.Errorf( - "collateral input, %v, must be positive", msg.Coll.String()) - } else { - inColl.Amount = msg.Coll.Amount - } - - // Send collateral from the caller to the module - err = k.checkEnoughBalance(ctx, inColl, caller) - if err != nil { - return response, err - } - err = k.BankKeeper.SendCoinsFromAccountToModule( - ctx, caller, types.ModuleName, sdk.NewCoins(inColl), - ) - if err != nil { - return response, err - } - - if err := ctx.EventManager().EmitTypedEvent(&types.EventTransfer{ - Coin: inColl, - From: caller.String(), - To: k.AccountKeeper.GetModuleAddress(types.ModuleName).String(), - }); err != nil { - return response, err - } - - // Compute GOV rewarded to user - priceCollStable, err := k.OracleKeeper.GetExchangeRate( - ctx, asset.Registry.Pair(denoms.USDC, denoms.NUSD)) - if err != nil { - return response, err - } - inUSD := priceCollStable.MulInt(inColl.Amount) - outGovAmount, err := k.GovAmtFromRecollateralize(ctx, inUSD) - if err != nil { - return response, err - } - outGov := sdk.NewCoin(denoms.NIBI, outGovAmount) - - // Mint and send GOV reward from the module to the caller - err = k.BankKeeper.MintCoins(ctx, types.ModuleName, sdk.NewCoins(outGov)) - if err != nil { - return response, err - } - - err = ctx.EventManager().EmitTypedEvent(&types.EventMintNIBI{Amount: outGov.Amount}) - if err != nil { - return response, err - } - - err = k.BankKeeper.SendCoinsFromModuleToAccount( - ctx, types.ModuleName, caller, sdk.NewCoins(outGov), - ) - if err != nil { - return response, err - } - - if err := ctx.EventManager().EmitTypedEvent(&types.EventTransfer{ - Coin: outGov, - From: k.AccountKeeper.GetModuleAddress(types.ModuleName).String(), - To: caller.String(), - }); err != nil { - return response, err - } - - if err := ctx.EventManager().EmitTypedEvent(&types.EventRecollateralize{ - InCoin: inColl, - OutCoin: outGov, - Caller: caller.String(), - CollRatio: targetCollRatio, - }); err != nil { - return response, err - } - - return &types.MsgRecollateralizeResponse{ - Gov: outGov, - }, err -} - -/* -GovAmtFromRecollateralize computes the GOV token given as a reward for calling -recollateralize. - -Args: - - ctx (sdk.Context): Carries information about the current state of the application. - inUSD (sdk.Dec): Value in NUSD stablecoin to be used for recollateralization. - -Returns: - - govOut (sdk.Int): Amount of GOV token rewarded for 'Recollateralize'. -*/ -func (k *Keeper) GovAmtFromRecollateralize( - ctx sdk.Context, inUSD sdk.Dec, -) (govOut sdkmath.Int, err error) { - params := k.GetParams(ctx) - bonusRate := params.GetBonusRateRecollAsDec() - - priceGovStable, err := k.OracleKeeper.GetExchangeRate( - ctx, asset.Registry.Pair(denoms.NIBI, denoms.NUSD)) - if err != nil { - return sdkmath.Int{}, err - } - govOut = inUSD.Mul(sdk.OneDec().Add(bonusRate)). - Quo(priceGovStable).TruncateInt() - return govOut, err -} - -func (k *Keeper) GovAmtFromFullRecollateralize( - ctx sdk.Context, -) (govOut sdkmath.Int, err error) { - neededCollUSD, err := k.StableRequiredForTargetCollRatio(ctx) - if err != nil { - return sdkmath.Int{}, err - } - return k.GovAmtFromRecollateralize(ctx, neededCollUSD) -} - -// --------------------------------------------------------------------------- -// Buyback -// --------------------------------------------------------------------------- - -/* -BuybackGovAmtForTargetCollRatio returns the governance tokens that the protocol can -buyback in order to have the optimal collateral ration. - -Args: - - ctx (sdk.Context): Carries information about the current state of the application. - -Returns: - - neededGovAmt (sdk.Int): The needed Governance amount that the protocol can buyback in order to - achieve the optimal collateral ratio. - err (error): The error containing information if something went wrong. -*/ -func (k *Keeper) BuybackGovAmtForTargetCollRatio( - ctx sdk.Context, -) (neededGovAmt sdkmath.Int, err error) { - neededUSDForRecoll, _ := k.StableRequiredForTargetCollRatio(ctx) - neededUSDForBuyback := neededUSDForRecoll.Neg() - priceGovStable, err := k.OracleKeeper.GetExchangeRate( - ctx, asset.Registry.Pair(denoms.NIBI, denoms.NUSD)) - if err != nil { - return sdkmath.Int{}, err - } - - neededGovAmtDec := neededUSDForBuyback.Quo(priceGovStable) - neededGovAmt = neededGovAmtDec.Ceil().TruncateInt() - return neededGovAmt, err -} - -// Buyback buys governance tokens back from the user in order to release over collateralization. -func (k Keeper) Buyback( - goCtx context.Context, msg *types.MsgBuyback, -) (response *types.MsgBuybackResponse, err error) { - ctx := sdk.UnwrapSDKContext(goCtx) - caller, err := sdk.AccAddressFromBech32(msg.Creator) - if err != nil { - return response, err - } - - params := k.GetParams(ctx) - targetCollRatio := params.GetCollRatioAsDec() - - neededGovAmt, err := k.BuybackGovAmtForTargetCollRatio(ctx) - if err != nil { - return response, err - } else if neededGovAmt.LTE(sdk.ZeroInt()) { - return response, fmt.Errorf( - "protocol has insufficient COLL, so 'Buyback' is not needed") - } - - // The caller doesn't need to be put in the full amount, - // just a positive amount that is at most the 'neededCollAmount'. - inGov := sdk.NewCoin(msg.Gov.Denom, sdk.ZeroInt()) - if msg.Gov.Amount.GT(neededGovAmt) { - inGov.Amount = neededGovAmt - } else if msg.Gov.Amount.LTE(sdk.ZeroInt()) { - return response, fmt.Errorf( - "collateral input, %v, must be positive", msg.Gov.String()) - } else { - inGov.Amount = msg.Gov.Amount - } - - // Send NIBI from the caller to the module - err = k.checkEnoughBalance(ctx, inGov, caller) - if err != nil { - return response, err - } - err = k.BankKeeper.SendCoinsFromAccountToModule( - ctx, caller, types.ModuleName, sdk.NewCoins(inGov), - ) - if err != nil { - return response, err - } - - if err := ctx.EventManager().EmitTypedEvent(&types.EventTransfer{ - Coin: inGov, - From: caller.String(), - To: k.AccountKeeper.GetModuleAddress(types.ModuleName).String(), - }); err != nil { - return response, err - } - - // Burn the NIBI that was sent by the caller. - err = k.BankKeeper.BurnCoins(ctx, types.ModuleName, sdk.NewCoins(inGov)) - if err != nil { - return response, err - } - - err = ctx.EventManager().EmitTypedEvent( - &types.EventBurnNIBI{Amount: inGov.Amount}) - if err != nil { - return response, err - } - - // Compute USD (stable) value of the GOV sent by the caller: 'inUSD' - priceGovStable, err := k.OracleKeeper.GetExchangeRate( - ctx, asset.Registry.Pair(denoms.NIBI, denoms.NUSD)) - if err != nil { - return response, err - } - inUSD := priceGovStable.MulInt(inGov.Amount) - - // Compute collateral amount sent to caller: 'outColl' - outCollAmount, err := k.CollAmtFromBuyback(ctx, inUSD) - if err != nil { - return response, err - } - outColl := sdk.NewCoin(denoms.USDC, outCollAmount) - - // Send COLL from the module to the caller - err = k.BankKeeper.SendCoinsFromModuleToAccount( - ctx, types.ModuleName, caller, sdk.NewCoins(outColl), - ) - if err != nil { - return response, err - } - - if err := ctx.EventManager().EmitTypedEvent(&types.EventTransfer{ - Coin: outColl, - From: k.AccountKeeper.GetModuleAddress(types.ModuleName).String(), - To: caller.String(), - }); err != nil { - return response, err - } - - if err := ctx.EventManager().EmitTypedEvent(&types.EventBuyback{ - InCoin: inGov, - OutCoin: outColl, - Caller: caller.String(), - CollRatio: targetCollRatio, - }); err != nil { - return response, err - } - - return &types.MsgBuybackResponse{ - Coll: outColl, - }, err -} - -/* -CollAmtFromBuyback computes the COLL (collateral) given as a reward for calling -buyback. - -Args: - - ctx (sdk.Context): Carries information about the current state of the application. - valUSD (sdk.Dec): Value in NUSD stablecoin to be used for buyback. - -Returns: - - collAmt (sdk.Int): Amount of COLL token rewarded for 'Buyback'. -*/ -func (k *Keeper) CollAmtFromBuyback( - ctx sdk.Context, valUSD sdk.Dec, -) (collAmt sdkmath.Int, err error) { - priceCollStable, err := k.OracleKeeper.GetExchangeRate( - ctx, asset.Registry.Pair(denoms.USDC, denoms.NUSD)) - if err != nil { - return sdkmath.Int{}, err - } - collAmt = valUSD. - Quo(priceCollStable).TruncateInt() - return collAmt, err -} - -// TODO hygiene: cover with test cases | https://github.com/NibiruChain/nibiru/issues/537 -func (k *Keeper) CollAmtFromFullBuyback( - ctx sdk.Context, -) (collAmt sdkmath.Int, err error) { - neededUSDForRecoll, err := k.StableRequiredForTargetCollRatio(ctx) - if err != nil { - return sdkmath.Int{}, err - } - neededUSDForBuyback := neededUSDForRecoll.Neg() - return k.CollAmtFromBuyback(ctx, neededUSDForBuyback) -} diff --git a/x/stablecoin/keeper/collateral_ratio_test.go b/x/stablecoin/keeper/collateral_ratio_test.go deleted file mode 100644 index 465639ca1..000000000 --- a/x/stablecoin/keeper/collateral_ratio_test.go +++ /dev/null @@ -1,1220 +0,0 @@ -package keeper_test - -import ( - "fmt" - "testing" - - sdkmath "cosmossdk.io/math" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/NibiruChain/nibiru/x/common" - "github.com/NibiruChain/nibiru/x/common/asset" - "github.com/NibiruChain/nibiru/x/common/denoms" - "github.com/NibiruChain/nibiru/x/common/testutil" - "github.com/NibiruChain/nibiru/x/common/testutil/testapp" - "github.com/NibiruChain/nibiru/x/stablecoin/types" -) - -func TestSetCollRatio_Input(t *testing.T) { - type TestCase struct { - name string - inCollRatio sdk.Dec - expectedPass bool - } - - executeTest := func(t *testing.T, testCase TestCase) { - tc := testCase - t.Run(tc.name, func(t *testing.T) { - nibiruApp, ctx := testapp.NewNibiruTestAppAndContext() - stablecoinKeeper := &nibiruApp.StablecoinKeeper - - err := stablecoinKeeper.SetCollRatio(ctx, tc.inCollRatio) - if tc.expectedPass { - require.NoError( - t, err, "Error setting the CollRatio: %d", tc.inCollRatio) - return - } - require.Error(t, err) - }) - } - - testCases := []TestCase{ - { - name: "Upper bound of CollRatio", - inCollRatio: sdk.OneDec(), - expectedPass: true, - }, { - name: "Lower bound of CollRatio", - inCollRatio: sdk.ZeroDec(), - expectedPass: true, - }, { - name: "CollRatio above 100", - inCollRatio: sdk.MustNewDecFromStr("1.5"), - expectedPass: false, - }, { - name: "Negative CollRatio not allowed", - inCollRatio: sdk.OneDec().Neg(), - expectedPass: false, - }, - } - for _, testCase := range testCases { - executeTest(t, testCase) - } -} - -func TestSetCollRatioUpdate(t *testing.T) { - type TestCase struct { - name string - inCollRatio sdk.Dec - price sdk.Dec - expectedCollRatio sdk.Dec - expectedPass bool - } - - executeTest := func(t *testing.T, testCase TestCase) { - tc := testCase - t.Run(tc.name, func(t *testing.T) { - nibiruApp, ctx := testapp.NewNibiruTestAppAndContext() - - stablecoinKeeper := &nibiruApp.StablecoinKeeper - oracleKeeper := &nibiruApp.OracleKeeper - - oracleKeeper.SetPrice(ctx, asset.Registry.Pair(denoms.USDC, denoms.NUSD), tc.price) - err := stablecoinKeeper.SetCollRatio(ctx, tc.inCollRatio) - require.NoError(t, err) - err = stablecoinKeeper.EvaluateCollRatio(ctx) - if tc.expectedPass { - require.NoError( - t, err, "Error setting the CollRatio: %d", tc.inCollRatio) - - currCollRatio := stablecoinKeeper.GetCollRatio(ctx) - require.Equal(t, tc.expectedCollRatio, currCollRatio) - return - } - require.Error(t, err) - }) - } - - testCases := []TestCase{ - { - name: "Collateral price is higher than stable", - inCollRatio: sdk.MustNewDecFromStr("0.8"), - price: sdk.MustNewDecFromStr("1.1"), - expectedCollRatio: sdk.MustNewDecFromStr("0.8025"), - expectedPass: true, - }, - { - name: "Price is slightly higher than peg", - inCollRatio: sdk.MustNewDecFromStr("0.8"), - price: sdk.MustNewDecFromStr("1.00000001"), - expectedCollRatio: sdk.MustNewDecFromStr("0.8"), - expectedPass: true, - }, - { - name: "Price is slightly lower than peg", - inCollRatio: sdk.MustNewDecFromStr("0.8"), - price: sdk.MustNewDecFromStr("0.99999999991"), - expectedCollRatio: sdk.MustNewDecFromStr("0.8"), - expectedPass: true, - }, - { - name: "Collateral price is lower than stable", - inCollRatio: sdk.MustNewDecFromStr("0.8"), - price: sdk.MustNewDecFromStr("0.9"), - expectedCollRatio: sdk.MustNewDecFromStr("0.7975"), - expectedPass: true, - }, - } - for _, testCase := range testCases { - executeTest(t, testCase) - } -} - -func TestGetCollRatio_Input(t *testing.T) { - testName := "GetCollRatio after setting default params returns expected value" - t.Run(testName, func(t *testing.T) { - nibiruApp, ctx := testapp.NewNibiruTestAppAndContext() - stablecoinKeeper := &nibiruApp.StablecoinKeeper - - stablecoinKeeper.SetParams(ctx, types.DefaultParams()) - expectedCollRatioInt := sdk.NewInt(types.DefaultParams().CollRatio) - - outCollRatio := stablecoinKeeper.GetCollRatio(ctx) - outCollRatioInt := outCollRatio.Mul(sdk.MustNewDecFromStr("1000000")).RoundInt() - require.EqualValues(t, expectedCollRatioInt, outCollRatioInt) - }) - - testName = "Setting to non-default value returns expected value" - t.Run(testName, func(t *testing.T) { - nibiruApp, ctx := testapp.NewNibiruTestAppAndContext() - stablecoinKeeper := &nibiruApp.StablecoinKeeper - - expectedCollRatio := sdk.MustNewDecFromStr("0.5") - expectedCollRatioInt := expectedCollRatio.Mul(sdk.MustNewDecFromStr("1000000")).RoundInt() - require.NoError(t, stablecoinKeeper.SetCollRatio(ctx, expectedCollRatio)) - - outCollRatio := stablecoinKeeper.GetCollRatio(ctx) - outCollRatioInt := outCollRatio.Mul(sdk.MustNewDecFromStr("1000000")).RoundInt() - require.EqualValues(t, expectedCollRatioInt, outCollRatioInt) - }) -} - -func TestStableRequiredForTargetCollRatio(t *testing.T) { - testCases := []struct { - name string - protocolColl sdkmath.Int - priceCollStable sdk.Dec - postedAssetPairs []asset.Pair - stableSupply sdkmath.Int - targetCollRatio sdk.Dec - neededUSD sdk.Dec - - expectedPass bool - }{ - { - name: "Too little collateral gives correct positive value", - protocolColl: sdk.NewInt(500), - priceCollStable: sdk.OneDec(), // startCollUSD = 500 * 1 -> 500 - postedAssetPairs: []asset.Pair{ - asset.Registry.Pair(denoms.USDC, denoms.NUSD), - }, - stableSupply: sdk.NewInt(1000), - targetCollRatio: sdk.MustNewDecFromStr("0.6"), // 0.6 * 1000 = 600 - neededUSD: sdk.MustNewDecFromStr("100"), // = 600 - 500 - expectedPass: true, - }, { - name: "Too much collateral gives correct negative value", - protocolColl: sdk.NewInt(600), - priceCollStable: sdk.OneDec(), // startCollUSD = 600 * 1 = 600 - postedAssetPairs: []asset.Pair{ - asset.Registry.Pair(denoms.USDC, denoms.NUSD), - }, - stableSupply: sdk.NewInt(1000), - targetCollRatio: sdk.MustNewDecFromStr("0.5"), // 0.5 * 1000 = 500 - neededUSD: sdk.MustNewDecFromStr("-100"), // = 500 - 600 - expectedPass: true, - }, { - name: "No price available for the collateral", - protocolColl: sdk.NewInt(500), - priceCollStable: sdk.OneDec(), // startCollUSD = 500 * 1 -> 500 - postedAssetPairs: []asset.Pair{}, - stableSupply: sdk.NewInt(1_000), - targetCollRatio: sdk.MustNewDecFromStr("0.6"), // 0.6 * 1000 = 600 - neededUSD: sdk.MustNewDecFromStr("100"), // = 600 - 500 - expectedPass: false, - }, - } - - for _, testCase := range testCases { - tc := testCase - t.Run(tc.name, func(t *testing.T) { - nibiruApp, ctx := testapp.NewNibiruTestAppAndContext() - stablecoinKeeper := &nibiruApp.StablecoinKeeper - require.NoError(t, stablecoinKeeper.SetCollRatio(ctx, tc.targetCollRatio)) - require.NoError(t, nibiruApp.BankKeeper.MintCoins( - ctx, types.ModuleName, sdk.NewCoins( - sdk.NewCoin(denoms.USDC, tc.protocolColl), - sdk.NewCoin(denoms.NUSD, tc.stableSupply), - ), - )) - - // Post prices to each specified market with the oracle. - prices := map[asset.Pair]sdk.Dec{ - asset.Registry.Pair(denoms.USDC, denoms.NUSD): tc.priceCollStable, - } - for _, pair := range tc.postedAssetPairs { - nibiruApp.OracleKeeper.SetPrice(ctx, pair, prices[pair]) - } - - neededUSD, err := stablecoinKeeper.StableRequiredForTargetCollRatio(ctx) - if tc.expectedPass { - require.NoError(t, err) - require.EqualValues(t, tc.neededUSD, neededUSD) - } else { - require.Error(t, err) - } - }) - } -} - -func TestRecollateralizeCollAmtForTargetCollRatio(t *testing.T) { - type TestCaseRecollateralizeCollAmtForTargetCollRatio struct { - name string - protocolColl sdkmath.Int - priceCollStable sdk.Dec - stableSupply sdkmath.Int - targetCollRatio sdk.Dec - neededCollAmt sdkmath.Int - expectedPass bool - } - - expectedPasses := []TestCaseRecollateralizeCollAmtForTargetCollRatio{ - { - name: "under-collateralized; untruncated integer amount", - protocolColl: sdk.NewInt(500), - priceCollStable: sdk.OneDec(), // startCollUSD = 500 * 1 -> 500 - stableSupply: sdk.NewInt(1000), - targetCollRatio: sdk.MustNewDecFromStr("0.6"), // 0.6 * 1000 = 600 - neededCollAmt: sdk.NewInt(100), // = 600 - 500 - expectedPass: true, - }, - { - name: "under-collateralized; truncated integer amount", - protocolColl: sdk.NewInt(500), - priceCollStable: sdk.OneDec(), // startCollUSD = 500 * 1 -> 500 - stableSupply: sdk.NewInt(1000), - targetCollRatio: sdk.MustNewDecFromStr("0.6025"), // 0.6025 * 1000 = 602.5 - neededCollAmt: sdk.NewInt(103), // 602.5 - 500 -> 103 required - expectedPass: true, - }, - { - name: "under-collateralized; truncated integer amount; non-unit price", - protocolColl: sdk.NewInt(500), - priceCollStable: sdk.MustNewDecFromStr("0.999"), // startCollUSD = 500 * 0.999 -> 499.5 - stableSupply: sdk.NewInt(1000), - targetCollRatio: sdk.MustNewDecFromStr("0.603"), // 0.603 * 1000 = 603 - // 603 - 499.5 = 103.5 -> 104 required - neededCollAmt: sdk.NewInt(104), - expectedPass: true, - }, - } - - for _, testCase := range expectedPasses { - tc := testCase - t.Run(tc.name, func(t *testing.T) { - nibiruApp, ctx := testapp.NewNibiruTestAppAndContext() - stablecoinKeeper := &nibiruApp.StablecoinKeeper - require.NoError(t, stablecoinKeeper.SetCollRatio(ctx, tc.targetCollRatio)) - require.NoError(t, nibiruApp.BankKeeper.MintCoins( - ctx, types.ModuleName, sdk.NewCoins( - sdk.NewCoin(denoms.USDC, tc.protocolColl), - sdk.NewCoin(denoms.NUSD, tc.stableSupply), - ), - )) - - // Post the price - pair := asset.Registry.Pair(denoms.USDC, denoms.NUSD) - nibiruApp.OracleKeeper.SetPrice(ctx, pair, tc.priceCollStable) - - neededCollAmount, err := stablecoinKeeper.RecollateralizeCollAmtForTargetCollRatio(ctx) - if tc.expectedPass { - require.NoError(t, err) - require.EqualValues(t, tc.neededCollAmt, neededCollAmount) - } else { - require.Error(t, err) - } - }) - } - - expectedFails := []TestCaseRecollateralizeCollAmtForTargetCollRatio{ - { - name: "error from price not being posted", - protocolColl: sdk.NewInt(500), - priceCollStable: sdk.OneDec(), // startCollUSD = 500 * 1 -> 500 - stableSupply: sdk.NewInt(1000), - targetCollRatio: sdk.MustNewDecFromStr("0.6"), // 0.6 * 1000 = 600 - neededCollAmt: sdk.NewInt(100), // = 600 - 500 - expectedPass: false, - }, - } - - for _, testCase := range expectedFails { - tc := testCase - t.Run(tc.name, func(t *testing.T) { - nibiruApp, ctx := testapp.NewNibiruTestAppAndContext() - stablecoinKeeper := &nibiruApp.StablecoinKeeper - require.NoError(t, stablecoinKeeper.SetCollRatio(ctx, tc.targetCollRatio)) - require.NoError(t, nibiruApp.BankKeeper.MintCoins( - ctx, types.ModuleName, sdk.NewCoins( - sdk.NewCoin(denoms.USDC, tc.protocolColl), - sdk.NewCoin(denoms.NUSD, tc.stableSupply), - ), - )) - - // Post the price - // pair := asset.AssetRegistry.Pair(denoms.USDC, denoms.NUSD) - // nibiruApp.OracleKeeper.SetPrice(ctx, pair, tc.priceCollStable) - - neededCollAmount, err := stablecoinKeeper.RecollateralizeCollAmtForTargetCollRatio(ctx) - if tc.expectedPass { - require.NoError(t, err) - require.EqualValues(t, tc.neededCollAmt, neededCollAmount) - } else { - require.Error(t, err) - } - }) - } -} - -func TestGovAmtFromFullRecollateralize(t *testing.T) { - testCases := []struct { - name string - protocolColl sdkmath.Int - priceCollStable sdk.Dec - priceGovStable sdk.Dec - stableSupply sdkmath.Int - targetCollRatio sdk.Dec - postedAssetPairs []asset.Pair - - govOut sdkmath.Int - expectedPass bool - }{ - { - name: "no prices posted", - protocolColl: sdk.NewInt(500), - stableSupply: sdk.NewInt(1000), - targetCollRatio: sdk.MustNewDecFromStr("0.6"), - postedAssetPairs: []asset.Pair{}, - govOut: sdkmath.Int{}, - expectedPass: false, - }, - { - name: "only post collateral price", - protocolColl: sdk.NewInt(500), - stableSupply: sdk.NewInt(1000), - targetCollRatio: sdk.MustNewDecFromStr("0.6"), // 0.6 * 1000 = 600 - priceCollStable: sdk.OneDec(), - postedAssetPairs: []asset.Pair{ - asset.Registry.Pair(denoms.USDC, denoms.NUSD), - }, - govOut: sdkmath.Int{}, - expectedPass: false, - }, - { - name: "only post gov price", - protocolColl: sdk.NewInt(500), - stableSupply: sdk.NewInt(1000), - targetCollRatio: sdk.MustNewDecFromStr("0.6"), // 0.6 * 1000 = 600 - priceGovStable: sdk.OneDec(), - postedAssetPairs: []asset.Pair{ - asset.Registry.Pair(denoms.NIBI, denoms.NUSD), - }, - govOut: sdkmath.Int{}, - expectedPass: false, - }, - { - name: "correct computation - positive", - protocolColl: sdk.NewInt(5_000), - stableSupply: sdk.NewInt(10_000), - targetCollRatio: sdk.MustNewDecFromStr("0.7"), // 0.7 * 10_000 = 7_000 - postedAssetPairs: []asset.Pair{ - asset.Registry.Pair(denoms.NIBI, denoms.NUSD), - asset.Registry.Pair(denoms.USDC, denoms.NUSD), - }, - priceCollStable: sdk.OneDec(), - priceGovStable: sdk.NewDec(2), - // govOut = neededUSD * (1 + bonusRate) / priceGov - // = 2000 * (1.002) / 2 = 1002 - govOut: sdk.NewInt(1002), - expectedPass: true, - }, - { - name: "correct computation - positive, new price", - protocolColl: sdk.NewInt(50_000), - stableSupply: sdk.NewInt(100_000), - targetCollRatio: sdk.MustNewDecFromStr("0.7"), // 0.7 * 100_000 = 70_000 - postedAssetPairs: []asset.Pair{ - asset.Registry.Pair(denoms.NIBI, denoms.NUSD), - asset.Registry.Pair(denoms.USDC, denoms.NUSD), - }, - priceCollStable: sdk.OneDec(), - priceGovStable: sdk.NewDec(10), - // govOut = neededUSD * (1 + bonusRate) / priceGov - // = 20000 * (1.002) / 10 = 2004 - govOut: sdk.NewInt(2004), - expectedPass: true, - }, - { - name: "correct computation - negative", - protocolColl: sdk.NewInt(70_000), - stableSupply: sdk.NewInt(100_000), - targetCollRatio: sdk.MustNewDecFromStr("0.5"), // 0.5 * 100_000 = 50_000 - postedAssetPairs: []asset.Pair{ - asset.Registry.Pair(denoms.NIBI, denoms.NUSD), - asset.Registry.Pair(denoms.USDC, denoms.NUSD), - }, - priceCollStable: sdk.OneDec(), - priceGovStable: sdk.NewDec(10), - // govOut = neededUSD * (1 + bonusRate) / priceGov - // = -20000 * (1.002) / 10 = 2004 - govOut: sdk.NewInt(-2004), - expectedPass: true, - }, - } - - for _, testCase := range testCases { - tc := testCase - t.Run(tc.name, func(t *testing.T) { - nibiruApp, ctx := testapp.NewNibiruTestAppAndContext() - stablecoinKeeper := &nibiruApp.StablecoinKeeper - require.NoError(t, stablecoinKeeper.SetCollRatio(ctx, tc.targetCollRatio)) - require.NoError(t, nibiruApp.BankKeeper.MintCoins( - ctx, types.ModuleName, sdk.NewCoins( - sdk.NewCoin(denoms.USDC, tc.protocolColl), - sdk.NewCoin(denoms.NUSD, tc.stableSupply), - ), - )) - - prices := map[asset.Pair]sdk.Dec{ - asset.Registry.Pair(denoms.NIBI, denoms.NUSD): tc.priceGovStable, - asset.Registry.Pair(denoms.USDC, denoms.NUSD): tc.priceCollStable, - } - for _, pair := range tc.postedAssetPairs { - nibiruApp.OracleKeeper.SetPrice(ctx, pair, prices[pair]) - } - - // Post prices to each specified market with the oracle. - prices = map[asset.Pair]sdk.Dec{ - asset.Registry.Pair(denoms.USDC, denoms.NUSD): tc.priceCollStable, - asset.Registry.Pair(denoms.NIBI, denoms.NUSD): tc.priceGovStable, - } - for _, assetPair := range tc.postedAssetPairs { - nibiruApp.OracleKeeper.SetPrice(ctx, assetPair, prices[assetPair]) - } - - govOut, err := stablecoinKeeper.GovAmtFromFullRecollateralize(ctx) - if tc.expectedPass { - require.NoError(t, err) - require.EqualValues(t, tc.govOut, govOut) - } else { - require.Error(t, err) - } - }) - } -} - -// --------------------------------------------------------------------------- -// Buyback and Recollateralize Tests -// --------------------------------------------------------------------------- - -type NeededCollScenario struct { - protocolColl sdkmath.Int - priceCollStable sdk.Dec - stableSupply sdkmath.Int - collRatio sdk.Dec -} - -func (scenario NeededCollScenario) CalcNeededUSD() (neededUSD sdk.Dec) { - stableUSD := scenario.collRatio.MulInt(scenario.stableSupply) - collUSD := scenario.priceCollStable.MulInt(scenario.protocolColl) - return stableUSD.Sub(collUSD) -} - -func TestRecollateralize(t *testing.T) { - testCases := []struct { - name string - expectedPass bool - err error - - postedAssetPairs []asset.Pair - scenario NeededCollScenario - priceGovStable sdk.Dec - expectedNeededUSD sdk.Dec - accFunds sdk.Coins - - msg types.MsgRecollateralize - response *types.MsgRecollateralizeResponse - }{ - { - name: "both prices are $1", - postedAssetPairs: []asset.Pair{ - asset.Registry.Pair(denoms.NIBI, denoms.NUSD), - asset.Registry.Pair(denoms.USDC, denoms.NUSD), - }, - scenario: NeededCollScenario{ - protocolColl: sdk.NewInt(500_000), - priceCollStable: sdk.OneDec(), - stableSupply: sdk.NewInt(1 * common.TO_MICRO), - collRatio: sdk.MustNewDecFromStr("0.6"), - // neededUSD = (0.6 * 1000e3) - (500e3 *1) = 100_000 - }, - priceGovStable: sdk.OneDec(), - accFunds: sdk.NewCoins( - sdk.NewInt64Coin(denoms.USDC, 1_000*common.TO_MICRO), - ), - - expectedNeededUSD: sdk.NewDec(100_000), - msg: types.MsgRecollateralize{ - Creator: testutil.AccAddress().String(), - Coll: sdk.NewCoin(denoms.USDC, sdk.NewInt(100_000)), - }, - response: &types.MsgRecollateralizeResponse{ - /* - Gov.Amount = inCollUSD * (1 + bonusRate) / priceGovStable - = 100_000 * (1.002) / priceGovStable - = 100_200 / priceGovStable - */ - Gov: sdk.NewCoin(denoms.NIBI, sdk.NewInt(100_200)), - }, - expectedPass: true, - }, - { - name: "arbitrary valid prices", - postedAssetPairs: []asset.Pair{ - asset.Registry.Pair(denoms.NIBI, denoms.NUSD), - asset.Registry.Pair(denoms.USDC, denoms.NUSD), - }, - scenario: NeededCollScenario{ - protocolColl: sdk.NewInt(500_000), - priceCollStable: sdk.MustNewDecFromStr("1.099999"), - stableSupply: sdk.NewInt(1 * common.TO_MICRO), - collRatio: sdk.MustNewDecFromStr("0.7"), - // neededUSD = (0.7 * 1000e3) - (500e3 *1.09999) = 150_000.5 - }, - priceGovStable: sdk.NewDec(5), - accFunds: sdk.NewCoins( - sdk.NewInt64Coin(denoms.USDC, 1_000*common.TO_MICRO), - ), - - expectedNeededUSD: sdk.MustNewDecFromStr("150000.5"), - msg: types.MsgRecollateralize{ - Creator: testutil.AccAddress().String(), - Coll: sdk.NewCoin(denoms.USDC, sdk.NewInt(50_000)), - }, - response: &types.MsgRecollateralizeResponse{ - /* - Gov.Amount = inCollUSD * (1 + bonusRate) / priceGovStable - = msg.Coll.Amount * priceCollStable (1.002) / priceGovStable - = 50_000 * 1.099999 * (1.002) / priceGovStable - = 55109.9499 / priceGovStable - = 11021.98998 -> 11_021 - */ - Gov: sdk.NewCoin(denoms.NIBI, sdk.NewInt(11_021)), - }, - expectedPass: true, - }, - { - name: "protocol has sufficient collateral - error", - postedAssetPairs: []asset.Pair{ - asset.Registry.Pair(denoms.NIBI, denoms.NUSD), - asset.Registry.Pair(denoms.USDC, denoms.NUSD), - }, - priceGovStable: sdk.OneDec(), - scenario: NeededCollScenario{ - protocolColl: sdk.NewInt(500), - priceCollStable: sdk.MustNewDecFromStr("1.099999"), - stableSupply: sdk.NewInt(1_000), - collRatio: sdk.MustNewDecFromStr("0.5"), - // neededUSD = (0.5 * 1000) - (500 *1.09999) = -49.9995 - }, - expectedNeededUSD: sdk.MustNewDecFromStr("-49.9995"), - accFunds: sdk.NewCoins( - sdk.NewInt64Coin(denoms.USDC, 1*common.TO_MICRO), - ), - - // Since 'neededUSD' is - msg: types.MsgRecollateralize{ - Creator: testutil.AccAddress().String(), - Coll: sdk.NewCoin(denoms.USDC, sdk.NewInt(100)), - }, - expectedPass: false, - err: fmt.Errorf("protocol has sufficient COLL"), - }, - { - name: "caller is broke - error", - postedAssetPairs: []asset.Pair{ - asset.Registry.Pair(denoms.NIBI, denoms.NUSD), - asset.Registry.Pair(denoms.USDC, denoms.NUSD), - }, - priceGovStable: sdk.OneDec(), - scenario: NeededCollScenario{ - protocolColl: sdk.NewInt(500), - priceCollStable: sdk.MustNewDecFromStr("1.5"), - stableSupply: sdk.NewInt(1_000), - collRatio: sdk.MustNewDecFromStr("0.9"), - // neededUSD = (0.9 * 1000) - (500 * 1.5) = 150 - }, - expectedNeededUSD: sdk.MustNewDecFromStr("150"), - accFunds: sdk.NewCoins( - sdk.NewInt64Coin(denoms.USDC, 99), - ), - - // Since 'neededUSD' is - msg: types.MsgRecollateralize{ - Creator: testutil.AccAddress().String(), - Coll: sdk.NewCoin(denoms.USDC, sdk.NewInt(200)), - }, - expectedPass: false, - err: fmt.Errorf("Not enough balance"), - }, - { - name: "negative msg.Coll.Amount - error", - postedAssetPairs: []asset.Pair{ - asset.Registry.Pair(denoms.NIBI, denoms.NUSD), - asset.Registry.Pair(denoms.USDC, denoms.NUSD), - }, - priceGovStable: sdk.OneDec(), - scenario: NeededCollScenario{ - protocolColl: sdk.NewInt(500), - priceCollStable: sdk.OneDec(), - stableSupply: sdk.NewInt(1_000), - collRatio: sdk.MustNewDecFromStr("0.9"), - // neededUSD = (0.9 * 1000) - (500 * 1) = 400 - }, - expectedNeededUSD: sdk.MustNewDecFromStr("400"), - accFunds: sdk.NewCoins( - sdk.NewInt64Coin(denoms.USDC, 400), - ), - - msg: types.MsgRecollateralize{ - Creator: testutil.AccAddress().String(), - Coll: sdk.Coin{Denom: denoms.USDC, Amount: sdk.NewInt(-200)}, - }, - expectedPass: false, - err: fmt.Errorf( - "collateral input, -200%v, must be positive", denoms.USDC), - }, - { - name: "oracle prices are expired - error", - postedAssetPairs: []asset.Pair{ - asset.Registry.Pair(denoms.USDC, denoms.NUSD), - }, - priceGovStable: sdk.OneDec(), - scenario: NeededCollScenario{ - protocolColl: sdk.NewInt(500), - priceCollStable: sdk.OneDec(), - stableSupply: sdk.NewInt(1_000), - collRatio: sdk.MustNewDecFromStr("0.9"), - // neededUSD = (0.9 * 1000) - (500 * 1) = 400 - }, - expectedNeededUSD: sdk.MustNewDecFromStr("400"), - accFunds: sdk.NewCoins( - sdk.NewInt64Coin(denoms.USDC, 400), - ), - msg: types.MsgRecollateralize{ - Creator: testutil.AccAddress().String(), - Coll: sdk.NewInt64Coin(denoms.USDC, 400), - }, - - expectedPass: false, - err: fmt.Errorf("collections: not found"), - }, - } - - for _, testCase := range testCases { - tc := testCase - t.Run(tc.name, func(t *testing.T) { - require.EqualValues(t, tc.expectedNeededUSD, tc.scenario.CalcNeededUSD()) - - nibiruApp, ctx := testapp.NewNibiruTestAppAndContext() - stablecoinKeeper := &nibiruApp.StablecoinKeeper - require.NoError(t, stablecoinKeeper.SetCollRatio(ctx, tc.scenario.collRatio)) - require.NoError(t, nibiruApp.BankKeeper.MintCoins( - ctx, types.ModuleName, sdk.NewCoins( - sdk.NewCoin(denoms.USDC, tc.scenario.protocolColl), - sdk.NewCoin(denoms.NUSD, tc.scenario.stableSupply), - ), - )) - // Fund account - caller, err := sdk.AccAddressFromBech32(tc.msg.Creator) - if tc.expectedPass { - require.NoError(t, err) - } - err = testapp.FundAccount(nibiruApp.BankKeeper, ctx, caller, tc.accFunds) - if tc.expectedPass { - require.NoError(t, err) - } - - prices := map[asset.Pair]sdk.Dec{ - asset.Registry.Pair(denoms.NIBI, denoms.NUSD): tc.priceGovStable, - asset.Registry.Pair(denoms.USDC, denoms.NUSD): tc.scenario.priceCollStable, - } - for _, pair := range tc.postedAssetPairs { - nibiruApp.OracleKeeper.SetPrice(ctx, pair, prices[pair]) - } - - // Post prices to each specified market with the oracle. - prices = map[asset.Pair]sdk.Dec{ - asset.Registry.Pair(denoms.USDC, denoms.NUSD): tc.scenario.priceCollStable, - asset.Registry.Pair(denoms.NIBI, denoms.NUSD): tc.priceGovStable, - } - for _, assetPair := range tc.postedAssetPairs { - nibiruApp.OracleKeeper.SetPrice(ctx, assetPair, prices[assetPair]) - } - - goCtx := sdk.WrapSDKContext(ctx) - response, err := stablecoinKeeper.Recollateralize(goCtx, &tc.msg) - if tc.expectedPass { - require.NoError(t, err) - require.EqualValues(t, tc.response, response) - } else { - assert.Error(t, err) - require.ErrorContains(t, err, tc.err.Error()) - } - }, - ) - } -} - -func TestRecollateralize_Short(t *testing.T) { - testCases := []struct { - name string - test func() - }{ - { - name: "invalid address - error", - test: func() { - nibiruApp, ctx := testapp.NewNibiruTestAppAndContext() - goCtx := sdk.WrapSDKContext(ctx) - - msg := &types.MsgRecollateralize{ - Creator: "invalid-address", - } - _, err := nibiruApp.StablecoinKeeper.Recollateralize(goCtx, msg) - require.Error(t, err) - }, - }, - { - name: "prices expired - error", - test: func() { - nibiruApp, ctx := testapp.NewNibiruTestAppAndContext() - goCtx := sdk.WrapSDKContext(ctx) - sender := testutil.AccAddress() - msg := &types.MsgRecollateralize{ - Creator: sender.String(), - Coll: sdk.NewInt64Coin(denoms.USDC, 100), - } - _, err := nibiruApp.StablecoinKeeper.Recollateralize(goCtx, msg) - require.ErrorContains(t, err, "collections: not found") - }, - }, - } - - for _, testCase := range testCases { - tc := testCase - t.Run(tc.name, func(t *testing.T) { - tc.test() - }) - } -} - -func TestBuyback_MsgFormat(t *testing.T) { - for _, testCase := range []struct { - name string - caller string - gov sdk.Coin - err error - }{ - { - name: "regular invalid address", - caller: "invalid_address", - err: fmt.Errorf("decoding bech32 failed: invalid separator index "), - }, - { - name: "non-bech32 caller has invalid address for the msg", - caller: "nibi_non_bech32", - err: fmt.Errorf("decoding bech32 failed: invalid separator index "), - }, - { - name: "valid creator address", - caller: testutil.AccAddress().String(), - err: nil, - }, - } { - tc := testCase - t.Run(tc.name, func(t *testing.T) { - nibiruApp, ctx := testapp.NewNibiruTestAppAndContext() - msg := types.MsgBuyback{ - Creator: tc.caller, - Gov: tc.gov, - } - - _, err := nibiruApp.StablecoinKeeper.Buyback( - sdk.WrapSDKContext(ctx), - &msg, - ) - - require.Error(t, err) - if tc.err != nil { - require.Contains(t, err.Error(), tc.err.Error()) - } - }) - } -} - -func TestBuyback(t *testing.T) { - testCases := []struct { - name string - expectedPass bool - - postedAssetPairs []asset.Pair - scenario NeededCollScenario - priceGovStable sdk.Dec - expectedNeededUSD sdk.Dec - accFunds sdk.Coins - expectedAccFundsAfter sdk.Coins - - msg types.MsgBuyback - response *types.MsgBuybackResponse - }{ - { - name: "both prices are $1", - postedAssetPairs: []asset.Pair{ - asset.Registry.Pair(denoms.NIBI, denoms.NUSD), - asset.Registry.Pair(denoms.USDC, denoms.NUSD), - }, - scenario: NeededCollScenario{ - protocolColl: sdk.NewInt(700_000), - priceCollStable: sdk.OneDec(), - stableSupply: sdk.NewInt(1 * common.TO_MICRO), - collRatio: sdk.MustNewDecFromStr("0.6"), - // neededUSD = (0.6 * 1000e3) - (700e3 *1) = -100_000 - }, - priceGovStable: sdk.OneDec(), - accFunds: sdk.NewCoins( - sdk.NewInt64Coin(denoms.NIBI, 1*common.TO_MICRO), - ), - expectedAccFundsAfter: sdk.NewCoins( - sdk.NewInt64Coin(denoms.NIBI, 900_000), // accFunds - inGov.Amount - sdk.NewInt64Coin(denoms.USDC, 100_000), // response.Coll - ), - - expectedNeededUSD: sdk.NewDec(-100_000), - msg: types.MsgBuyback{ - Creator: testutil.AccAddress().String(), - Gov: sdk.NewCoin(denoms.NIBI, sdk.NewInt(100_000)), - }, - response: &types.MsgBuybackResponse{ - /* - Coll.Amount = inUSD * / priceCollStable - = 100_000 / priceCollStable - */ - Coll: sdk.NewCoin(denoms.USDC, sdk.NewInt(100_000)), - }, - expectedPass: true, - }, - { - name: "arbitrary valid prices", - postedAssetPairs: []asset.Pair{ - asset.Registry.Pair(denoms.NIBI, denoms.NUSD), - asset.Registry.Pair(denoms.USDC, denoms.NUSD), - }, - scenario: NeededCollScenario{ - protocolColl: sdk.NewInt(850_000), - priceCollStable: sdk.MustNewDecFromStr("1.099999"), - stableSupply: sdk.NewInt(1 * common.TO_MICRO), - collRatio: sdk.MustNewDecFromStr("0.7"), - // neededUSD = (0.7 * 1000e3) - (850e3 *1.09999) = -234999.15 - }, - priceGovStable: sdk.NewDec(5), - accFunds: sdk.NewCoins( - sdk.NewInt64Coin(denoms.NIBI, 1*common.TO_MICRO), - ), - expectedAccFundsAfter: sdk.NewCoins( - sdk.NewInt64Coin(denoms.NIBI, 953_000), // accFunds - inGov.Amount - sdk.NewInt64Coin(denoms.USDC, 213_636), // response.Coll - ), - - expectedNeededUSD: sdk.MustNewDecFromStr("-234999.15"), - msg: types.MsgBuyback{ - Creator: testutil.AccAddress().String(), - Gov: sdk.NewCoin(denoms.NIBI, sdk.NewInt(50_000)), - }, - response: &types.MsgBuybackResponse{ - /* - neededGovAmt = neededUSD.neg() / priceGovStable - inGov.Amount = min(msg.Gov.Amount, neededGovAmt) - = min(47_000, 50_000) - Coll.Amount = inUSD / priceCollStable - = (inGov.Amount * priceGovStable) / priceCollStable - = 47000 * 5 / 1.099999 - = 213636.55785141626 -> 213_636 - */ - Coll: sdk.NewCoin(denoms.USDC, sdk.NewInt(213_636)), - }, - expectedPass: true, - }, - { - name: "msg has more NIBI than the protocol needs, only needed sent", - postedAssetPairs: []asset.Pair{ - asset.Registry.Pair(denoms.NIBI, denoms.NUSD), - asset.Registry.Pair(denoms.USDC, denoms.NUSD), - }, - scenario: NeededCollScenario{ - protocolColl: sdk.NewInt(700_000), - priceCollStable: sdk.OneDec(), - stableSupply: sdk.NewInt(1 * common.TO_MICRO), - collRatio: sdk.MustNewDecFromStr("0.6"), - // neededUSD = (0.6 * 1000e3) - (700e3 *1) = -100_000 - }, - priceGovStable: sdk.OneDec(), - accFunds: sdk.NewCoins( - sdk.NewInt64Coin(denoms.NIBI, 1*common.TO_MICRO), - ), - expectedAccFundsAfter: sdk.NewCoins( - sdk.NewInt64Coin(denoms.NIBI, 900_000), // accFunds - inGov.Amount - sdk.NewInt64Coin(denoms.USDC, 100_000), // response.Coll - ), - - expectedNeededUSD: sdk.NewDec(-100_000), - msg: types.MsgBuyback{ - Creator: testutil.AccAddress().String(), - Gov: sdk.NewCoin(denoms.NIBI, sdk.NewInt(200_000)), - }, - response: &types.MsgBuybackResponse{ - // Coll.Amount = inUSD * / priceCollStable - Coll: sdk.NewCoin(denoms.USDC, sdk.NewInt(100_000)), - }, - expectedPass: true, - }, - { - name: "protocol under-collateralized, so buyback won't run", - postedAssetPairs: []asset.Pair{ - asset.Registry.Pair(denoms.NIBI, denoms.NUSD), - asset.Registry.Pair(denoms.USDC, denoms.NUSD), - }, - scenario: NeededCollScenario{ - protocolColl: sdk.NewInt(700_000), - priceCollStable: sdk.OneDec(), - stableSupply: sdk.NewInt(1 * common.TO_MICRO), - collRatio: sdk.MustNewDecFromStr("0.8"), - // neededUSD = (0.8 * 1000e3) - (700e3 *1) = 100_000 - }, - priceGovStable: sdk.OneDec(), - accFunds: sdk.NewCoins( - sdk.NewInt64Coin(denoms.NIBI, 1_000*common.TO_MICRO), - ), - - expectedNeededUSD: sdk.NewDec(100_000), - msg: types.MsgBuyback{ - Creator: testutil.AccAddress().String(), - Gov: sdk.NewCoin(denoms.NIBI, sdk.NewInt(100_000)), - }, - response: &types.MsgBuybackResponse{}, - expectedPass: false, - }, - { - name: "caller has insufficient funds", - postedAssetPairs: []asset.Pair{ - asset.Registry.Pair(denoms.NIBI, denoms.NUSD), - asset.Registry.Pair(denoms.USDC, denoms.NUSD), - }, - scenario: NeededCollScenario{ - protocolColl: sdk.NewInt(700_000), - priceCollStable: sdk.OneDec(), - stableSupply: sdk.NewInt(1 * common.TO_MICRO), - collRatio: sdk.MustNewDecFromStr("0.6"), - // neededUSD = (0.6 * 1000e3) - (700e3 *1) = -100_000 - }, - priceGovStable: sdk.OneDec(), - accFunds: sdk.NewCoins( - sdk.NewInt64Coin(denoms.NIBI, 1), - ), - - expectedNeededUSD: sdk.NewDec(-100_000), - msg: types.MsgBuyback{ - Creator: testutil.AccAddress().String(), - Gov: sdk.NewCoin(denoms.NIBI, sdk.NewInt(100_000)), - }, - response: &types.MsgBuybackResponse{}, - expectedPass: false, - }, - { - name: "fail: missing collateral price post", - postedAssetPairs: []asset.Pair{ - asset.Registry.Pair(denoms.NIBI, denoms.NUSD), - }, - scenario: NeededCollScenario{ - protocolColl: sdk.NewInt(700_000), - priceCollStable: sdk.OneDec(), - stableSupply: sdk.NewInt(1 * common.TO_MICRO), - collRatio: sdk.MustNewDecFromStr("0.6"), - // neededUSD = (0.6 * 1000e3) - (700e3 *1) = -100_000 - }, - priceGovStable: sdk.OneDec(), - accFunds: sdk.NewCoins( - sdk.NewInt64Coin(denoms.NIBI, 1_000*common.TO_MICRO), - ), - - expectedNeededUSD: sdk.NewDec(-100_000), - msg: types.MsgBuyback{ - Creator: testutil.AccAddress().String(), - Gov: sdk.NewCoin(denoms.NIBI, sdk.NewInt(100_000)), - }, - response: &types.MsgBuybackResponse{}, - expectedPass: false, - }, - { - name: "fail: missing NIBI price post", - postedAssetPairs: []asset.Pair{ - asset.Registry.Pair(denoms.USDC, denoms.NUSD), - }, - scenario: NeededCollScenario{ - protocolColl: sdk.NewInt(700_000), - priceCollStable: sdk.OneDec(), - stableSupply: sdk.NewInt(1 * common.TO_MICRO), - collRatio: sdk.MustNewDecFromStr("0.6"), - // neededUSD = (0.6 * 1000e3) - (700e3 *1) = -100_000 - }, - priceGovStable: sdk.OneDec(), - accFunds: sdk.NewCoins( - sdk.NewInt64Coin(denoms.NIBI, 1_000*common.TO_MICRO), - ), - - expectedNeededUSD: sdk.NewDec(-100_000), - msg: types.MsgBuyback{ - Creator: testutil.AccAddress().String(), - Gov: sdk.NewCoin(denoms.NIBI, sdk.NewInt(100_000)), - }, - response: &types.MsgBuybackResponse{}, - expectedPass: false, - }, - } - - for _, testCase := range testCases { - tc := testCase - t.Run(tc.name, func(t *testing.T) { - require.EqualValues(t, tc.expectedNeededUSD, tc.scenario.CalcNeededUSD()) - - nibiruApp, ctx := testapp.NewNibiruTestAppAndContext() - stablecoinKeeper := &nibiruApp.StablecoinKeeper - require.NoError(t, stablecoinKeeper.SetCollRatio(ctx, tc.scenario.collRatio)) - - // Fund module account based on scenario - require.NoError(t, nibiruApp.BankKeeper.MintCoins( - ctx, types.ModuleName, sdk.NewCoins( - sdk.NewCoin(denoms.USDC, tc.scenario.protocolColl), - sdk.NewCoin(denoms.NUSD, tc.scenario.stableSupply), - ), - )) - - // Fund caller account - caller, err := sdk.AccAddressFromBech32(tc.msg.Creator) - if tc.expectedPass { - require.NoError(t, err) - } - err = testapp.FundAccount(nibiruApp.BankKeeper, ctx, caller, tc.accFunds) - if tc.expectedPass { - require.NoError(t, err) - } - - // Set up markets for the oracle keeper. - prices := map[asset.Pair]sdk.Dec{ - asset.Registry.Pair(denoms.NIBI, denoms.NUSD): tc.priceGovStable, - asset.Registry.Pair(denoms.USDC, denoms.NUSD): tc.scenario.priceCollStable, - } - for _, pair := range tc.postedAssetPairs { - nibiruApp.OracleKeeper.SetPrice(ctx, pair, prices[pair]) - } - - // Post prices to each specified market with the oracle. - for _, assetPair := range tc.postedAssetPairs { - nibiruApp.OracleKeeper.SetPrice(ctx, assetPair, prices[assetPair]) - } - - goCtx := sdk.WrapSDKContext(ctx) - response, err := stablecoinKeeper.Buyback(goCtx, &tc.msg) - if tc.expectedPass { - require.NoError(t, err) - require.EqualValues(t, tc.response, response) - require.EqualValues(t, - tc.expectedAccFundsAfter, - nibiruApp.BankKeeper.GetAllBalances(ctx, caller)) - } else { - require.Error(t, err) - } - }, - ) - } -} - -func TestBuybackGovAmtForTargetCollRatio(t *testing.T) { - testCases := []struct { - name string - scenario NeededCollScenario - expectedPass bool - - postedAssetPairs []asset.Pair - priceGovStable sdk.Dec - - outGovAmt sdkmath.Int - }{ - { - name: "both prices $1, correct amount out", - postedAssetPairs: []asset.Pair{ - asset.Registry.Pair(denoms.NIBI, denoms.NUSD), - asset.Registry.Pair(denoms.USDC, denoms.NUSD), - }, - scenario: NeededCollScenario{ - protocolColl: sdk.NewInt(700_000), - priceCollStable: sdk.OneDec(), - stableSupply: sdk.NewInt(1 * common.TO_MICRO), - collRatio: sdk.MustNewDecFromStr("0.6"), - // neededUSD = (0.6 * 1000e3) - (700e3 *1) = -100_000 - }, - priceGovStable: sdk.OneDec(), - outGovAmt: sdk.NewInt(100_000), - expectedPass: true, - }, - { - name: "both prices $1, correct amount out, no prices", - postedAssetPairs: []asset.Pair{}, - scenario: NeededCollScenario{ - protocolColl: sdk.NewInt(700_000), - priceCollStable: sdk.OneDec(), - stableSupply: sdk.NewInt(1 * common.TO_MICRO), - collRatio: sdk.MustNewDecFromStr("0.6"), - // neededUSD = (0.6 * 1000e3) - (700e3 *1) = -100_000 - }, - priceGovStable: sdk.OneDec(), - outGovAmt: sdk.NewInt(100_000), - expectedPass: false, - }, - { - name: "both prices $1, only coll price posted", - postedAssetPairs: []asset.Pair{ - asset.Registry.Pair(denoms.USDC, denoms.NUSD), - }, - scenario: NeededCollScenario{ - protocolColl: sdk.NewInt(700_000), - priceCollStable: sdk.OneDec(), - stableSupply: sdk.NewInt(1 * common.TO_MICRO), - collRatio: sdk.MustNewDecFromStr("0.6"), - // neededUSD = (0.6 * 1000e3) - (700e3 *1) = -100_000 - }, - priceGovStable: sdk.OneDec(), - outGovAmt: sdk.NewInt(99_000), - expectedPass: false, - }, - } - - for _, testCase := range testCases { - tc := testCase - t.Run(tc.name, func(t *testing.T) { - nibiruApp, ctx := testapp.NewNibiruTestAppAndContext() - stablecoinKeeper := &nibiruApp.StablecoinKeeper - require.NoError(t, stablecoinKeeper.SetCollRatio(ctx, tc.scenario.collRatio)) - require.NoError(t, nibiruApp.BankKeeper.MintCoins( - ctx, types.ModuleName, sdk.NewCoins( - sdk.NewCoin(denoms.USDC, tc.scenario.protocolColl), - sdk.NewCoin(denoms.NUSD, tc.scenario.stableSupply), - ), - )) - - prices := map[asset.Pair]sdk.Dec{ - asset.Registry.Pair(denoms.NIBI, denoms.NUSD): tc.priceGovStable, - asset.Registry.Pair(denoms.USDC, denoms.NUSD): tc.scenario.priceCollStable, - } - for _, pair := range tc.postedAssetPairs { - nibiruApp.OracleKeeper.SetPrice(ctx, pair, prices[pair]) - } - - // Post prices to each specified market with the oracle. - for _, assetPair := range tc.postedAssetPairs { - nibiruApp.OracleKeeper.SetPrice(ctx, assetPair, prices[assetPair]) - } - - outGovAmt, err := stablecoinKeeper.BuybackGovAmtForTargetCollRatio(ctx) - if tc.expectedPass { - require.NoError(t, err) - require.EqualValues(t, tc.outGovAmt, outGovAmt) - } else { - require.Error(t, err) - } - }, - ) - } -} diff --git a/x/stablecoin/keeper/grpc_query.go b/x/stablecoin/keeper/grpc_query.go deleted file mode 100644 index 1ffc855c6..000000000 --- a/x/stablecoin/keeper/grpc_query.go +++ /dev/null @@ -1,80 +0,0 @@ -package keeper - -import ( - "context" - - "github.com/NibiruChain/nibiru/x/stablecoin/types" - - sdk "github.com/cosmos/cosmos-sdk/types" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" -) - -var _ types.QueryServer = Keeper{} - -func (k Keeper) Params( - goCtx context.Context, req *types.QueryParamsRequest, -) (*types.QueryParamsResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - ctx := sdk.UnwrapSDKContext(goCtx) - - return &types.QueryParamsResponse{Params: k.GetParams(ctx)}, nil -} - -func (k Keeper) ModuleAccountBalances( - goCtx context.Context, req *types.QueryModuleAccountBalances, -) (*types.QueryModuleAccountBalancesResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - ctx := sdk.UnwrapSDKContext(goCtx) - - var balances sdk.Coins = k.BankKeeper.GetAllBalances( - ctx, k.AccountKeeper.GetModuleAddress(types.ModuleName), - ) - return &types.QueryModuleAccountBalancesResponse{ - ModuleAccountBalances: balances, - }, nil -} - -func (k Keeper) CirculatingSupplies( - goCtx context.Context, req *types.QueryCirculatingSupplies, -) (*types.QueryCirculatingSuppliesResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - ctx := sdk.UnwrapSDKContext(goCtx) - - return &types.QueryCirculatingSuppliesResponse{ - Nibi: k.GetSupplyNIBI(ctx), - Nusd: k.GetSupplyNUSD(ctx), - }, nil -} - -func (k Keeper) LiquidityRatioInfo( - goCtx context.Context, req *types.QueryLiquidityRatioInfoRequest, -) (res *types.QueryLiquidityRatioInfoResponse, err error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - ctx := sdk.UnwrapSDKContext(goCtx) - - liqRatio, err := k.GetLiquidityRatio(ctx) - if err != nil { - return res, err - } - lowerBand, upperBand, err := k.GetLiquidityRatioBands(ctx) - if err != nil { - return res, err - } - - return &types.QueryLiquidityRatioInfoResponse{ - Info: types.LiquidityRatioInfo{ - LiquidityRatio: liqRatio, - UpperBand: upperBand, - LowerBand: lowerBand, - }, - }, nil -} diff --git a/x/stablecoin/keeper/grpc_query_test.go b/x/stablecoin/keeper/grpc_query_test.go deleted file mode 100644 index ed77f527d..000000000 --- a/x/stablecoin/keeper/grpc_query_test.go +++ /dev/null @@ -1,25 +0,0 @@ -package keeper_test - -import ( - "testing" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" - - "github.com/NibiruChain/nibiru/x/common/testutil/testapp" - "github.com/NibiruChain/nibiru/x/stablecoin/types" -) - -func TestParamsQuery(t *testing.T) { - nibiruApp, ctx := testapp.NewNibiruTestAppAndContext() - keeper := &nibiruApp.StablecoinKeeper - wctx := sdk.WrapSDKContext(ctx) - params := types.DefaultParams() - keeper.SetParams(ctx, params) - - response, err := keeper.Params( - wctx, &types.QueryParamsRequest{}, - ) - require.NoError(t, err) - require.Equal(t, &types.QueryParamsResponse{Params: params}, response) -} diff --git a/x/stablecoin/keeper/hooks.go b/x/stablecoin/keeper/hooks.go deleted file mode 100644 index a2a941b76..000000000 --- a/x/stablecoin/keeper/hooks.go +++ /dev/null @@ -1,46 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - - epochstypes "github.com/NibiruChain/nibiru/x/epochs/types" -) - -func (k Keeper) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNumber uint64) { -} - -func (k Keeper) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumber uint64) { - params := k.GetParams(ctx) - if epochIdentifier == params.DistrEpochIdentifier { - err := k.EvaluateCollRatio(ctx) - - params = k.GetParams(ctx) - params.IsCollateralRatioValid = err == nil - - k.SetParams(ctx, params) - } -} - -// ___________________________________________________________________________________________________ - -// Hooks wrapper struct for incentives keeper. -type Hooks struct { - k Keeper -} - -var _ epochstypes.EpochHooks = Hooks{} - -// Hooks Return the wrapper struct. -func (k Keeper) Hooks() Hooks { - return Hooks{k} -} - -// BeforeEpochStart epochs hooks. -func (h Hooks) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNumber uint64) { - h.k.BeforeEpochStart(ctx, epochIdentifier, epochNumber) -} - -// AfterEpochEnd epochs hooks -func (h Hooks) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumber uint64) { - h.k.AfterEpochEnd(ctx, epochIdentifier, epochNumber) -} diff --git a/x/stablecoin/keeper/keeper.go b/x/stablecoin/keeper/keeper.go deleted file mode 100644 index f164b8401..000000000 --- a/x/stablecoin/keeper/keeper.go +++ /dev/null @@ -1,84 +0,0 @@ -package keeper - -import ( - "fmt" - - storetypes "github.com/cosmos/cosmos-sdk/store/types" - - "github.com/cometbft/cometbft/libs/log" - - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - - "github.com/NibiruChain/nibiru/x/common/denoms" - "github.com/NibiruChain/nibiru/x/stablecoin/types" -) - -type Keeper struct { - cdc codec.BinaryCodec - storeKey storetypes.StoreKey - memKey storetypes.StoreKey - ParamSubspace paramtypes.Subspace - - AccountKeeper types.AccountKeeper - BankKeeper types.BankKeeper - OracleKeeper types.OracleKeeper - SpotKeeper types.SpotKeeper -} - -// NewKeeper Creates a new x/stablecoin Keeper instance. -func NewKeeper( - cdc codec.BinaryCodec, - storeKey, - memKey storetypes.StoreKey, - paramSubspace paramtypes.Subspace, - - accountKeeper types.AccountKeeper, - bankKeeper types.BankKeeper, - priceKeeper types.OracleKeeper, - spotKeeper types.SpotKeeper, -) Keeper { - // Ensure that the module account is set. - if moduleAcc := accountKeeper.GetModuleAddress(types.ModuleName); moduleAcc == nil { - panic("The stablecoin module account has not been set") - } - - // Set param.types.'KeyTable' if it has not already been set - if !paramSubspace.HasKeyTable() { - paramSubspace = paramSubspace.WithKeyTable(types.ParamKeyTable()) - } - - return Keeper{ - cdc: cdc, - storeKey: storeKey, - memKey: memKey, - ParamSubspace: paramSubspace, - - AccountKeeper: accountKeeper, - BankKeeper: bankKeeper, - OracleKeeper: priceKeeper, - SpotKeeper: spotKeeper, - } -} - -func (k Keeper) Logger(ctx sdk.Context) log.Logger { - return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) -} - -// GetModuleAccountBalance gets the airdrop coin balance of module account. -func (k Keeper) GetModuleAccountBalance(ctx sdk.Context) sdk.Coin { - moduleAccAddr := k.AccountKeeper.GetModuleAddress(types.ModuleName) - return k.BankKeeper.GetBalance(ctx, moduleAccAddr, denoms.NIBI) -} - -// GetParams get all parameters as types.Params -func (k *Keeper) GetParams(ctx sdk.Context) (params types.Params) { - k.ParamSubspace.GetParamSet(ctx, ¶ms) - return params -} - -// SetParams set the params -func (k *Keeper) SetParams(ctx sdk.Context, params types.Params) { - k.ParamSubspace.SetParamSet(ctx, ¶ms) -} diff --git a/x/stablecoin/keeper/keeper_test.go b/x/stablecoin/keeper/keeper_test.go deleted file mode 100644 index 2c97db77e..000000000 --- a/x/stablecoin/keeper/keeper_test.go +++ /dev/null @@ -1,59 +0,0 @@ -package keeper_test - -import ( - "testing" - - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/stretchr/testify/require" - - "github.com/NibiruChain/nibiru/x/common/testutil/testapp" - "github.com/NibiruChain/nibiru/x/stablecoin/types" -) - -// Params -func TestGetAndSetParams(t *testing.T) { - tests := []struct { - name string - requiredParams func() types.Params - }{ - { - "get default params", - func() types.Params { - return types.DefaultParams() - }, - }, - { - "Get non-default params", - func() types.Params { - collRatio := sdk.MustNewDecFromStr("0.5") - feeRatio := collRatio - feeRatioEF := collRatio - bonusRateRecoll := sdk.MustNewDecFromStr("0.002") - adjustmentStep := sdk.MustNewDecFromStr("0.0035") - priceLowerBound := sdk.MustNewDecFromStr("0.9990") - priceUpperBound := sdk.MustNewDecFromStr("1.0002") - - params := types.NewParams( - collRatio, feeRatio, feeRatioEF, bonusRateRecoll, "15 min", adjustmentStep, - priceLowerBound, - priceUpperBound, true) - - return params - }, - }, - } - - for _, tc := range tests { - tc := tc - t.Run(tc.name, func(t *testing.T) { - nibiruApp, ctx := testapp.NewNibiruTestAppAndContext() - stableKeeper := nibiruApp.StablecoinKeeper - - params := tc.requiredParams() - stableKeeper.SetParams(ctx, params) - - require.EqualValues(t, params, stableKeeper.GetParams(ctx)) - }) - } -} diff --git a/x/stablecoin/keeper/mint_burn_stable.go b/x/stablecoin/keeper/mint_burn_stable.go deleted file mode 100644 index da7c95bd4..000000000 --- a/x/stablecoin/keeper/mint_burn_stable.go +++ /dev/null @@ -1,367 +0,0 @@ -/* -Package keeper that mints Nibiru stablecoins, maintains their price stability, -and ensures that the protocol remains collateralized enough for stablecoins to -be redeemed. -*/ -package keeper - -import ( - "context" - - sdkerrors "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/NibiruChain/nibiru/x/common" - "github.com/NibiruChain/nibiru/x/common/asset" - "github.com/NibiruChain/nibiru/x/common/denoms" - "github.com/NibiruChain/nibiru/x/stablecoin/types" -) - -// MintStable mints stable coins given collateral (COLL) and governance (GOV) -func (k Keeper) MintStable( - goCtx context.Context, msg *types.MsgMintStable, -) (*types.MsgMintStableResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - msgCreator, err := sdk.AccAddressFromBech32(msg.Creator) - if err != nil { - return nil, err - } - - params := k.GetParams(ctx) - if !params.IsCollateralRatioValid { - return nil, types.NoValidCollateralRatio - } - - feeRatio := params.GetFeeRatioAsDec() - collRatio := params.GetCollRatioAsDec() - efFeeRatio := params.GetEfFeeRatioAsDec() - govRatio := sdk.OneDec().Sub(collRatio) - - // The user deposits a mixture of collateral and GOV tokens based on the collateral ratio. - neededColl, collFees, err := k. - calcNeededCollateralAndFees(ctx, msg.Stable, collRatio, feeRatio) - if err != nil { - return nil, err - } - neededGov, govFees, err := k. - calcNeededGovAndFees(ctx, msg.Stable, govRatio, feeRatio) - if err != nil { - return nil, err - } - - coinsNeededToMint := sdk.NewCoins(neededColl, neededGov) - coinsNeededToMintPlusFees := coinsNeededToMint.Add(govFees, collFees) - - err = k.CheckEnoughBalances(ctx, coinsNeededToMintPlusFees, msgCreator) - if err != nil { - return nil, err - } - - err = k.sendCoinsToModuleAccount(ctx, msgCreator, coinsNeededToMint) - if err != nil { - return nil, err - } - - err = k.burnGovTokens(ctx, neededGov) - if err != nil { - return nil, err - } - - err = k.splitAndSendFeesToEfAndTreasury(ctx, msgCreator, efFeeRatio, sdk.NewCoins(collFees, govFees)) - if err != nil { - return nil, err - } - - err = k.mintStable(ctx, msg.Stable) - if err != nil { - return nil, err - } - - err = k.sendCoinsFromModuleAccountToUser(ctx, msgCreator, sdk.NewCoins(msg.Stable)) - if err != nil { - return nil, err - } - - return &types.MsgMintStableResponse{ - Stable: msg.Stable, - UsedCoins: sdk.NewCoins(neededGov, neededColl), - FeesPayed: sdk.NewCoins(govFees, collFees), - }, nil -} - -// calcNeededGovAndFees returns the needed governance tokens and fees -func (k Keeper) calcNeededGovAndFees( - ctx sdk.Context, stable sdk.Coin, govRatio sdk.Dec, feeRatio sdk.Dec, -) (sdk.Coin, sdk.Coin, error) { - priceGov, err := k.OracleKeeper.GetExchangeRate( - ctx, asset.Registry.Pair(denoms.NIBI, denoms.NUSD)) - if err != nil { - return sdk.Coin{}, sdk.Coin{}, err - } - - neededGovUSD := sdk.NewDecFromInt(stable.Amount).Mul(govRatio) - neededGovAmt := neededGovUSD.Quo(priceGov).TruncateInt() - neededGov := sdk.NewCoin(denoms.NIBI, neededGovAmt) - govFeeAmt := sdk.NewDecFromInt(neededGovAmt).Mul(feeRatio).RoundInt() - govFee := sdk.NewCoin(denoms.NIBI, govFeeAmt) - - return neededGov, govFee, nil -} - -// calcNeededCollateralAndFees returns the needed collateral and the collateral fees -func (k Keeper) calcNeededCollateralAndFees( - ctx sdk.Context, - stable sdk.Coin, - collRatio sdk.Dec, - feeRatio sdk.Dec, -) (sdk.Coin, sdk.Coin, error) { - priceColl, err := k.OracleKeeper.GetExchangeRate( - ctx, asset.Registry.Pair(denoms.USDC, denoms.NUSD)) - if err != nil { - return sdk.Coin{}, sdk.Coin{}, err - } - - neededCollUSD := sdk.NewDecFromInt(stable.Amount).Mul(collRatio) - neededCollAmt := neededCollUSD.Quo(priceColl).TruncateInt() - neededColl := sdk.NewCoin(denoms.USDC, neededCollAmt) - collFeeAmt := sdk.NewDecFromInt(neededCollAmt).Mul(feeRatio).RoundInt() - collFee := sdk.NewCoin(denoms.USDC, collFeeAmt) - - return neededColl, collFee, nil -} - -// sendCoinsToModuleAccount sends coins from account to the module account -func (k Keeper) sendCoinsToModuleAccount( - ctx sdk.Context, from sdk.AccAddress, coins sdk.Coins, -) (err error) { - err = k.BankKeeper.SendCoinsFromAccountToModule( - ctx, from, types.ModuleName, coins) - if err != nil { - return err - } - - for _, coin := range coins { - moduleAddress := k.AccountKeeper.GetModuleAddress(types.ModuleName) - err = ctx.EventManager().EmitTypedEvent(&types.EventTransfer{ - Coin: coin, From: from.String(), To: moduleAddress.String(), - }) - if err != nil { - return err - } - } - return nil -} - -// sendCoinsFromModuleAccountToUser sends coins minted in Module Account to address to -func (k Keeper) sendCoinsFromModuleAccountToUser( - ctx sdk.Context, to sdk.AccAddress, coins sdk.Coins, -) error { - err := k.BankKeeper.SendCoinsFromModuleToAccount( - ctx, types.ModuleName, to, coins) - if err != nil { - return err - } - - for _, coin := range coins { - moduleAddress := k.AccountKeeper.GetModuleAddress(types.ModuleName) - err = ctx.EventManager().EmitTypedEvent(&types.EventTransfer{ - Coin: coin, From: moduleAddress.String(), To: to.String(), - }) - if err != nil { - return err - } - } - - return nil -} - -func (k Keeper) burnCoins(ctx sdk.Context, coins sdk.Coins) error { - err := k.BankKeeper.BurnCoins(ctx, types.ModuleName, coins) - if err != nil { - return err - } - - return nil -} - -// burnGovTokens burns governance coins -func (k Keeper) burnGovTokens(ctx sdk.Context, govTokens sdk.Coin) error { - err := k.burnCoins(ctx, sdk.NewCoins(govTokens)) - if err != nil { - return err - } - - err = ctx.EventManager().EmitTypedEvent( - &types.EventBurnNIBI{Amount: govTokens.Amount}) - if err != nil { - return err - } - - return nil -} - -func (k Keeper) burnStableTokens(ctx sdk.Context, stable sdk.Coin) error { - err := k.burnCoins(ctx, sdk.NewCoins(stable)) - if err != nil { - return err - } - - err = ctx.EventManager().EmitTypedEvent( - &types.EventBurnStable{Amount: stable.Amount}) - if err != nil { - return err - } - - return nil -} - -// mintStable mints NIBI tokens into module account -func (k Keeper) mintStable(ctx sdk.Context, stable sdk.Coin) error { - err := k.BankKeeper.MintCoins(ctx, types.ModuleName, sdk.NewCoins(stable)) - if err != nil { - return err - } - - err = ctx.EventManager().EmitTypedEvent(&types.EventMintStable{Amount: stable.Amount}) - if err != nil { - return err - } - - return nil -} - -// mintGov mints governance tokens into module account -func (k Keeper) mintGov(ctx sdk.Context, gov sdk.Coin) error { - err := k.BankKeeper.MintCoins(ctx, types.ModuleName, sdk.NewCoins(gov)) - if err != nil { - return err - } - - err = ctx.EventManager().EmitTypedEvent(&types.EventMintNIBI{Amount: gov.Amount}) - if err != nil { - return err - } - - return nil -} - -// splitAndSendFeesToEfAndTreasury sends fees to the Stable Ecosystem Fund and treasury pool -func (k Keeper) splitAndSendFeesToEfAndTreasury( - ctx sdk.Context, account sdk.AccAddress, efFeeRatio sdk.Dec, coins sdk.Coins, -) error { - efCoins := sdk.Coins{} - treasuryCoins := sdk.Coins{} - for _, c := range coins { - amountEf := sdk.NewDecFromInt(c.Amount).Mul(efFeeRatio).TruncateInt() - amountTreasury := c.Amount.Sub(amountEf) - - if c.Denom == denoms.NIBI { - stableCoins := sdk.NewCoins(sdk.NewCoin(c.Denom, amountEf)) - err := k.BankKeeper.SendCoinsFromAccountToModule( - ctx, account, types.StableEFModuleAccount, stableCoins) - if err != nil { - return err - } - - err = k.BankKeeper.BurnCoins(ctx, types.StableEFModuleAccount, stableCoins) - if err != nil { - return err - } - } else { - efCoins = efCoins.Add(sdk.NewCoin(c.Denom, amountEf)) - } - treasuryCoins = treasuryCoins.Add(sdk.NewCoin(c.Denom, amountTreasury)) - } - - err := k.BankKeeper.SendCoinsFromAccountToModule( - ctx, account, types.StableEFModuleAccount, efCoins) - if err != nil { - return err - } - - err = k.BankKeeper.SendCoinsFromAccountToModule( - ctx, account, common.TreasuryPoolModuleAccount, treasuryCoins, - ) - if err != nil { - return err - } - - return nil -} - -// BurnStable burns stable coin (plus fees) and returns the equivalent of collateral and gov token. -// Fees are distributed between ecosystem fund and treasury based on feeRatio. -func (k Keeper) BurnStable(goCtx context.Context, msg *types.MsgBurnStable, -) (*types.MsgBurnStableResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - msgCreator, err := sdk.AccAddressFromBech32(msg.Creator) - if err != nil { - return nil, err - } - - if msg.Stable.Amount == sdk.ZeroInt() { - return nil, sdkerrors.Wrap(types.NoCoinFound, msg.Stable.Denom) - } - - params := k.GetParams(ctx) - if !params.IsCollateralRatioValid { - return nil, types.NoValidCollateralRatio - } - - feeRatio := params.GetFeeRatioAsDec() - collRatio := params.GetCollRatioAsDec() - govRatio := sdk.OneDec().Sub(collRatio) - - redeemGovCoin, govFees, err := k.calcNeededGovAndFees(ctx, msg.Stable, govRatio, feeRatio) - if err != nil { - return nil, err - } - redeemCollCoin, collFees, err := k.calcNeededCollateralAndFees(ctx, msg.Stable, collRatio, feeRatio) - if err != nil { - return nil, err - } - - if err = k.mintGov(ctx, redeemGovCoin); err != nil { - return nil, err - } - // The user receives a mixure of collateral (COLL) and governance (GOV) tokens - // based on the collateral ratio. - - // Send NUSD from account to module - stablesToBurn := sdk.NewCoins(msg.Stable) - err = k.BankKeeper.SendCoinsFromAccountToModule( - ctx, msgCreator, types.ModuleName, stablesToBurn) - if err != nil { - return nil, err - } - - redeemedCoins := sdk.NewCoins(redeemCollCoin, redeemGovCoin) - err = k.sendCoinsFromModuleAccountToUser(ctx, msgCreator, redeemedCoins) - if err != nil { - return nil, err - } - - feesToSendEF := sdk.NewCoins(govFees, collFees) - err = k.splitAndSendFeesToEfAndTreasury( - ctx, - msgCreator, - params.GetEfFeeRatioAsDec(), - feesToSendEF, - ) - if err != nil { - return nil, err - } - - err = k.burnStableTokens(ctx, msg.Stable) - if err != nil { - return nil, err - } - - return &types.MsgBurnStableResponse{ - Collateral: redeemCollCoin.Sub(collFees), - Gov: redeemGovCoin.Sub(govFees), - FeesPayed: sdk.NewCoins(govFees, collFees), - }, nil -} diff --git a/x/stablecoin/keeper/mint_burn_stable_test.go b/x/stablecoin/keeper/mint_burn_stable_test.go deleted file mode 100644 index 092315910..000000000 --- a/x/stablecoin/keeper/mint_burn_stable_test.go +++ /dev/null @@ -1,608 +0,0 @@ -package keeper_test - -import ( - "testing" - - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/NibiruChain/nibiru/x/common" - "github.com/NibiruChain/nibiru/x/common/asset" - "github.com/NibiruChain/nibiru/x/common/denoms" - "github.com/NibiruChain/nibiru/x/common/testutil" - "github.com/NibiruChain/nibiru/x/common/testutil/testapp" - "github.com/NibiruChain/nibiru/x/stablecoin/types" -) - -// ------------------------------------------------------------------ -// MintStable -// ------------------------------------------------------------------ - -func TestMsgMint_ValidateBasic(t *testing.T) { - testCases := []struct { - name string - msg types.MsgMintStable - err error - }{ - { - name: "invalid address", - msg: types.MsgMintStable{ - Creator: "invalid_address", - }, - err: sdkerrors.ErrInvalidAddress, - }, { - name: "valid address", - msg: types.MsgMintStable{ - Creator: testutil.AccAddress().String(), - }, - }, - } - for _, testCase := range testCases { - tc := testCase - t.Run(tc.name, func(t *testing.T) { - err := tc.msg.ValidateBasic() - if tc.err != nil { - require.ErrorIs(t, err, tc.err) - return - } - require.NoError(t, err) - }) - } -} - -func TestMsgMintStableResponse_HappyPath(t *testing.T) { - accFundsGovAmount := sdk.NewCoin(denoms.NIBI, sdk.NewInt(10_000)) - accFundsCollAmount := sdk.NewCoin(denoms.USDC, sdk.NewInt(900_000)) - neededGovFees := sdk.NewCoin(denoms.NIBI, sdk.NewInt(20)) // 0.002 fee - neededCollFees := sdk.NewCoin(denoms.USDC, sdk.NewInt(1_800)) // 0.002 fee - - accFundsAmt := sdk.NewCoins( - accFundsGovAmount.Add(neededGovFees), - accFundsCollAmount.Add(neededCollFees), - ) - - tests := []struct { - name string - accFunds sdk.Coins - msgMint types.MsgMintStable - msgResponse types.MsgMintStableResponse - govPrice sdk.Dec - collPrice sdk.Dec - supplyNIBI sdk.Coin - supplyNUSD sdk.Coin - err error - isCollateralRatioValid bool - }{ - { - name: "Not able to mint because of no posted prices", - accFunds: accFundsAmt, - msgMint: types.MsgMintStable{ - Creator: testutil.AccAddress().String(), - Stable: sdk.NewCoin(denoms.NUSD, sdk.NewInt(1*common.TO_MICRO)), - }, - govPrice: sdk.MustNewDecFromStr("10"), - collPrice: sdk.OneDec(), - err: types.NoValidCollateralRatio, - isCollateralRatioValid: false, - }, - { - name: "Successful mint", - accFunds: accFundsAmt, - msgMint: types.MsgMintStable{ - Creator: testutil.AccAddress().String(), - Stable: sdk.NewCoin(denoms.NUSD, sdk.NewInt(1*common.TO_MICRO)), - }, - msgResponse: types.MsgMintStableResponse{ - Stable: sdk.NewCoin(denoms.NUSD, sdk.NewInt(1*common.TO_MICRO)), - UsedCoins: sdk.NewCoins(accFundsCollAmount, accFundsGovAmount), - FeesPayed: sdk.NewCoins(neededCollFees, neededGovFees), - }, - govPrice: sdk.MustNewDecFromStr("10"), - collPrice: sdk.OneDec(), - supplyNIBI: sdk.NewCoin(denoms.NIBI, sdk.NewInt(10)), - // 10_000 - 20 (neededAmt - fees) - 10 (0.5 of fees from EFund are burned) - supplyNUSD: sdk.NewCoin(denoms.NUSD, sdk.NewInt(1*common.TO_MICRO)), - err: nil, - isCollateralRatioValid: true, - }, - } - - for _, tc := range tests { - tc := tc - t.Run(tc.name, func(t *testing.T) { - nibiruApp, ctx := testapp.NewNibiruTestAppAndContext() - acc, _ := sdk.AccAddressFromBech32(tc.msgMint.Creator) - - // We get module account, to create it. - nibiruApp.AccountKeeper.GetModuleAccount(ctx, types.StableEFModuleAccount) - - // Set up pairs for the oracle keeper. - collRatio := sdk.MustNewDecFromStr("0.9") - feeRatio := sdk.MustNewDecFromStr("0.002") - feeRatioEF := sdk.MustNewDecFromStr("0.5") - bonusRateRecoll := sdk.MustNewDecFromStr("0.002") - adjustmentStep := sdk.MustNewDecFromStr("0.0025") - priceLowerBound := sdk.MustNewDecFromStr("0.9999") - priceUpperBound := sdk.MustNewDecFromStr("1.0001") - - nibiruApp.StablecoinKeeper.SetParams( - ctx, types.NewParams( - collRatio, - feeRatio, - feeRatioEF, - bonusRateRecoll, - "15 min", - adjustmentStep, - priceLowerBound, - priceUpperBound, - tc.isCollateralRatioValid, - ), - ) - - // Post prices to each pair with the oracle. - nibiruApp.OracleKeeper.SetPrice(ctx, asset.Registry.Pair(denoms.NIBI, denoms.NUSD), tc.govPrice) - nibiruApp.OracleKeeper.SetPrice(ctx, asset.Registry.Pair(denoms.USDC, denoms.NUSD), tc.collPrice) - - // Fund account - require.NoError(t, testapp.FundAccount(nibiruApp.BankKeeper, ctx, acc, tc.accFunds)) - - // Mint NUSD -> Response contains Stable (sdk.Coin) - goCtx := sdk.WrapSDKContext(ctx) - mintStableResponse, err := nibiruApp.StablecoinKeeper.MintStable( - goCtx, &tc.msgMint) - - if tc.err != nil { - require.ErrorIs(t, err, tc.err) - return - } - - require.NoError(t, err) - assert.EqualValues(t, tc.msgResponse, *mintStableResponse) - assert.Equal(t, nibiruApp.StablecoinKeeper.GetSupplyNIBI(ctx), tc.supplyNIBI) - assert.Equal(t, nibiruApp.StablecoinKeeper.GetSupplyNUSD(ctx), tc.supplyNUSD) - - // Check balances in EF - efModuleBalance := nibiruApp.BankKeeper.GetAllBalances( - ctx, nibiruApp.AccountKeeper.GetModuleAddress(types.StableEFModuleAccount), - ) - collFeesInEf := sdk.NewDecFromInt(neededCollFees.Amount).Mul(sdk.MustNewDecFromStr("0.5")).TruncateInt() - assert.Equal(t, sdk.NewCoins(sdk.NewCoin(denoms.USDC, collFeesInEf)), efModuleBalance) - - // Check balances in Treasury - treasuryModuleBalance := nibiruApp.BankKeeper. - GetAllBalances(ctx, nibiruApp.AccountKeeper.GetModuleAddress(common.TreasuryPoolModuleAccount)) - collFeesInTreasury := sdk.NewDecFromInt(neededCollFees.Amount).Mul(sdk.MustNewDecFromStr("0.5")).TruncateInt() - govFeesInTreasury := sdk.NewDecFromInt(neededGovFees.Amount).Mul(sdk.MustNewDecFromStr("0.5")).TruncateInt() - assert.Equal( - t, - sdk.NewCoins( - sdk.NewCoin(denoms.USDC, collFeesInTreasury), - sdk.NewCoin(denoms.NIBI, govFeesInTreasury), - ), - treasuryModuleBalance, - ) - }) - } -} - -func TestMsgMintStableResponse_NotEnoughFunds(t *testing.T) { - testCases := []struct { - name string - accFunds sdk.Coins - msgMint types.MsgMintStable - msgResponse types.MsgMintStableResponse - govPrice sdk.Dec - collPrice sdk.Dec - err error - }{ - { - name: "User has no GOV", - accFunds: sdk.NewCoins( - sdk.NewCoin(denoms.USDC, sdk.NewInt(9001)), - sdk.NewCoin(denoms.NIBI, sdk.ZeroInt()), - ), - msgMint: types.MsgMintStable{ - Creator: testutil.AccAddress().String(), - Stable: sdk.NewCoin(denoms.NUSD, sdk.NewInt(100)), - }, - msgResponse: types.MsgMintStableResponse{ - Stable: sdk.NewCoin(denoms.NUSD, sdk.ZeroInt()), - }, - govPrice: sdk.MustNewDecFromStr("10"), - collPrice: sdk.OneDec(), - err: types.NotEnoughBalance.Wrap(denoms.NIBI), - }, - { - name: "User has no COLL", - accFunds: sdk.NewCoins( - sdk.NewCoin(denoms.USDC, sdk.ZeroInt()), - sdk.NewCoin(denoms.NIBI, sdk.NewInt(9001)), - ), - msgMint: types.MsgMintStable{ - Creator: testutil.AccAddress().String(), - Stable: sdk.NewCoin(denoms.NUSD, sdk.NewInt(100)), - }, - msgResponse: types.MsgMintStableResponse{ - Stable: sdk.NewCoin(denoms.NUSD, sdk.ZeroInt()), - }, - govPrice: sdk.MustNewDecFromStr("10"), - collPrice: sdk.OneDec(), - err: types.NotEnoughBalance.Wrap(denoms.USDC), - }, - { - name: "Not enough GOV", - accFunds: sdk.NewCoins( - sdk.NewCoin(denoms.USDC, sdk.NewInt(9001)), - sdk.NewCoin(denoms.NIBI, sdk.OneInt()), - ), - msgMint: types.MsgMintStable{ - Creator: testutil.AccAddress().String(), - Stable: sdk.NewCoin(denoms.NUSD, sdk.NewInt(1000)), - }, - msgResponse: types.MsgMintStableResponse{ - Stable: sdk.NewCoin(denoms.NUSD, sdk.ZeroInt()), - }, - govPrice: sdk.MustNewDecFromStr("10"), - collPrice: sdk.OneDec(), - err: types.NotEnoughBalance.Wrap( - sdk.NewCoin(denoms.NIBI, sdk.OneInt()).String()), - }, - { - name: "Not enough COLL", - accFunds: sdk.NewCoins( - sdk.NewCoin(denoms.USDC, sdk.OneInt()), - sdk.NewCoin(denoms.NIBI, sdk.NewInt(9001)), - ), - msgMint: types.MsgMintStable{ - Creator: testutil.AccAddress().String(), - Stable: sdk.NewCoin(denoms.NUSD, sdk.NewInt(100)), - }, - msgResponse: types.MsgMintStableResponse{ - Stable: sdk.NewCoin(denoms.NUSD, sdk.ZeroInt()), - }, - govPrice: sdk.MustNewDecFromStr("10"), - collPrice: sdk.OneDec(), - err: types.NotEnoughBalance.Wrap( - sdk.NewCoin(denoms.USDC, sdk.OneInt()).String()), - }, - } - - for _, testCase := range testCases { - tc := testCase - t.Run(tc.name, func(t *testing.T) { - nibiruApp, ctx := testapp.NewNibiruTestAppAndContext() - acc, _ := sdk.AccAddressFromBech32(tc.msgMint.Creator) - - // We get module account, to create it. - nibiruApp.AccountKeeper.GetModuleAccount(ctx, types.StableEFModuleAccount) - - collRatio := sdk.MustNewDecFromStr("0.9") - feeRatio := sdk.ZeroDec() - feeRatioEF := sdk.MustNewDecFromStr("0.5") - bonusRateRecoll := sdk.MustNewDecFromStr("0.002") - adjustmentStep := sdk.MustNewDecFromStr("0.0025") - priceLowerBound := sdk.MustNewDecFromStr("0.9999") - priceUpperBound := sdk.MustNewDecFromStr("1.0001") - - nibiruApp.StablecoinKeeper.SetParams( - ctx, types.NewParams( - collRatio, - feeRatio, - feeRatioEF, - bonusRateRecoll, - "15 min", - adjustmentStep, - priceLowerBound, - priceUpperBound, - true, - ), - ) - - t.Log("Post prices to each pair with the oracle.") - nibiruApp.OracleKeeper.SetPrice(ctx, asset.Registry.Pair(denoms.NIBI, denoms.NUSD), tc.govPrice) - nibiruApp.OracleKeeper.SetPrice(ctx, asset.Registry.Pair(denoms.USDC, denoms.NUSD), tc.collPrice) - - // Fund account - require.NoError(t, testapp.FundAccount(nibiruApp.BankKeeper, ctx, acc, tc.accFunds)) - - // Mint NUSD -> Response contains Stable (sdk.Coin) - goCtx := sdk.WrapSDKContext(ctx) - mintStableResponse, err := nibiruApp.StablecoinKeeper.MintStable( - goCtx, &tc.msgMint) - - if tc.err != nil { - require.ErrorIs(t, err, tc.err) - return - } - - require.NoError(t, err) - assert.EqualValues(t, tc.msgResponse, *mintStableResponse) - - balances := nibiruApp.BankKeeper.GetAllBalances(ctx, nibiruApp.AccountKeeper.GetModuleAddress(types.StableEFModuleAccount)) - assert.Equal(t, mintStableResponse.FeesPayed, balances) - }) - } -} - -// ------------------------------------------------------------------ -// BurnStable / Redeem -// ------------------------------------------------------------------ - -func TestMsgBurn_ValidateBasic(t *testing.T) { - testCases := []struct { - name string - msg types.MsgBurnStable - err error - }{ - { - name: "invalid address", - msg: types.MsgBurnStable{ - Creator: "invalid_address", - }, - err: sdkerrors.ErrInvalidAddress, - }, { - name: "valid address", - msg: types.MsgBurnStable{ - Creator: testutil.AccAddress().String(), - }, - }, - } - for _, testCase := range testCases { - tc := testCase - t.Run(tc.name, func(t *testing.T) { - err := tc.msg.ValidateBasic() - if tc.err != nil { - require.ErrorIs(t, err, tc.err) - return - } - require.NoError(t, err) - }) - } -} - -func TestMsgBurnResponse_NotEnoughFunds(t *testing.T) { - tests := []struct { - name string - accFunds sdk.Coins - moduleFunds sdk.Coins - msgBurn types.MsgBurnStable - msgResponse *types.MsgBurnStableResponse - govPrice sdk.Dec - collPrice sdk.Dec - expectedPass bool - err string - }{ - { - name: "Not enough stable", - accFunds: sdk.NewCoins(sdk.NewInt64Coin(denoms.NUSD, 10)), - msgBurn: types.MsgBurnStable{ - Creator: testutil.AccAddress().String(), - Stable: sdk.NewInt64Coin(denoms.NUSD, 9001), - }, - msgResponse: &types.MsgBurnStableResponse{ - Collateral: sdk.NewCoin(denoms.NIBI, sdk.ZeroInt()), - Gov: sdk.NewCoin(denoms.USDC, sdk.ZeroInt()), - }, - govPrice: sdk.MustNewDecFromStr("10"), - collPrice: sdk.OneDec(), - expectedPass: false, - err: "insufficient funds", - }, - { - name: "Stable is zero", - govPrice: sdk.MustNewDecFromStr("10"), - collPrice: sdk.OneDec(), - accFunds: sdk.NewCoins( - sdk.NewInt64Coin(denoms.NUSD, 1000*common.TO_MICRO), - ), - moduleFunds: sdk.NewCoins( - sdk.NewInt64Coin(denoms.USDC, 100*common.TO_MICRO), - ), - msgBurn: types.MsgBurnStable{ - Creator: testutil.AccAddress().String(), - Stable: sdk.NewCoin(denoms.NUSD, sdk.ZeroInt()), - }, - msgResponse: &types.MsgBurnStableResponse{ - Gov: sdk.NewCoin(denoms.NIBI, sdk.ZeroInt()), - Collateral: sdk.NewCoin(denoms.USDC, sdk.ZeroInt()), - FeesPayed: sdk.NewCoins(), - }, - expectedPass: true, - err: types.NoCoinFound.Wrap(denoms.NUSD).Error(), - }, - } - - for _, tc := range tests { - tc := tc - t.Run(tc.name, func(t *testing.T) { - nibiruApp, ctx := testapp.NewNibiruTestAppAndContext() - acc, _ := sdk.AccAddressFromBech32(tc.msgBurn.Creator) - - // Set stablecoin params - collRatio := sdk.MustNewDecFromStr("0.9") - feeRatio := sdk.MustNewDecFromStr("0.002") - feeRatioEF := sdk.MustNewDecFromStr("0.5") - bonusRateRecoll := sdk.MustNewDecFromStr("0.002") - adjustmentStep := sdk.MustNewDecFromStr("0.0025") - priceLowerBound := sdk.MustNewDecFromStr("0.9999") - priceUpperBound := sdk.MustNewDecFromStr("1.0001") - - nibiruApp.StablecoinKeeper.SetParams( - ctx, types.NewParams( - collRatio, - feeRatio, - feeRatioEF, - bonusRateRecoll, - "15 min", - adjustmentStep, - priceLowerBound, - priceUpperBound, - true, - ), - ) - - defaultParams := types.DefaultParams() - defaultParams.IsCollateralRatioValid = true - nibiruApp.StablecoinKeeper.SetParams(ctx, defaultParams) - - t.Log("Post prices to each pair with the oracle.") - nibiruApp.OracleKeeper.SetPrice(ctx, asset.Registry.Pair(denoms.NIBI, denoms.NUSD), tc.govPrice) - nibiruApp.OracleKeeper.SetPrice(ctx, asset.Registry.Pair(denoms.USDC, denoms.NUSD), tc.collPrice) - - // Add collaterals to the module - require.NoError(t, nibiruApp.BankKeeper.MintCoins(ctx, types.ModuleName, tc.moduleFunds)) - require.NoError(t, testapp.FundAccount(nibiruApp.BankKeeper, ctx, acc, tc.accFunds)) - - // Burn NUSD -> Response contains GOV and COLL - goCtx := sdk.WrapSDKContext(ctx) - burnStableResponse, err := nibiruApp.StablecoinKeeper.BurnStable( - goCtx, &tc.msgBurn) - - if !tc.expectedPass { - require.Error(t, err) - require.Contains(t, err.Error(), tc.err) - - return - } - require.NoError(t, err) - assert.EqualValues(t, tc.msgResponse, burnStableResponse) - }) - } -} - -func TestMsgBurnResponse_HappyPath(t *testing.T) { - tests := []struct { - name string - accFunds sdk.Coins - moduleFunds sdk.Coins - msgBurn types.MsgBurnStable - msgResponse types.MsgBurnStableResponse - govPrice sdk.Dec - collPrice sdk.Dec - supplyNIBI sdk.Coin - supplyNUSD sdk.Coin - ecosystemFund sdk.Coins - treasuryFund sdk.Coins - expectedPass bool - err error - isCollateralRatioValid bool - }{ - { - name: "invalid collateral ratio", - govPrice: sdk.MustNewDecFromStr("10"), - collPrice: sdk.OneDec(), - accFunds: sdk.NewCoins( - sdk.NewInt64Coin(denoms.NUSD, 1_000*common.TO_MICRO), - ), - moduleFunds: sdk.NewCoins( - sdk.NewInt64Coin(denoms.USDC, 100*common.TO_MICRO), - ), - msgBurn: types.MsgBurnStable{ - Creator: testutil.AccAddress().String(), - Stable: sdk.NewInt64Coin(denoms.NUSD, 10*common.TO_MICRO), - }, - ecosystemFund: sdk.NewCoins(sdk.NewInt64Coin(denoms.USDC, 9000)), - treasuryFund: sdk.NewCoins(sdk.NewInt64Coin(denoms.USDC, 9000), sdk.NewInt64Coin(denoms.NIBI, 100)), - expectedPass: false, - isCollateralRatioValid: false, - err: types.NoValidCollateralRatio, - }, - { - name: "Happy path", - govPrice: sdk.MustNewDecFromStr("10"), - collPrice: sdk.OneDec(), - accFunds: sdk.NewCoins( - sdk.NewInt64Coin(denoms.NUSD, 1_000*common.TO_MICRO), - ), - moduleFunds: sdk.NewCoins( - sdk.NewInt64Coin(denoms.USDC, 100*common.TO_MICRO), - ), - msgBurn: types.MsgBurnStable{ - Creator: testutil.AccAddress().String(), - Stable: sdk.NewInt64Coin(denoms.NUSD, 10*common.TO_MICRO), - }, - msgResponse: types.MsgBurnStableResponse{ - Gov: sdk.NewInt64Coin(denoms.NIBI, 100_000-200), // amount - fees 0,02% - Collateral: sdk.NewInt64Coin(denoms.USDC, 9*common.TO_MICRO-18_000), // amount - fees 0,02% - FeesPayed: sdk.NewCoins( - sdk.NewInt64Coin(denoms.NIBI, 200), - sdk.NewInt64Coin(denoms.USDC, 18_000), - ), - }, - supplyNIBI: sdk.NewCoin(denoms.NIBI, sdk.NewInt(100_000-100)), // nibiru minus 0.5 of fees burned (the part that goes to EF) - supplyNUSD: sdk.NewCoin(denoms.NUSD, sdk.NewInt(1_000*common.TO_MICRO-10*common.TO_MICRO)), - ecosystemFund: sdk.NewCoins(sdk.NewInt64Coin(denoms.USDC, 9000)), - treasuryFund: sdk.NewCoins(sdk.NewInt64Coin(denoms.USDC, 9000), sdk.NewInt64Coin(denoms.NIBI, 100)), - expectedPass: true, - isCollateralRatioValid: true, - }, - } - - for _, tc := range tests { - tc := tc - t.Run(tc.name, func(t *testing.T) { - nibiruApp, ctx := testapp.NewNibiruTestAppAndContext() - acc, _ := sdk.AccAddressFromBech32(tc.msgBurn.Creator) - - // Set stablecoin params - collRatio := sdk.MustNewDecFromStr("0.9") - feeRatio := sdk.MustNewDecFromStr("0.002") - feeRatioEF := sdk.MustNewDecFromStr("0.5") - bonusRateRecoll := sdk.MustNewDecFromStr("0.002") - adjustmentStep := sdk.MustNewDecFromStr("0.0025") - priceLowerBound := sdk.MustNewDecFromStr("0.9999") - priceUpperBound := sdk.MustNewDecFromStr("1.0001") - - nibiruApp.StablecoinKeeper.SetParams( - ctx, types.NewParams( - collRatio, - feeRatio, - feeRatioEF, - bonusRateRecoll, - "15 min", - adjustmentStep, - priceLowerBound, - priceUpperBound, - tc.isCollateralRatioValid, - ), - ) - - nibiruApp.OracleKeeper.SetPrice(ctx, asset.Registry.Pair(denoms.NIBI, denoms.NUSD), tc.govPrice) - nibiruApp.OracleKeeper.SetPrice(ctx, asset.Registry.Pair(denoms.USDC, denoms.NUSD), tc.collPrice) - - // Add collaterals to the module - require.NoError(t, nibiruApp.BankKeeper.MintCoins(ctx, types.ModuleName, tc.moduleFunds)) - require.NoError(t, testapp.FundAccount(nibiruApp.BankKeeper, ctx, acc, tc.accFunds)) - - // Burn NUSD -> Response contains GOV and COLL - goCtx := sdk.WrapSDKContext(ctx) - burnStableResponse, err := nibiruApp.StablecoinKeeper.BurnStable( - goCtx, &tc.msgBurn) - - if !tc.expectedPass { - require.ErrorIs(t, err, tc.err) - return - } - - require.NoError(t, err) - assert.EqualValues(t, tc.msgResponse, *burnStableResponse) - - require.Equal(t, tc.supplyNIBI, nibiruApp.StablecoinKeeper.GetSupplyNIBI(ctx)) - require.Equal(t, tc.supplyNUSD, nibiruApp.StablecoinKeeper.GetSupplyNUSD(ctx)) - - // Funds sypplies - require.Equal(t, - tc.ecosystemFund, - nibiruApp.BankKeeper.GetAllBalances( - ctx, - nibiruApp.AccountKeeper.GetModuleAddress(types.StableEFModuleAccount))) - require.Equal(t, - tc.treasuryFund, - nibiruApp.BankKeeper.GetAllBalances( - ctx, - nibiruApp.AccountKeeper.GetModuleAddress(common.TreasuryPoolModuleAccount))) - }) - } -} diff --git a/x/stablecoin/keeper/msg_server.go b/x/stablecoin/keeper/msg_server.go deleted file mode 100644 index e30961110..000000000 --- a/x/stablecoin/keeper/msg_server.go +++ /dev/null @@ -1,70 +0,0 @@ -package keeper - -import ( - "context" - - "github.com/NibiruChain/nibiru/x/stablecoin/types" -) - -type msgServer struct { - Keeper -} - -// NewMsgServerImpl returns an implementation of the MsgServer interface -// for the provided Keeper. -func NewMsgServerImpl(keeper Keeper) types.MsgServer { - return &msgServer{Keeper: keeper} -} - -var _ types.MsgServer = msgServer{} - -/* -Args: - - goCtx - -Returns - - MsgMintStableResponse: - error: -*/ -func (k msgServer) MsgMintStable( - goCtx context.Context, msg *types.MsgMintStable, -) (*types.MsgMintStableResponse, error) { - mintStableResponse, err := k.MintStable(goCtx, msg) - if err != nil { - return nil, err - } - - return mintStableResponse, nil -} - -func (k msgServer) MsgBurnStable( - goCtx context.Context, msg *types.MsgBurnStable, -) (*types.MsgBurnStableResponse, error) { - burnStableResponse, err := k.BurnStable(goCtx, msg) - if err != nil { - return nil, err - } - return burnStableResponse, nil -} - -func (k msgServer) MsgRecollateralize( - goCtx context.Context, msg *types.MsgRecollateralize, -) (*types.MsgRecollateralizeResponse, error) { - response, err := k.Recollateralize(goCtx, msg) - if err != nil { - return nil, err - } - return response, nil -} - -func (k msgServer) MsgBuyback( - goCtx context.Context, msg *types.MsgBuyback, -) (*types.MsgBuybackResponse, error) { - response, err := k.Buyback(goCtx, msg) - if err != nil { - return nil, err - } - return response, nil -} diff --git a/x/stablecoin/keeper/msg_server_test.go b/x/stablecoin/keeper/msg_server_test.go deleted file mode 100644 index 50b7c60c5..000000000 --- a/x/stablecoin/keeper/msg_server_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package keeper_test - -import ( - "testing" - - "github.com/stretchr/testify/require" - - "github.com/NibiruChain/nibiru/x/common/testutil/testapp" - sckeeper "github.com/NibiruChain/nibiru/x/stablecoin/keeper" -) - -func TestNewMsgServerImpl(t *testing.T) { - type TestCase struct { - name string - keeper sckeeper.Keeper - } - - executeTest := func(t *testing.T, testCase TestCase) { - tc := testCase - t.Run(tc.name, func(t *testing.T) { - msgServer := sckeeper.NewMsgServerImpl(tc.keeper) - require.True(t, msgServer != nil) - }) - } - - nibiruApp, _ := testapp.NewNibiruTestAppAndContext() - testCases := []TestCase{ - { - name: "Default NibiruApp.StablecoinKeeper, should pass", - keeper: nibiruApp.StablecoinKeeper, - }, - } - - for _, testCase := range testCases { - executeTest(t, testCase) - } -} diff --git a/x/stablecoin/keeper/needed.go b/x/stablecoin/keeper/needed.go deleted file mode 100644 index bee3da047..000000000 --- a/x/stablecoin/keeper/needed.go +++ /dev/null @@ -1,49 +0,0 @@ -package keeper - -import ( - sdkmath "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// NeededGovAmtGivenColl Computes the amount of NIBI needed to mint NUSD given some COLL amount. -// Args: -// -// collAmt sdk.Int: Amount of COLL given. -// -// Returns: -// -// neededGovAmt sdk.Int: Amount of NIBI needed. -// mintableStableAmt sdk.Int: Amount of NUSD that can be minted. -func NeededGovAmtGivenColl( - collAmt sdkmath.Int, priceGov sdk.Dec, priceColl sdk.Dec, - collRatio sdk.Dec, -) (neededGovAmt sdkmath.Int, mintableStableAmt sdkmath.Int) { - collUSD := sdk.NewDecFromInt(collAmt).Mul(priceColl) - neededGovUSD := (collUSD.Quo(collRatio)).Sub(collUSD) - - neededGovAmt = neededGovUSD.Quo(priceGov).TruncateInt() - mintableStableAmt = collUSD.Add(neededGovUSD).TruncateInt() - return neededGovAmt, mintableStableAmt -} - -// NeededCollAmtGivenGov Computes the amount of COLL needed to mint NUSD given some NIBI amount. -// Args: -// -// govAmt sdk.Int: Amount of NIBI given. -// -// Returns: -// -// neededCollAmt sdk.Int: Amount of COLL needed. -// mintableStableAmt sdk.Int: Amount of NUSD that can be minted. -func NeededCollAmtGivenGov( - govAmt sdkmath.Int, priceGov sdk.Dec, priceColl sdk.Dec, - collRatio sdk.Dec, -) (neededCollAmt sdkmath.Int, mintableStableAmt sdkmath.Int) { - govUSD := sdk.NewDecFromInt(govAmt).Mul(priceGov) - govRatio := sdk.OneDec().Sub(collRatio) - neededCollUSD := collRatio.Quo(govRatio).Mul(govUSD) - - neededCollAmt = neededCollUSD.Quo(priceColl).TruncateInt() - mintableStableAmt = govUSD.Add(neededCollUSD).TruncateInt() - return neededCollAmt, mintableStableAmt -} diff --git a/x/stablecoin/keeper/needed_test.go b/x/stablecoin/keeper/needed_test.go deleted file mode 100644 index 8db6f256e..000000000 --- a/x/stablecoin/keeper/needed_test.go +++ /dev/null @@ -1,130 +0,0 @@ -package keeper_test - -import ( - "testing" - - sdkmath "cosmossdk.io/math" - - "github.com/NibiruChain/nibiru/x/stablecoin/keeper" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestAsInt(t *testing.T) { - testCases := []struct { - name string - inDec sdk.Dec - outInt sdkmath.Int - }{ - { - name: "One to int", - inDec: sdk.OneDec(), - outInt: sdk.OneInt(), - }, - { - name: "Small loss of precision due to truncation", - inDec: sdk.MustNewDecFromStr("1.1"), - outInt: sdk.OneInt(), - }, - { - name: "Large loss of precision due to truncation", - inDec: sdk.MustNewDecFromStr("9.999"), - outInt: sdk.NewInt(9), - }, - { - name: "Negative precision loss", - inDec: sdk.MustNewDecFromStr("-4.9999999999999"), - outInt: sdk.NewInt(-4), - }, - } - for _, testCase := range testCases { - tc := testCase - t.Run(tc.name, func(t *testing.T) { - sdkInt := tc.inDec.TruncateInt() - require.Equal(t, tc.outInt, sdkInt) - }) - } -} - -func TestMint_NeededCollAmtGivenGov(t *testing.T) { - testCases := []struct { - name string - govAmt sdkmath.Int - priceGov sdk.Dec - priceColl sdk.Dec - collRatio sdk.Dec - expectedNeededCollAmt sdkmath.Int - expectedMintableStableAmt sdkmath.Int - }{ - { - name: "Low collateral ratio", - govAmt: sdk.NewInt(10), - priceGov: sdk.NewDec(80), // 80 * 10 = 800 - priceColl: sdk.NewDec(10), // c * 10 = 200 - collRatio: sdk.MustNewDecFromStr("0.2"), - expectedNeededCollAmt: sdk.NewInt(20), // → c = 20 - expectedMintableStableAmt: sdk.NewInt(1000), - }, { - name: "High collateral ratio", - govAmt: sdk.NewInt(10), - priceGov: sdk.OneDec(), // 10 * 1 = 10 - priceColl: sdk.MustNewDecFromStr("2"), // c * 2 = 90 - collRatio: sdk.MustNewDecFromStr("0.9"), - expectedNeededCollAmt: sdk.NewInt(45), // → c = 45 - expectedMintableStableAmt: sdk.NewInt(100), - }, - } - for _, testCase := range testCases { - tc := testCase - t.Run(tc.name, func(t *testing.T) { - neededCollAmt, mintableStableAmt := keeper.NeededCollAmtGivenGov( - tc.govAmt, tc.priceGov, tc.priceColl, tc.collRatio) - assert.EqualValues(t, tc.expectedNeededCollAmt, neededCollAmt) - assert.EqualValues(t, tc.expectedMintableStableAmt, mintableStableAmt) - }) - } -} - -func TestMint_NeededGovAmtGivenColl(t *testing.T) { - testCases := []struct { - name string - collAmt sdkmath.Int - priceGov sdk.Dec - priceColl sdk.Dec - collRatio sdk.Dec - neededGovAmt sdkmath.Int - mintableStableAmt sdkmath.Int - err error - }{ - { - name: "collRatio above 50%", - collAmt: sdk.NewInt(70), - priceGov: sdk.NewDec(10), - priceColl: sdk.OneDec(), // 70 * 1 = 70 - collRatio: sdk.MustNewDecFromStr("0.7"), - neededGovAmt: sdk.NewInt(3), // 10 * 3 = 30 - mintableStableAmt: sdk.NewInt(100), // = 70 + 30 - err: nil, - }, { - name: "collRatio below 50%", - collAmt: sdk.NewInt(40), - priceGov: sdk.NewDec(10), - priceColl: sdk.NewDec(2), // 40 * 2 = 80 - collRatio: sdk.MustNewDecFromStr("0.8"), - neededGovAmt: sdk.NewInt(2), // 2 * 10 = 20 - mintableStableAmt: sdk.NewInt(100), // = 80 + 20 - err: nil, - }, - } - for _, testCase := range testCases { - tc := testCase - t.Run(tc.name, func(t *testing.T) { - neededGovAmt, mintableStableAmt := keeper.NeededGovAmtGivenColl( - tc.collAmt, tc.priceGov, tc.priceColl, tc.collRatio) - require.Equal(t, neededGovAmt, tc.neededGovAmt) - require.Equal(t, mintableStableAmt, tc.mintableStableAmt) - }) - } -} diff --git a/x/stablecoin/keeper/params_test.go b/x/stablecoin/keeper/params_test.go deleted file mode 100644 index 1a2431503..000000000 --- a/x/stablecoin/keeper/params_test.go +++ /dev/null @@ -1,92 +0,0 @@ -package keeper_test - -import ( - "fmt" - "testing" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" - - "github.com/NibiruChain/nibiru/x/common" - "github.com/NibiruChain/nibiru/x/common/testutil/testapp" - "github.com/NibiruChain/nibiru/x/stablecoin/types" -) - -func TestGetParams(t *testing.T) { - nibiruApp, ctx := testapp.NewNibiruTestAppAndContext() - stableKeeper := &nibiruApp.StablecoinKeeper - - params := types.DefaultParams() - - stableKeeper.SetParams(ctx, params) - - require.EqualValues(t, params, stableKeeper.GetParams(ctx)) -} - -func TestNewParams_Errors(t *testing.T) { - tests := []struct { - name string - params types.Params - expectedError error - }{ - { - "collateral ratio bigger than 1", - types.NewParams( - sdk.MustNewDecFromStr("2"), - sdk.OneDec(), - sdk.OneDec(), - sdk.MustNewDecFromStr("0.002"), - "15 min", - sdk.MustNewDecFromStr("0.0025"), - sdk.MustNewDecFromStr("0.9999"), - sdk.MustNewDecFromStr("1.0001"), - true, - ), - fmt.Errorf( - "collateral ratio is above max value(1e6): %s", - sdk.MustNewDecFromStr("2").Mul(sdk.NewDec(1*common.TO_MICRO)).TruncateInt()), - }, - { - "fee ratio bigger than 1", - types.NewParams( - sdk.OneDec(), - sdk.MustNewDecFromStr("2"), - sdk.OneDec(), - sdk.MustNewDecFromStr("0.002"), - "15 min", - sdk.MustNewDecFromStr("0.0025"), - sdk.MustNewDecFromStr("0.9999"), - sdk.MustNewDecFromStr("1.0001"), - true, - ), - fmt.Errorf( - "fee ratio is above max value(1e6): %s", - sdk.MustNewDecFromStr("2").Mul(sdk.NewDec(1*common.TO_MICRO)).TruncateInt()), - }, - { - "stable EF fee ratio bigger than 1", - types.NewParams( - sdk.OneDec(), - sdk.OneDec(), - sdk.MustNewDecFromStr("2"), - sdk.MustNewDecFromStr("0.002"), - "15 min", - sdk.MustNewDecFromStr("0.0025"), - sdk.MustNewDecFromStr("0.9999"), - sdk.MustNewDecFromStr("1.0001"), - false, - ), - fmt.Errorf( - "stable EF fee ratio is above max value(1e6): %s", - sdk.MustNewDecFromStr("2").Mul(sdk.NewDec(1*common.TO_MICRO)).TruncateInt()), - }, - } - - for _, tc := range tests { - tc := tc - t.Run(tc.name, func(t *testing.T) { - err := tc.params.Validate() - require.EqualError(t, err, tc.expectedError.Error()) - }) - } -} diff --git a/x/stablecoin/keeper/supply.go b/x/stablecoin/keeper/supply.go deleted file mode 100644 index 9a2025b0c..000000000 --- a/x/stablecoin/keeper/supply.go +++ /dev/null @@ -1,74 +0,0 @@ -package keeper - -import ( - "fmt" - - sdkmath "cosmossdk.io/math" - - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/NibiruChain/nibiru/x/common/denoms" -) - -var LiquidityRatioBands = sdk.MustNewDecFromStr("0.001") - -func (k Keeper) GetSupplyNUSD( - ctx sdk.Context, -) sdk.Coin { - return k.BankKeeper.GetSupply(ctx, denoms.NUSD) -} - -func (k Keeper) GetSupplyNIBI( - ctx sdk.Context, -) sdk.Coin { - return k.BankKeeper.GetSupply(ctx, denoms.NIBI) -} - -func (k Keeper) GetStableMarketCap(ctx sdk.Context) sdkmath.Int { - return k.GetSupplyNUSD(ctx).Amount -} - -func (k Keeper) GetGovMarketCap(ctx sdk.Context) (sdkmath.Int, error) { - pool, err := k.SpotKeeper.FetchPoolFromPair(ctx, denoms.NIBI, denoms.NUSD) - if err != nil { - return sdkmath.Int{}, err - } - - price, err := pool.CalcSpotPrice(denoms.NIBI, denoms.NUSD) - if err != nil { - return sdkmath.Int{}, err - } - - nibiSupply := k.GetSupplyNIBI(ctx) - - return sdk.NewDecFromInt(nibiSupply.Amount).Mul(price).RoundInt(), nil -} - -// GetLiquidityRatio returns the liquidity ratio defined as govMarketCap / stableMarketCap -func (k Keeper) GetLiquidityRatio(ctx sdk.Context) (sdk.Dec, error) { - govMarketCap, err := k.GetGovMarketCap(ctx) - if err != nil { - return sdk.Dec{}, err - } - - stableMarketCap := k.GetStableMarketCap(ctx) - if stableMarketCap.Equal(sdk.ZeroInt()) { - return sdk.Dec{}, fmt.Errorf("stable maket cap is equal to zero") - } - - return sdk.NewDecFromInt(govMarketCap).Quo(sdk.NewDecFromInt(stableMarketCap)), nil -} - -func (k Keeper) GetLiquidityRatioBands(ctx sdk.Context) ( - lowBand sdk.Dec, upBand sdk.Dec, err error, -) { - liquidityRatio, err := k.GetLiquidityRatio(ctx) - if err != nil { - return sdk.Dec{}, sdk.Dec{}, err - } - - lowBand = liquidityRatio.Mul(sdk.OneDec().Sub(LiquidityRatioBands)) - upBand = liquidityRatio.Mul(sdk.OneDec().Add(LiquidityRatioBands)) - - return lowBand, upBand, err -} diff --git a/x/stablecoin/keeper/supply_test.go b/x/stablecoin/keeper/supply_test.go deleted file mode 100644 index 14fb9d8bc..000000000 --- a/x/stablecoin/keeper/supply_test.go +++ /dev/null @@ -1,118 +0,0 @@ -package keeper_test - -import ( - "testing" - - "github.com/NibiruChain/nibiru/x/common" - "github.com/NibiruChain/nibiru/x/common/denoms" - "github.com/NibiruChain/nibiru/x/common/testutil" - "github.com/NibiruChain/nibiru/x/common/testutil/testapp" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" - - spottypes "github.com/NibiruChain/nibiru/x/spot/types" - "github.com/NibiruChain/nibiru/x/stablecoin/mock" - "github.com/NibiruChain/nibiru/x/stablecoin/types" -) - -func TestKeeper_GetStableMarketCap(t *testing.T) { - nibiruApp, ctx := testapp.NewNibiruTestAppAndContext() - k := nibiruApp.StablecoinKeeper - - // We set some supply - err := k.BankKeeper.MintCoins(ctx, types.ModuleName, sdk.NewCoins( - sdk.NewInt64Coin(denoms.NUSD, 1*common.TO_MICRO), - )) - require.NoError(t, err) - - // We set some supply - marketCap := k.GetStableMarketCap(ctx) - - require.Equal(t, sdk.NewInt(1*common.TO_MICRO), marketCap) -} - -func TestKeeper_GetGovMarketCap(t *testing.T) { - nibiruApp, ctx := testapp.NewNibiruTestAppAndContext() - keeper := nibiruApp.StablecoinKeeper - - poolAccountAddr := testutil.AccAddress() - poolParams := spottypes.PoolParams{ - SwapFee: sdk.NewDecWithPrec(3, 2), - ExitFee: sdk.NewDecWithPrec(3, 2), - PoolType: spottypes.PoolType_BALANCER, - } - poolAssets := []spottypes.PoolAsset{ - { - Token: sdk.NewInt64Coin(denoms.NIBI, 2*common.TO_MICRO), - Weight: sdk.NewInt(100), - }, - { - Token: sdk.NewInt64Coin(denoms.NUSD, 1*common.TO_MICRO), - Weight: sdk.NewInt(100), - }, - } - - pool, err := spottypes.NewPool(1, poolAccountAddr, poolParams, poolAssets) - require.NoError(t, err) - keeper.SpotKeeper = mock.NewKeeper(pool) - - // We set some supply - err = keeper.BankKeeper.MintCoins(ctx, types.ModuleName, sdk.NewCoins( - sdk.NewInt64Coin(denoms.NIBI, 1*common.TO_MICRO), - )) - require.NoError(t, err) - - marketCap, err := keeper.GetGovMarketCap(ctx) - require.NoError(t, err) - - require.Equal(t, sdk.NewInt(2*common.TO_MICRO), marketCap) // 1 * 10^6 * 2 (price of gov token) -} - -func TestKeeper_GetLiquidityRatio_AndBands(t *testing.T) { - nibiruApp, ctx := testapp.NewNibiruTestAppAndContext() - keeper := nibiruApp.StablecoinKeeper - - poolAccountAddr := testutil.AccAddress() - poolParams := spottypes.PoolParams{ - SwapFee: sdk.NewDecWithPrec(3, 2), - ExitFee: sdk.NewDecWithPrec(3, 2), - PoolType: spottypes.PoolType_BALANCER, - } - poolAssets := []spottypes.PoolAsset{ - { - Token: sdk.NewInt64Coin(denoms.NIBI, 2*common.TO_MICRO), - Weight: sdk.NewInt(100), - }, - { - Token: sdk.NewInt64Coin(denoms.NUSD, 1*common.TO_MICRO), - Weight: sdk.NewInt(100), - }, - } - - pool, err := spottypes.NewPool(1, poolAccountAddr, poolParams, poolAssets) - require.NoError(t, err) - keeper.SpotKeeper = mock.NewKeeper(pool) - - // We set some supply - err = keeper.BankKeeper.MintCoins(ctx, types.ModuleName, sdk.NewCoins( - sdk.NewInt64Coin(denoms.NIBI, 1*common.TO_MICRO), - )) - require.NoError(t, err) - - err = keeper.BankKeeper.MintCoins(ctx, types.ModuleName, sdk.NewCoins( - sdk.NewInt64Coin(denoms.NUSD, 1*common.TO_MICRO), - )) - require.NoError(t, err) - - liquidityRatio, err := keeper.GetLiquidityRatio(ctx) - require.NoError(t, err) - - require.Equal(t, sdk.MustNewDecFromStr("2"), liquidityRatio) // 2 * 1 * 10^6 / Stable 1 * 10^6 - - lowBand, upBand, err := keeper.GetLiquidityRatioBands(ctx) - require.NoError(t, err) - - require.Equal(t, sdk.MustNewDecFromStr("1.998"), lowBand) - require.Equal(t, sdk.MustNewDecFromStr("2.002"), upBand) -} diff --git a/x/stablecoin/mock/dex_keeper.go b/x/stablecoin/mock/dex_keeper.go deleted file mode 100644 index 9f348b35c..000000000 --- a/x/stablecoin/mock/dex_keeper.go +++ /dev/null @@ -1,25 +0,0 @@ -package mock - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/NibiruChain/nibiru/x/spot/types" -) - -type Keeper struct { - pool types.Pool -} - -func NewKeeper(pool types.Pool) Keeper { - return Keeper{ - pool: pool, - } -} - -func (k Keeper) FetchPoolFromPair(ctx sdk.Context, denomA string, denomB string) (pool types.Pool, err error) { - return k.pool, nil -} - -func (k Keeper) FetchPool(ctx sdk.Context, poolId uint64) (pool types.Pool, err error) { - return k.pool, nil -} diff --git a/x/stablecoin/module.go b/x/stablecoin/module.go deleted file mode 100644 index 394e5269b..000000000 --- a/x/stablecoin/module.go +++ /dev/null @@ -1,167 +0,0 @@ -package stablecoin - -import ( - "context" - "encoding/json" - "fmt" - - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/spf13/cobra" - - abci "github.com/cometbft/cometbft/abci/types" - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - - "github.com/NibiruChain/nibiru/x/stablecoin/client/cli" - "github.com/NibiruChain/nibiru/x/stablecoin/keeper" - "github.com/NibiruChain/nibiru/x/stablecoin/types" -) - -// type check to ensure the interface is properly implemented -var ( - _ module.AppModule = AppModule{} - _ module.AppModuleBasic = AppModuleBasic{} -) - -// ---------------------------------------------------------------------------- -// AppModuleBasic -// ---------------------------------------------------------------------------- - -type AppModuleBasic struct { - binaryCodec codec.BinaryCodec -} - -func NewAppModuleBasic(binaryCodec codec.BinaryCodec) AppModuleBasic { - return AppModuleBasic{binaryCodec: binaryCodec} -} - -func (AppModuleBasic) Name() string { - return types.ModuleName -} - -// RegisterInterfaces registers interfaces and implementations of the stablecoin module. -func (AppModuleBasic) RegisterInterfaces(interfaceRegistry codectypes.InterfaceRegistry) { - types.RegisterInterfaces(interfaceRegistry) -} - -func (AppModuleBasic) RegisterLegacyAminoCodec(aminoCodec *codec.LegacyAmino) { - types.RegisterLegacyAminoCodec(aminoCodec) -} - -// DefaultGenesis returns default genesis state as raw bytes for the erc20 -// module. -func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { - return cdc.MustMarshalJSON(types.DefaultGenesis()) -} - -// ValidateGenesis performs genesis state validation for the capability module. -func (AppModuleBasic) ValidateGenesis( - cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage, -) error { - var genState types.GenesisState - if err := cdc.UnmarshalJSON(bz, &genState); err != nil { - return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) - } - return genState.Validate() -} - -// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. -func (AppModuleBasic) RegisterGRPCGatewayRoutes( - clientCtx client.Context, mux *runtime.ServeMux, -) { - if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { - panic(err) - } -} - -// GetTxCmd returns the capability module's root tx command. -func (a AppModuleBasic) GetTxCmd() *cobra.Command { - return cli.GetTxCmd() -} - -// GetQueryCmd returns the capability module's root query command. -func (AppModuleBasic) GetQueryCmd() *cobra.Command { - return cli.GetQueryCmd() -} - -// ---------------------------------------------------------------------------- -// AppModule -// ---------------------------------------------------------------------------- - -// AppModule implements the AppModule interface for the module. -type AppModule struct { - AppModuleBasic - - keeper keeper.Keeper - ak types.AccountKeeper - bk types.BankKeeper - pk types.OracleKeeper -} - -func NewAppModule( - cdc codec.Codec, - keeper keeper.Keeper, - ak types.AccountKeeper, - bk types.BankKeeper, - pk types.OracleKeeper, -) AppModule { - return AppModule{ - AppModuleBasic: NewAppModuleBasic(cdc), - keeper: keeper, - ak: ak, - bk: bk, - pk: pk, - } -} - -// Name returns the capability module's name. -func (am AppModule) Name() string { - return am.AppModuleBasic.Name() -} - -// RegisterServices registers a GRPC query service to respond to the -// module-specific GRPC queries. -func (am AppModule) RegisterServices(cfg module.Configurator) { - types.RegisterQueryServer(cfg.QueryServer(), am.keeper) - types.RegisterMsgServer(cfg.MsgServer(), am.keeper) -} - -// RegisterInvariants registers the capability module's invariants. -func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} - -// InitGenesis performs the capability module's genesis initialization It returns -// no validator updates. -func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { - var genState types.GenesisState - // Initialize global index to index in genesis state - cdc.MustUnmarshalJSON(gs, &genState) - - InitGenesis(ctx, am.keeper, genState) - - // See https://github.com/cosmos/cosmos-sdk/issues/5569 on why we do this. - am.ak.GetModuleAccount(ctx, types.StableEFModuleAccount) - - return []abci.ValidatorUpdate{} -} - -// ExportGenesis returns the capability module's exported genesis state as raw JSON bytes. -func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { - genState := ExportGenesis(ctx, am.keeper) - return cdc.MustMarshalJSON(genState) -} - -// ConsensusVersion implements ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return 2 } - -// BeginBlock executes all ABCI BeginBlock logic respective to the capability module. -func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} - -// EndBlock executes all ABCI EndBlock logic respective to the capability module. It -// returns no validator updates. -func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { - EndBlocker(ctx, am.keeper) - return []abci.ValidatorUpdate{} -} diff --git a/x/stablecoin/module_simulation.go b/x/stablecoin/module_simulation.go deleted file mode 100644 index 999b91544..000000000 --- a/x/stablecoin/module_simulation.go +++ /dev/null @@ -1,56 +0,0 @@ -package stablecoin - -import ( - "math/rand" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/cosmos/cosmos-sdk/x/simulation" - - scsim "github.com/NibiruChain/nibiru/x/stablecoin/simulation" - "github.com/NibiruChain/nibiru/x/stablecoin/types" -) - -const ( - defaultWeightMsgMintStable int = 100 -) - -// GenerateGenesisState creates a randomized GenState of the module -func (AppModule) GenerateGenesisState(simState *module.SimulationState) { - accs := make([]string, len(simState.Accounts)) - for i, acc := range simState.Accounts { - accs[i] = acc.Address.String() - } - scGenesis := types.GenesisState{} - simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&scGenesis) -} - -// ProposalContents doesn't return any content functions for governance proposals -func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalMsg { - return nil -} - -// RegisterStoreDecoder registers a decoder -func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {} - -// WeightedOperations returns the all the gov module operations with their respective weights. -func (am AppModule) WeightedOperations( - simState module.SimulationState, -) []simtypes.WeightedOperation { - operations := make([]simtypes.WeightedOperation, 0) - - opWeightMsgMintStable := "op_weight_msg_mint_sc" - var weightMsgMintStable int - simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgMintStable, &weightMsgMintStable, nil, - func(_ *rand.Rand) { - weightMsgMintStable = defaultWeightMsgMintStable - }, - ) - operations = append(operations, simulation.NewWeightedOperation( - weightMsgMintStable, - scsim.SimulateMsgMintStable(am.keeper, am.ak, am.bk), - )) - - return operations -} diff --git a/x/stablecoin/simulation/msg.go b/x/stablecoin/simulation/msg.go deleted file mode 100644 index 0cb5b5a87..000000000 --- a/x/stablecoin/simulation/msg.go +++ /dev/null @@ -1,39 +0,0 @@ -package simulation - -import ( - "math/rand" - - "github.com/cosmos/cosmos-sdk/baseapp" - sdk "github.com/cosmos/cosmos-sdk/types" - simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - - "github.com/NibiruChain/nibiru/x/common/denoms" - "github.com/NibiruChain/nibiru/x/stablecoin/keeper" - "github.com/NibiruChain/nibiru/x/stablecoin/types" -) - -func SimulateMsgMintStable( - k keeper.Keeper, - ak types.AccountKeeper, - bk types.BankKeeper, -) simtypes.Operation { - return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, - accs []simtypes.Account, chainID string, - ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { - simAcc, _ := simtypes.RandomAcc(r, accs) - // How much stable should get minted? - simStable := sdk.NewCoin(denoms.NUSD, sdk.NewInt(100)) - msg := &types.MsgMintStable{ - Creator: simAcc.Address.String(), - Stable: simStable, - } - - // TODO: Implement the actual MintStable simulation. - simOpMsg := simtypes.NoOpMsg( - types.ModuleName, msg.Type(), "SimulateMintStable not implemented", - ) - var futureOp []simtypes.FutureOperation = nil - return simOpMsg, futureOp, nil - } -} diff --git a/x/stablecoin/simulation/sim.go b/x/stablecoin/simulation/sim.go deleted file mode 100644 index 92c437c0d..000000000 --- a/x/stablecoin/simulation/sim.go +++ /dev/null @@ -1,15 +0,0 @@ -package simulation - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - simtypes "github.com/cosmos/cosmos-sdk/types/simulation" -) - -// FindAccount find a specific address from an account list -func FindAccount(accs []simtypes.Account, address string) (simtypes.Account, bool) { - creator, err := sdk.AccAddressFromBech32(address) - if err != nil { - panic(err) - } - return simtypes.FindAccount(accs, creator) -} diff --git a/x/stablecoin/types/codec.go b/x/stablecoin/types/codec.go deleted file mode 100644 index 79939a20f..000000000 --- a/x/stablecoin/types/codec.go +++ /dev/null @@ -1,24 +0,0 @@ -package types - -import ( - "github.com/cosmos/cosmos-sdk/codec" - cdctypes "github.com/cosmos/cosmos-sdk/codec/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/msgservice" -) - -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(&MsgMintStable{}, "stablecoin/MintStable", nil) - cdc.RegisterConcrete(&MsgBurnStable{}, "stablecoin/BurnStable", nil) -} - -func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { - registry.RegisterImplementations((*sdk.Msg)(nil), - &MsgMintStable{}, - &MsgBurnStable{}, - ) - - msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) -} - -var ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry()) diff --git a/x/stablecoin/types/errors.go b/x/stablecoin/types/errors.go deleted file mode 100644 index 401fc88e1..000000000 --- a/x/stablecoin/types/errors.go +++ /dev/null @@ -1,14 +0,0 @@ -package types - -// DONTCOVER - -import ( - sdkerrors "cosmossdk.io/errors" -) - -// x/stablecoin module sentinel errors -var ( - NoCoinFound = sdkerrors.Register(ModuleName, 1, "No coin found") - NotEnoughBalance = sdkerrors.Register(ModuleName, 2, "Not enough balance") - NoValidCollateralRatio = sdkerrors.Register(ModuleName, 3, "No valid collateral ratio, waiting for new prices") -) diff --git a/x/stablecoin/types/events.pb.go b/x/stablecoin/types/events.pb.go deleted file mode 100644 index c1304ccf5..000000000 --- a/x/stablecoin/types/events.pb.go +++ /dev/null @@ -1,1749 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: nibiru/stablecoin/v1/events.proto - -package types - -import ( - fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - types "github.com/cosmos/cosmos-sdk/types" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type EventTransfer struct { - Coin types.Coin `protobuf:"bytes,1,opt,name=coin,proto3" json:"coin"` - From string `protobuf:"bytes,2,opt,name=from,proto3" json:"from,omitempty"` - To string `protobuf:"bytes,3,opt,name=to,proto3" json:"to,omitempty"` -} - -func (m *EventTransfer) Reset() { *m = EventTransfer{} } -func (m *EventTransfer) String() string { return proto.CompactTextString(m) } -func (*EventTransfer) ProtoMessage() {} -func (*EventTransfer) Descriptor() ([]byte, []int) { - return fileDescriptor_10d156cd0ca9fb9a, []int{0} -} -func (m *EventTransfer) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *EventTransfer) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_EventTransfer.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *EventTransfer) XXX_Merge(src proto.Message) { - xxx_messageInfo_EventTransfer.Merge(m, src) -} -func (m *EventTransfer) XXX_Size() int { - return m.Size() -} -func (m *EventTransfer) XXX_DiscardUnknown() { - xxx_messageInfo_EventTransfer.DiscardUnknown(m) -} - -var xxx_messageInfo_EventTransfer proto.InternalMessageInfo - -func (m *EventTransfer) GetCoin() types.Coin { - if m != nil { - return m.Coin - } - return types.Coin{} -} - -func (m *EventTransfer) GetFrom() string { - if m != nil { - return m.From - } - return "" -} - -func (m *EventTransfer) GetTo() string { - if m != nil { - return m.To - } - return "" -} - -type EventMintStable struct { - Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount"` -} - -func (m *EventMintStable) Reset() { *m = EventMintStable{} } -func (m *EventMintStable) String() string { return proto.CompactTextString(m) } -func (*EventMintStable) ProtoMessage() {} -func (*EventMintStable) Descriptor() ([]byte, []int) { - return fileDescriptor_10d156cd0ca9fb9a, []int{1} -} -func (m *EventMintStable) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *EventMintStable) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_EventMintStable.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *EventMintStable) XXX_Merge(src proto.Message) { - xxx_messageInfo_EventMintStable.Merge(m, src) -} -func (m *EventMintStable) XXX_Size() int { - return m.Size() -} -func (m *EventMintStable) XXX_DiscardUnknown() { - xxx_messageInfo_EventMintStable.DiscardUnknown(m) -} - -var xxx_messageInfo_EventMintStable proto.InternalMessageInfo - -type EventBurnStable struct { - Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount"` -} - -func (m *EventBurnStable) Reset() { *m = EventBurnStable{} } -func (m *EventBurnStable) String() string { return proto.CompactTextString(m) } -func (*EventBurnStable) ProtoMessage() {} -func (*EventBurnStable) Descriptor() ([]byte, []int) { - return fileDescriptor_10d156cd0ca9fb9a, []int{2} -} -func (m *EventBurnStable) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *EventBurnStable) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_EventBurnStable.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *EventBurnStable) XXX_Merge(src proto.Message) { - xxx_messageInfo_EventBurnStable.Merge(m, src) -} -func (m *EventBurnStable) XXX_Size() int { - return m.Size() -} -func (m *EventBurnStable) XXX_DiscardUnknown() { - xxx_messageInfo_EventBurnStable.DiscardUnknown(m) -} - -var xxx_messageInfo_EventBurnStable proto.InternalMessageInfo - -type EventMintNIBI struct { - Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount"` -} - -func (m *EventMintNIBI) Reset() { *m = EventMintNIBI{} } -func (m *EventMintNIBI) String() string { return proto.CompactTextString(m) } -func (*EventMintNIBI) ProtoMessage() {} -func (*EventMintNIBI) Descriptor() ([]byte, []int) { - return fileDescriptor_10d156cd0ca9fb9a, []int{3} -} -func (m *EventMintNIBI) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *EventMintNIBI) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_EventMintNIBI.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *EventMintNIBI) XXX_Merge(src proto.Message) { - xxx_messageInfo_EventMintNIBI.Merge(m, src) -} -func (m *EventMintNIBI) XXX_Size() int { - return m.Size() -} -func (m *EventMintNIBI) XXX_DiscardUnknown() { - xxx_messageInfo_EventMintNIBI.DiscardUnknown(m) -} - -var xxx_messageInfo_EventMintNIBI proto.InternalMessageInfo - -type EventBurnNIBI struct { - Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount"` -} - -func (m *EventBurnNIBI) Reset() { *m = EventBurnNIBI{} } -func (m *EventBurnNIBI) String() string { return proto.CompactTextString(m) } -func (*EventBurnNIBI) ProtoMessage() {} -func (*EventBurnNIBI) Descriptor() ([]byte, []int) { - return fileDescriptor_10d156cd0ca9fb9a, []int{4} -} -func (m *EventBurnNIBI) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *EventBurnNIBI) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_EventBurnNIBI.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *EventBurnNIBI) XXX_Merge(src proto.Message) { - xxx_messageInfo_EventBurnNIBI.Merge(m, src) -} -func (m *EventBurnNIBI) XXX_Size() int { - return m.Size() -} -func (m *EventBurnNIBI) XXX_DiscardUnknown() { - xxx_messageInfo_EventBurnNIBI.DiscardUnknown(m) -} - -var xxx_messageInfo_EventBurnNIBI proto.InternalMessageInfo - -type EventRecollateralize struct { - Caller string `protobuf:"bytes,1,opt,name=caller,proto3" json:"caller,omitempty"` - InCoin types.Coin `protobuf:"bytes,2,opt,name=in_coin,json=inCoin,proto3" json:"in_coin"` - OutCoin types.Coin `protobuf:"bytes,3,opt,name=out_coin,json=outCoin,proto3" json:"out_coin"` - CollRatio github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=coll_ratio,json=collRatio,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"coll_ratio"` -} - -func (m *EventRecollateralize) Reset() { *m = EventRecollateralize{} } -func (m *EventRecollateralize) String() string { return proto.CompactTextString(m) } -func (*EventRecollateralize) ProtoMessage() {} -func (*EventRecollateralize) Descriptor() ([]byte, []int) { - return fileDescriptor_10d156cd0ca9fb9a, []int{5} -} -func (m *EventRecollateralize) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *EventRecollateralize) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_EventRecollateralize.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *EventRecollateralize) XXX_Merge(src proto.Message) { - xxx_messageInfo_EventRecollateralize.Merge(m, src) -} -func (m *EventRecollateralize) XXX_Size() int { - return m.Size() -} -func (m *EventRecollateralize) XXX_DiscardUnknown() { - xxx_messageInfo_EventRecollateralize.DiscardUnknown(m) -} - -var xxx_messageInfo_EventRecollateralize proto.InternalMessageInfo - -func (m *EventRecollateralize) GetCaller() string { - if m != nil { - return m.Caller - } - return "" -} - -func (m *EventRecollateralize) GetInCoin() types.Coin { - if m != nil { - return m.InCoin - } - return types.Coin{} -} - -func (m *EventRecollateralize) GetOutCoin() types.Coin { - if m != nil { - return m.OutCoin - } - return types.Coin{} -} - -type EventBuyback struct { - Caller string `protobuf:"bytes,1,opt,name=caller,proto3" json:"caller,omitempty"` - InCoin types.Coin `protobuf:"bytes,2,opt,name=in_coin,json=inCoin,proto3" json:"in_coin"` - OutCoin types.Coin `protobuf:"bytes,3,opt,name=out_coin,json=outCoin,proto3" json:"out_coin"` - CollRatio github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=coll_ratio,json=collRatio,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"coll_ratio"` -} - -func (m *EventBuyback) Reset() { *m = EventBuyback{} } -func (m *EventBuyback) String() string { return proto.CompactTextString(m) } -func (*EventBuyback) ProtoMessage() {} -func (*EventBuyback) Descriptor() ([]byte, []int) { - return fileDescriptor_10d156cd0ca9fb9a, []int{6} -} -func (m *EventBuyback) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *EventBuyback) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_EventBuyback.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *EventBuyback) XXX_Merge(src proto.Message) { - xxx_messageInfo_EventBuyback.Merge(m, src) -} -func (m *EventBuyback) XXX_Size() int { - return m.Size() -} -func (m *EventBuyback) XXX_DiscardUnknown() { - xxx_messageInfo_EventBuyback.DiscardUnknown(m) -} - -var xxx_messageInfo_EventBuyback proto.InternalMessageInfo - -func (m *EventBuyback) GetCaller() string { - if m != nil { - return m.Caller - } - return "" -} - -func (m *EventBuyback) GetInCoin() types.Coin { - if m != nil { - return m.InCoin - } - return types.Coin{} -} - -func (m *EventBuyback) GetOutCoin() types.Coin { - if m != nil { - return m.OutCoin - } - return types.Coin{} -} - -func init() { - proto.RegisterType((*EventTransfer)(nil), "nibiru.stablecoin.v1.EventTransfer") - proto.RegisterType((*EventMintStable)(nil), "nibiru.stablecoin.v1.EventMintStable") - proto.RegisterType((*EventBurnStable)(nil), "nibiru.stablecoin.v1.EventBurnStable") - proto.RegisterType((*EventMintNIBI)(nil), "nibiru.stablecoin.v1.EventMintNIBI") - proto.RegisterType((*EventBurnNIBI)(nil), "nibiru.stablecoin.v1.EventBurnNIBI") - proto.RegisterType((*EventRecollateralize)(nil), "nibiru.stablecoin.v1.EventRecollateralize") - proto.RegisterType((*EventBuyback)(nil), "nibiru.stablecoin.v1.EventBuyback") -} - -func init() { proto.RegisterFile("nibiru/stablecoin/v1/events.proto", fileDescriptor_10d156cd0ca9fb9a) } - -var fileDescriptor_10d156cd0ca9fb9a = []byte{ - // 434 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x94, 0x3f, 0x6f, 0xd4, 0x30, - 0x18, 0xc6, 0xe3, 0x34, 0x4a, 0x39, 0xf3, 0x4f, 0xb2, 0x4e, 0x28, 0x74, 0x48, 0xcb, 0x0d, 0xa8, - 0x0b, 0x36, 0xa1, 0x0b, 0x62, 0x4c, 0x01, 0xe9, 0x90, 0xda, 0x21, 0x20, 0x21, 0x58, 0x2a, 0x27, - 0xb8, 0x77, 0x56, 0x13, 0xbf, 0x95, 0xed, 0x44, 0x94, 0x4f, 0xc1, 0xc7, 0xea, 0xd8, 0x11, 0x31, - 0x9c, 0xd0, 0xdd, 0xc8, 0xc8, 0x17, 0x40, 0x76, 0x22, 0xb8, 0xf1, 0x90, 0x6e, 0x62, 0x8a, 0x1d, - 0x3f, 0xcf, 0xef, 0x7d, 0xec, 0x57, 0x7a, 0xf1, 0x23, 0x25, 0x4b, 0xa9, 0x5b, 0x66, 0x2c, 0x2f, - 0x6b, 0x51, 0x81, 0x54, 0xac, 0xcb, 0x98, 0xe8, 0x84, 0xb2, 0x86, 0x5e, 0x6a, 0xb0, 0x40, 0xc6, - 0xbd, 0x84, 0xfe, 0x95, 0xd0, 0x2e, 0xdb, 0x1b, 0xcf, 0x60, 0x06, 0x5e, 0xc0, 0xdc, 0xaa, 0xd7, - 0xee, 0xa5, 0x15, 0x98, 0x06, 0x0c, 0x2b, 0xb9, 0x11, 0xac, 0xcb, 0x4a, 0x61, 0x79, 0xc6, 0xbc, - 0xc5, 0x9f, 0x4f, 0xe6, 0xf8, 0xee, 0x2b, 0xc7, 0x7e, 0xa7, 0xb9, 0x32, 0xe7, 0x42, 0x93, 0x23, - 0x1c, 0xb9, 0xe3, 0x04, 0x1d, 0xa0, 0xc3, 0xdb, 0xcf, 0x1e, 0xd2, 0xde, 0x4f, 0x9d, 0x9f, 0x0e, - 0x7e, 0x7a, 0x0c, 0x52, 0xe5, 0xd1, 0xf5, 0x62, 0x3f, 0x28, 0xbc, 0x98, 0x10, 0x1c, 0x9d, 0x6b, - 0x68, 0x92, 0xf0, 0x00, 0x1d, 0x8e, 0x0a, 0xbf, 0x26, 0xf7, 0x70, 0x68, 0x21, 0xd9, 0xf1, 0x7f, - 0x42, 0x0b, 0x93, 0x0f, 0xf8, 0xbe, 0xaf, 0x74, 0x22, 0x95, 0x7d, 0xeb, 0x93, 0x93, 0xd7, 0x38, - 0xe6, 0x0d, 0xb4, 0xca, 0xfa, 0x6a, 0xa3, 0x9c, 0x3a, 0xe4, 0xf7, 0xc5, 0xfe, 0xe3, 0x99, 0xb4, - 0xf3, 0xb6, 0xa4, 0x15, 0x34, 0x6c, 0xc8, 0xdf, 0x7f, 0x9e, 0x98, 0x4f, 0x17, 0xcc, 0x5e, 0x5d, - 0x0a, 0x43, 0xa7, 0xca, 0x16, 0x83, 0xfb, 0x0f, 0x3a, 0x6f, 0xb5, 0xda, 0x32, 0xfa, 0xfd, 0xf0, - 0x3e, 0x2e, 0xf5, 0xe9, 0x34, 0x9f, 0x6e, 0x1d, 0xec, 0x32, 0x6f, 0x15, 0xfc, 0x0b, 0xe1, 0xb1, - 0x27, 0x17, 0xa2, 0x82, 0xba, 0xe6, 0x56, 0x68, 0x5e, 0xcb, 0x2f, 0x82, 0x3c, 0xc0, 0x71, 0xc5, - 0xeb, 0x5a, 0xe8, 0xbe, 0x40, 0x31, 0xec, 0xc8, 0x73, 0xbc, 0x2b, 0xd5, 0x99, 0x6f, 0x7a, 0xb8, - 0x59, 0xd3, 0x63, 0xa9, 0xdc, 0x8e, 0xbc, 0xc0, 0xb7, 0xa0, 0xb5, 0xbd, 0x75, 0x67, 0x33, 0xeb, - 0x2e, 0xb4, 0xd6, 0x7b, 0x4f, 0x30, 0x76, 0xf1, 0xce, 0x34, 0xb7, 0x12, 0x92, 0xe8, 0x9f, 0xaf, - 0xfc, 0x52, 0x54, 0xc5, 0xc8, 0x11, 0x0a, 0x07, 0x98, 0xfc, 0x44, 0xf8, 0xce, 0xf0, 0x9e, 0x57, - 0x25, 0xaf, 0x2e, 0xfe, 0xeb, 0xdb, 0xe6, 0x6f, 0xae, 0x97, 0x29, 0xba, 0x59, 0xa6, 0xe8, 0xc7, - 0x32, 0x45, 0x5f, 0x57, 0x69, 0x70, 0xb3, 0x4a, 0x83, 0x6f, 0xab, 0x34, 0xf8, 0xf8, 0x74, 0x0d, - 0x76, 0xea, 0xc7, 0xc4, 0xf1, 0x9c, 0x4b, 0xc5, 0x86, 0xa9, 0xf2, 0x79, 0x7d, 0xae, 0x78, 0x74, - 0x19, 0xfb, 0x41, 0x70, 0xf4, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x5c, 0x6f, 0x32, 0xc4, 0x79, 0x04, - 0x00, 0x00, -} - -func (m *EventTransfer) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *EventTransfer) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *EventTransfer) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.To) > 0 { - i -= len(m.To) - copy(dAtA[i:], m.To) - i = encodeVarintEvents(dAtA, i, uint64(len(m.To))) - i-- - dAtA[i] = 0x1a - } - if len(m.From) > 0 { - i -= len(m.From) - copy(dAtA[i:], m.From) - i = encodeVarintEvents(dAtA, i, uint64(len(m.From))) - i-- - dAtA[i] = 0x12 - } - { - size, err := m.Coin.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintEvents(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *EventMintStable) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *EventMintStable) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *EventMintStable) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.Amount.Size() - i -= size - if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintEvents(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *EventBurnStable) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *EventBurnStable) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *EventBurnStable) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.Amount.Size() - i -= size - if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintEvents(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *EventMintNIBI) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *EventMintNIBI) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *EventMintNIBI) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.Amount.Size() - i -= size - if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintEvents(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *EventBurnNIBI) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *EventBurnNIBI) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *EventBurnNIBI) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.Amount.Size() - i -= size - if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintEvents(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *EventRecollateralize) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *EventRecollateralize) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *EventRecollateralize) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.CollRatio.Size() - i -= size - if _, err := m.CollRatio.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintEvents(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - { - size, err := m.OutCoin.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintEvents(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - { - size, err := m.InCoin.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintEvents(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.Caller) > 0 { - i -= len(m.Caller) - copy(dAtA[i:], m.Caller) - i = encodeVarintEvents(dAtA, i, uint64(len(m.Caller))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *EventBuyback) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *EventBuyback) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *EventBuyback) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.CollRatio.Size() - i -= size - if _, err := m.CollRatio.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintEvents(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - { - size, err := m.OutCoin.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintEvents(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - { - size, err := m.InCoin.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintEvents(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.Caller) > 0 { - i -= len(m.Caller) - copy(dAtA[i:], m.Caller) - i = encodeVarintEvents(dAtA, i, uint64(len(m.Caller))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintEvents(dAtA []byte, offset int, v uint64) int { - offset -= sovEvents(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *EventTransfer) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Coin.Size() - n += 1 + l + sovEvents(uint64(l)) - l = len(m.From) - if l > 0 { - n += 1 + l + sovEvents(uint64(l)) - } - l = len(m.To) - if l > 0 { - n += 1 + l + sovEvents(uint64(l)) - } - return n -} - -func (m *EventMintStable) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Amount.Size() - n += 1 + l + sovEvents(uint64(l)) - return n -} - -func (m *EventBurnStable) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Amount.Size() - n += 1 + l + sovEvents(uint64(l)) - return n -} - -func (m *EventMintNIBI) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Amount.Size() - n += 1 + l + sovEvents(uint64(l)) - return n -} - -func (m *EventBurnNIBI) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Amount.Size() - n += 1 + l + sovEvents(uint64(l)) - return n -} - -func (m *EventRecollateralize) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Caller) - if l > 0 { - n += 1 + l + sovEvents(uint64(l)) - } - l = m.InCoin.Size() - n += 1 + l + sovEvents(uint64(l)) - l = m.OutCoin.Size() - n += 1 + l + sovEvents(uint64(l)) - l = m.CollRatio.Size() - n += 1 + l + sovEvents(uint64(l)) - return n -} - -func (m *EventBuyback) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Caller) - if l > 0 { - n += 1 + l + sovEvents(uint64(l)) - } - l = m.InCoin.Size() - n += 1 + l + sovEvents(uint64(l)) - l = m.OutCoin.Size() - n += 1 + l + sovEvents(uint64(l)) - l = m.CollRatio.Size() - n += 1 + l + sovEvents(uint64(l)) - return n -} - -func sovEvents(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozEvents(x uint64) (n int) { - return sovEvents(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *EventTransfer) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: EventTransfer: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: EventTransfer: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Coin", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthEvents - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthEvents - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Coin.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field From", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthEvents - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEvents - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.From = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field To", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthEvents - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEvents - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.To = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipEvents(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthEvents - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *EventMintStable) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: EventMintStable: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: EventMintStable: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthEvents - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEvents - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipEvents(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthEvents - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *EventBurnStable) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: EventBurnStable: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: EventBurnStable: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthEvents - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEvents - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipEvents(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthEvents - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *EventMintNIBI) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: EventMintNIBI: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: EventMintNIBI: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthEvents - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEvents - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipEvents(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthEvents - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *EventBurnNIBI) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: EventBurnNIBI: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: EventBurnNIBI: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthEvents - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEvents - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipEvents(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthEvents - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *EventRecollateralize) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: EventRecollateralize: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: EventRecollateralize: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Caller", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthEvents - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEvents - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Caller = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field InCoin", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthEvents - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthEvents - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.InCoin.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OutCoin", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthEvents - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthEvents - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.OutCoin.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CollRatio", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthEvents - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEvents - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.CollRatio.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipEvents(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthEvents - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *EventBuyback) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: EventBuyback: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: EventBuyback: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Caller", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthEvents - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEvents - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Caller = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field InCoin", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthEvents - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthEvents - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.InCoin.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OutCoin", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthEvents - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthEvents - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.OutCoin.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CollRatio", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthEvents - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEvents - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.CollRatio.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipEvents(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthEvents - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipEvents(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowEvents - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowEvents - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowEvents - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthEvents - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupEvents - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthEvents - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthEvents = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowEvents = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupEvents = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/stablecoin/types/expected_keepers.go b/x/stablecoin/types/expected_keepers.go deleted file mode 100644 index dc7d2c1f5..000000000 --- a/x/stablecoin/types/expected_keepers.go +++ /dev/null @@ -1,46 +0,0 @@ -package types // noalias - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - - "github.com/NibiruChain/nibiru/x/common/asset" - spottypes "github.com/NibiruChain/nibiru/x/spot/types" -) - -// AccountKeeper defines the expected account keeper used for simulations (noalias) -type AccountKeeper interface { - GetModuleAddress(name string) sdk.AccAddress - GetModuleAccount(ctx sdk.Context, moduleName string) authtypes.ModuleAccountI - GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI - SetAccount(sdk.Context, authtypes.AccountI) -} - -// BankKeeper defines the expected interface needed to retrieve account balances. -type BankKeeper interface { - SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins - MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error - SendCoinsFromAccountToModule( - ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, - amt sdk.Coins, - ) error - SendCoinsFromModuleToAccount( - ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, - amt sdk.Coins, - ) error - BurnCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error - GetSupply(ctx sdk.Context, denom string) sdk.Coin - GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin - GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins -} - -type OracleKeeper interface { - GetExchangeRate(ctx sdk.Context, pair asset.Pair) (sdk.Dec, error) - GetExchangeRateTwap(ctx sdk.Context, pair asset.Pair) (sdk.Dec, error) -} - -type SpotKeeper interface { - FetchPoolFromPair(ctx sdk.Context, denomA string, denomB string, - ) (pool spottypes.Pool, err error) - FetchPool(ctx sdk.Context, poolId uint64) (pool spottypes.Pool, err error) -} diff --git a/x/stablecoin/types/expected_keepers_test.go b/x/stablecoin/types/expected_keepers_test.go deleted file mode 100644 index 4898cc178..000000000 --- a/x/stablecoin/types/expected_keepers_test.go +++ /dev/null @@ -1,54 +0,0 @@ -package types_test - -import ( - "reflect" - "testing" - - "github.com/stretchr/testify/assert" - - "github.com/NibiruChain/nibiru/x/common/testutil/testapp" - sctypes "github.com/NibiruChain/nibiru/x/stablecoin/types" -) - -// Verifies that the expected keepers (e.g. 'KeeperName') in x/stablecoin are -// implemented on the corresponding 'NibiruApp.KeeperName' field -func TestExpectedKeepers(t *testing.T) { - type TestCase struct { - name string - expectedKeeper interface{} - appKeeper interface{} - } - - nibiruApp, _ := testapp.NewNibiruTestAppAndContext() - testCases := []TestCase{ - { - name: "OracleKeeper from x/oracle", - expectedKeeper: (*sctypes.OracleKeeper)(nil), - appKeeper: nibiruApp.OracleKeeper, - }, - { - name: "bankKeeper from the cosmos-sdk", - expectedKeeper: (*sctypes.BankKeeper)(nil), - appKeeper: nibiruApp.BankKeeper, - }, - { - name: "accountKeeper from the cosmos-sdk", - expectedKeeper: (*sctypes.AccountKeeper)(nil), - appKeeper: nibiruApp.AccountKeeper, - }, - } - - executeTest := func(t *testing.T, testCase TestCase) { - tc := testCase - t.Run(tc.name, func(t *testing.T) { - _interface := reflect.TypeOf(tc.expectedKeeper).Elem() - isImplementingExpectedMethods := reflect. - TypeOf(tc.appKeeper).Implements(_interface) - assert.True(t, isImplementingExpectedMethods) - }) - } - - for _, testCase := range testCases { - executeTest(t, testCase) - } -} diff --git a/x/stablecoin/types/genesis.go b/x/stablecoin/types/genesis.go deleted file mode 100644 index bb41c9ceb..000000000 --- a/x/stablecoin/types/genesis.go +++ /dev/null @@ -1,24 +0,0 @@ -package types - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/NibiruChain/nibiru/x/common/denoms" -) - -// DefaultIndex is the default capability global index -const DefaultIndex uint64 = 1 - -// DefaultGenesis returns the default Capability genesis state -func DefaultGenesis() *GenesisState { - return &GenesisState{ - Params: DefaultParams(), - ModuleAccountBalance: sdk.NewCoin(denoms.USDC, sdk.ZeroInt()), - } -} - -// Validate performs basic genesis state validation returning an error upon any -// failure. -func (gs GenesisState) Validate() error { - return gs.Params.Validate() -} diff --git a/x/stablecoin/types/genesis.pb.go b/x/stablecoin/types/genesis.pb.go deleted file mode 100644 index db29b5597..000000000 --- a/x/stablecoin/types/genesis.pb.go +++ /dev/null @@ -1,383 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: nibiru/stablecoin/v1/genesis.proto - -package types - -import ( - fmt "fmt" - types "github.com/cosmos/cosmos-sdk/types" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// GenesisState defines the stablecoin module's genesis state. -type GenesisState struct { - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` - ModuleAccountBalance types.Coin `protobuf:"bytes,2,opt,name=module_account_balance,json=moduleAccountBalance,proto3" json:"module_account_balance" yaml:"module_account_balance"` -} - -func (m *GenesisState) Reset() { *m = GenesisState{} } -func (m *GenesisState) String() string { return proto.CompactTextString(m) } -func (*GenesisState) ProtoMessage() {} -func (*GenesisState) Descriptor() ([]byte, []int) { - return fileDescriptor_0aa97d97dd3fb3f7, []int{0} -} -func (m *GenesisState) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *GenesisState) XXX_Merge(src proto.Message) { - xxx_messageInfo_GenesisState.Merge(m, src) -} -func (m *GenesisState) XXX_Size() int { - return m.Size() -} -func (m *GenesisState) XXX_DiscardUnknown() { - xxx_messageInfo_GenesisState.DiscardUnknown(m) -} - -var xxx_messageInfo_GenesisState proto.InternalMessageInfo - -func (m *GenesisState) GetParams() Params { - if m != nil { - return m.Params - } - return Params{} -} - -func (m *GenesisState) GetModuleAccountBalance() types.Coin { - if m != nil { - return m.ModuleAccountBalance - } - return types.Coin{} -} - -func init() { - proto.RegisterType((*GenesisState)(nil), "nibiru.stablecoin.v1.GenesisState") -} - -func init() { - proto.RegisterFile("nibiru/stablecoin/v1/genesis.proto", fileDescriptor_0aa97d97dd3fb3f7) -} - -var fileDescriptor_0aa97d97dd3fb3f7 = []byte{ - // 298 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x50, 0xb1, 0x4e, 0xc3, 0x30, - 0x14, 0x8c, 0x11, 0xea, 0x10, 0x98, 0xaa, 0x0a, 0x95, 0x0a, 0x5c, 0x88, 0x84, 0xc4, 0x64, 0x13, - 0xd8, 0xba, 0x91, 0x0e, 0x48, 0x0c, 0x08, 0x95, 0x8d, 0xa5, 0xb2, 0x8d, 0x95, 0x5a, 0x4a, 0xfc, - 0xaa, 0xd8, 0x89, 0xe8, 0x5f, 0xf0, 0x4d, 0x4c, 0x1d, 0x3b, 0x32, 0x55, 0x28, 0xf9, 0x03, 0xbe, - 0x00, 0xc5, 0x8e, 0x04, 0x43, 0xb6, 0xa7, 0x7b, 0xf7, 0xee, 0xdd, 0x5d, 0x18, 0x69, 0xc5, 0x55, - 0x51, 0x52, 0x63, 0x19, 0xcf, 0xa4, 0x00, 0xa5, 0x69, 0x15, 0xd3, 0x54, 0x6a, 0x69, 0x94, 0x21, - 0xeb, 0x02, 0x2c, 0x0c, 0x47, 0x9e, 0x43, 0xfe, 0x38, 0xa4, 0x8a, 0x27, 0x58, 0x80, 0xc9, 0xc1, - 0x50, 0xce, 0x8c, 0xa4, 0x55, 0xcc, 0xa5, 0x65, 0x31, 0x75, 0x4b, 0x77, 0x35, 0x19, 0xa5, 0x90, - 0x82, 0x1b, 0x69, 0x3b, 0x75, 0xe8, 0x65, 0xef, 0xbf, 0x35, 0x2b, 0x58, 0xde, 0xbd, 0x8b, 0x3e, - 0x51, 0x78, 0xfc, 0xe0, 0x0d, 0xbc, 0x58, 0x66, 0xe5, 0x70, 0x16, 0x0e, 0x3c, 0x61, 0x8c, 0x2e, - 0xd0, 0xf5, 0xd1, 0xed, 0x19, 0xe9, 0x33, 0x44, 0x9e, 0x1d, 0x27, 0x39, 0xdc, 0xee, 0xa7, 0xc1, - 0xa2, 0xbb, 0x18, 0x56, 0xe1, 0x49, 0x0e, 0x6f, 0x65, 0x26, 0x97, 0x4c, 0x08, 0x28, 0xb5, 0x5d, - 0x72, 0x96, 0x31, 0x2d, 0xe4, 0xf8, 0xc0, 0x69, 0x9d, 0x12, 0x1f, 0x83, 0xb4, 0x31, 0x48, 0x17, - 0x83, 0xcc, 0x41, 0xe9, 0xe4, 0xaa, 0x15, 0xfa, 0xd9, 0x4f, 0xcf, 0x37, 0x2c, 0xcf, 0x66, 0x51, - 0xbf, 0x4c, 0xb4, 0x18, 0xf9, 0xc5, 0xbd, 0xc7, 0x13, 0x0f, 0x27, 0x8f, 0xdb, 0x1a, 0xa3, 0x5d, - 0x8d, 0xd1, 0x77, 0x8d, 0xd1, 0x47, 0x83, 0x83, 0x5d, 0x83, 0x83, 0xaf, 0x06, 0x07, 0xaf, 0x37, - 0xa9, 0xb2, 0xab, 0x92, 0x13, 0x01, 0x39, 0x7d, 0x72, 0x39, 0xe6, 0x2b, 0xa6, 0x34, 0xed, 0x8a, - 0x79, 0xff, 0x5f, 0x8d, 0xdd, 0xac, 0xa5, 0xe1, 0x03, 0xd7, 0xcb, 0xdd, 0x6f, 0x00, 0x00, 0x00, - 0xff, 0xff, 0xf8, 0x3a, 0xd0, 0x91, 0xac, 0x01, 0x00, 0x00, -} - -func (m *GenesisState) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.ModuleAccountBalance.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { - offset -= sovGenesis(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *GenesisState) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Params.Size() - n += 1 + l + sovGenesis(uint64(l)) - l = m.ModuleAccountBalance.Size() - n += 1 + l + sovGenesis(uint64(l)) - return n -} - -func sovGenesis(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozGenesis(x uint64) (n int) { - return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *GenesisState) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ModuleAccountBalance", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ModuleAccountBalance.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGenesis(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthGenesis - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipGenesis(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowGenesis - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowGenesis - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowGenesis - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthGenesis - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupGenesis - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthGenesis - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/stablecoin/types/genesis_test.go b/x/stablecoin/types/genesis_test.go deleted file mode 100644 index 28e060f33..000000000 --- a/x/stablecoin/types/genesis_test.go +++ /dev/null @@ -1,79 +0,0 @@ -package types_test - -import ( - "testing" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" - - "github.com/NibiruChain/nibiru/x/stablecoin/types" -) - -func TestGenesisState_Validate(t *testing.T) { - defaultFeeRatio := sdk.MustNewDecFromStr("0.002") - defaultFeeRatioEF := sdk.MustNewDecFromStr("0.5") - defaultBonusRateRecoll := sdk.MustNewDecFromStr("0.002") - adjustmentStep := sdk.MustNewDecFromStr("0.0025") - priceLowerBound := sdk.MustNewDecFromStr("0.9999") - priceUpperBound := sdk.MustNewDecFromStr("1.0001") - - testCases := []struct { - description string - genState *types.GenesisState - expectValid bool - }{ - { - description: "default is valid", - genState: types.DefaultGenesis(), - expectValid: true, - }, - { - description: "valid genesis state", - genState: &types.GenesisState{}, - expectValid: true, - }, - { - description: "manually set default params", - genState: &types.GenesisState{ - Params: types.DefaultParams(), - }, - expectValid: true, - }, - { - description: "set non-default, valid collRatio at genesis", - genState: &types.GenesisState{ - Params: types.NewParams( - sdk.MustNewDecFromStr("0.7"), defaultFeeRatio, defaultFeeRatioEF, defaultBonusRateRecoll, "15 min", adjustmentStep, priceLowerBound, priceUpperBound, true), - }, - expectValid: true, - }, - { - description: "set invalid negative collRatio at genesis", - genState: &types.GenesisState{ - Params: types.NewParams( - sdk.MustNewDecFromStr("-0.5"), defaultFeeRatio, defaultFeeRatioEF, defaultBonusRateRecoll, "15 min", adjustmentStep, priceLowerBound, priceUpperBound, true), - }, - expectValid: false, - }, - { - description: "set invalid > max collRatio at genesis", - genState: &types.GenesisState{ - Params: types.NewParams( - sdk.MustNewDecFromStr("1.5"), defaultFeeRatio, defaultFeeRatioEF, defaultBonusRateRecoll, "15 min", adjustmentStep, priceLowerBound, priceUpperBound, true), - }, - expectValid: false, - }, - } - - for _, testCase := range testCases { - tc := testCase - t.Run(tc.description, func(t *testing.T) { - err := tc.genState.Validate() - if tc.expectValid { - require.NoError(t, err) - } else { - require.Error(t, err) - } - }) - } -} diff --git a/x/stablecoin/types/keys.go b/x/stablecoin/types/keys.go deleted file mode 100644 index 08d778208..000000000 --- a/x/stablecoin/types/keys.go +++ /dev/null @@ -1,21 +0,0 @@ -package types - -const ( - // ModuleName defines the module name - ModuleName = "stablecoin" - - // StoreKey defines the primary module store key - StoreKey = ModuleName - - // RouterKey is the message route for slashing - RouterKey = ModuleName - - // QuerierRoute defines the module's query routing key - QuerierRoute = ModuleName - - // MemStoreKey defines the in-memory store key - MemStoreKey = "mem_stablecoin" -) - -// Stable Ecosystem Fund -const StableEFModuleAccount = "stable_ef" diff --git a/x/stablecoin/types/messages.go b/x/stablecoin/types/messages.go deleted file mode 100644 index 1ac40303f..000000000 --- a/x/stablecoin/types/messages.go +++ /dev/null @@ -1,165 +0,0 @@ -package types - -import ( - sdkerrors "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/errors" -) - -// ---------------------------------------------------------------- -// MsgMintStable -// ---------------------------------------------------------------- - -var ( - _ sdk.Msg = &MsgMintStable{} - _ sdk.Msg = &MsgBurnStable{} - _ sdk.Msg = &MsgRecollateralize{} - _ sdk.Msg = &MsgBuyback{} -) - -func (msg *MsgMintStable) Route() string { - return RouterKey -} - -func (msg *MsgMintStable) Type() string { - return "mint-stable" -} - -func (msg *MsgMintStable) GetSigners() []sdk.AccAddress { - creator, err := sdk.AccAddressFromBech32(msg.Creator) - if err != nil { - panic(err) - } - return []sdk.AccAddress{creator} -} - -func (msg *MsgMintStable) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(msg) - return sdk.MustSortJSON(bz) -} - -func (msg *MsgMintStable) ValidateBasic() error { - _, err := sdk.AccAddressFromBech32(msg.Creator) - if err != nil { - return sdkerrors.Wrapf(errors.ErrInvalidAddress, "invalid creator address (%s)", err) - } - return nil -} - -// ---------------------------------------------------------------- -// MsgBurnStable -// ---------------------------------------------------------------- - -var _ sdk.Msg = &MsgBurnStable{} - -func NewMsgBurn(creator string, coin sdk.Coin) *MsgBurnStable { - return &MsgBurnStable{ - Creator: creator, - Stable: coin, - } -} - -func (msg *MsgBurnStable) GetSigners() []sdk.AccAddress { - creator, err := sdk.AccAddressFromBech32(msg.Creator) - if err != nil { - panic(err) - } - return []sdk.AccAddress{creator} -} - -func (msg *MsgBurnStable) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(msg) - return sdk.MustSortJSON(bz) -} - -func (msg *MsgBurnStable) ValidateBasic() error { - _, err := sdk.AccAddressFromBech32(msg.Creator) - if err != nil { - return sdkerrors.Wrapf(errors.ErrInvalidAddress, "invalid creator address (%s)", err) - } - return nil -} - -// ---------------------------------------------------------------- -// MsgRecollateralize -// ---------------------------------------------------------------- - -var _ sdk.Msg = &MsgRecollateralize{} - -func NewMsgRecollateralize(creator string, coin sdk.Coin) *MsgRecollateralize { - return &MsgRecollateralize{ - Creator: creator, - Coll: coin, - } -} - -func (msg *MsgRecollateralize) Route() string { - return RouterKey -} - -func (msg *MsgRecollateralize) Type() string { - return "recoll" -} - -func (msg *MsgRecollateralize) GetSigners() []sdk.AccAddress { - creator, err := sdk.AccAddressFromBech32(msg.Creator) - if err != nil { - panic(err) - } - return []sdk.AccAddress{creator} -} - -func (msg *MsgRecollateralize) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(msg) - return sdk.MustSortJSON(bz) -} - -func (msg *MsgRecollateralize) ValidateBasic() error { - _, err := sdk.AccAddressFromBech32(msg.Creator) - if err != nil { - return sdkerrors.Wrapf(errors.ErrInvalidAddress, "invalid creator address (%s)", err) - } - return nil -} - -// ---------------------------------------------------------------- -// MsgBuyback -// ---------------------------------------------------------------- - -var _ sdk.Msg = &MsgBuyback{} - -func NewMsgBuyback(creator string, coin sdk.Coin) *MsgBuyback { - return &MsgBuyback{ - Creator: creator, - Gov: coin, - } -} - -func (msg *MsgBuyback) Route() string { - return RouterKey -} - -func (msg *MsgBuyback) Type() string { - return "recoll" -} - -func (msg *MsgBuyback) GetSigners() []sdk.AccAddress { - creator, err := sdk.AccAddressFromBech32(msg.Creator) - if err != nil { - panic(err) - } - return []sdk.AccAddress{creator} -} - -func (msg *MsgBuyback) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(msg) - return sdk.MustSortJSON(bz) -} - -func (msg *MsgBuyback) ValidateBasic() error { - _, err := sdk.AccAddressFromBech32(msg.Creator) - if err != nil { - return sdkerrors.Wrapf(errors.ErrInvalidAddress, "invalid creator address (%s)", err) - } - return nil -} diff --git a/x/stablecoin/types/messages_test.go b/x/stablecoin/types/messages_test.go deleted file mode 100644 index 7057b4a02..000000000 --- a/x/stablecoin/types/messages_test.go +++ /dev/null @@ -1,103 +0,0 @@ -package types - -import ( - "testing" - - "github.com/NibiruChain/nibiru/x/common/testutil" - - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/stretchr/testify/require" -) - -func TestMsgMintStable_ValidateBasic(t *testing.T) { - tests := []struct { - name string - msg MsgMintStable - err error - }{ - { - name: "invalid address", - msg: MsgMintStable{ - Creator: "invalid_address", - }, - err: sdkerrors.ErrInvalidAddress, - }, { - name: "valid address", - msg: MsgMintStable{ - Creator: testutil.AccAddress().String(), - }, - }, - } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - err := test.msg.ValidateBasic() - if test.err != nil { - require.ErrorIs(t, err, test.err) - return - } - require.NoError(t, err) - }) - } -} - -func TestMsgBurn_ValidateBasic(t *testing.T) { - tests := []struct { - name string - msgBurn MsgBurnStable - err error - }{ - { - name: "Invalid MsgBurn.Creator address", - msgBurn: MsgBurnStable{ - Creator: "invalid_address", - }, - err: sdkerrors.ErrInvalidAddress, - }, { - name: "Valid MsgBurn.Creator address", - msgBurn: MsgBurnStable{ - Creator: testutil.AccAddress().String(), - }, - }, - } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - err := test.msgBurn.ValidateBasic() - if test.err != nil { - require.ErrorIs(t, err, test.err) - return - } - require.NoError(t, err) - }) - } -} - -func TestMsgRecollateralize_ValidateBasic(t *testing.T) { - tests := []struct { - name string - msg MsgRecollateralize - err error - }{ - { - name: "Invalid MsgBurn.Creator address", - msg: MsgRecollateralize{ - Creator: "invalid_address", - }, - err: sdkerrors.ErrInvalidAddress, - }, { - name: "Valid MsgBurn.Creator address", - msg: MsgRecollateralize{ - Creator: testutil.AccAddress().String(), - }, - }, - } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - err := test.msg.ValidateBasic() - if test.err != nil { - require.ErrorIs(t, err, test.err) - return - } - require.NoError(t, err) - }) - } -} diff --git a/x/stablecoin/types/params.go b/x/stablecoin/types/params.go deleted file mode 100644 index b34e00bc5..000000000 --- a/x/stablecoin/types/params.go +++ /dev/null @@ -1,308 +0,0 @@ -package types - -import ( - fmt "fmt" - - sdk "github.com/cosmos/cosmos-sdk/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - - "github.com/NibiruChain/nibiru/x/common" - epochstypes "github.com/NibiruChain/nibiru/x/epochs/types" -) - -var _ paramtypes.ParamSet = (*Params)(nil) - -// ParamKeyTable the param key table for launch module -func ParamKeyTable() paramtypes.KeyTable { - return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) -} - -// NewParams creates a new Params instance -func NewParams( - collRatio sdk.Dec, - feeRatio sdk.Dec, - efFeeRatio sdk.Dec, - bonusRateRecoll sdk.Dec, - distrEpochIdentifier string, - adjustmentStep sdk.Dec, - priceLowerBound sdk.Dec, - priceUpperBound sdk.Dec, - isCollateralRatioValid bool, -) Params { - million := sdk.NewDec(1 * common.TO_MICRO) - collRatioInt := collRatio.Mul(million).RoundInt().Int64() - feeRationInt := feeRatio.Mul(million).RoundInt().Int64() - efFeeRatioInt := efFeeRatio.Mul(million).RoundInt().Int64() - bonusRateRecollInt := bonusRateRecoll.Mul(million).RoundInt().Int64() - - adjustmentStepInt := adjustmentStep.Mul(million).RoundInt().Int64() - priceLowerBoundInt := priceLowerBound.Mul(million).RoundInt().Int64() - priceUpperBoundInt := priceUpperBound.Mul(million).RoundInt().Int64() - - return Params{ - CollRatio: collRatioInt, - FeeRatio: feeRationInt, - EfFeeRatio: efFeeRatioInt, - BonusRateRecoll: bonusRateRecollInt, - DistrEpochIdentifier: distrEpochIdentifier, - AdjustmentStep: adjustmentStepInt, - PriceLowerBound: priceLowerBoundInt, - PriceUpperBound: priceUpperBoundInt, - IsCollateralRatioValid: isCollateralRatioValid, - } -} - -// DefaultParams returns a default set of parameters -func DefaultParams() Params { - genesisCollRatio := sdk.OneDec() - feeRatio := sdk.MustNewDecFromStr("0.002") - efFeeRatio := sdk.MustNewDecFromStr("0.5") - bonusRateRecoll := sdk.MustNewDecFromStr("0.002") - adjustmentStep := sdk.MustNewDecFromStr("0.0025") - priceLowerBound := sdk.MustNewDecFromStr("0.9999") - priceUpperBound := sdk.MustNewDecFromStr("1.0001") - isCollateralRatioValid := false // Will be valid once we start posting prices and updating the collateral - - return NewParams(genesisCollRatio, feeRatio, efFeeRatio, bonusRateRecoll, epochstypes.FifteenMinuteEpochID, - adjustmentStep, - priceLowerBound, - priceUpperBound, isCollateralRatioValid) -} - -// ParamSetPairs get the params.ParamSet -func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { - return paramtypes.ParamSetPairs{ - paramtypes.NewParamSetPair( - []byte("CollRatio"), - &p.CollRatio, - validateCollRatio, - ), - paramtypes.NewParamSetPair( - []byte("FeeRatio"), - &p.FeeRatio, - validateFeeRatio, - ), - paramtypes.NewParamSetPair( - []byte("EfFeeRatio"), - &p.EfFeeRatio, - validateEfFeeRatio, - ), - paramtypes.NewParamSetPair( - []byte("BonusRateRecoll"), - &p.BonusRateRecoll, - validateBonusRateRecoll, - ), - paramtypes.NewParamSetPair( - []byte("DistrEpochIdentifier"), - &p.DistrEpochIdentifier, - validateDistrEpochIdentifier, - ), - paramtypes.NewParamSetPair( - []byte("AdjustmentStep"), - &p.AdjustmentStep, - validateAdjustmentStep, - ), - paramtypes.NewParamSetPair( - []byte("PriceLowerBound"), - &p.PriceLowerBound, - validatePriceLowerBound, - ), - paramtypes.NewParamSetPair( - []byte("PriceUpperBound"), - &p.PriceUpperBound, - validatePriceUpperBound, - ), - paramtypes.NewParamSetPair( - []byte("IsCollateralRatioValid"), - &p.IsCollateralRatioValid, - validateIsCollateralRatioValid, - ), - } -} - -// Validate validates the set of params -func (p *Params) Validate() error { - err := validateCollRatio(p.CollRatio) - if err != nil { - return err - } - - err = validateFeeRatio(p.FeeRatio) - if err != nil { - return err - } - - return validateEfFeeRatio(p.EfFeeRatio) -} - -func (p *Params) GetFeeRatioAsDec() sdk.Dec { - return sdk.NewDecFromInt(sdk.NewIntFromUint64(uint64(p.FeeRatio))). - Quo(sdk.MustNewDecFromStr("1000000")) -} - -func (p *Params) GetCollRatioAsDec() sdk.Dec { - return sdk.NewDecFromInt(sdk.NewIntFromUint64(uint64(p.CollRatio))). - Quo(sdk.MustNewDecFromStr("1000000")) -} - -func (p *Params) GetEfFeeRatioAsDec() sdk.Dec { - return sdk.NewDecFromInt(sdk.NewIntFromUint64(uint64(p.EfFeeRatio))). - Quo(sdk.MustNewDecFromStr("1000000")) -} - -func (p *Params) GetBonusRateRecollAsDec() sdk.Dec { - return sdk.NewDecFromInt(sdk.NewIntFromUint64(uint64(p.BonusRateRecoll))). - Quo(sdk.MustNewDecFromStr("1000000")) -} - -func (p *Params) GetAdjustmentStepAsDec() sdk.Dec { - return sdk.NewDecFromInt(sdk.NewIntFromUint64(uint64(p.AdjustmentStep))). - Quo(sdk.MustNewDecFromStr("1000000")) -} - -func (p *Params) GetPriceLowerBoundAsDec() sdk.Dec { - return sdk.NewDecFromInt(sdk.NewIntFromUint64(uint64(p.PriceLowerBound))). - Quo(sdk.MustNewDecFromStr("1000000")) -} - -func (p *Params) GetPriceUpperBoundAsDec() sdk.Dec { - return sdk.NewDecFromInt(sdk.NewIntFromUint64(uint64(p.PriceUpperBound))). - Quo(sdk.MustNewDecFromStr("1000000")) -} - -func validateCollRatio(i interface{}) error { - collRatio, err := getAsInt64(i) - if err != nil { - return err - } - - if collRatio > 1*common.TO_MICRO { - return fmt.Errorf("collateral ratio is above max value(1e6): %d", collRatio) - } else if collRatio < 0 { - return fmt.Errorf("collateral Ratio is negative: %d", collRatio) - } else { - return nil - } -} - -func validateIsCollateralRatioValid(i interface{}) error { - _, ok := i.(bool) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - return nil -} - -func validateBonusRateRecoll(i interface{}) error { - bonusRateRecoll, err := getAsInt64(i) - if err != nil { - return err - } - - if bonusRateRecoll > 1*common.TO_MICRO { - return fmt.Errorf("collateral Ratio is above max value(1e6): %d", bonusRateRecoll) - } else if bonusRateRecoll < 0 { - return fmt.Errorf("collateral Ratio is negative: %d", bonusRateRecoll) - } else { - return nil - } -} - -func validateFeeRatio(i interface{}) error { - feeRatio, err := getAsInt64(i) - if err != nil { - return err - } - - if feeRatio > 1*common.TO_MICRO { - return fmt.Errorf("fee ratio is above max value(1e6): %d", feeRatio) - } else if feeRatio < 0 { - return fmt.Errorf("fee ratio is negative: %d", feeRatio) - } else { - return nil - } -} - -func validateEfFeeRatio(i interface{}) error { - efFeeRatio, err := getAsInt64(i) - if err != nil { - return err - } - - if efFeeRatio > 1*common.TO_MICRO { - return fmt.Errorf("stable EF fee ratio is above max value(1e6): %d", efFeeRatio) - } else if efFeeRatio < 0 { - return fmt.Errorf("stable EF fee ratio is negative: %d", efFeeRatio) - } else { - return nil - } -} - -func validateDistrEpochIdentifier(i interface{}) error { - _, err := getString(i) - if err != nil { - return err - } - return nil -} - -func validateAdjustmentStep(i interface{}) error { - adjustmentStep, err := getAsInt64(i) - if err != nil { - return err - } - - if adjustmentStep > 1*common.TO_MICRO { - return fmt.Errorf("AdjustmentStep is above max value(1e6): %d", adjustmentStep) - } else if adjustmentStep < 0 { - return fmt.Errorf("AdjustmentStep is negative: %d", adjustmentStep) - } else { - return nil - } -} - -func validatePriceLowerBound(i interface{}) error { - priceLowerBound, err := getAsInt64(i) - if err != nil { - return err - } - - if priceLowerBound > 1*common.TO_MICRO { - return fmt.Errorf("PriceLowerBound is above max value(1e6): %d", priceLowerBound) - } else if priceLowerBound < 0 { - return fmt.Errorf("PriceLowerBound is negative: %d", priceLowerBound) - } else { - return nil - } -} - -func validatePriceUpperBound(i interface{}) error { - priceUpperBound, err := getAsInt64(i) - if err != nil { - return err - } - - if priceUpperBound > 2*common.TO_MICRO { - return fmt.Errorf("PriceUpperBound is above max value(1e6): %d", priceUpperBound) - } else if priceUpperBound < 0 { - return fmt.Errorf("PriceUpperBound is negative: %d", priceUpperBound) - } else { - return nil - } -} - -func getString(i interface{}) (string, error) { - value, ok := i.(string) - if !ok { - return "invalid", fmt.Errorf("invalid parameter type: %T", i) - } - return value, nil -} - -func getAsInt64(i interface{}) (int64, error) { - value, ok := i.(int64) - if !ok { - return 0, fmt.Errorf("invalid parameter type: %T", i) - } - return value, nil -} diff --git a/x/stablecoin/types/params.pb.go b/x/stablecoin/types/params.pb.go deleted file mode 100644 index 5e50937e4..000000000 --- a/x/stablecoin/types/params.pb.go +++ /dev/null @@ -1,631 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: nibiru/stablecoin/v1/params.proto - -package types - -import ( - fmt "fmt" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// Params defines the parameters for the module. -type Params struct { - // collRatio is the ratio needed as collateral to exchange for stables - CollRatio int64 `protobuf:"varint,1,opt,name=coll_ratio,json=collRatio,proto3" json:"coll_ratio,omitempty"` - // feeRatio is the ratio taken as fees when minting or burning stables - FeeRatio int64 `protobuf:"varint,2,opt,name=fee_ratio,json=feeRatio,proto3" json:"fee_ratio,omitempty"` - // efFeeRatio is the ratio taken from the fees that goes to Ecosystem Fund - EfFeeRatio int64 `protobuf:"varint,3,opt,name=ef_fee_ratio,json=efFeeRatio,proto3" json:"ef_fee_ratio,omitempty"` - // BonusRateRecoll is the percentage of extra stablecoin value given to the - // caller of 'Recollateralize' in units of governance tokens. - BonusRateRecoll int64 `protobuf:"varint,4,opt,name=bonus_rate_recoll,json=bonusRateRecoll,proto3" json:"bonus_rate_recoll,omitempty"` - // distr_epoch_identifier defines the frequnecy of update for the collateral - // ratio - DistrEpochIdentifier string `protobuf:"bytes,5,opt,name=distr_epoch_identifier,json=distrEpochIdentifier,proto3" json:"distr_epoch_identifier,omitempty" yaml:"distr_epoch_identifier"` - // adjustmentStep is the size of the step taken when updating the collateral - // ratio - AdjustmentStep int64 `protobuf:"varint,6,opt,name=adjustment_step,json=adjustmentStep,proto3" json:"adjustment_step,omitempty"` - // priceLowerBound is the lower bound for the stable coin to trigger a - // collateral ratio update - PriceLowerBound int64 `protobuf:"varint,7,opt,name=price_lower_bound,json=priceLowerBound,proto3" json:"price_lower_bound,omitempty"` - // priceUpperBound is the upper bound for the stable coin to trigger a - // collateral ratio update - PriceUpperBound int64 `protobuf:"varint,8,opt,name=price_upper_bound,json=priceUpperBound,proto3" json:"price_upper_bound,omitempty"` - // isCollateralRatioValid checks if the collateral ratio is correctly updated - IsCollateralRatioValid bool `protobuf:"varint,9,opt,name=is_collateral_ratio_valid,json=isCollateralRatioValid,proto3" json:"is_collateral_ratio_valid,omitempty"` -} - -func (m *Params) Reset() { *m = Params{} } -func (m *Params) String() string { return proto.CompactTextString(m) } -func (*Params) ProtoMessage() {} -func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_2d2b84d268bc3814, []int{0} -} -func (m *Params) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Params.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Params) XXX_Merge(src proto.Message) { - xxx_messageInfo_Params.Merge(m, src) -} -func (m *Params) XXX_Size() int { - return m.Size() -} -func (m *Params) XXX_DiscardUnknown() { - xxx_messageInfo_Params.DiscardUnknown(m) -} - -var xxx_messageInfo_Params proto.InternalMessageInfo - -func (m *Params) GetCollRatio() int64 { - if m != nil { - return m.CollRatio - } - return 0 -} - -func (m *Params) GetFeeRatio() int64 { - if m != nil { - return m.FeeRatio - } - return 0 -} - -func (m *Params) GetEfFeeRatio() int64 { - if m != nil { - return m.EfFeeRatio - } - return 0 -} - -func (m *Params) GetBonusRateRecoll() int64 { - if m != nil { - return m.BonusRateRecoll - } - return 0 -} - -func (m *Params) GetDistrEpochIdentifier() string { - if m != nil { - return m.DistrEpochIdentifier - } - return "" -} - -func (m *Params) GetAdjustmentStep() int64 { - if m != nil { - return m.AdjustmentStep - } - return 0 -} - -func (m *Params) GetPriceLowerBound() int64 { - if m != nil { - return m.PriceLowerBound - } - return 0 -} - -func (m *Params) GetPriceUpperBound() int64 { - if m != nil { - return m.PriceUpperBound - } - return 0 -} - -func (m *Params) GetIsCollateralRatioValid() bool { - if m != nil { - return m.IsCollateralRatioValid - } - return false -} - -func init() { - proto.RegisterType((*Params)(nil), "nibiru.stablecoin.v1.Params") -} - -func init() { proto.RegisterFile("nibiru/stablecoin/v1/params.proto", fileDescriptor_2d2b84d268bc3814) } - -var fileDescriptor_2d2b84d268bc3814 = []byte{ - // 400 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x92, 0xc1, 0x8a, 0xd3, 0x40, - 0x18, 0x80, 0x1b, 0xab, 0xb5, 0x19, 0xc4, 0x62, 0x28, 0x25, 0x2a, 0x8d, 0x69, 0x2f, 0x16, 0x0f, - 0x89, 0xc5, 0x93, 0x1e, 0x5b, 0x14, 0x14, 0x11, 0x89, 0xa8, 0xb0, 0x97, 0x61, 0x92, 0xfc, 0x69, - 0x67, 0x49, 0x32, 0xc3, 0xcc, 0xa4, 0xbb, 0x7d, 0x8b, 0x7d, 0x8b, 0x7d, 0x95, 0x3d, 0xf6, 0xb8, - 0xa7, 0x65, 0x69, 0xdf, 0x60, 0x9f, 0x60, 0x99, 0x49, 0xb7, 0xe9, 0x61, 0x6f, 0xe1, 0xfb, 0xbe, - 0x84, 0x3f, 0x33, 0x3f, 0x1a, 0x95, 0x34, 0xa6, 0xa2, 0x0a, 0xa5, 0x22, 0x71, 0x0e, 0x09, 0xa3, - 0x65, 0xb8, 0x9a, 0x86, 0x9c, 0x08, 0x52, 0xc8, 0x80, 0x0b, 0xa6, 0x98, 0xd3, 0xaf, 0x93, 0xa0, - 0x49, 0x82, 0xd5, 0xf4, 0x4d, 0x7f, 0xc1, 0x16, 0xcc, 0x04, 0xa1, 0x7e, 0xaa, 0xdb, 0xf1, 0x65, - 0x1b, 0x75, 0x7e, 0x9b, 0x97, 0x9d, 0x21, 0x42, 0x09, 0xcb, 0x73, 0x2c, 0x88, 0xa2, 0xcc, 0xb5, - 0x7c, 0x6b, 0xd2, 0x8e, 0x6c, 0x4d, 0x22, 0x0d, 0x9c, 0xb7, 0xc8, 0xce, 0x00, 0xf6, 0xf6, 0x89, - 0xb1, 0xdd, 0x0c, 0xa0, 0x96, 0x3e, 0x7a, 0x01, 0x19, 0x6e, 0x7c, 0xdb, 0x78, 0x04, 0xd9, 0xb7, - 0x87, 0xe2, 0x03, 0x7a, 0x15, 0xb3, 0xb2, 0x92, 0x3a, 0x00, 0x2c, 0x40, 0x7f, 0xd8, 0x7d, 0x6a, - 0xb2, 0x9e, 0x11, 0x11, 0x51, 0x10, 0x19, 0xec, 0xfc, 0x47, 0x83, 0x94, 0x4a, 0x25, 0x30, 0x70, - 0x96, 0x2c, 0x31, 0x4d, 0xa1, 0x54, 0x34, 0xa3, 0x20, 0xdc, 0x67, 0xbe, 0x35, 0xb1, 0x67, 0xa3, - 0xbb, 0x9b, 0x77, 0xc3, 0x35, 0x29, 0xf2, 0x2f, 0xe3, 0xc7, 0xbb, 0x71, 0xd4, 0x37, 0xe2, 0xab, - 0xe6, 0xdf, 0x0f, 0xd8, 0x79, 0x8f, 0x7a, 0x24, 0x3d, 0xad, 0xa4, 0x2a, 0xa0, 0x54, 0x58, 0x2a, - 0xe0, 0x6e, 0xc7, 0x8c, 0xf0, 0xb2, 0xc1, 0x7f, 0x14, 0x70, 0x3d, 0x2d, 0x17, 0x34, 0x01, 0x9c, - 0xb3, 0x33, 0x10, 0x38, 0x66, 0x55, 0x99, 0xba, 0xcf, 0xeb, 0x69, 0x8d, 0xf8, 0xa9, 0xf9, 0x4c, - 0xe3, 0xa6, 0xad, 0x38, 0x3f, 0xb4, 0xdd, 0xa3, 0xf6, 0xaf, 0xe6, 0x75, 0xfb, 0x19, 0xbd, 0xa6, - 0x12, 0xeb, 0x9f, 0x24, 0x0a, 0x04, 0xd9, 0x1f, 0x36, 0x5e, 0x91, 0x9c, 0xa6, 0xae, 0xed, 0x5b, - 0x93, 0x6e, 0x34, 0xa0, 0x72, 0x7e, 0xf0, 0xe6, 0xec, 0xfe, 0x69, 0x3b, 0xfb, 0x71, 0xb5, 0xf5, - 0xac, 0xcd, 0xd6, 0xb3, 0x6e, 0xb7, 0x9e, 0x75, 0xb1, 0xf3, 0x5a, 0x9b, 0x9d, 0xd7, 0xba, 0xde, - 0x79, 0xad, 0x93, 0x8f, 0x0b, 0xaa, 0x96, 0x55, 0x1c, 0x24, 0xac, 0x08, 0x7f, 0x99, 0xab, 0x9f, - 0x2f, 0x09, 0x2d, 0xc3, 0xfd, 0xa6, 0x9c, 0x1f, 0xef, 0x8a, 0x5a, 0x73, 0x90, 0x71, 0xc7, 0x5c, - 0xfe, 0xa7, 0xfb, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd7, 0x67, 0x2b, 0x61, 0x4d, 0x02, 0x00, 0x00, -} - -func (m *Params) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Params) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.IsCollateralRatioValid { - i-- - if m.IsCollateralRatioValid { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x48 - } - if m.PriceUpperBound != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.PriceUpperBound)) - i-- - dAtA[i] = 0x40 - } - if m.PriceLowerBound != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.PriceLowerBound)) - i-- - dAtA[i] = 0x38 - } - if m.AdjustmentStep != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.AdjustmentStep)) - i-- - dAtA[i] = 0x30 - } - if len(m.DistrEpochIdentifier) > 0 { - i -= len(m.DistrEpochIdentifier) - copy(dAtA[i:], m.DistrEpochIdentifier) - i = encodeVarintParams(dAtA, i, uint64(len(m.DistrEpochIdentifier))) - i-- - dAtA[i] = 0x2a - } - if m.BonusRateRecoll != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.BonusRateRecoll)) - i-- - dAtA[i] = 0x20 - } - if m.EfFeeRatio != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.EfFeeRatio)) - i-- - dAtA[i] = 0x18 - } - if m.FeeRatio != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.FeeRatio)) - i-- - dAtA[i] = 0x10 - } - if m.CollRatio != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.CollRatio)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func encodeVarintParams(dAtA []byte, offset int, v uint64) int { - offset -= sovParams(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *Params) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.CollRatio != 0 { - n += 1 + sovParams(uint64(m.CollRatio)) - } - if m.FeeRatio != 0 { - n += 1 + sovParams(uint64(m.FeeRatio)) - } - if m.EfFeeRatio != 0 { - n += 1 + sovParams(uint64(m.EfFeeRatio)) - } - if m.BonusRateRecoll != 0 { - n += 1 + sovParams(uint64(m.BonusRateRecoll)) - } - l = len(m.DistrEpochIdentifier) - if l > 0 { - n += 1 + l + sovParams(uint64(l)) - } - if m.AdjustmentStep != 0 { - n += 1 + sovParams(uint64(m.AdjustmentStep)) - } - if m.PriceLowerBound != 0 { - n += 1 + sovParams(uint64(m.PriceLowerBound)) - } - if m.PriceUpperBound != 0 { - n += 1 + sovParams(uint64(m.PriceUpperBound)) - } - if m.IsCollateralRatioValid { - n += 2 - } - return n -} - -func sovParams(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozParams(x uint64) (n int) { - return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *Params) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Params: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field CollRatio", wireType) - } - m.CollRatio = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.CollRatio |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field FeeRatio", wireType) - } - m.FeeRatio = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.FeeRatio |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field EfFeeRatio", wireType) - } - m.EfFeeRatio = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.EfFeeRatio |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field BonusRateRecoll", wireType) - } - m.BonusRateRecoll = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.BonusRateRecoll |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DistrEpochIdentifier", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DistrEpochIdentifier = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 6: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field AdjustmentStep", wireType) - } - m.AdjustmentStep = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.AdjustmentStep |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 7: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field PriceLowerBound", wireType) - } - m.PriceLowerBound = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.PriceLowerBound |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 8: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field PriceUpperBound", wireType) - } - m.PriceUpperBound = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.PriceUpperBound |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 9: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field IsCollateralRatioValid", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.IsCollateralRatioValid = bool(v != 0) - default: - iNdEx = preIndex - skippy, err := skipParams(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthParams - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipParams(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowParams - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowParams - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowParams - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthParams - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupParams - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthParams - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/stablecoin/types/query.pb.go b/x/stablecoin/types/query.pb.go deleted file mode 100644 index bdba4d595..000000000 --- a/x/stablecoin/types/query.pb.go +++ /dev/null @@ -1,2225 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: nibiru/stablecoin/v1/query.proto - -package types - -import ( - context "context" - fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - types "github.com/cosmos/cosmos-sdk/types" - _ "github.com/cosmos/cosmos-sdk/types/query" - _ "github.com/cosmos/gogoproto/gogoproto" - grpc1 "github.com/cosmos/gogoproto/grpc" - proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// QueryParamsRequest is request type for the Query/Params RPC method. -type QueryParamsRequest struct { -} - -func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } -func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } -func (*QueryParamsRequest) ProtoMessage() {} -func (*QueryParamsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_cd427158b4504e94, []int{0} -} -func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryParamsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryParamsRequest.Merge(m, src) -} -func (m *QueryParamsRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryParamsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo - -// QueryParamsResponse is response type for the Query/Params RPC method. -type QueryParamsResponse struct { - // params holds all the parameters of this module. - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` -} - -func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } -func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } -func (*QueryParamsResponse) ProtoMessage() {} -func (*QueryParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_cd427158b4504e94, []int{1} -} -func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryParamsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryParamsResponse.Merge(m, src) -} -func (m *QueryParamsResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryParamsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo - -func (m *QueryParamsResponse) GetParams() Params { - if m != nil { - return m.Params - } - return Params{} -} - -// QueryModuleAccountBalances is the request type for the balance of the -// x/stablecoin module account. -type QueryModuleAccountBalances struct { -} - -func (m *QueryModuleAccountBalances) Reset() { *m = QueryModuleAccountBalances{} } -func (m *QueryModuleAccountBalances) String() string { return proto.CompactTextString(m) } -func (*QueryModuleAccountBalances) ProtoMessage() {} -func (*QueryModuleAccountBalances) Descriptor() ([]byte, []int) { - return fileDescriptor_cd427158b4504e94, []int{2} -} -func (m *QueryModuleAccountBalances) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryModuleAccountBalances) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryModuleAccountBalances.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryModuleAccountBalances) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryModuleAccountBalances.Merge(m, src) -} -func (m *QueryModuleAccountBalances) XXX_Size() int { - return m.Size() -} -func (m *QueryModuleAccountBalances) XXX_DiscardUnknown() { - xxx_messageInfo_QueryModuleAccountBalances.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryModuleAccountBalances proto.InternalMessageInfo - -type QueryModuleAccountBalancesResponse struct { - // ModuleAccountBalances is the balance of all coins in the x/stablecoin - // module. - ModuleAccountBalances github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=module_account_balances,json=moduleAccountBalances,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"module_account_balances" yaml:"coins"` -} - -func (m *QueryModuleAccountBalancesResponse) Reset() { *m = QueryModuleAccountBalancesResponse{} } -func (m *QueryModuleAccountBalancesResponse) String() string { return proto.CompactTextString(m) } -func (*QueryModuleAccountBalancesResponse) ProtoMessage() {} -func (*QueryModuleAccountBalancesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_cd427158b4504e94, []int{3} -} -func (m *QueryModuleAccountBalancesResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryModuleAccountBalancesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryModuleAccountBalancesResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryModuleAccountBalancesResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryModuleAccountBalancesResponse.Merge(m, src) -} -func (m *QueryModuleAccountBalancesResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryModuleAccountBalancesResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryModuleAccountBalancesResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryModuleAccountBalancesResponse proto.InternalMessageInfo - -func (m *QueryModuleAccountBalancesResponse) GetModuleAccountBalances() github_com_cosmos_cosmos_sdk_types.Coins { - if m != nil { - return m.ModuleAccountBalances - } - return nil -} - -// QueryCirculatingSupplies is the request type for the circulating supply of -// both NIBI and NUSD. -type QueryCirculatingSupplies struct { -} - -func (m *QueryCirculatingSupplies) Reset() { *m = QueryCirculatingSupplies{} } -func (m *QueryCirculatingSupplies) String() string { return proto.CompactTextString(m) } -func (*QueryCirculatingSupplies) ProtoMessage() {} -func (*QueryCirculatingSupplies) Descriptor() ([]byte, []int) { - return fileDescriptor_cd427158b4504e94, []int{4} -} -func (m *QueryCirculatingSupplies) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryCirculatingSupplies) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryCirculatingSupplies.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryCirculatingSupplies) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryCirculatingSupplies.Merge(m, src) -} -func (m *QueryCirculatingSupplies) XXX_Size() int { - return m.Size() -} -func (m *QueryCirculatingSupplies) XXX_DiscardUnknown() { - xxx_messageInfo_QueryCirculatingSupplies.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryCirculatingSupplies proto.InternalMessageInfo - -type QueryCirculatingSuppliesResponse struct { - Nibi types.Coin `protobuf:"bytes,1,opt,name=nibi,proto3" json:"nibi"` - Nusd types.Coin `protobuf:"bytes,2,opt,name=nusd,proto3" json:"nusd"` -} - -func (m *QueryCirculatingSuppliesResponse) Reset() { *m = QueryCirculatingSuppliesResponse{} } -func (m *QueryCirculatingSuppliesResponse) String() string { return proto.CompactTextString(m) } -func (*QueryCirculatingSuppliesResponse) ProtoMessage() {} -func (*QueryCirculatingSuppliesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_cd427158b4504e94, []int{5} -} -func (m *QueryCirculatingSuppliesResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryCirculatingSuppliesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryCirculatingSuppliesResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryCirculatingSuppliesResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryCirculatingSuppliesResponse.Merge(m, src) -} -func (m *QueryCirculatingSuppliesResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryCirculatingSuppliesResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryCirculatingSuppliesResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryCirculatingSuppliesResponse proto.InternalMessageInfo - -func (m *QueryCirculatingSuppliesResponse) GetNibi() types.Coin { - if m != nil { - return m.Nibi - } - return types.Coin{} -} - -func (m *QueryCirculatingSuppliesResponse) GetNusd() types.Coin { - if m != nil { - return m.Nusd - } - return types.Coin{} -} - -// QueryGovToMintStable is the request type for the Query/GovToMintStable RPC -// method -type QueryGovToMintStable struct { - Collateral types.Coin `protobuf:"bytes,1,opt,name=collateral,proto3" json:"collateral"` -} - -func (m *QueryGovToMintStable) Reset() { *m = QueryGovToMintStable{} } -func (m *QueryGovToMintStable) String() string { return proto.CompactTextString(m) } -func (*QueryGovToMintStable) ProtoMessage() {} -func (*QueryGovToMintStable) Descriptor() ([]byte, []int) { - return fileDescriptor_cd427158b4504e94, []int{6} -} -func (m *QueryGovToMintStable) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryGovToMintStable) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryGovToMintStable.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryGovToMintStable) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryGovToMintStable.Merge(m, src) -} -func (m *QueryGovToMintStable) XXX_Size() int { - return m.Size() -} -func (m *QueryGovToMintStable) XXX_DiscardUnknown() { - xxx_messageInfo_QueryGovToMintStable.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryGovToMintStable proto.InternalMessageInfo - -func (m *QueryGovToMintStable) GetCollateral() types.Coin { - if m != nil { - return m.Collateral - } - return types.Coin{} -} - -// QueryGovToMintStableResponse is the response type for 'QueryGovToMintStable' -type QueryGovToMintStableResponse struct { - Gov types.Coin `protobuf:"bytes,1,opt,name=gov,proto3" json:"gov"` -} - -func (m *QueryGovToMintStableResponse) Reset() { *m = QueryGovToMintStableResponse{} } -func (m *QueryGovToMintStableResponse) String() string { return proto.CompactTextString(m) } -func (*QueryGovToMintStableResponse) ProtoMessage() {} -func (*QueryGovToMintStableResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_cd427158b4504e94, []int{7} -} -func (m *QueryGovToMintStableResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryGovToMintStableResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryGovToMintStableResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryGovToMintStableResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryGovToMintStableResponse.Merge(m, src) -} -func (m *QueryGovToMintStableResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryGovToMintStableResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryGovToMintStableResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryGovToMintStableResponse proto.InternalMessageInfo - -func (m *QueryGovToMintStableResponse) GetGov() types.Coin { - if m != nil { - return m.Gov - } - return types.Coin{} -} - -type LiquidityRatioInfo struct { - LiquidityRatio github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=liquidity_ratio,json=liquidityRatio,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"liquidity_ratio"` - UpperBand github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=upper_band,json=upperBand,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"upper_band"` - LowerBand github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=lower_band,json=lowerBand,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"lower_band"` -} - -func (m *LiquidityRatioInfo) Reset() { *m = LiquidityRatioInfo{} } -func (m *LiquidityRatioInfo) String() string { return proto.CompactTextString(m) } -func (*LiquidityRatioInfo) ProtoMessage() {} -func (*LiquidityRatioInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_cd427158b4504e94, []int{8} -} -func (m *LiquidityRatioInfo) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *LiquidityRatioInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_LiquidityRatioInfo.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *LiquidityRatioInfo) XXX_Merge(src proto.Message) { - xxx_messageInfo_LiquidityRatioInfo.Merge(m, src) -} -func (m *LiquidityRatioInfo) XXX_Size() int { - return m.Size() -} -func (m *LiquidityRatioInfo) XXX_DiscardUnknown() { - xxx_messageInfo_LiquidityRatioInfo.DiscardUnknown(m) -} - -var xxx_messageInfo_LiquidityRatioInfo proto.InternalMessageInfo - -type QueryLiquidityRatioInfoRequest struct { -} - -func (m *QueryLiquidityRatioInfoRequest) Reset() { *m = QueryLiquidityRatioInfoRequest{} } -func (m *QueryLiquidityRatioInfoRequest) String() string { return proto.CompactTextString(m) } -func (*QueryLiquidityRatioInfoRequest) ProtoMessage() {} -func (*QueryLiquidityRatioInfoRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_cd427158b4504e94, []int{9} -} -func (m *QueryLiquidityRatioInfoRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryLiquidityRatioInfoRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryLiquidityRatioInfoRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryLiquidityRatioInfoRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryLiquidityRatioInfoRequest.Merge(m, src) -} -func (m *QueryLiquidityRatioInfoRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryLiquidityRatioInfoRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryLiquidityRatioInfoRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryLiquidityRatioInfoRequest proto.InternalMessageInfo - -type QueryLiquidityRatioInfoResponse struct { - Info LiquidityRatioInfo `protobuf:"bytes,1,opt,name=info,proto3" json:"info"` -} - -func (m *QueryLiquidityRatioInfoResponse) Reset() { *m = QueryLiquidityRatioInfoResponse{} } -func (m *QueryLiquidityRatioInfoResponse) String() string { return proto.CompactTextString(m) } -func (*QueryLiquidityRatioInfoResponse) ProtoMessage() {} -func (*QueryLiquidityRatioInfoResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_cd427158b4504e94, []int{10} -} -func (m *QueryLiquidityRatioInfoResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryLiquidityRatioInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryLiquidityRatioInfoResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryLiquidityRatioInfoResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryLiquidityRatioInfoResponse.Merge(m, src) -} -func (m *QueryLiquidityRatioInfoResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryLiquidityRatioInfoResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryLiquidityRatioInfoResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryLiquidityRatioInfoResponse proto.InternalMessageInfo - -func (m *QueryLiquidityRatioInfoResponse) GetInfo() LiquidityRatioInfo { - if m != nil { - return m.Info - } - return LiquidityRatioInfo{} -} - -func init() { - proto.RegisterType((*QueryParamsRequest)(nil), "nibiru.stablecoin.v1.QueryParamsRequest") - proto.RegisterType((*QueryParamsResponse)(nil), "nibiru.stablecoin.v1.QueryParamsResponse") - proto.RegisterType((*QueryModuleAccountBalances)(nil), "nibiru.stablecoin.v1.QueryModuleAccountBalances") - proto.RegisterType((*QueryModuleAccountBalancesResponse)(nil), "nibiru.stablecoin.v1.QueryModuleAccountBalancesResponse") - proto.RegisterType((*QueryCirculatingSupplies)(nil), "nibiru.stablecoin.v1.QueryCirculatingSupplies") - proto.RegisterType((*QueryCirculatingSuppliesResponse)(nil), "nibiru.stablecoin.v1.QueryCirculatingSuppliesResponse") - proto.RegisterType((*QueryGovToMintStable)(nil), "nibiru.stablecoin.v1.QueryGovToMintStable") - proto.RegisterType((*QueryGovToMintStableResponse)(nil), "nibiru.stablecoin.v1.QueryGovToMintStableResponse") - proto.RegisterType((*LiquidityRatioInfo)(nil), "nibiru.stablecoin.v1.LiquidityRatioInfo") - proto.RegisterType((*QueryLiquidityRatioInfoRequest)(nil), "nibiru.stablecoin.v1.QueryLiquidityRatioInfoRequest") - proto.RegisterType((*QueryLiquidityRatioInfoResponse)(nil), "nibiru.stablecoin.v1.QueryLiquidityRatioInfoResponse") -} - -func init() { proto.RegisterFile("nibiru/stablecoin/v1/query.proto", fileDescriptor_cd427158b4504e94) } - -var fileDescriptor_cd427158b4504e94 = []byte{ - // 744 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0xcd, 0x6e, 0xd3, 0x4a, - 0x18, 0x8d, 0xfb, 0x27, 0x75, 0x7a, 0x75, 0xaf, 0x34, 0x4d, 0x75, 0x83, 0x15, 0x39, 0xc1, 0x42, - 0x90, 0x82, 0xb0, 0x9b, 0x16, 0x10, 0xea, 0x06, 0x70, 0x91, 0x10, 0x88, 0x22, 0x9a, 0x22, 0x55, - 0x62, 0x13, 0x8d, 0x9d, 0xa9, 0x3b, 0xc2, 0x99, 0x71, 0x3d, 0x76, 0x20, 0x5b, 0x58, 0xc2, 0x02, - 0xa9, 0x6f, 0x81, 0x10, 0x0b, 0x16, 0x2c, 0x78, 0x82, 0x2e, 0x2b, 0xb1, 0x41, 0x2c, 0x0a, 0x6a, - 0x79, 0x02, 0x9e, 0x00, 0xcd, 0xd8, 0x4e, 0x53, 0x3a, 0x89, 0x12, 0x56, 0x89, 0x66, 0xce, 0x39, - 0xdf, 0x99, 0x33, 0xf3, 0x7d, 0x06, 0x55, 0x4a, 0x5c, 0x12, 0x25, 0x36, 0x8f, 0x91, 0x1b, 0x60, - 0x8f, 0x11, 0x6a, 0x77, 0xea, 0xf6, 0x6e, 0x82, 0xa3, 0xae, 0x15, 0x46, 0x2c, 0x66, 0xb0, 0x98, - 0x22, 0xac, 0x13, 0x84, 0xd5, 0xa9, 0xeb, 0x45, 0x9f, 0xf9, 0x4c, 0x02, 0x6c, 0xf1, 0x2f, 0xc5, - 0xea, 0x65, 0x9f, 0x31, 0x3f, 0xc0, 0x36, 0x0a, 0x89, 0x8d, 0x28, 0x65, 0x31, 0x8a, 0x09, 0xa3, - 0x3c, 0xdb, 0xbd, 0xec, 0x31, 0xde, 0x66, 0xdc, 0x76, 0x11, 0xc7, 0x69, 0x09, 0xbb, 0x53, 0x77, - 0x71, 0x8c, 0xea, 0x76, 0x88, 0x7c, 0x42, 0x25, 0x38, 0xc3, 0x1a, 0xfd, 0xd8, 0x1c, 0x25, 0x8b, - 0xa7, 0xfb, 0xe7, 0x95, 0xbe, 0x43, 0x14, 0xa1, 0x76, 0x56, 0xce, 0x2c, 0x02, 0xb8, 0x21, 0x8a, - 0x3c, 0x96, 0x8b, 0x0d, 0xbc, 0x9b, 0x60, 0x1e, 0x9b, 0x1b, 0x60, 0xfe, 0xd4, 0x2a, 0x0f, 0x19, - 0xe5, 0x18, 0xae, 0x82, 0x99, 0x94, 0x5c, 0xd2, 0xaa, 0x5a, 0x6d, 0x6e, 0xb9, 0x6c, 0xa9, 0x8e, - 0x6d, 0xa5, 0x2c, 0x67, 0x6a, 0xff, 0xb0, 0x52, 0x68, 0x64, 0x0c, 0xb3, 0x0c, 0x74, 0x29, 0xb9, - 0xce, 0x5a, 0x49, 0x80, 0xef, 0x78, 0x1e, 0x4b, 0x68, 0xec, 0xa0, 0x00, 0x51, 0x0f, 0x73, 0xf3, - 0xb3, 0x06, 0xcc, 0xc1, 0xdb, 0x3d, 0x03, 0x7b, 0x1a, 0xf8, 0xbf, 0x2d, 0x11, 0x4d, 0x94, 0x42, - 0x9a, 0x6e, 0x86, 0x29, 0x69, 0xd5, 0xc9, 0xda, 0xdc, 0xf2, 0x39, 0x2b, 0xcd, 0xc4, 0x12, 0x99, - 0x58, 0x59, 0x26, 0xd6, 0x1a, 0x23, 0xd4, 0xb9, 0x2d, 0xfc, 0xfc, 0x3a, 0xac, 0xfc, 0xd3, 0x45, - 0xed, 0x60, 0xd5, 0x14, 0x6e, 0xb9, 0xf9, 0xee, 0x7b, 0xa5, 0xe6, 0x93, 0x78, 0x27, 0x71, 0x2d, - 0x8f, 0xb5, 0xed, 0x2c, 0xd0, 0xf4, 0xe7, 0x2a, 0x6f, 0x3d, 0xb3, 0xe3, 0x6e, 0x88, 0xb9, 0x14, - 0xe0, 0x8d, 0x85, 0xb6, 0xd2, 0xbc, 0x0e, 0x4a, 0xd2, 0xfb, 0x1a, 0x89, 0xbc, 0x24, 0x40, 0x31, - 0xa1, 0xfe, 0x66, 0x12, 0x86, 0x01, 0xc1, 0xdc, 0x7c, 0xa3, 0x81, 0xea, 0xa0, 0xcd, 0xde, 0xb1, - 0x56, 0xc0, 0x94, 0x08, 0x32, 0x4b, 0x75, 0xc8, 0x11, 0xd2, 0x48, 0x25, 0x58, 0x92, 0x12, 0xde, - 0x2a, 0x4d, 0x8c, 0x4a, 0x4a, 0x78, 0xcb, 0xdc, 0x02, 0x45, 0xe9, 0xe6, 0x1e, 0xeb, 0x3c, 0x61, - 0xeb, 0x84, 0xc6, 0x9b, 0xf2, 0xe6, 0xe0, 0x2d, 0x00, 0x3c, 0x16, 0x04, 0x28, 0xc6, 0x11, 0x0a, - 0x46, 0xf5, 0xd1, 0x47, 0x31, 0x37, 0x40, 0x59, 0x25, 0xdc, 0x3b, 0x62, 0x1d, 0x4c, 0xfa, 0xac, - 0x33, 0xaa, 0xb2, 0xc0, 0x9a, 0xaf, 0x27, 0x00, 0x7c, 0x48, 0x76, 0x13, 0xd2, 0x22, 0x71, 0xb7, - 0x21, 0xde, 0xfd, 0x7d, 0xba, 0xcd, 0xe0, 0x16, 0xf8, 0x2f, 0xc8, 0x57, 0x9b, 0x91, 0x58, 0x96, - 0xaa, 0xb3, 0x8e, 0x25, 0xa8, 0xdf, 0x0e, 0x2b, 0x17, 0x47, 0xb8, 0xcf, 0xbb, 0xd8, 0x6b, 0xfc, - 0x1b, 0x9c, 0x12, 0x87, 0xeb, 0x00, 0x24, 0x61, 0x88, 0xa3, 0xa6, 0x8b, 0x68, 0x1a, 0xeb, 0xf8, - 0x9a, 0xb3, 0x52, 0xc1, 0x41, 0xb4, 0x25, 0xe4, 0x02, 0xf6, 0x3c, 0x97, 0x9b, 0xfc, 0x3b, 0x39, - 0xa9, 0x20, 0xe4, 0xcc, 0x2a, 0x30, 0x64, 0xc0, 0x67, 0x13, 0xc9, 0x9b, 0x16, 0x83, 0xca, 0x40, - 0x44, 0x76, 0x0b, 0x0e, 0x98, 0x22, 0x74, 0x9b, 0x65, 0xd7, 0x50, 0x53, 0xb7, 0xef, 0x59, 0x7e, - 0xfe, 0x84, 0x04, 0x77, 0xf9, 0xfd, 0x34, 0x98, 0x96, 0x75, 0xe0, 0x2b, 0x0d, 0xcc, 0xa4, 0xbd, - 0x0e, 0x07, 0x48, 0x9d, 0x1d, 0x2d, 0xfa, 0xe2, 0x08, 0xc8, 0xd4, 0xad, 0x79, 0xe1, 0xe5, 0x97, - 0x9f, 0x7b, 0x13, 0x06, 0x2c, 0xdb, 0x43, 0xe6, 0x18, 0xfc, 0xa4, 0x81, 0x05, 0xe5, 0xd4, 0x80, - 0x4b, 0x43, 0x4a, 0x29, 0x19, 0xfa, 0xcd, 0x71, 0x19, 0x3d, 0xaf, 0x75, 0xe9, 0xf5, 0x0a, 0x5c, - 0x54, 0x78, 0x55, 0x4f, 0x2c, 0xf8, 0x41, 0x03, 0xf3, 0x8a, 0xa9, 0x00, 0xad, 0x21, 0x26, 0x14, - 0x78, 0xfd, 0xc6, 0x78, 0xf8, 0x9e, 0x65, 0x5b, 0x5a, 0x5e, 0x84, 0x97, 0x14, 0x96, 0xbd, 0x13, - 0x5e, 0x93, 0xe7, 0xc6, 0x3e, 0x6a, 0xca, 0x86, 0xbc, 0x36, 0xa4, 0xfe, 0xc0, 0xd7, 0xaa, 0x5f, - 0x1f, 0x93, 0x35, 0x82, 0xe9, 0x3f, 0xc6, 0x42, 0x53, 0x3c, 0x57, 0xe7, 0xc1, 0xfe, 0x91, 0xa1, - 0x1d, 0x1c, 0x19, 0xda, 0x8f, 0x23, 0x43, 0x7b, 0x7b, 0x6c, 0x14, 0x0e, 0x8e, 0x8d, 0xc2, 0xd7, - 0x63, 0xa3, 0xf0, 0x74, 0xa9, 0xaf, 0x09, 0x1f, 0x49, 0xb1, 0xb5, 0x1d, 0x44, 0x68, 0x2e, 0xfc, - 0xa2, 0x5f, 0x5a, 0xb6, 0xa4, 0x3b, 0x23, 0xbf, 0x99, 0x2b, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, - 0xec, 0x4c, 0xa2, 0xce, 0x10, 0x08, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// QueryClient is the client API for Query service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type QueryClient interface { - // Parameters queries the parameters of the x/stablecoin module. - Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) - // ModuleAccountBalances queries the account balance of x/stablecoin. - ModuleAccountBalances(ctx context.Context, in *QueryModuleAccountBalances, opts ...grpc.CallOption) (*QueryModuleAccountBalancesResponse, error) - CirculatingSupplies(ctx context.Context, in *QueryCirculatingSupplies, opts ...grpc.CallOption) (*QueryCirculatingSuppliesResponse, error) - LiquidityRatioInfo(ctx context.Context, in *QueryLiquidityRatioInfoRequest, opts ...grpc.CallOption) (*QueryLiquidityRatioInfoResponse, error) -} - -type queryClient struct { - cc grpc1.ClientConn -} - -func NewQueryClient(cc grpc1.ClientConn) QueryClient { - return &queryClient{cc} -} - -func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { - out := new(QueryParamsResponse) - err := c.cc.Invoke(ctx, "/nibiru.stablecoin.v1.Query/Params", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) ModuleAccountBalances(ctx context.Context, in *QueryModuleAccountBalances, opts ...grpc.CallOption) (*QueryModuleAccountBalancesResponse, error) { - out := new(QueryModuleAccountBalancesResponse) - err := c.cc.Invoke(ctx, "/nibiru.stablecoin.v1.Query/ModuleAccountBalances", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) CirculatingSupplies(ctx context.Context, in *QueryCirculatingSupplies, opts ...grpc.CallOption) (*QueryCirculatingSuppliesResponse, error) { - out := new(QueryCirculatingSuppliesResponse) - err := c.cc.Invoke(ctx, "/nibiru.stablecoin.v1.Query/CirculatingSupplies", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) LiquidityRatioInfo(ctx context.Context, in *QueryLiquidityRatioInfoRequest, opts ...grpc.CallOption) (*QueryLiquidityRatioInfoResponse, error) { - out := new(QueryLiquidityRatioInfoResponse) - err := c.cc.Invoke(ctx, "/nibiru.stablecoin.v1.Query/LiquidityRatioInfo", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// QueryServer is the server API for Query service. -type QueryServer interface { - // Parameters queries the parameters of the x/stablecoin module. - Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) - // ModuleAccountBalances queries the account balance of x/stablecoin. - ModuleAccountBalances(context.Context, *QueryModuleAccountBalances) (*QueryModuleAccountBalancesResponse, error) - CirculatingSupplies(context.Context, *QueryCirculatingSupplies) (*QueryCirculatingSuppliesResponse, error) - LiquidityRatioInfo(context.Context, *QueryLiquidityRatioInfoRequest) (*QueryLiquidityRatioInfoResponse, error) -} - -// UnimplementedQueryServer can be embedded to have forward compatible implementations. -type UnimplementedQueryServer struct { -} - -func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") -} -func (*UnimplementedQueryServer) ModuleAccountBalances(ctx context.Context, req *QueryModuleAccountBalances) (*QueryModuleAccountBalancesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ModuleAccountBalances not implemented") -} -func (*UnimplementedQueryServer) CirculatingSupplies(ctx context.Context, req *QueryCirculatingSupplies) (*QueryCirculatingSuppliesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CirculatingSupplies not implemented") -} -func (*UnimplementedQueryServer) LiquidityRatioInfo(ctx context.Context, req *QueryLiquidityRatioInfoRequest) (*QueryLiquidityRatioInfoResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method LiquidityRatioInfo not implemented") -} - -func RegisterQueryServer(s grpc1.Server, srv QueryServer) { - s.RegisterService(&_Query_serviceDesc, srv) -} - -func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryParamsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).Params(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/nibiru.stablecoin.v1.Query/Params", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_ModuleAccountBalances_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryModuleAccountBalances) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).ModuleAccountBalances(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/nibiru.stablecoin.v1.Query/ModuleAccountBalances", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).ModuleAccountBalances(ctx, req.(*QueryModuleAccountBalances)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_CirculatingSupplies_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryCirculatingSupplies) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).CirculatingSupplies(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/nibiru.stablecoin.v1.Query/CirculatingSupplies", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).CirculatingSupplies(ctx, req.(*QueryCirculatingSupplies)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_LiquidityRatioInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryLiquidityRatioInfoRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).LiquidityRatioInfo(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/nibiru.stablecoin.v1.Query/LiquidityRatioInfo", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).LiquidityRatioInfo(ctx, req.(*QueryLiquidityRatioInfoRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "nibiru.stablecoin.v1.Query", - HandlerType: (*QueryServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Params", - Handler: _Query_Params_Handler, - }, - { - MethodName: "ModuleAccountBalances", - Handler: _Query_ModuleAccountBalances_Handler, - }, - { - MethodName: "CirculatingSupplies", - Handler: _Query_CirculatingSupplies_Handler, - }, - { - MethodName: "LiquidityRatioInfo", - Handler: _Query_LiquidityRatioInfo_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "nibiru/stablecoin/v1/query.proto", -} - -func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *QueryModuleAccountBalances) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryModuleAccountBalances) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryModuleAccountBalances) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *QueryModuleAccountBalancesResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryModuleAccountBalancesResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryModuleAccountBalancesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.ModuleAccountBalances) > 0 { - for iNdEx := len(m.ModuleAccountBalances) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.ModuleAccountBalances[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *QueryCirculatingSupplies) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryCirculatingSupplies) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryCirculatingSupplies) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *QueryCirculatingSuppliesResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryCirculatingSuppliesResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryCirculatingSuppliesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Nusd.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size, err := m.Nibi.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *QueryGovToMintStable) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryGovToMintStable) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryGovToMintStable) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Collateral.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *QueryGovToMintStableResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryGovToMintStableResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryGovToMintStableResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Gov.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *LiquidityRatioInfo) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *LiquidityRatioInfo) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *LiquidityRatioInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.LowerBand.Size() - i -= size - if _, err := m.LowerBand.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - { - size := m.UpperBand.Size() - i -= size - if _, err := m.UpperBand.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size := m.LiquidityRatio.Size() - i -= size - if _, err := m.LiquidityRatio.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *QueryLiquidityRatioInfoRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryLiquidityRatioInfoRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryLiquidityRatioInfoRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *QueryLiquidityRatioInfoResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryLiquidityRatioInfoResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryLiquidityRatioInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Info.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { - offset -= sovQuery(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *QueryParamsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *QueryParamsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Params.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func (m *QueryModuleAccountBalances) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *QueryModuleAccountBalancesResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.ModuleAccountBalances) > 0 { - for _, e := range m.ModuleAccountBalances { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - return n -} - -func (m *QueryCirculatingSupplies) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *QueryCirculatingSuppliesResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Nibi.Size() - n += 1 + l + sovQuery(uint64(l)) - l = m.Nusd.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func (m *QueryGovToMintStable) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Collateral.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func (m *QueryGovToMintStableResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Gov.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func (m *LiquidityRatioInfo) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.LiquidityRatio.Size() - n += 1 + l + sovQuery(uint64(l)) - l = m.UpperBand.Size() - n += 1 + l + sovQuery(uint64(l)) - l = m.LowerBand.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func (m *QueryLiquidityRatioInfoRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *QueryLiquidityRatioInfoResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Info.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func sovQuery(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozQuery(x uint64) (n int) { - return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryModuleAccountBalances) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryModuleAccountBalances: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryModuleAccountBalances: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryModuleAccountBalancesResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryModuleAccountBalancesResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryModuleAccountBalancesResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ModuleAccountBalances", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ModuleAccountBalances = append(m.ModuleAccountBalances, types.Coin{}) - if err := m.ModuleAccountBalances[len(m.ModuleAccountBalances)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryCirculatingSupplies) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryCirculatingSupplies: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryCirculatingSupplies: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryCirculatingSuppliesResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryCirculatingSuppliesResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryCirculatingSuppliesResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Nibi", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Nibi.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Nusd", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Nusd.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryGovToMintStable) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryGovToMintStable: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGovToMintStable: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Collateral", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Collateral.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryGovToMintStableResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryGovToMintStableResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGovToMintStableResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Gov", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Gov.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *LiquidityRatioInfo) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: LiquidityRatioInfo: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: LiquidityRatioInfo: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LiquidityRatio", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.LiquidityRatio.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UpperBand", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.UpperBand.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LowerBand", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.LowerBand.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryLiquidityRatioInfoRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryLiquidityRatioInfoRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryLiquidityRatioInfoRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryLiquidityRatioInfoResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryLiquidityRatioInfoResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryLiquidityRatioInfoResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Info", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Info.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipQuery(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowQuery - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowQuery - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowQuery - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthQuery - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupQuery - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthQuery - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/stablecoin/types/query.pb.gw.go b/x/stablecoin/types/query.pb.gw.go deleted file mode 100644 index 8f967bbc3..000000000 --- a/x/stablecoin/types/query.pb.gw.go +++ /dev/null @@ -1,348 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: nibiru/stablecoin/v1/query.proto - -/* -Package types is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package types - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryParamsRequest - var metadata runtime.ServerMetadata - - msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryParamsRequest - var metadata runtime.ServerMetadata - - msg, err := server.Params(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_ModuleAccountBalances_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryModuleAccountBalances - var metadata runtime.ServerMetadata - - msg, err := client.ModuleAccountBalances(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_ModuleAccountBalances_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryModuleAccountBalances - var metadata runtime.ServerMetadata - - msg, err := server.ModuleAccountBalances(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_CirculatingSupplies_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryCirculatingSupplies - var metadata runtime.ServerMetadata - - msg, err := client.CirculatingSupplies(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_CirculatingSupplies_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryCirculatingSupplies - var metadata runtime.ServerMetadata - - msg, err := server.CirculatingSupplies(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_LiquidityRatioInfo_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryLiquidityRatioInfoRequest - var metadata runtime.ServerMetadata - - msg, err := client.LiquidityRatioInfo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_LiquidityRatioInfo_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryLiquidityRatioInfoRequest - var metadata runtime.ServerMetadata - - msg, err := server.LiquidityRatioInfo(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". -// UnaryRPC :call QueryServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. -func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - - mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_ModuleAccountBalances_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_ModuleAccountBalances_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_ModuleAccountBalances_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_CirculatingSupplies_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_CirculatingSupplies_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_CirculatingSupplies_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_LiquidityRatioInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_LiquidityRatioInfo_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_LiquidityRatioInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterQueryHandler(ctx, mux, conn) -} - -// RegisterQueryHandler registers the http handlers for service Query to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) -} - -// RegisterQueryHandlerClient registers the http handlers for service Query -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "QueryClient" to call the correct interceptors. -func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - - mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_ModuleAccountBalances_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_ModuleAccountBalances_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_ModuleAccountBalances_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_CirculatingSupplies_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_CirculatingSupplies_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_CirculatingSupplies_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_LiquidityRatioInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_LiquidityRatioInfo_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_LiquidityRatioInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"nibiru", "stablecoin", "v1", "params"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_ModuleAccountBalances_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"nibiru", "stablecoin", "module_account_balance"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_CirculatingSupplies_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"nibiru", "stablecoin", "circulating_supplies"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_LiquidityRatioInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"nibiru", "stablecoin", "liquidity_ratio_info"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Query_Params_0 = runtime.ForwardResponseMessage - - forward_Query_ModuleAccountBalances_0 = runtime.ForwardResponseMessage - - forward_Query_CirculatingSupplies_0 = runtime.ForwardResponseMessage - - forward_Query_LiquidityRatioInfo_0 = runtime.ForwardResponseMessage -) diff --git a/x/stablecoin/types/tx.pb.go b/x/stablecoin/types/tx.pb.go deleted file mode 100644 index 598f15437..000000000 --- a/x/stablecoin/types/tx.pb.go +++ /dev/null @@ -1,2228 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: nibiru/stablecoin/v1/tx.proto - -package types - -import ( - context "context" - fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - types "github.com/cosmos/cosmos-sdk/types" - _ "github.com/cosmos/gogoproto/gogoproto" - grpc1 "github.com/cosmos/gogoproto/grpc" - proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// MsgMintStable: Msg to mint NUSD. A user deposits NIBI and collateral and gets -// NUSD in return. The amount of NUSD received depends on the current price set -// by the oracle library and the current collateral ratio for the protocol. -type MsgMintStable struct { - Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - Stable types.Coin `protobuf:"bytes,2,opt,name=stable,proto3" json:"stable"` -} - -func (m *MsgMintStable) Reset() { *m = MsgMintStable{} } -func (m *MsgMintStable) String() string { return proto.CompactTextString(m) } -func (*MsgMintStable) ProtoMessage() {} -func (*MsgMintStable) Descriptor() ([]byte, []int) { - return fileDescriptor_7c52aa4b3b498950, []int{0} -} -func (m *MsgMintStable) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgMintStable) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgMintStable.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgMintStable) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgMintStable.Merge(m, src) -} -func (m *MsgMintStable) XXX_Size() int { - return m.Size() -} -func (m *MsgMintStable) XXX_DiscardUnknown() { - xxx_messageInfo_MsgMintStable.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgMintStable proto.InternalMessageInfo - -func (m *MsgMintStable) GetCreator() string { - if m != nil { - return m.Creator - } - return "" -} - -func (m *MsgMintStable) GetStable() types.Coin { - if m != nil { - return m.Stable - } - return types.Coin{} -} - -// MsgMintStableResponse specifies the amount of NUSD token the user will -// receive after their mint transaction -type MsgMintStableResponse struct { - Stable types.Coin `protobuf:"bytes,1,opt,name=stable,proto3" json:"stable"` - UsedCoins github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=used_coins,json=usedCoins,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"used_coins"` - FeesPayed github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=fees_payed,json=feesPayed,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"fees_payed"` -} - -func (m *MsgMintStableResponse) Reset() { *m = MsgMintStableResponse{} } -func (m *MsgMintStableResponse) String() string { return proto.CompactTextString(m) } -func (*MsgMintStableResponse) ProtoMessage() {} -func (*MsgMintStableResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_7c52aa4b3b498950, []int{1} -} -func (m *MsgMintStableResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgMintStableResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgMintStableResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgMintStableResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgMintStableResponse.Merge(m, src) -} -func (m *MsgMintStableResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgMintStableResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgMintStableResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgMintStableResponse proto.InternalMessageInfo - -func (m *MsgMintStableResponse) GetStable() types.Coin { - if m != nil { - return m.Stable - } - return types.Coin{} -} - -func (m *MsgMintStableResponse) GetUsedCoins() github_com_cosmos_cosmos_sdk_types.Coins { - if m != nil { - return m.UsedCoins - } - return nil -} - -func (m *MsgMintStableResponse) GetFeesPayed() github_com_cosmos_cosmos_sdk_types.Coins { - if m != nil { - return m.FeesPayed - } - return nil -} - -// MsgBurnStable allows users to burn NUSD in exchange for NIBI and collateral. -// The amount of NIBI and Collateral received depends on the current price set by -// the x/oracle library and the current collateral ratio. -type MsgBurnStable struct { - Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - Stable types.Coin `protobuf:"bytes,2,opt,name=stable,proto3" json:"stable"` -} - -func (m *MsgBurnStable) Reset() { *m = MsgBurnStable{} } -func (m *MsgBurnStable) String() string { return proto.CompactTextString(m) } -func (*MsgBurnStable) ProtoMessage() {} -func (*MsgBurnStable) Descriptor() ([]byte, []int) { - return fileDescriptor_7c52aa4b3b498950, []int{2} -} -func (m *MsgBurnStable) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgBurnStable) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgBurnStable.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgBurnStable) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgBurnStable.Merge(m, src) -} -func (m *MsgBurnStable) XXX_Size() int { - return m.Size() -} -func (m *MsgBurnStable) XXX_DiscardUnknown() { - xxx_messageInfo_MsgBurnStable.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgBurnStable proto.InternalMessageInfo - -func (m *MsgBurnStable) GetCreator() string { - if m != nil { - return m.Creator - } - return "" -} - -func (m *MsgBurnStable) GetStable() types.Coin { - if m != nil { - return m.Stable - } - return types.Coin{} -} - -// MsgBurnStableResponse specifies the amount of collateral and governance -// token the user will receive after their burn transaction. -type MsgBurnStableResponse struct { - Collateral types.Coin `protobuf:"bytes,1,opt,name=collateral,proto3" json:"collateral"` - Gov types.Coin `protobuf:"bytes,2,opt,name=gov,proto3" json:"gov"` - FeesPayed github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=fees_payed,json=feesPayed,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"fees_payed"` -} - -func (m *MsgBurnStableResponse) Reset() { *m = MsgBurnStableResponse{} } -func (m *MsgBurnStableResponse) String() string { return proto.CompactTextString(m) } -func (*MsgBurnStableResponse) ProtoMessage() {} -func (*MsgBurnStableResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_7c52aa4b3b498950, []int{3} -} -func (m *MsgBurnStableResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgBurnStableResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgBurnStableResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgBurnStableResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgBurnStableResponse.Merge(m, src) -} -func (m *MsgBurnStableResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgBurnStableResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgBurnStableResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgBurnStableResponse proto.InternalMessageInfo - -func (m *MsgBurnStableResponse) GetCollateral() types.Coin { - if m != nil { - return m.Collateral - } - return types.Coin{} -} - -func (m *MsgBurnStableResponse) GetGov() types.Coin { - if m != nil { - return m.Gov - } - return types.Coin{} -} - -func (m *MsgBurnStableResponse) GetFeesPayed() github_com_cosmos_cosmos_sdk_types.Coins { - if m != nil { - return m.FeesPayed - } - return nil -} - -// MsgRecollateralize -type MsgRecollateralize struct { - Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - Coll types.Coin `protobuf:"bytes,2,opt,name=coll,proto3" json:"coll"` -} - -func (m *MsgRecollateralize) Reset() { *m = MsgRecollateralize{} } -func (m *MsgRecollateralize) String() string { return proto.CompactTextString(m) } -func (*MsgRecollateralize) ProtoMessage() {} -func (*MsgRecollateralize) Descriptor() ([]byte, []int) { - return fileDescriptor_7c52aa4b3b498950, []int{4} -} -func (m *MsgRecollateralize) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgRecollateralize) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgRecollateralize.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgRecollateralize) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgRecollateralize.Merge(m, src) -} -func (m *MsgRecollateralize) XXX_Size() int { - return m.Size() -} -func (m *MsgRecollateralize) XXX_DiscardUnknown() { - xxx_messageInfo_MsgRecollateralize.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgRecollateralize proto.InternalMessageInfo - -func (m *MsgRecollateralize) GetCreator() string { - if m != nil { - return m.Creator - } - return "" -} - -func (m *MsgRecollateralize) GetColl() types.Coin { - if m != nil { - return m.Coll - } - return types.Coin{} -} - -// MsgRecollateralizeResponse is the output of a successful 'Recollateralize' -type MsgRecollateralizeResponse struct { - // Gov (sdk.Coin): Tokens rewarded to the caller in exchange for her - // collateral. - Gov types.Coin `protobuf:"bytes,1,opt,name=gov,proto3" json:"gov"` -} - -func (m *MsgRecollateralizeResponse) Reset() { *m = MsgRecollateralizeResponse{} } -func (m *MsgRecollateralizeResponse) String() string { return proto.CompactTextString(m) } -func (*MsgRecollateralizeResponse) ProtoMessage() {} -func (*MsgRecollateralizeResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_7c52aa4b3b498950, []int{5} -} -func (m *MsgRecollateralizeResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgRecollateralizeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgRecollateralizeResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgRecollateralizeResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgRecollateralizeResponse.Merge(m, src) -} -func (m *MsgRecollateralizeResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgRecollateralizeResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgRecollateralizeResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgRecollateralizeResponse proto.InternalMessageInfo - -func (m *MsgRecollateralizeResponse) GetGov() types.Coin { - if m != nil { - return m.Gov - } - return types.Coin{} -} - -// MsgBuyback -type MsgBuyback struct { - Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - // Gov (sdk.Coin): Tokens the caller wants to sell to the protocol in exchange - // for collateral. - Gov types.Coin `protobuf:"bytes,2,opt,name=gov,proto3" json:"gov"` -} - -func (m *MsgBuyback) Reset() { *m = MsgBuyback{} } -func (m *MsgBuyback) String() string { return proto.CompactTextString(m) } -func (*MsgBuyback) ProtoMessage() {} -func (*MsgBuyback) Descriptor() ([]byte, []int) { - return fileDescriptor_7c52aa4b3b498950, []int{6} -} -func (m *MsgBuyback) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgBuyback) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgBuyback.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgBuyback) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgBuyback.Merge(m, src) -} -func (m *MsgBuyback) XXX_Size() int { - return m.Size() -} -func (m *MsgBuyback) XXX_DiscardUnknown() { - xxx_messageInfo_MsgBuyback.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgBuyback proto.InternalMessageInfo - -func (m *MsgBuyback) GetCreator() string { - if m != nil { - return m.Creator - } - return "" -} - -func (m *MsgBuyback) GetGov() types.Coin { - if m != nil { - return m.Gov - } - return types.Coin{} -} - -// MsgBuybackResponse is the output of a successful 'Buyback' -type MsgBuybackResponse struct { - // Coll (sdk.Coin): Tokens sold to the caller in exchange for her collateral. - Coll types.Coin `protobuf:"bytes,1,opt,name=coll,proto3" json:"coll"` -} - -func (m *MsgBuybackResponse) Reset() { *m = MsgBuybackResponse{} } -func (m *MsgBuybackResponse) String() string { return proto.CompactTextString(m) } -func (*MsgBuybackResponse) ProtoMessage() {} -func (*MsgBuybackResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_7c52aa4b3b498950, []int{7} -} -func (m *MsgBuybackResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgBuybackResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgBuybackResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgBuybackResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgBuybackResponse.Merge(m, src) -} -func (m *MsgBuybackResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgBuybackResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgBuybackResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgBuybackResponse proto.InternalMessageInfo - -func (m *MsgBuybackResponse) GetColl() types.Coin { - if m != nil { - return m.Coll - } - return types.Coin{} -} - -func init() { - proto.RegisterType((*MsgMintStable)(nil), "nibiru.stablecoin.v1.MsgMintStable") - proto.RegisterType((*MsgMintStableResponse)(nil), "nibiru.stablecoin.v1.MsgMintStableResponse") - proto.RegisterType((*MsgBurnStable)(nil), "nibiru.stablecoin.v1.MsgBurnStable") - proto.RegisterType((*MsgBurnStableResponse)(nil), "nibiru.stablecoin.v1.MsgBurnStableResponse") - proto.RegisterType((*MsgRecollateralize)(nil), "nibiru.stablecoin.v1.MsgRecollateralize") - proto.RegisterType((*MsgRecollateralizeResponse)(nil), "nibiru.stablecoin.v1.MsgRecollateralizeResponse") - proto.RegisterType((*MsgBuyback)(nil), "nibiru.stablecoin.v1.MsgBuyback") - proto.RegisterType((*MsgBuybackResponse)(nil), "nibiru.stablecoin.v1.MsgBuybackResponse") -} - -func init() { proto.RegisterFile("nibiru/stablecoin/v1/tx.proto", fileDescriptor_7c52aa4b3b498950) } - -var fileDescriptor_7c52aa4b3b498950 = []byte{ - // 580 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x95, 0x31, 0x6f, 0x13, 0x31, - 0x14, 0xc7, 0xe3, 0x24, 0x6a, 0xd5, 0x87, 0x10, 0xd2, 0xa9, 0x48, 0xe9, 0x51, 0xae, 0xe1, 0x58, - 0x22, 0xa1, 0xda, 0x49, 0x3b, 0x30, 0x22, 0xa5, 0x13, 0x48, 0x01, 0x14, 0x26, 0x58, 0x2a, 0xdf, - 0xc5, 0x5c, 0x4d, 0x13, 0x3b, 0x3a, 0x3b, 0x51, 0xc3, 0xd8, 0x4f, 0x50, 0x89, 0x99, 0x1d, 0xf1, - 0x49, 0x3a, 0x56, 0x62, 0x61, 0x02, 0x94, 0xf0, 0x1d, 0x58, 0x91, 0x9d, 0x4b, 0x72, 0x6d, 0xda, - 0xe3, 0x32, 0x94, 0x29, 0x4e, 0xfc, 0x7f, 0xef, 0xfd, 0xde, 0xff, 0xd9, 0x0e, 0x3c, 0x14, 0x3c, - 0xe0, 0xf1, 0x80, 0x28, 0x4d, 0x83, 0x2e, 0x0b, 0x25, 0x17, 0x64, 0xd8, 0x20, 0xfa, 0x04, 0xf7, - 0x63, 0xa9, 0xa5, 0xb3, 0x39, 0xdd, 0xc6, 0x8b, 0x6d, 0x3c, 0x6c, 0xb8, 0x5e, 0x28, 0x55, 0x4f, - 0x2a, 0x12, 0x50, 0xc5, 0xc8, 0xb0, 0x11, 0x30, 0x4d, 0x1b, 0xc4, 0x6e, 0xda, 0x28, 0x77, 0x33, - 0x92, 0x91, 0xb4, 0x4b, 0x62, 0x56, 0xc9, 0xaf, 0xdb, 0x91, 0x94, 0x51, 0x97, 0x11, 0xda, 0xe7, - 0x84, 0x0a, 0x21, 0x35, 0xd5, 0x5c, 0x0a, 0x35, 0xdd, 0xf5, 0x03, 0xb8, 0xdb, 0x52, 0x51, 0x8b, - 0x0b, 0xfd, 0xc6, 0xd6, 0x72, 0x2a, 0xb0, 0x1e, 0xc6, 0x8c, 0x6a, 0x19, 0x57, 0x50, 0x15, 0xd5, - 0x36, 0xda, 0xb3, 0xaf, 0xce, 0x53, 0x58, 0x9b, 0xf2, 0x54, 0x8a, 0x55, 0x54, 0xbb, 0xb3, 0xb7, - 0x85, 0xa7, 0x3c, 0xd8, 0xf0, 0xe0, 0x84, 0x07, 0x1f, 0x48, 0x2e, 0x9a, 0xe5, 0xf3, 0x1f, 0x3b, - 0x85, 0x76, 0x22, 0xf7, 0xbf, 0x14, 0xe1, 0xfe, 0xa5, 0x22, 0x6d, 0xa6, 0xfa, 0x52, 0x28, 0x96, - 0x4a, 0x89, 0x56, 0x4a, 0xe9, 0x7c, 0x00, 0x18, 0x28, 0xd6, 0x39, 0x34, 0xdd, 0xab, 0x4a, 0xb1, - 0x5a, 0xca, 0x0e, 0xae, 0x9b, 0xe0, 0xaf, 0x3f, 0x77, 0x6a, 0x11, 0xd7, 0x47, 0x83, 0x00, 0x87, - 0xb2, 0x47, 0x12, 0x33, 0xa7, 0x1f, 0xbb, 0xaa, 0x73, 0x4c, 0xf4, 0xa8, 0xcf, 0x94, 0x0d, 0x50, - 0xed, 0x0d, 0x93, 0xde, 0x2e, 0x4d, 0xad, 0xf7, 0x8c, 0xa9, 0xc3, 0x3e, 0x1d, 0xb1, 0x4e, 0xa5, - 0x74, 0x0b, 0xb5, 0x4c, 0xfa, 0xd7, 0x26, 0x7b, 0x32, 0x8e, 0xe6, 0x20, 0x16, 0xb7, 0x37, 0x8e, - 0x3f, 0xc8, 0x8e, 0x63, 0x51, 0x64, 0x3e, 0x8e, 0x67, 0x00, 0xa1, 0xec, 0x76, 0xa9, 0x66, 0x31, - 0xed, 0xe6, 0x1d, 0x49, 0x2a, 0xc4, 0x69, 0x40, 0x29, 0x92, 0xc3, 0xbc, 0x40, 0x46, 0xfb, 0x5f, - 0xdd, 0x0d, 0xc1, 0x69, 0xa9, 0xa8, 0xcd, 0x16, 0xc4, 0xfc, 0x63, 0x96, 0xc5, 0xfb, 0x50, 0x36, - 0xd2, 0xbc, 0xfd, 0x58, 0xb1, 0xff, 0x0a, 0xdc, 0xe5, 0x22, 0x73, 0x8b, 0x13, 0x87, 0x50, 0x7e, - 0x87, 0xfc, 0xb7, 0x00, 0x76, 0x5c, 0xa3, 0x80, 0x86, 0xc7, 0x19, 0xb4, 0xab, 0x9b, 0xef, 0x3f, - 0xb7, 0x86, 0x24, 0xa9, 0xe7, 0x8c, 0xb3, 0xb6, 0xd1, 0x0a, 0x6d, 0xef, 0x7d, 0x2e, 0x43, 0xa9, - 0xa5, 0x22, 0xe7, 0x14, 0x01, 0xa4, 0x9e, 0x93, 0xc7, 0xf8, 0xba, 0xa7, 0x0c, 0x5f, 0x7a, 0x0e, - 0xdc, 0x27, 0x39, 0x44, 0x33, 0x3a, 0xdf, 0x3f, 0xfd, 0xf6, 0xfb, 0x53, 0x71, 0xdb, 0x77, 0xc9, - 0xf2, 0x1b, 0xda, 0xe3, 0x42, 0xef, 0xaa, 0xd0, 0x42, 0xa4, 0x2e, 0xd1, 0xcd, 0x10, 0x0b, 0x51, - 0x06, 0xc4, 0xf2, 0x4d, 0xc9, 0x84, 0x08, 0x06, 0xb1, 0x30, 0x10, 0x67, 0x08, 0xee, 0x5d, 0x3d, - 0x6b, 0xb5, 0x1b, 0x8b, 0x5c, 0x51, 0xba, 0xf5, 0xbc, 0xca, 0x39, 0xd3, 0x23, 0xcb, 0xf4, 0xc0, - 0xdf, 0xba, 0x86, 0x29, 0xb6, 0x31, 0xce, 0x08, 0xd6, 0x67, 0xe7, 0xa8, 0x9a, 0xd1, 0xae, 0x55, - 0xb8, 0xb5, 0x7f, 0x29, 0x72, 0xba, 0x61, 0xb5, 0xcd, 0x17, 0xe7, 0x63, 0x0f, 0x5d, 0x8c, 0x3d, - 0xf4, 0x6b, 0xec, 0xa1, 0xb3, 0x89, 0x57, 0xb8, 0x98, 0x78, 0x85, 0xef, 0x13, 0xaf, 0xf0, 0xae, - 0x9e, 0xba, 0xca, 0x2f, 0x6d, 0xfc, 0xc1, 0x11, 0xe5, 0x62, 0x96, 0xeb, 0x24, 0x9d, 0xcd, 0x5e, - 0xec, 0x60, 0xcd, 0xfe, 0x77, 0xed, 0xff, 0x0d, 0x00, 0x00, 0xff, 0xff, 0xa1, 0x81, 0x2d, 0x97, - 0x46, 0x07, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// MsgClient is the client API for Msg service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type MsgClient interface { - // MintStable defines a method for trading a mixture of GOV and COLL to mint - // an equivalent value of stablecoins. - MintStable(ctx context.Context, in *MsgMintStable, opts ...grpc.CallOption) (*MsgMintStableResponse, error) - // BurnStable defines a method for redeeming/burning stablecoins to receive an - // equivalent value as a mixture of governance and collateral tokens. - BurnStable(ctx context.Context, in *MsgBurnStable, opts ...grpc.CallOption) (*MsgBurnStableResponse, error) - // Recollateralize defines a method for manually adding collateral to the - // protocol in exchange for an equivalent stablecoin value in governance tokens - // plus a small bonus. - Recollateralize(ctx context.Context, in *MsgRecollateralize, opts ...grpc.CallOption) (*MsgRecollateralizeResponse, error) - // Buyback defines a method for manually adding NIBI to the protocol - // in exchange for an equivalent stablecoin value in collateral, effectively - // executing a share buyback for Nibiru Chain. The NIBI purchased by the protocol - // is then burned, distributing value to all NIBI hodlers. - Buyback(ctx context.Context, in *MsgBuyback, opts ...grpc.CallOption) (*MsgBuybackResponse, error) -} - -type msgClient struct { - cc grpc1.ClientConn -} - -func NewMsgClient(cc grpc1.ClientConn) MsgClient { - return &msgClient{cc} -} - -func (c *msgClient) MintStable(ctx context.Context, in *MsgMintStable, opts ...grpc.CallOption) (*MsgMintStableResponse, error) { - out := new(MsgMintStableResponse) - err := c.cc.Invoke(ctx, "/nibiru.stablecoin.v1.Msg/MintStable", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) BurnStable(ctx context.Context, in *MsgBurnStable, opts ...grpc.CallOption) (*MsgBurnStableResponse, error) { - out := new(MsgBurnStableResponse) - err := c.cc.Invoke(ctx, "/nibiru.stablecoin.v1.Msg/BurnStable", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) Recollateralize(ctx context.Context, in *MsgRecollateralize, opts ...grpc.CallOption) (*MsgRecollateralizeResponse, error) { - out := new(MsgRecollateralizeResponse) - err := c.cc.Invoke(ctx, "/nibiru.stablecoin.v1.Msg/Recollateralize", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) Buyback(ctx context.Context, in *MsgBuyback, opts ...grpc.CallOption) (*MsgBuybackResponse, error) { - out := new(MsgBuybackResponse) - err := c.cc.Invoke(ctx, "/nibiru.stablecoin.v1.Msg/Buyback", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// MsgServer is the server API for Msg service. -type MsgServer interface { - // MintStable defines a method for trading a mixture of GOV and COLL to mint - // an equivalent value of stablecoins. - MintStable(context.Context, *MsgMintStable) (*MsgMintStableResponse, error) - // BurnStable defines a method for redeeming/burning stablecoins to receive an - // equivalent value as a mixture of governance and collateral tokens. - BurnStable(context.Context, *MsgBurnStable) (*MsgBurnStableResponse, error) - // Recollateralize defines a method for manually adding collateral to the - // protocol in exchange for an equivalent stablecoin value in governance tokens - // plus a small bonus. - Recollateralize(context.Context, *MsgRecollateralize) (*MsgRecollateralizeResponse, error) - // Buyback defines a method for manually adding NIBI to the protocol - // in exchange for an equivalent stablecoin value in collateral, effectively - // executing a share buyback for Nibiru Chain. The NIBI purchased by the protocol - // is then burned, distributing value to all NIBI hodlers. - Buyback(context.Context, *MsgBuyback) (*MsgBuybackResponse, error) -} - -// UnimplementedMsgServer can be embedded to have forward compatible implementations. -type UnimplementedMsgServer struct { -} - -func (*UnimplementedMsgServer) MintStable(ctx context.Context, req *MsgMintStable) (*MsgMintStableResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method MintStable not implemented") -} -func (*UnimplementedMsgServer) BurnStable(ctx context.Context, req *MsgBurnStable) (*MsgBurnStableResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method BurnStable not implemented") -} -func (*UnimplementedMsgServer) Recollateralize(ctx context.Context, req *MsgRecollateralize) (*MsgRecollateralizeResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Recollateralize not implemented") -} -func (*UnimplementedMsgServer) Buyback(ctx context.Context, req *MsgBuyback) (*MsgBuybackResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Buyback not implemented") -} - -func RegisterMsgServer(s grpc1.Server, srv MsgServer) { - s.RegisterService(&_Msg_serviceDesc, srv) -} - -func _Msg_MintStable_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgMintStable) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).MintStable(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/nibiru.stablecoin.v1.Msg/MintStable", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).MintStable(ctx, req.(*MsgMintStable)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_BurnStable_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgBurnStable) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).BurnStable(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/nibiru.stablecoin.v1.Msg/BurnStable", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).BurnStable(ctx, req.(*MsgBurnStable)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_Recollateralize_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgRecollateralize) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).Recollateralize(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/nibiru.stablecoin.v1.Msg/Recollateralize", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).Recollateralize(ctx, req.(*MsgRecollateralize)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_Buyback_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgBuyback) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).Buyback(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/nibiru.stablecoin.v1.Msg/Buyback", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).Buyback(ctx, req.(*MsgBuyback)) - } - return interceptor(ctx, in, info, handler) -} - -var _Msg_serviceDesc = grpc.ServiceDesc{ - ServiceName: "nibiru.stablecoin.v1.Msg", - HandlerType: (*MsgServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "MintStable", - Handler: _Msg_MintStable_Handler, - }, - { - MethodName: "BurnStable", - Handler: _Msg_BurnStable_Handler, - }, - { - MethodName: "Recollateralize", - Handler: _Msg_Recollateralize_Handler, - }, - { - MethodName: "Buyback", - Handler: _Msg_Buyback_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "nibiru/stablecoin/v1/tx.proto", -} - -func (m *MsgMintStable) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgMintStable) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgMintStable) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Stable.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.Creator) > 0 { - i -= len(m.Creator) - copy(dAtA[i:], m.Creator) - i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgMintStableResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgMintStableResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgMintStableResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.FeesPayed) > 0 { - for iNdEx := len(m.FeesPayed) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.FeesPayed[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - } - if len(m.UsedCoins) > 0 { - for iNdEx := len(m.UsedCoins) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.UsedCoins[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - { - size, err := m.Stable.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *MsgBurnStable) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgBurnStable) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgBurnStable) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Stable.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.Creator) > 0 { - i -= len(m.Creator) - copy(dAtA[i:], m.Creator) - i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgBurnStableResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgBurnStableResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgBurnStableResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.FeesPayed) > 0 { - for iNdEx := len(m.FeesPayed) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.FeesPayed[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - } - { - size, err := m.Gov.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size, err := m.Collateral.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *MsgRecollateralize) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgRecollateralize) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgRecollateralize) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Coll.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.Creator) > 0 { - i -= len(m.Creator) - copy(dAtA[i:], m.Creator) - i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgRecollateralizeResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgRecollateralizeResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgRecollateralizeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Gov.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *MsgBuyback) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgBuyback) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgBuyback) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Gov.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.Creator) > 0 { - i -= len(m.Creator) - copy(dAtA[i:], m.Creator) - i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgBuybackResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgBuybackResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgBuybackResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Coll.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func encodeVarintTx(dAtA []byte, offset int, v uint64) int { - offset -= sovTx(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *MsgMintStable) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Creator) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.Stable.Size() - n += 1 + l + sovTx(uint64(l)) - return n -} - -func (m *MsgMintStableResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Stable.Size() - n += 1 + l + sovTx(uint64(l)) - if len(m.UsedCoins) > 0 { - for _, e := range m.UsedCoins { - l = e.Size() - n += 1 + l + sovTx(uint64(l)) - } - } - if len(m.FeesPayed) > 0 { - for _, e := range m.FeesPayed { - l = e.Size() - n += 1 + l + sovTx(uint64(l)) - } - } - return n -} - -func (m *MsgBurnStable) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Creator) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.Stable.Size() - n += 1 + l + sovTx(uint64(l)) - return n -} - -func (m *MsgBurnStableResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Collateral.Size() - n += 1 + l + sovTx(uint64(l)) - l = m.Gov.Size() - n += 1 + l + sovTx(uint64(l)) - if len(m.FeesPayed) > 0 { - for _, e := range m.FeesPayed { - l = e.Size() - n += 1 + l + sovTx(uint64(l)) - } - } - return n -} - -func (m *MsgRecollateralize) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Creator) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.Coll.Size() - n += 1 + l + sovTx(uint64(l)) - return n -} - -func (m *MsgRecollateralizeResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Gov.Size() - n += 1 + l + sovTx(uint64(l)) - return n -} - -func (m *MsgBuyback) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Creator) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.Gov.Size() - n += 1 + l + sovTx(uint64(l)) - return n -} - -func (m *MsgBuybackResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Coll.Size() - n += 1 + l + sovTx(uint64(l)) - return n -} - -func sovTx(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozTx(x uint64) (n int) { - return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *MsgMintStable) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgMintStable: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgMintStable: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Creator = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Stable", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Stable.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgMintStableResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgMintStableResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgMintStableResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Stable", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Stable.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UsedCoins", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.UsedCoins = append(m.UsedCoins, types.Coin{}) - if err := m.UsedCoins[len(m.UsedCoins)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FeesPayed", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.FeesPayed = append(m.FeesPayed, types.Coin{}) - if err := m.FeesPayed[len(m.FeesPayed)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgBurnStable) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgBurnStable: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgBurnStable: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Creator = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Stable", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Stable.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgBurnStableResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgBurnStableResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgBurnStableResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Collateral", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Collateral.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Gov", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Gov.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FeesPayed", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.FeesPayed = append(m.FeesPayed, types.Coin{}) - if err := m.FeesPayed[len(m.FeesPayed)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgRecollateralize) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgRecollateralize: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgRecollateralize: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Creator = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Coll", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Coll.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgRecollateralizeResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgRecollateralizeResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgRecollateralizeResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Gov", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Gov.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgBuyback) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgBuyback: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgBuyback: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Creator = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Gov", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Gov.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgBuybackResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgBuybackResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgBuybackResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Coll", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Coll.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipTx(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTx - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTx - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTx - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthTx - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupTx - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthTx - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/stablecoin/types/tx.pb.gw.go b/x/stablecoin/types/tx.pb.gw.go deleted file mode 100644 index c4534226b..000000000 --- a/x/stablecoin/types/tx.pb.gw.go +++ /dev/null @@ -1,420 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: nibiru/stablecoin/v1/tx.proto - -/* -Package types is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package types - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Msg_MintStable_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Msg_MintStable_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq MsgMintStable - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_MintStable_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.MintStable(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Msg_MintStable_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq MsgMintStable - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_MintStable_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.MintStable(ctx, &protoReq) - return msg, metadata, err - -} - -var ( - filter_Msg_BurnStable_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Msg_BurnStable_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq MsgBurnStable - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_BurnStable_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.BurnStable(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Msg_BurnStable_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq MsgBurnStable - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_BurnStable_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.BurnStable(ctx, &protoReq) - return msg, metadata, err - -} - -var ( - filter_Msg_Recollateralize_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Msg_Recollateralize_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq MsgRecollateralize - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Recollateralize_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Recollateralize(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Msg_Recollateralize_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq MsgRecollateralize - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Recollateralize_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Recollateralize(ctx, &protoReq) - return msg, metadata, err - -} - -var ( - filter_Msg_Buyback_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Msg_Buyback_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq MsgBuyback - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Buyback_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Buyback(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Msg_Buyback_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq MsgBuyback - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Buyback_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Buyback(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux". -// UnaryRPC :call MsgServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead. -func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error { - - mux.Handle("POST", pattern_Msg_MintStable_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Msg_MintStable_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_MintStable_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("POST", pattern_Msg_BurnStable_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Msg_BurnStable_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_BurnStable_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("POST", pattern_Msg_Recollateralize_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Msg_Recollateralize_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Recollateralize_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("POST", pattern_Msg_Buyback_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Msg_Buyback_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Buyback_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterMsgHandler(ctx, mux, conn) -} - -// RegisterMsgHandler registers the http handlers for service Msg to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn)) -} - -// RegisterMsgHandlerClient registers the http handlers for service Msg -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "MsgClient" to call the correct interceptors. -func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error { - - mux.Handle("POST", pattern_Msg_MintStable_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Msg_MintStable_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_MintStable_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("POST", pattern_Msg_BurnStable_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Msg_BurnStable_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_BurnStable_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("POST", pattern_Msg_Recollateralize_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Msg_Recollateralize_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Recollateralize_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("POST", pattern_Msg_Buyback_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Msg_Buyback_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Buyback_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Msg_MintStable_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"nibiru", "stablecoin", "mint-sc"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Msg_BurnStable_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"nibiru", "stablecoin", "burn-sc"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Msg_Recollateralize_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"nibiru", "stablecoin", "recoll"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Msg_Buyback_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"nibiru", "stablecoin", "buyback"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Msg_MintStable_0 = runtime.ForwardResponseMessage - - forward_Msg_BurnStable_0 = runtime.ForwardResponseMessage - - forward_Msg_Recollateralize_0 = runtime.ForwardResponseMessage - - forward_Msg_Buyback_0 = runtime.ForwardResponseMessage -) diff --git a/x/stablecoin/types/types.go b/x/stablecoin/types/types.go deleted file mode 100644 index ab1254f4c..000000000 --- a/x/stablecoin/types/types.go +++ /dev/null @@ -1 +0,0 @@ -package types