Documentation ¶
Index ¶
- func CalculateInterestFactor(perSecondInterestRate sdk.Dec, secondsElapsed sdkmath.Int) sdk.Dec
- func FilterCDPs(ctx sdk.Context, k Keeper, params types.QueryCdpsParams) (types.AugmentedCDPs, error)
- func FindIntersection(x types.CDPs, y types.CDPs) types.CDPs
- func GrpcFilterCDPs(ctx sdk.Context, k Keeper, req types.QueryCdpsRequest) (types.CDPResponses, error)
- func NewMsgServerImpl(keeper Keeper) types.MsgServer
- func NewQuerier(keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier
- func NewQueryServerImpl(keeper Keeper) types.QueryServer
- type Keeper
- func (k Keeper) AccumulateInterest(ctx sdk.Context, ctype string) error
- func (k Keeper) AddCdp(ctx sdk.Context, owner sdk.AccAddress, collateral sdk.Coin, principal sdk.Coin, ...) error
- func (k Keeper) AddPrincipal(ctx sdk.Context, owner sdk.AccAddress, collateralType string, ...) error
- func (k Keeper) AfterCDPCreated(ctx sdk.Context, cdp types.CDP)
- func (k Keeper) ApplyLiquidationPenalty(ctx sdk.Context, collateralType string, debt sdkmath.Int) sdkmath.Int
- func (k Keeper) AttemptKeeperLiquidation(ctx sdk.Context, keeper, owner sdk.AccAddress, collateralType string) error
- func (k Keeper) AuctionCollateral(ctx sdk.Context, deposits types.Deposits, collateralType string, ...) error
- func (k Keeper) BeforeCDPModified(ctx sdk.Context, cdp types.CDP)
- func (k Keeper) BurnDebtCoins(ctx sdk.Context, moduleAccount string, denom string, paymentCoins sdk.Coin) error
- func (k Keeper) CalculateCollateralToDebtRatio(ctx sdk.Context, collateral sdk.Coin, collateralType string, debt sdk.Coin) sdk.Dec
- func (k Keeper) CalculateCollateralizationRatio(ctx sdk.Context, collateral sdk.Coin, collateralType string, ...) (sdk.Dec, error)
- func (k Keeper) CalculateCollateralizationRatioFromAbsoluteRatio(ctx sdk.Context, collateralType string, absoluteRatio sdk.Dec, ...) (sdk.Dec, error)
- func (k Keeper) CalculateNewInterest(ctx sdk.Context, cdp types.CDP) sdk.Coin
- func (k Keeper) CdpCollateralRatioIndexIterator(ctx sdk.Context, collateralType string, targetRatio sdk.Dec) sdk.Iterator
- func (k Keeper) CdpDenomIndexIterator(ctx sdk.Context, collateralType string) sdk.Iterator
- func (k Keeper) CreateAuctionsFromDeposit(ctx sdk.Context, collateral sdk.Coin, collateralType string, ...) error
- func (k Keeper) DecrementTotalPrincipal(ctx sdk.Context, collateralType string, principal sdk.Coin)
- func (k Keeper) DeleteCDP(ctx sdk.Context, cdp types.CDP) error
- func (k Keeper) DeleteCdpAndCollateralRatioIndex(ctx sdk.Context, cdp types.CDP) error
- func (k Keeper) DeleteDeposit(ctx sdk.Context, cdpID uint64, depositor sdk.AccAddress)
- func (k Keeper) DepositCollateral(ctx sdk.Context, owner, depositor sdk.AccAddress, collateral sdk.Coin, ...) error
- func (k Keeper) GetAllCdps(ctx sdk.Context) (cdps types.CDPs)
- func (k Keeper) GetAllCdpsByCollateralType(ctx sdk.Context, collateralType string) (cdps types.CDPs)
- func (k Keeper) GetAllCdpsByCollateralTypeAndRatio(ctx sdk.Context, collateralType string, targetRatio sdk.Dec) (cdps types.CDPs)
- func (k Keeper) GetCDP(ctx sdk.Context, collateralType string, cdpID uint64) (types.CDP, bool)
- func (k Keeper) GetCdpByOwnerAndCollateralType(ctx sdk.Context, owner sdk.AccAddress, collateralType string) (types.CDP, bool)
- func (k Keeper) GetCdpID(ctx sdk.Context, owner sdk.AccAddress, collateralType string) (uint64, bool)
- func (k Keeper) GetCdpIdsByOwner(ctx sdk.Context, owner sdk.AccAddress) ([]uint64, bool)
- func (k Keeper) GetCollateral(ctx sdk.Context, collateralType string) (types.CollateralParam, bool)
- func (k Keeper) GetCollateralTypes(ctx sdk.Context) []string
- func (k Keeper) GetDebtDenom(ctx sdk.Context) string
- func (k Keeper) GetDebtParam(ctx sdk.Context, denom string) (types.DebtParam, bool)
- func (k Keeper) GetDeposit(ctx sdk.Context, cdpID uint64, depositor sdk.AccAddress) (deposit types.Deposit, found bool)
- func (k Keeper) GetDeposits(ctx sdk.Context, cdpID uint64) (deposits types.Deposits)
- func (k Keeper) GetGovDenom(ctx sdk.Context) string
- func (k Keeper) GetInterestFactor(ctx sdk.Context, ctype string) (sdk.Dec, bool)
- func (k Keeper) GetMarketStatus(ctx sdk.Context, marketID string) bool
- func (k Keeper) GetNextCdpID(ctx sdk.Context) (id uint64)
- func (k Keeper) GetParams(ctx sdk.Context) types.Params
- func (k Keeper) GetPreviousAccrualTime(ctx sdk.Context, ctype string) (time.Time, bool)
- func (k Keeper) GetSliceOfCDPsByRatioAndType(ctx sdk.Context, cutoffCount sdkmath.Int, targetRatio sdk.Dec, ...) (cdps types.CDPs)
- func (k Keeper) GetTotalDebt(ctx sdk.Context, accountName string) sdkmath.Int
- func (k Keeper) GetTotalPrincipal(ctx sdk.Context, collateralType, principalDenom string) (total sdkmath.Int)
- func (k Keeper) GetTotalSurplus(ctx sdk.Context, accountName string) sdkmath.Int
- func (k Keeper) IncrementTotalPrincipal(ctx sdk.Context, collateralType string, principal sdk.Coin)
- func (k Keeper) IndexCdpByCollateralRatio(ctx sdk.Context, collateralType string, id uint64, collateralRatio sdk.Dec)
- func (k Keeper) IndexCdpByOwner(ctx sdk.Context, cdp types.CDP)
- func (k Keeper) IterateAllCdps(ctx sdk.Context, cb func(cdp types.CDP) (stop bool))
- func (k Keeper) IterateCdpsByCollateralRatio(ctx sdk.Context, collateralType string, targetRatio sdk.Dec, ...)
- func (k Keeper) IterateCdpsByCollateralType(ctx sdk.Context, collateralType string, cb func(cdp types.CDP) (stop bool))
- func (k Keeper) IterateDeposits(ctx sdk.Context, cdpID uint64, cb func(deposit types.Deposit) (stop bool))
- func (k Keeper) LiquidateCdps(ctx sdk.Context, marketID string, collateralType string, ...) error
- func (k Keeper) LoadAugmentedCDP(ctx sdk.Context, cdp types.CDP) types.AugmentedCDP
- func (k Keeper) LoadCDPResponse(ctx sdk.Context, cdp types.CDP) types.CDPResponse
- func (k Keeper) MintDebtCoins(ctx sdk.Context, moduleAccount string, denom string, principalCoins sdk.Coin) error
- func (k Keeper) NetSurplusAndDebt(ctx sdk.Context) error
- func (k Keeper) RemoveCdpCollateralRatioIndex(ctx sdk.Context, collateralType string, id uint64, collateralRatio sdk.Dec)
- func (k Keeper) RemoveCdpOwnerIndex(ctx sdk.Context, cdp types.CDP)
- func (k Keeper) RepayPrincipal(ctx sdk.Context, owner sdk.AccAddress, collateralType string, payment sdk.Coin) error
- func (k Keeper) ReturnCollateral(ctx sdk.Context, cdp types.CDP)
- func (k Keeper) RunSurplusAndDebtAuctions(ctx sdk.Context) error
- func (k Keeper) SeizeCollateral(ctx sdk.Context, cdp types.CDP) error
- func (k Keeper) SetCDP(ctx sdk.Context, cdp types.CDP) error
- func (k Keeper) SetCdpAndCollateralRatioIndex(ctx sdk.Context, cdp types.CDP, ratio sdk.Dec) error
- func (k Keeper) SetDebtDenom(ctx sdk.Context, denom string)
- func (k Keeper) SetDeposit(ctx sdk.Context, deposit types.Deposit)
- func (k Keeper) SetGovDenom(ctx sdk.Context, denom string)
- func (k *Keeper) SetHooks(hooks types.CDPHooks) *Keeper
- func (k Keeper) SetInterestFactor(ctx sdk.Context, ctype string, interestFactor sdk.Dec)
- func (k Keeper) SetMarketStatus(ctx sdk.Context, marketID string, up bool)
- func (k Keeper) SetNextCdpID(ctx sdk.Context, id uint64)
- func (k Keeper) SetParams(ctx sdk.Context, params types.Params)
- func (k Keeper) SetPreviousAccrualTime(ctx sdk.Context, ctype string, previousAccrualTime time.Time)
- func (k Keeper) SetTotalPrincipal(ctx sdk.Context, collateralType, principalDenom string, total sdkmath.Int)
- func (k Keeper) SynchronizeInterest(ctx sdk.Context, cdp types.CDP) types.CDP
- func (k Keeper) SynchronizeInterestForRiskyCDPs(ctx sdk.Context, slice sdkmath.Int, targetRatio sdk.Dec, collateralType string) error
- func (k Keeper) UpdateCdpAndCollateralRatioIndex(ctx sdk.Context, cdp types.CDP, ratio sdk.Dec) error
- func (k Keeper) UpdatePricefeedStatus(ctx sdk.Context, marketID string) (ok bool)
- func (k Keeper) ValidateBalance(ctx sdk.Context, amount sdk.Coin, sender sdk.AccAddress) error
- func (k Keeper) ValidateCollateral(ctx sdk.Context, collateral sdk.Coin, collateralType string) error
- func (k Keeper) ValidateCollateralizationRatio(ctx sdk.Context, collateral sdk.Coin, collateralType string, ...) error
- func (k Keeper) ValidateDebtLimit(ctx sdk.Context, collateralType string, principal sdk.Coin) error
- func (k Keeper) ValidateLiquidation(ctx sdk.Context, collateral sdk.Coin, collateralType string, ...) error
- func (k Keeper) ValidatePaymentCoins(ctx sdk.Context, cdp types.CDP, payment sdk.Coin) error
- func (k Keeper) ValidatePrincipalAdd(ctx sdk.Context, principal sdk.Coin) error
- func (k Keeper) ValidatePrincipalDraw(ctx sdk.Context, principal sdk.Coin, expectedDenom string) error
- func (k Keeper) WithdrawCollateral(ctx sdk.Context, owner, depositor sdk.AccAddress, collateral sdk.Coin, ...) error
- type QueryServer
- func (s QueryServer) Accounts(c context.Context, req *types.QueryAccountsRequest) (*types.QueryAccountsResponse, error)
- func (s QueryServer) Cdp(c context.Context, req *types.QueryCdpRequest) (*types.QueryCdpResponse, error)
- func (s QueryServer) Cdps(c context.Context, req *types.QueryCdpsRequest) (*types.QueryCdpsResponse, error)
- func (s QueryServer) Deposits(c context.Context, req *types.QueryDepositsRequest) (*types.QueryDepositsResponse, error)
- func (s QueryServer) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error)
- func (s QueryServer) TotalCollateral(c context.Context, req *types.QueryTotalCollateralRequest) (*types.QueryTotalCollateralResponse, error)
- func (s QueryServer) TotalPrincipal(c context.Context, req *types.QueryTotalPrincipalRequest) (*types.QueryTotalPrincipalResponse, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalculateInterestFactor ¶ added in v0.13.0
CalculateInterestFactor calculates the simple interest scaling factor, which is equal to: (per-second interest rate ** number of seconds elapsed) Will return 1.000x, multiply by principal to get new principal with added interest
func FilterCDPs ¶ added in v0.11.0
func FilterCDPs(ctx sdk.Context, k Keeper, params types.QueryCdpsParams) (types.AugmentedCDPs, error)
FilterCDPs queries the store for all CDPs that match query params
func FindIntersection ¶ added in v0.11.0
FindIntersection finds the intersection of two CDP arrays in linear time complexity O(n + n)
func GrpcFilterCDPs ¶ added in v0.16.0
func GrpcFilterCDPs(ctx sdk.Context, k Keeper, req types.QueryCdpsRequest) (types.CDPResponses, error)
FilterCDPs queries the store for all CDPs that match query req
func NewMsgServerImpl ¶ added in v0.16.0
NewMsgServerImpl returns an implementation of the cdp MsgServer interface for the provided Keeper.
func NewQuerier ¶
func NewQuerier(keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier
NewQuerier returns a new querier function
func NewQueryServerImpl ¶ added in v0.16.0
func NewQueryServerImpl(keeper Keeper) types.QueryServer
NewQueryServer returns an implementation of the pricefeed MsgServer interface for the provided Keeper.
Types ¶
type Keeper ¶
type Keeper struct {
// contains filtered or unexported fields
}
Keeper keeper for the cdp module
func NewKeeper ¶
func NewKeeper(cdc codec.Codec, key storetypes.StoreKey, paramstore paramtypes.Subspace, pfk types.PricefeedKeeper, ak types.AuctionKeeper, bk types.BankKeeper, ack types.AccountKeeper, maccs map[string][]string, ) Keeper
NewKeeper creates a new keeper
func (Keeper) AccumulateInterest ¶ added in v0.13.0
AccumulateInterest calculates the new interest that has accrued for the input collateral type based on the total amount of principal that has been created with that collateral type and the amount of time that has passed since interest was last accumulated
func (Keeper) AddCdp ¶
func (k Keeper) AddCdp(ctx sdk.Context, owner sdk.AccAddress, collateral sdk.Coin, principal sdk.Coin, collateralType string) error
AddCdp adds a cdp for a specific owner and collateral type
func (Keeper) AddPrincipal ¶
func (k Keeper) AddPrincipal(ctx sdk.Context, owner sdk.AccAddress, collateralType string, principal sdk.Coin) error
AddPrincipal adds debt to a cdp if the additional debt does not put the cdp below the liquidation ratio
func (Keeper) AfterCDPCreated ¶ added in v0.13.0
AfterCDPCreated - call hook if registered
func (Keeper) ApplyLiquidationPenalty ¶
func (k Keeper) ApplyLiquidationPenalty(ctx sdk.Context, collateralType string, debt sdkmath.Int) sdkmath.Int
ApplyLiquidationPenalty multiplies the input debt amount by the liquidation penalty
func (Keeper) AttemptKeeperLiquidation ¶ added in v0.13.0
func (k Keeper) AttemptKeeperLiquidation(ctx sdk.Context, keeper, owner sdk.AccAddress, collateralType string) error
AttemptKeeperLiquidation liquidates the cdp with the input collateral type and owner if it is below the required collateralization ratio if the cdp is liquidated, the keeper that sent the transaction is rewarded a percentage of the collateral according to that collateral types' keeper reward percentage.
func (Keeper) AuctionCollateral ¶
func (k Keeper) AuctionCollateral(ctx sdk.Context, deposits types.Deposits, collateralType string, debt sdkmath.Int, bidDenom string) error
AuctionCollateral creates auctions from the input deposits which attempt to raise the corresponding amount of debt
func (Keeper) BeforeCDPModified ¶ added in v0.13.0
BeforeCDPModified - call hook if registered
func (Keeper) BurnDebtCoins ¶
func (k Keeper) BurnDebtCoins(ctx sdk.Context, moduleAccount string, denom string, paymentCoins sdk.Coin) error
BurnDebtCoins burns debt coins from the cdp module account
func (Keeper) CalculateCollateralToDebtRatio ¶
func (k Keeper) CalculateCollateralToDebtRatio(ctx sdk.Context, collateral sdk.Coin, collateralType string, debt sdk.Coin) sdk.Dec
CalculateCollateralToDebtRatio returns the collateral to debt ratio of the input collateral and debt amounts
func (Keeper) CalculateCollateralizationRatio ¶
func (k Keeper) CalculateCollateralizationRatio(ctx sdk.Context, collateral sdk.Coin, collateralType string, principal sdk.Coin, fees sdk.Coin, pfType pricefeedType) (sdk.Dec, error)
CalculateCollateralizationRatio returns the collateralization ratio of the input collateral to the input debt plus fees
func (Keeper) CalculateCollateralizationRatioFromAbsoluteRatio ¶
func (k Keeper) CalculateCollateralizationRatioFromAbsoluteRatio(ctx sdk.Context, collateralType string, absoluteRatio sdk.Dec, pfType pricefeedType) (sdk.Dec, error)
CalculateCollateralizationRatioFromAbsoluteRatio takes a coin's denom and an absolute ratio and returns the respective collateralization ratio
func (Keeper) CalculateNewInterest ¶ added in v0.13.0
CalculateNewInterest returns the amount of interest that has accrued to the cdp since its interest was last synchronized
func (Keeper) CdpCollateralRatioIndexIterator ¶
func (k Keeper) CdpCollateralRatioIndexIterator(ctx sdk.Context, collateralType string, targetRatio sdk.Dec) sdk.Iterator
CdpCollateralRatioIndexIterator returns an sdk.Iterator for all cdps that have collateral denom matching denom and collateral:debt ratio LESS THAN targetRatio
func (Keeper) CdpDenomIndexIterator ¶
CdpDenomIndexIterator returns an sdk.Iterator for all cdps with matching collateral denom
func (Keeper) CreateAuctionsFromDeposit ¶
func (k Keeper) CreateAuctionsFromDeposit( ctx sdk.Context, collateral sdk.Coin, collateralType string, returnAddr sdk.AccAddress, debt, auctionSize sdkmath.Int, principalDenom string, ) error
CreateAuctionsFromDeposit creates auctions from the input deposit
func (Keeper) DecrementTotalPrincipal ¶
DecrementTotalPrincipal decrements the total amount of debt that has been drawn for a particular collateral type
func (Keeper) DeleteCdpAndCollateralRatioIndex ¶ added in v0.13.0
DeleteCdpAndCollateralRatioIndex deletes an existing cdp in the store by removing the old index value and deleting the cdp object from the store
func (Keeper) DeleteDeposit ¶
DeleteDeposit deletes a deposit from the store
func (Keeper) DepositCollateral ¶
func (k Keeper) DepositCollateral(ctx sdk.Context, owner, depositor sdk.AccAddress, collateral sdk.Coin, collateralType string) error
DepositCollateral adds collateral to a cdp
func (Keeper) GetAllCdps ¶
GetAllCdps returns all cdps from the store
func (Keeper) GetAllCdpsByCollateralType ¶ added in v0.11.0
func (k Keeper) GetAllCdpsByCollateralType(ctx sdk.Context, collateralType string) (cdps types.CDPs)
GetAllCdpsByCollateralType returns all cdps of a particular collateral type from the store
func (Keeper) GetAllCdpsByCollateralTypeAndRatio ¶ added in v0.11.0
func (k Keeper) GetAllCdpsByCollateralTypeAndRatio(ctx sdk.Context, collateralType string, targetRatio sdk.Dec) (cdps types.CDPs)
GetAllCdpsByCollateralTypeAndRatio returns all cdps of a particular collateral type and below a certain collateralization ratio
func (Keeper) GetCdpByOwnerAndCollateralType ¶ added in v0.11.0
func (k Keeper) GetCdpByOwnerAndCollateralType(ctx sdk.Context, owner sdk.AccAddress, collateralType string) (types.CDP, bool)
GetCdpByOwnerAndCollateralType queries cdps owned by owner and returns the cdp with matching denom
func (Keeper) GetCdpID ¶
func (k Keeper) GetCdpID(ctx sdk.Context, owner sdk.AccAddress, collateralType string) (uint64, bool)
GetCdpID returns the id of the cdp corresponding to a specific owner and collateral denom
func (Keeper) GetCdpIdsByOwner ¶
GetCdpIdsByOwner returns all the ids of cdps corresponding to a particular owner
func (Keeper) GetCollateral ¶
GetCollateral returns the collateral param with corresponding denom
func (Keeper) GetCollateralTypes ¶ added in v0.11.0
GetCollateralTypes returns an array of collateral types
func (Keeper) GetDebtDenom ¶
GetDebtDenom returns the denom of debt in the system
func (Keeper) GetDebtParam ¶
GetDebtParam returns the debt param with matching denom
func (Keeper) GetDeposit ¶
func (k Keeper) GetDeposit(ctx sdk.Context, cdpID uint64, depositor sdk.AccAddress) (deposit types.Deposit, found bool)
GetDeposit returns the deposit of a depositor on a particular cdp from the store
func (Keeper) GetDeposits ¶
GetDeposits returns all the deposits to a cdp
func (Keeper) GetGovDenom ¶
GetGovDenom returns the denom of the governance token
func (Keeper) GetInterestFactor ¶ added in v0.13.0
GetInterestFactor returns the current interest factor for an individual collateral type
func (Keeper) GetMarketStatus ¶ added in v0.8.0
GetMarketStatus returns true if the market has a price, otherwise false
func (Keeper) GetNextCdpID ¶
GetNextCdpID returns the highest cdp id from the store
func (Keeper) GetPreviousAccrualTime ¶ added in v0.13.0
GetPreviousAccrualTime returns the last time an individual market accrued interest
func (Keeper) GetSliceOfCDPsByRatioAndType ¶ added in v0.13.0
func (k Keeper) GetSliceOfCDPsByRatioAndType(ctx sdk.Context, cutoffCount sdkmath.Int, targetRatio sdk.Dec, collateralType string) (cdps types.CDPs)
GetSliceOfCDPsByRatioAndType returns a slice of cdps of size equal to the input cutoffCount sorted by target ratio in ascending order (ie, the lowest collateral:debt ratio cdps are returned first)
func (Keeper) GetTotalDebt ¶
GetTotalDebt returns the total amount of debt tokens held by the liquidator module account
func (Keeper) GetTotalPrincipal ¶
func (k Keeper) GetTotalPrincipal(ctx sdk.Context, collateralType, principalDenom string) (total sdkmath.Int)
GetTotalPrincipal returns the total amount of principal that has been drawn for a particular collateral
func (Keeper) GetTotalSurplus ¶
GetTotalSurplus returns the total amount of surplus tokens held by the liquidator module account
func (Keeper) IncrementTotalPrincipal ¶
IncrementTotalPrincipal increments the total amount of debt that has been drawn with that collateral type
func (Keeper) IndexCdpByCollateralRatio ¶
func (k Keeper) IndexCdpByCollateralRatio(ctx sdk.Context, collateralType string, id uint64, collateralRatio sdk.Dec)
IndexCdpByCollateralRatio sets the cdp id in the store, indexed by the collateral type and collateral to debt ratio
func (Keeper) IndexCdpByOwner ¶
IndexCdpByOwner sets the cdp id in the store, indexed by the owner
func (Keeper) IterateAllCdps ¶
IterateAllCdps iterates over all cdps and performs a callback function
func (Keeper) IterateCdpsByCollateralRatio ¶
func (k Keeper) IterateCdpsByCollateralRatio(ctx sdk.Context, collateralType string, targetRatio sdk.Dec, cb func(cdp types.CDP) (stop bool))
IterateCdpsByCollateralRatio iterate over cdps with collateral denom equal to denom and collateral:debt ratio LESS THAN targetRatio and performs a callback function.
func (Keeper) IterateCdpsByCollateralType ¶ added in v0.11.0
func (k Keeper) IterateCdpsByCollateralType(ctx sdk.Context, collateralType string, cb func(cdp types.CDP) (stop bool))
IterateCdpsByCollateralType iterates over cdps with matching denom and performs a callback function
func (Keeper) IterateDeposits ¶
func (k Keeper) IterateDeposits(ctx sdk.Context, cdpID uint64, cb func(deposit types.Deposit) (stop bool))
IterateDeposits iterates over the all the deposits of a cdp and performs a callback function
func (Keeper) LiquidateCdps ¶
func (k Keeper) LiquidateCdps(ctx sdk.Context, marketID string, collateralType string, liquidationRatio sdk.Dec, count sdkmath.Int) error
LiquidateCdps seizes collateral from all CDPs below the input liquidation ratio
func (Keeper) LoadAugmentedCDP ¶
LoadAugmentedCDP creates a new augmented CDP from an existing CDP
func (Keeper) LoadCDPResponse ¶ added in v0.16.0
LoadCDPResponse creates a new CDPResponse from an existing CDP
func (Keeper) MintDebtCoins ¶
func (k Keeper) MintDebtCoins(ctx sdk.Context, moduleAccount string, denom string, principalCoins sdk.Coin) error
MintDebtCoins mints debt coins in the cdp module account
func (Keeper) NetSurplusAndDebt ¶
NetSurplusAndDebt burns surplus and debt coins equal to the minimum of surplus and debt balances held by the liquidator module account for example, if there is 1000 debt and 100 surplus, 100 surplus and 100 debt are burned, netting to 900 debt
func (Keeper) RemoveCdpCollateralRatioIndex ¶
func (k Keeper) RemoveCdpCollateralRatioIndex(ctx sdk.Context, collateralType string, id uint64, collateralRatio sdk.Dec)
RemoveCdpCollateralRatioIndex deletes the cdp id from the store's index of cdps by collateral type and collateral to debt ratio
func (Keeper) RemoveCdpOwnerIndex ¶
RemoveCdpOwnerIndex deletes the cdp id from the store's index of cdps by owner
func (Keeper) RepayPrincipal ¶
func (k Keeper) RepayPrincipal(ctx sdk.Context, owner sdk.AccAddress, collateralType string, payment sdk.Coin) error
RepayPrincipal removes debt from the cdp If all debt is repaid, the collateral is returned to depositors and the cdp is removed from the store
func (Keeper) ReturnCollateral ¶
ReturnCollateral returns collateral to depositors on a cdp and removes deposits from the store
func (Keeper) RunSurplusAndDebtAuctions ¶
RunSurplusAndDebtAuctions nets the surplus and debt balances and then creates surplus or debt auctions if the remaining balance is above the auction threshold parameter
func (Keeper) SeizeCollateral ¶
SeizeCollateral liquidates the collateral in the input cdp. the following operations are performed: 1. Collateral for all deposits is sent from the cdp module to the liquidator module account 2. The liquidation penalty is applied 3. Debt coins are sent from the cdp module to the liquidator module account 4. The total amount of principal outstanding for that collateral type is decremented (this is the equivalent of saying that fees are no longer accumulated by a cdp once it gets liquidated)
func (Keeper) SetCdpAndCollateralRatioIndex ¶
SetCdpAndCollateralRatioIndex sets the cdp and collateral ratio index in the store
func (Keeper) SetDebtDenom ¶
SetDebtDenom set the denom of debt in the system
func (Keeper) SetDeposit ¶
SetDeposit sets the deposit in the store
func (Keeper) SetGovDenom ¶
SetGovDenom set the denom of the governance token in the system
func (Keeper) SetInterestFactor ¶ added in v0.13.0
SetInterestFactor sets the current interest factor for an individual collateral type
func (Keeper) SetMarketStatus ¶ added in v0.8.0
SetMarketStatus sets the status of the input market, true means the market is up and running, false means it is down
func (Keeper) SetNextCdpID ¶
SetNextCdpID sets the highest cdp id in the store
func (Keeper) SetPreviousAccrualTime ¶ added in v0.13.0
func (k Keeper) SetPreviousAccrualTime(ctx sdk.Context, ctype string, previousAccrualTime time.Time)
SetPreviousAccrualTime sets the most recent accrual time for a particular market
func (Keeper) SetTotalPrincipal ¶
func (k Keeper) SetTotalPrincipal(ctx sdk.Context, collateralType, principalDenom string, total sdkmath.Int)
SetTotalPrincipal sets the total amount of principal that has been drawn for the input collateral
func (Keeper) SynchronizeInterest ¶ added in v0.13.0
SynchronizeInterest updates the input cdp object to reflect the current accumulated interest, updates the cdp state in the store, and returns the updated cdp object
func (Keeper) SynchronizeInterestForRiskyCDPs ¶ added in v0.13.0
func (k Keeper) SynchronizeInterestForRiskyCDPs(ctx sdk.Context, slice sdkmath.Int, targetRatio sdk.Dec, collateralType string) error
SynchronizeInterestForRiskyCDPs synchronizes the interest for the slice of cdps with the lowest collateral:debt ratio
func (Keeper) UpdateCdpAndCollateralRatioIndex ¶ added in v0.13.0
func (k Keeper) UpdateCdpAndCollateralRatioIndex(ctx sdk.Context, cdp types.CDP, ratio sdk.Dec) error
UpdateCdpAndCollateralRatioIndex updates the state of an existing cdp in the store by replacing the old index values and updating the store to the latest cdp object values
func (Keeper) UpdatePricefeedStatus ¶ added in v0.8.0
UpdatePricefeedStatus determines if the price of an asset is available and updates the global status of the market
func (Keeper) ValidateBalance ¶ added in v0.13.0
ValidateBalance validates that the input account has sufficient spendable funds
func (Keeper) ValidateCollateral ¶
func (k Keeper) ValidateCollateral(ctx sdk.Context, collateral sdk.Coin, collateralType string) error
ValidateCollateral validates that a collateral is valid for use in cdps
func (Keeper) ValidateCollateralizationRatio ¶
func (k Keeper) ValidateCollateralizationRatio(ctx sdk.Context, collateral sdk.Coin, collateralType string, principal sdk.Coin, fees sdk.Coin) error
ValidateCollateralizationRatio validate that adding the input principal doesn't put the cdp below the liquidation ratio
func (Keeper) ValidateDebtLimit ¶
ValidateDebtLimit validates that the input debt amount does not exceed the global debt limit or the debt limit for that collateral
func (Keeper) ValidateLiquidation ¶ added in v0.13.0
func (k Keeper) ValidateLiquidation(ctx sdk.Context, collateral sdk.Coin, collateralType string, principal sdk.Coin, fees sdk.Coin) error
ValidateLiquidation validate that adding the input principal puts the cdp below the liquidation ratio
func (Keeper) ValidatePaymentCoins ¶
ValidatePaymentCoins validates that the input coins are valid for repaying debt
func (Keeper) ValidatePrincipalAdd ¶
ValidatePrincipalAdd validates that an asset is valid for use as debt when creating a new cdp
type QueryServer ¶ added in v0.16.0
type QueryServer struct {
// contains filtered or unexported fields
}
func (QueryServer) Accounts ¶ added in v0.16.0
func (s QueryServer) Accounts(c context.Context, req *types.QueryAccountsRequest) (*types.QueryAccountsResponse, error)
Accounts queries the CDP module accounts.
func (QueryServer) Cdp ¶ added in v0.16.0
func (s QueryServer) Cdp(c context.Context, req *types.QueryCdpRequest) (*types.QueryCdpResponse, error)
Cdp queries a CDP with the input owner address and collateral type.
func (QueryServer) Cdps ¶ added in v0.16.0
func (s QueryServer) Cdps(c context.Context, req *types.QueryCdpsRequest) (*types.QueryCdpsResponse, error)
Cdps queries all active CDPs.
func (QueryServer) Deposits ¶ added in v0.16.0
func (s QueryServer) Deposits(c context.Context, req *types.QueryDepositsRequest) (*types.QueryDepositsResponse, error)
Deposits queries deposits associated with the CDP owned by an address for a collateral type.
func (QueryServer) Params ¶ added in v0.16.0
func (s QueryServer) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error)
Params queries all parameters of the cdp module.
func (QueryServer) TotalCollateral ¶ added in v0.16.0
func (s QueryServer) TotalCollateral(c context.Context, req *types.QueryTotalCollateralRequest) (*types.QueryTotalCollateralResponse, error)
TotalCollateral queries the total collateral of a given collateral type.
func (QueryServer) TotalPrincipal ¶ added in v0.16.0
func (s QueryServer) TotalPrincipal(c context.Context, req *types.QueryTotalPrincipalRequest) (*types.QueryTotalPrincipalResponse, error)
TotalPrincipal queries the total principal of a given collateral type.