Documentation ¶
Index ¶
- func APYToSPY(apy sdk.Dec) (sdk.Dec, error)
- func CalculateBorrowInterestFactor(perSecondInterestRate sdk.Dec, secondsElapsed sdkmath.Int) sdk.Dec
- func CalculateBorrowRate(model types.InterestRateModel, cash, borrows, reserves sdk.Dec) (sdk.Dec, error)
- func CalculateSupplyInterestFactor(newInterest, cash, borrows, reserves sdk.Dec) sdk.Dec
- func CalculateUtilizationRatio(cash, borrows, reserves sdk.Dec) sdk.Dec
- func NewMsgServerImpl(keeper Keeper) types.MsgServer
- func NewQueryServerImpl(keeper Keeper, ak types.AccountKeeper, bk types.BankKeeper) types.QueryServer
- func SPYToEstimatedAPY(apy sdk.Dec) sdk.Dec
- type Keeper
- func (k Keeper) AccrueInterest(ctx sdk.Context, denom string) error
- func (k Keeper) AfterBorrowCreated(ctx sdk.Context, borrow types.Borrow)
- func (k Keeper) AfterBorrowModified(ctx sdk.Context, borrow types.Borrow)
- func (k Keeper) AfterDepositCreated(ctx sdk.Context, deposit types.Deposit)
- func (k Keeper) AfterDepositModified(ctx sdk.Context, deposit types.Deposit)
- func (k Keeper) ApplyInterestRateUpdates(ctx sdk.Context)
- func (k Keeper) AttemptKeeperLiquidation(ctx sdk.Context, keeper sdk.AccAddress, borrower sdk.AccAddress) error
- func (k Keeper) BeforeBorrowModified(ctx sdk.Context, borrow types.Borrow)
- func (k Keeper) BeforeDepositModified(ctx sdk.Context, deposit types.Deposit)
- func (k Keeper) Borrow(ctx sdk.Context, borrower sdk.AccAddress, coins sdk.Coins) error
- func (k Keeper) CalculateLtv(ctx sdk.Context, deposit types.Deposit, borrow types.Borrow) (sdk.Dec, error)
- func (k Keeper) CalculatePaymentAmount(owed sdk.Coins, payment sdk.Coins) (sdk.Coins, error)
- func (k Keeper) CalculateWithdrawAmount(available sdk.Coins, request sdk.Coins) (sdk.Coins, error)
- func (k Keeper) DecrementBorrowedCoins(ctx sdk.Context, coins sdk.Coins) error
- func (k Keeper) DecrementSuppliedCoins(ctx sdk.Context, coins sdk.Coins) error
- func (k Keeper) DeleteBorrow(ctx sdk.Context, borrow types.Borrow)
- func (k Keeper) DeleteDeposit(ctx sdk.Context, deposit types.Deposit)
- func (k Keeper) DeleteMoneyMarket(ctx sdk.Context, denom string)
- func (k Keeper) Deposit(ctx sdk.Context, depositor sdk.AccAddress, coins sdk.Coins) error
- func (k Keeper) GetAllMoneyMarkets(ctx sdk.Context) (moneyMarkets types.MoneyMarkets)
- func (k Keeper) GetBorrow(ctx sdk.Context, borrower sdk.AccAddress) (types.Borrow, bool)
- func (k Keeper) GetBorrowInterestFactor(ctx sdk.Context, denom string) (sdk.Dec, bool)
- func (k Keeper) GetBorrowedCoins(ctx sdk.Context) (sdk.Coins, bool)
- func (k Keeper) GetDeposit(ctx sdk.Context, depositor sdk.AccAddress) (types.Deposit, bool)
- func (k Keeper) GetDepositsByUser(ctx sdk.Context, user sdk.AccAddress) []types.Deposit
- func (k Keeper) GetMinimumBorrowUSDValue(ctx sdk.Context) sdk.Dec
- func (k Keeper) GetMoneyMarket(ctx sdk.Context, denom string) (types.MoneyMarket, bool)
- func (k Keeper) GetParams(ctx sdk.Context) types.Params
- func (k Keeper) GetPreviousAccrualTime(ctx sdk.Context, denom string) (time.Time, bool)
- func (k Keeper) GetStoreLTV(ctx sdk.Context, addr sdk.AccAddress) (sdk.Dec, error)
- func (k Keeper) GetSuppliedCoins(ctx sdk.Context) (sdk.Coins, bool)
- func (k Keeper) GetSupplyInterestFactor(ctx sdk.Context, denom string) (sdk.Dec, bool)
- func (k Keeper) GetSyncedBorrow(ctx sdk.Context, borrower sdk.AccAddress) (types.Borrow, bool)
- func (k Keeper) GetSyncedDeposit(ctx sdk.Context, depositor sdk.AccAddress) (types.Deposit, bool)
- func (k Keeper) GetTotalDeposited(ctx sdk.Context, depositDenom string) (total sdkmath.Int)
- func (k Keeper) GetTotalReserves(ctx sdk.Context) (sdk.Coins, bool)
- func (k Keeper) IncrementBorrowedCoins(ctx sdk.Context, newCoins sdk.Coins)
- func (k Keeper) IncrementSuppliedCoins(ctx sdk.Context, newCoins sdk.Coins)
- func (k Keeper) IsWithinValidLtvRange(ctx sdk.Context, deposit types.Deposit, borrow types.Borrow) (bool, error)
- func (k Keeper) IterateBorrowInterestFactors(ctx sdk.Context, cb func(denom string, factor sdk.Dec) (stop bool))
- func (k Keeper) IterateBorrows(ctx sdk.Context, cb func(borrow types.Borrow) (stop bool))
- func (k Keeper) IterateDeposits(ctx sdk.Context, cb func(deposit types.Deposit) (stop bool))
- func (k Keeper) IterateMoneyMarkets(ctx sdk.Context, ...)
- func (k Keeper) IterateSupplyInterestFactors(ctx sdk.Context, cb func(denom string, factor sdk.Dec) (stop bool))
- func (k Keeper) LoadLiquidationData(ctx sdk.Context, deposit types.Deposit, borrow types.Borrow) (map[string]LiqData, error)
- func (k Keeper) Repay(ctx sdk.Context, sender, owner sdk.AccAddress, coins sdk.Coins) error
- func (k Keeper) SeizeDeposits(ctx sdk.Context, keeper sdk.AccAddress, deposit types.Deposit, ...) error
- func (k Keeper) SetBorrow(ctx sdk.Context, borrow types.Borrow)
- func (k Keeper) SetBorrowInterestFactor(ctx sdk.Context, denom string, borrowInterestFactor sdk.Dec)
- func (k Keeper) SetBorrowedCoins(ctx sdk.Context, borrowedCoins sdk.Coins)
- func (k Keeper) SetDeposit(ctx sdk.Context, deposit types.Deposit)
- func (k *Keeper) SetHooks(hooks types.HARDHooks) *Keeper
- func (k Keeper) SetMoneyMarket(ctx sdk.Context, denom string, moneyMarket types.MoneyMarket)
- func (k Keeper) SetParams(ctx sdk.Context, params types.Params)
- func (k Keeper) SetPreviousAccrualTime(ctx sdk.Context, denom string, previousAccrualTime time.Time)
- func (k Keeper) SetSuppliedCoins(ctx sdk.Context, suppliedCoins sdk.Coins)
- func (k Keeper) SetSupplyInterestFactor(ctx sdk.Context, denom string, supplyInterestFactor sdk.Dec)
- func (k Keeper) SetTotalReserves(ctx sdk.Context, coins sdk.Coins)
- func (k Keeper) StartAuctions(ctx sdk.Context, borrower sdk.AccAddress, borrows, deposits sdk.Coins, ...) (sdk.Coins, error)
- func (k Keeper) SyncBorrowInterest(ctx sdk.Context, addr sdk.AccAddress)
- func (k Keeper) SyncSupplyInterest(ctx sdk.Context, addr sdk.AccAddress)
- func (k Keeper) ValidateBorrow(ctx sdk.Context, borrower sdk.AccAddress, amount sdk.Coins) error
- func (k Keeper) ValidateDeposit(ctx sdk.Context, coins sdk.Coins) error
- func (k Keeper) ValidateRepay(ctx sdk.Context, sender, owner sdk.AccAddress, coins sdk.Coins) error
- func (k Keeper) Withdraw(ctx sdk.Context, depositor sdk.AccAddress, coins sdk.Coins) error
- type LiqData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func APYToSPY ¶
APYToSPY converts the input annual interest rate. For example, 10% apy would be passed as 1.10. SPY = Per second compounded interest rate is how cosmos mathematically represents APY.
func CalculateBorrowInterestFactor ¶
func CalculateBorrowInterestFactor(perSecondInterestRate sdk.Dec, secondsElapsed sdkmath.Int) sdk.Dec
CalculateBorrowInterestFactor 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 CalculateBorrowRate ¶
func CalculateBorrowRate(model types.InterestRateModel, cash, borrows, reserves sdk.Dec) (sdk.Dec, error)
CalculateBorrowRate calculates the borrow rate, which is the current APY expressed as a decimal based on the current utilization.
func CalculateSupplyInterestFactor ¶
CalculateSupplyInterestFactor calculates the supply interest factor, which is the percentage of borrow interest that flows to each unit of supply, i.e. at 50% utilization and 0% reserve factor, a 5% borrow interest will correspond to a 2.5% supply interest.
func CalculateUtilizationRatio ¶
CalculateUtilizationRatio calculates an asset's current utilization rate
func NewMsgServerImpl ¶ added in v0.16.0
NewMsgServerImpl returns an implementation of the hard MsgServer interface for the provided Keeper.
func NewQueryServerImpl ¶ added in v0.16.0
func NewQueryServerImpl(keeper Keeper, ak types.AccountKeeper, bk types.BankKeeper) types.QueryServer
NewQueryServerImpl creates a new server for handling gRPC queries.
Types ¶
type Keeper ¶
type Keeper struct {
// contains filtered or unexported fields
}
Keeper keeper for the hard module
func NewKeeper ¶
func NewKeeper(cdc codec.Codec, key storetypes.StoreKey, paramstore paramtypes.Subspace, ak types.AccountKeeper, bk types.BankKeeper, pfk types.PricefeedKeeper, auk types.AuctionKeeper, ) Keeper
NewKeeper creates a new keeper
func (Keeper) AccrueInterest ¶
AccrueInterest applies accrued interest to total borrows and reserves by calculating interest from the last checkpoint time and writing the updated values to the store.
func (Keeper) AfterBorrowCreated ¶
AfterBorrowCreated - call hook if registered
func (Keeper) AfterBorrowModified ¶
AfterBorrowModified - call hook if registered
func (Keeper) AfterDepositCreated ¶
AfterDepositCreated - call hook if registered
func (Keeper) AfterDepositModified ¶
AfterDepositModified - call hook if registered
func (Keeper) ApplyInterestRateUpdates ¶
ApplyInterestRateUpdates translates the current interest rate models from the params to the store, with each money market accruing interest.
func (Keeper) AttemptKeeperLiquidation ¶
func (k Keeper) AttemptKeeperLiquidation(ctx sdk.Context, keeper sdk.AccAddress, borrower sdk.AccAddress) error
AttemptKeeperLiquidation enables a keeper to liquidate an individual borrower's position
func (Keeper) BeforeBorrowModified ¶
BeforeBorrowModified - call hook if registered
func (Keeper) BeforeDepositModified ¶
BeforeDepositModified - call hook if registered
func (Keeper) CalculateLtv ¶
func (k Keeper) CalculateLtv(ctx sdk.Context, deposit types.Deposit, borrow types.Borrow) (sdk.Dec, error)
CalculateLtv calculates the potential LTV given a user's deposits and borrows. The boolean returned indicates if the LTV should be added to the store's LTV index.
func (Keeper) CalculatePaymentAmount ¶
CalculatePaymentAmount prevents overpayment when repaying borrowed coins
func (Keeper) CalculateWithdrawAmount ¶
CalculateWithdrawAmount enables full withdraw of deposited coins by adjusting withdraw amount to equal total deposit amount if the requested withdraw amount > current deposit amount
func (Keeper) DecrementBorrowedCoins ¶
DecrementBorrowedCoins decrements the total amount of borrowed coins by the coins parameter
func (Keeper) DecrementSuppliedCoins ¶
DecrementSuppliedCoins decrements the total amount of supplied coins by the coins parameter
func (Keeper) DeleteBorrow ¶
DeleteBorrow deletes a borrow from the store
func (Keeper) DeleteDeposit ¶
DeleteDeposit deletes a deposit from the store
func (Keeper) DeleteMoneyMarket ¶
DeleteMoneyMarket deletes a money market from the store
func (Keeper) GetAllMoneyMarkets ¶
func (k Keeper) GetAllMoneyMarkets(ctx sdk.Context) (moneyMarkets types.MoneyMarkets)
GetAllMoneyMarkets returns all money markets from the store
func (Keeper) GetBorrow ¶
GetBorrow returns a Borrow from the store for a particular borrower address and borrow denom
func (Keeper) GetBorrowInterestFactor ¶
GetBorrowInterestFactor returns the current borrow interest factor for an individual market
func (Keeper) GetBorrowedCoins ¶
GetBorrowedCoins returns an sdk.Coins object from the store representing all currently borrowed coins
func (Keeper) GetDeposit ¶
GetDeposit returns a deposit from the store for a particular depositor address, deposit denom
func (Keeper) GetDepositsByUser ¶
GetDepositsByUser gets all deposits for an individual user
func (Keeper) GetMinimumBorrowUSDValue ¶
GetMinimumBorrowUSDValue returns the minimum borrow USD value
func (Keeper) GetMoneyMarket ¶
GetMoneyMarket returns a money market from the store for a denom
func (Keeper) GetPreviousAccrualTime ¶
GetPreviousAccrualTime returns the last time an individual market accrued interest
func (Keeper) GetStoreLTV ¶
GetStoreLTV calculates the user's current LTV based on their deposits/borrows in the store and does not include any outsanding interest.
func (Keeper) GetSuppliedCoins ¶
GetSuppliedCoins returns an sdk.Coins object from the store representing all currently supplied coins
func (Keeper) GetSupplyInterestFactor ¶
GetSupplyInterestFactor returns the current supply interest factor for an individual market
func (Keeper) GetSyncedBorrow ¶
GetSyncedBorrow returns a borrow object containing current balances and indexes
func (Keeper) GetSyncedDeposit ¶
GetSyncedDeposit returns a deposit object containing current balances and indexes
func (Keeper) GetTotalDeposited ¶
GetTotalDeposited returns the total amount deposited for the input deposit type and deposit denom
func (Keeper) GetTotalReserves ¶
GetTotalReserves returns the total reserves for an individual market
func (Keeper) IncrementBorrowedCoins ¶
IncrementBorrowedCoins increments the total amount of borrowed coins by the newCoins parameter
func (Keeper) IncrementSuppliedCoins ¶
IncrementSuppliedCoins increments the total amount of supplied coins by the newCoins parameter
func (Keeper) IsWithinValidLtvRange ¶
func (k Keeper) IsWithinValidLtvRange(ctx sdk.Context, deposit types.Deposit, borrow types.Borrow) (bool, error)
IsWithinValidLtvRange compares a borrow and deposit to see if it's within a valid LTV range at current prices
func (Keeper) IterateBorrowInterestFactors ¶ added in v0.14.0
func (k Keeper) IterateBorrowInterestFactors(ctx sdk.Context, cb func(denom string, factor sdk.Dec) (stop bool))
IterateBorrowInterestFactors iterates over all borrow interest factors in the store and returns both the borrow interest factor and the key (denom) it's stored under
func (Keeper) IterateBorrows ¶
IterateBorrows iterates over all borrow objects in the store and performs a callback function
func (Keeper) IterateDeposits ¶
IterateDeposits iterates over all deposit objects in the store and performs a callback function
func (Keeper) IterateMoneyMarkets ¶
func (k Keeper) IterateMoneyMarkets(ctx sdk.Context, cb func(denom string, moneyMarket types.MoneyMarket) (stop bool))
IterateMoneyMarkets iterates over all money markets objects in the store and performs a callback function
that returns both the money market and the key (denom) it's stored under
func (Keeper) IterateSupplyInterestFactors ¶ added in v0.14.0
func (k Keeper) IterateSupplyInterestFactors(ctx sdk.Context, cb func(denom string, factor sdk.Dec) (stop bool))
IterateSupplyInterestFactors iterates over all supply interest factors in the store and returns both the supply interest factor and the key (denom) it's stored under
func (Keeper) LoadLiquidationData ¶
func (k Keeper) LoadLiquidationData(ctx sdk.Context, deposit types.Deposit, borrow types.Borrow) (map[string]LiqData, error)
LoadLiquidationData returns liquidation data, deposit, borrow
func (Keeper) SeizeDeposits ¶
func (k Keeper) SeizeDeposits(ctx sdk.Context, keeper sdk.AccAddress, deposit types.Deposit, borrow types.Borrow, dDenoms, bDenoms []string, ) error
SeizeDeposits seizes a list of deposits and sends them to auction
func (Keeper) SetBorrow ¶
SetBorrow sets the input borrow in the store, prefixed by the borrower address and borrow denom
func (Keeper) SetBorrowInterestFactor ¶
func (k Keeper) SetBorrowInterestFactor(ctx sdk.Context, denom string, borrowInterestFactor sdk.Dec)
SetBorrowInterestFactor sets the current borrow interest factor for an individual market
func (Keeper) SetBorrowedCoins ¶
SetBorrowedCoins sets the total amount of coins currently borrowed in the store
func (Keeper) SetDeposit ¶
SetDeposit sets the input deposit in the store, prefixed by the deposit type, deposit denom, and depositor address, in that order
func (Keeper) SetMoneyMarket ¶
SetMoneyMarket sets a money market in the store for a denom
func (Keeper) SetPreviousAccrualTime ¶
func (k Keeper) SetPreviousAccrualTime(ctx sdk.Context, denom string, previousAccrualTime time.Time)
SetPreviousAccrualTime sets the most recent accrual time for a particular market
func (Keeper) SetSuppliedCoins ¶
SetSuppliedCoins sets the total amount of coins currently supplied in the store
func (Keeper) SetSupplyInterestFactor ¶
func (k Keeper) SetSupplyInterestFactor(ctx sdk.Context, denom string, supplyInterestFactor sdk.Dec)
SetSupplyInterestFactor sets the current supply interest factor for an individual market
func (Keeper) SetTotalReserves ¶
SetTotalReserves sets the total reserves for an individual market
func (Keeper) StartAuctions ¶
func (k Keeper) StartAuctions(ctx sdk.Context, borrower sdk.AccAddress, borrows, deposits sdk.Coins, depositCoinValues, borrowCoinValues types.ValuationMap, ltv sdk.Dec, liqMap map[string]LiqData, ) (sdk.Coins, error)
StartAuctions attempts to start auctions for seized assets
func (Keeper) SyncBorrowInterest ¶
func (k Keeper) SyncBorrowInterest(ctx sdk.Context, addr sdk.AccAddress)
SyncBorrowInterest updates the user's owed interest on newly borrowed coins to the latest global state
func (Keeper) SyncSupplyInterest ¶
func (k Keeper) SyncSupplyInterest(ctx sdk.Context, addr sdk.AccAddress)
SyncSupplyInterest updates the user's earned interest on supplied coins based on the latest global state
func (Keeper) ValidateBorrow ¶
ValidateBorrow validates a borrow request against borrower and protocol requirements
func (Keeper) ValidateDeposit ¶
ValidateDeposit validates a deposit
func (Keeper) ValidateRepay ¶
ValidateRepay validates a requested loan repay