Documentation ¶
Overview ¶
Package keeper that mints Nibiru stablecoins, maintains their price stability, and ensures that the protocol remains collateralized enough for stablecoins to be redeemed.
Index ¶
- Variables
- func NeededCollAmtGivenGov(govAmt sdk.Int, priceGov sdk.Dec, priceColl sdk.Dec, collRatio sdk.Dec) (neededCollAmt sdk.Int, mintableStableAmt sdk.Int)
- func NeededGovAmtGivenColl(collAmt sdk.Int, priceGov sdk.Dec, priceColl sdk.Dec, collRatio sdk.Dec) (neededGovAmt sdk.Int, mintableStableAmt sdk.Int)
- func NewMsgServerImpl(keeper Keeper) types.MsgServer
- type Hooks
- type Keeper
- func (k Keeper) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumber uint64)
- func (k Keeper) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNumber uint64)
- func (k Keeper) BurnStable(goCtx context.Context, msg *types.MsgBurnStable) (*types.MsgBurnStableResponse, error)
- func (k Keeper) Buyback(goCtx context.Context, msg *types.MsgBuyback) (response *types.MsgBuybackResponse, err error)
- func (k *Keeper) BuybackGovAmtForTargetCollRatio(ctx sdk.Context) (neededGovAmt sdk.Int, err error)
- func (k Keeper) CheckEnoughBalances(ctx sdk.Context, coins sdk.Coins, account sdk.AccAddress) error
- func (k Keeper) CirculatingSupplies(goCtx context.Context, req *types.QueryCirculatingSupplies) (*types.QueryCirculatingSuppliesResponse, error)
- func (k *Keeper) CollAmtFromBuyback(ctx sdk.Context, valUSD sdk.Dec) (collAmt sdk.Int, err error)
- func (k *Keeper) CollAmtFromFullBuyback(ctx sdk.Context) (collAmt sdk.Int, err error)
- func (k *Keeper) EvaluateCollRatio(ctx sdk.Context) (err error)
- func (k *Keeper) GetCollRatio(ctx sdk.Context) (collRatio sdk.Dec)
- func (k Keeper) GetGovMarketCap(ctx sdk.Context) (sdk.Int, error)
- func (k Keeper) GetLiquidityRatio(ctx sdk.Context) (sdk.Dec, error)
- func (k Keeper) GetLiquidityRatioBands(ctx sdk.Context) (lowBand sdk.Dec, upBand sdk.Dec, err error)
- func (k Keeper) GetModuleAccountBalance(ctx sdk.Context) sdk.Coin
- func (k *Keeper) GetParams(ctx sdk.Context) (params types.Params)
- func (k Keeper) GetStableMarketCap(ctx sdk.Context) sdk.Int
- func (k Keeper) GetSupplyNIBI(ctx sdk.Context) sdk.Coin
- func (k Keeper) GetSupplyNUSD(ctx sdk.Context) sdk.Coin
- func (k *Keeper) GovAmtFromFullRecollateralize(ctx sdk.Context) (govOut sdk.Int, err error)
- func (k *Keeper) GovAmtFromRecollateralize(ctx sdk.Context, inUSD sdk.Dec) (govOut sdk.Int, err error)
- func (k Keeper) Hooks() Hooks
- func (k Keeper) LiquidityRatioInfo(goCtx context.Context, req *types.QueryLiquidityRatioInfoRequest) (res *types.QueryLiquidityRatioInfoResponse, err error)
- func (k Keeper) Logger(ctx sdk.Context) log.Logger
- func (k Keeper) MintStable(goCtx context.Context, msg *types.MsgMintStable) (*types.MsgMintStableResponse, error)
- func (k Keeper) ModuleAccountBalances(goCtx context.Context, req *types.QueryModuleAccountBalances) (*types.QueryModuleAccountBalancesResponse, error)
- func (k Keeper) Params(goCtx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error)
- func (k Keeper) Recollateralize(goCtx context.Context, msg *types.MsgRecollateralize) (response *types.MsgRecollateralizeResponse, err error)
- func (k *Keeper) RecollateralizeCollAmtForTargetCollRatio(ctx sdk.Context) (neededCollAmount sdk.Int, err error)
- func (k *Keeper) SetCollRatio(ctx sdk.Context, collRatio sdk.Dec) (err error)
- func (k *Keeper) SetParams(ctx sdk.Context, params types.Params)
- func (k *Keeper) StableRequiredForTargetCollRatio(ctx sdk.Context) (neededStable sdk.Dec, err error)
Constants ¶
This section is empty.
Variables ¶
var LiquidityRatioBands = sdk.MustNewDecFromStr("0.001")
Functions ¶
func NeededCollAmtGivenGov ¶
func NeededCollAmtGivenGov( govAmt sdk.Int, priceGov sdk.Dec, priceColl sdk.Dec, collRatio sdk.Dec) (neededCollAmt sdk.Int, mintableStableAmt sdk.Int)
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 NeededGovAmtGivenColl ¶
func NeededGovAmtGivenColl( collAmt sdk.Int, priceGov sdk.Dec, priceColl sdk.Dec, collRatio sdk.Dec) (neededGovAmt sdk.Int, mintableStableAmt sdk.Int)
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 NewMsgServerImpl ¶
NewMsgServerImpl returns an implementation of the MsgServer interface for the provided Keeper.
Types ¶
type Hooks ¶
type Hooks struct {
// contains filtered or unexported fields
}
Hooks wrapper struct for incentives keeper.
func (Hooks) AfterEpochEnd ¶
AfterEpochEnd epochs hooks
type Keeper ¶
type Keeper struct { ParamSubspace paramtypes.Subspace AccountKeeper types.AccountKeeper BankKeeper types.BankKeeper OracleKeeper types.OracleKeeper SpotKeeper types.SpotKeeper // contains filtered or unexported fields }
func NewKeeper ¶
func NewKeeper( cdc codec.BinaryCodec, storeKey, memKey sdk.StoreKey, paramSubspace paramtypes.Subspace, accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper, priceKeeper types.OracleKeeper, spotKeeper types.SpotKeeper, ) Keeper
NewKeeper Creates a new x/stablecoin Keeper instance.
func (Keeper) AfterEpochEnd ¶
func (Keeper) BeforeEpochStart ¶
func (Keeper) BurnStable ¶
func (k Keeper) BurnStable(goCtx context.Context, msg *types.MsgBurnStable, ) (*types.MsgBurnStableResponse, error)
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 (Keeper) Buyback ¶
func (k Keeper) Buyback( goCtx context.Context, msg *types.MsgBuyback, ) (response *types.MsgBuybackResponse, err error)
Buyback buys governance tokens back from the user in order to release over collateralization.
func (*Keeper) BuybackGovAmtForTargetCollRatio ¶
func (k *Keeper) BuybackGovAmtForTargetCollRatio( ctx sdk.Context, ) (neededGovAmt sdk.Int, err error)
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 (Keeper) CheckEnoughBalances ¶
CheckEnoughBalances checks if account address has enough balance of coins.
func (Keeper) CirculatingSupplies ¶ added in v0.1.0
func (k Keeper) CirculatingSupplies( goCtx context.Context, req *types.QueryCirculatingSupplies, ) (*types.QueryCirculatingSuppliesResponse, error)
func (*Keeper) CollAmtFromBuyback ¶
func (k *Keeper) CollAmtFromBuyback( ctx sdk.Context, valUSD sdk.Dec, ) (collAmt sdk.Int, err error)
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 (*Keeper) CollAmtFromFullBuyback ¶
TODO hygiene: cover with test cases | https://github.com/NibiruChain/nibiru/issues/537
func (*Keeper) EvaluateCollRatio ¶
Evaluate Coll ratio updates the collateral ratio if the price is out of the bounds.
func (*Keeper) GetCollRatio ¶
GetCollRatio queries the 'collRatio'.
func (Keeper) GetLiquidityRatio ¶
GetLiquidityRatio returns the liquidity ratio defined as govMarketCap / stableMarketCap
func (Keeper) GetLiquidityRatioBands ¶
func (Keeper) GetModuleAccountBalance ¶
GetModuleAccountBalance gets the airdrop coin balance of module account.
func (*Keeper) GovAmtFromFullRecollateralize ¶
func (*Keeper) GovAmtFromRecollateralize ¶
func (k *Keeper) GovAmtFromRecollateralize( ctx sdk.Context, inUSD sdk.Dec, ) (govOut sdk.Int, err error)
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 (Keeper) LiquidityRatioInfo ¶ added in v0.1.0
func (k Keeper) LiquidityRatioInfo( goCtx context.Context, req *types.QueryLiquidityRatioInfoRequest, ) (res *types.QueryLiquidityRatioInfoResponse, err error)
func (Keeper) MintStable ¶
func (k Keeper) MintStable( goCtx context.Context, msg *types.MsgMintStable, ) (*types.MsgMintStableResponse, error)
MintStable mints stable coins given collateral (COLL) and governance (GOV)
func (Keeper) ModuleAccountBalances ¶ added in v0.1.0
func (k Keeper) ModuleAccountBalances( goCtx context.Context, req *types.QueryModuleAccountBalances, ) (*types.QueryModuleAccountBalancesResponse, error)
func (Keeper) Params ¶
func (k Keeper) Params( goCtx context.Context, req *types.QueryParamsRequest, ) (*types.QueryParamsResponse, error)
func (Keeper) Recollateralize ¶
func (k Keeper) Recollateralize( goCtx context.Context, msg *types.MsgRecollateralize, ) (response *types.MsgRecollateralizeResponse, err error)
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 (*Keeper) RecollateralizeCollAmtForTargetCollRatio ¶
func (*Keeper) SetCollRatio ¶
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%).