pub struct Pallet<T>(_);
Expand description
The Pallet
struct, the main type that implements traits and standalone
functions within the pallet.
Implementations§
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn accrue_interest(asset_id: <T as Config>::CurrencyId) -> DispatchResult
pub fn accrue_interest(asset_id: <T as Config>::CurrencyId) -> DispatchResult
Accrue interest and update corresponding storage
pub fn get_market_status( asset_id: <T as Config>::CurrencyId ) -> Result<(Rate, Rate, Rate, Ratio, <T as Config>::Balance, <T as Config>::Balance, FixedU128), DispatchError>
sourcepub fn exchange_rate_stored(
asset_id: <T as Config>::CurrencyId
) -> Result<Rate, DispatchError>
pub fn exchange_rate_stored( asset_id: <T as Config>::CurrencyId ) -> Result<Rate, DispatchError>
Update the exchange rate according to the totalCash, totalBorrows and totalSupply. This function does not accrue interest before calculating the exchange rate. exchangeRate = (totalCash + totalBorrows - totalReserves) / totalSupply
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn add_market(
origin: OriginFor<T>,
asset_id: <T as Config>::CurrencyId,
market: Market<<T as Config>::Balance>
) -> DispatchResultWithPostInfo
pub fn add_market( origin: OriginFor<T>, asset_id: <T as Config>::CurrencyId, market: Market<<T as Config>::Balance> ) -> DispatchResultWithPostInfo
Creates a new lending market for a given currency. Returns Err
if a market already
exists for the given currency.
All provided market states must be Pending
, otherwise an error will be returned.
The lend_token id specified in the Market struct has to be unique, and cannot be later reused when creating a new market.
asset_id
: Currency to enable lending and borrowing for.market
: Configuration of the new lending market
sourcepub fn activate_market(
origin: OriginFor<T>,
asset_id: <T as Config>::CurrencyId
) -> DispatchResultWithPostInfo
pub fn activate_market( origin: OriginFor<T>, asset_id: <T as Config>::CurrencyId ) -> DispatchResultWithPostInfo
Activates a market. Returns Err
if the market does not exist.
If the market is already active, does nothing.
asset_id
: Currency to enable lending and borrowing for.
sourcepub fn update_rate_model(
origin: OriginFor<T>,
asset_id: <T as Config>::CurrencyId,
rate_model: InterestRateModel
) -> DispatchResultWithPostInfo
pub fn update_rate_model( origin: OriginFor<T>, asset_id: <T as Config>::CurrencyId, rate_model: InterestRateModel ) -> DispatchResultWithPostInfo
Updates the rate model of a stored market. Returns Err
if the market
currency does not exist or the rate model is invalid.
asset_id
: Market currencyrate_model
: The new rate model to set
sourcepub fn update_market(
origin: OriginFor<T>,
asset_id: <T as Config>::CurrencyId,
collateral_factor: Option<Ratio>,
liquidation_threshold: Option<Ratio>,
reserve_factor: Option<Ratio>,
close_factor: Option<Ratio>,
liquidate_incentive_reserved_factor: Option<Ratio>,
liquidate_incentive: Option<Rate>,
supply_cap: Option<<T as Config>::Balance>,
borrow_cap: Option<<T as Config>::Balance>
) -> DispatchResultWithPostInfo
pub fn update_market( origin: OriginFor<T>, asset_id: <T as Config>::CurrencyId, collateral_factor: Option<Ratio>, liquidation_threshold: Option<Ratio>, reserve_factor: Option<Ratio>, close_factor: Option<Ratio>, liquidate_incentive_reserved_factor: Option<Ratio>, liquidate_incentive: Option<Rate>, supply_cap: Option<<T as Config>::Balance>, borrow_cap: Option<<T as Config>::Balance> ) -> DispatchResultWithPostInfo
Updates a stored market. Returns Err
if the market currency does not exist.
asset_id
: market related currencycollateral_factor
: the collateral utilization ratioliquidation_threshold
: The collateral ratio when a borrower can be liquidatedreserve_factor
: fraction of interest set aside for reservesclose_factor
: max percentage of debt that can be liquidated in a single transactionliquidate_incentive_reserved_factor
: liquidation share set aside for reservesliquidate_incentive
: liquidation incentive ratiosupply_cap
: Upper bound of supplyingborrow_cap
: Upper bound of borrowing
sourcepub fn force_update_market(
origin: OriginFor<T>,
asset_id: <T as Config>::CurrencyId,
market: Market<<T as Config>::Balance>
) -> DispatchResultWithPostInfo
pub fn force_update_market( origin: OriginFor<T>, asset_id: <T as Config>::CurrencyId, market: Market<<T as Config>::Balance> ) -> DispatchResultWithPostInfo
Force updates a stored market. Returns Err
if the market currency
does not exist.
asset_id
: market related currencymarket
: Configuration of the new lending market
sourcepub fn add_reward(
origin: OriginFor<T>,
amount: <T as Config>::Balance
) -> DispatchResultWithPostInfo
pub fn add_reward( origin: OriginFor<T>, amount: <T as Config>::Balance ) -> DispatchResultWithPostInfo
Deposit incentive reward currency into the pallet account.
amount
: Reward amount added
sourcepub fn update_market_reward_speed(
origin: OriginFor<T>,
asset_id: <T as Config>::CurrencyId,
supply_reward_per_block: Option<<T as Config>::Balance>,
borrow_reward_per_block: Option<<T as Config>::Balance>
) -> DispatchResultWithPostInfo
pub fn update_market_reward_speed( origin: OriginFor<T>, asset_id: <T as Config>::CurrencyId, supply_reward_per_block: Option<<T as Config>::Balance>, borrow_reward_per_block: Option<<T as Config>::Balance> ) -> DispatchResultWithPostInfo
Updates reward speed for the specified market
The origin must conform to UpdateOrigin
.
asset_id
: Market related currencysupply_reward_per_block
: supply reward amount per block.borrow_reward_per_block
: borrow reward amount per block.
sourcepub fn claim_reward(origin: OriginFor<T>) -> DispatchResultWithPostInfo
pub fn claim_reward(origin: OriginFor<T>) -> DispatchResultWithPostInfo
Claim incentive rewards for all markets.
sourcepub fn claim_reward_for_market(
origin: OriginFor<T>,
asset_id: <T as Config>::CurrencyId
) -> DispatchResultWithPostInfo
pub fn claim_reward_for_market( origin: OriginFor<T>, asset_id: <T as Config>::CurrencyId ) -> DispatchResultWithPostInfo
Claim inceitve reward for the specified market.
asset_id
: Market related currency
sourcepub fn mint(
origin: OriginFor<T>,
asset_id: <T as Config>::CurrencyId,
mint_amount: <T as Config>::Balance
) -> DispatchResultWithPostInfo
pub fn mint( origin: OriginFor<T>, asset_id: <T as Config>::CurrencyId, mint_amount: <T as Config>::Balance ) -> DispatchResultWithPostInfo
The caller supplies (lends) assets into the market and receives a corresponding amount of lend tokens, at the current internal exchange rate.
asset_id
: the asset to be deposited.mint_amount
: the amount to be deposited.
sourcepub fn redeem(
origin: OriginFor<T>,
asset_id: <T as Config>::CurrencyId,
redeem_amount: <T as Config>::Balance
) -> DispatchResultWithPostInfo
pub fn redeem( origin: OriginFor<T>, asset_id: <T as Config>::CurrencyId, redeem_amount: <T as Config>::Balance ) -> DispatchResultWithPostInfo
The caller redeems lend tokens for the underlying asset, at the current internal exchange rate.
asset_id
: the asset to be redeemedredeem_amount
: the amount to be redeemed, expressed in the underyling currency (asset_id
)
sourcepub fn redeem_all(
origin: OriginFor<T>,
asset_id: <T as Config>::CurrencyId
) -> DispatchResultWithPostInfo
pub fn redeem_all( origin: OriginFor<T>, asset_id: <T as Config>::CurrencyId ) -> DispatchResultWithPostInfo
The caller redeems their entire lend token balance in exchange for the underlying asset. Note: this will fail if the account needs some of the collateral for backing open borrows, or if any of the lend tokens are used by other pallets (e.g. used as vault collateral)
asset_id
: the asset to be redeemed.
sourcepub fn borrow(
origin: OriginFor<T>,
asset_id: <T as Config>::CurrencyId,
borrow_amount: <T as Config>::Balance
) -> DispatchResultWithPostInfo
pub fn borrow( origin: OriginFor<T>, asset_id: <T as Config>::CurrencyId, borrow_amount: <T as Config>::Balance ) -> DispatchResultWithPostInfo
The caller borrows borrow_amount
of asset_id
from the protocol, using their
supplied assets as collateral.
asset_id
: the asset to be borrowed.borrow_amount
: the amount to be borrowed.
sourcepub fn repay_borrow(
origin: OriginFor<T>,
asset_id: <T as Config>::CurrencyId,
repay_amount: <T as Config>::Balance
) -> DispatchResultWithPostInfo
pub fn repay_borrow( origin: OriginFor<T>, asset_id: <T as Config>::CurrencyId, repay_amount: <T as Config>::Balance ) -> DispatchResultWithPostInfo
The caller repays some of their debts.
asset_id
: the asset to be repaid.repay_amount
: the amount to be repaid, in the underlying currency (asset_id
).
sourcepub fn repay_borrow_all(
origin: OriginFor<T>,
asset_id: <T as Config>::CurrencyId
) -> DispatchResultWithPostInfo
pub fn repay_borrow_all( origin: OriginFor<T>, asset_id: <T as Config>::CurrencyId ) -> DispatchResultWithPostInfo
The caller repays all of their debts.
asset_id
: the asset to be repaid.
sourcepub fn deposit_all_collateral(
origin: OriginFor<T>,
asset_id: <T as Config>::CurrencyId
) -> DispatchResultWithPostInfo
pub fn deposit_all_collateral( origin: OriginFor<T>, asset_id: <T as Config>::CurrencyId ) -> DispatchResultWithPostInfo
Caller enables their lend token balance as borrow collateral. This operation locks the lend tokens, so they are no longer transferrable. Any incoming lend tokens into the caller’s account (either by direct transfer or minting) are automatically locked as well, such that locking and unlocking borrow collateral is an atomic state (a “collateral toggle”). If any of the caller’s lend token balance is locked elsewhere (for instance, as bridge vault collateral), this operation will fail. If this operation is successful, the caller’s maximum allowed debt increases.
asset_id
: the underlying asset denoting the market whose lend tokens are to be enabled as collateral.
sourcepub fn withdraw_all_collateral(
origin: OriginFor<T>,
asset_id: <T as Config>::CurrencyId
) -> DispatchResultWithPostInfo
pub fn withdraw_all_collateral( origin: OriginFor<T>, asset_id: <T as Config>::CurrencyId ) -> DispatchResultWithPostInfo
Caller disables their lend token balance as borrow collateral. This operation unlocks the lend tokens, so they become transferrable. This operation can only succeed if the caller’s debt is backed by sufficient collateral excluding this currency.
asset_id
: the underlying asset denoting the market whose lend tokens are to be disabled as collateral.
sourcepub fn liquidate_borrow(
origin: OriginFor<T>,
borrower: T::AccountId,
liquidation_asset_id: <T as Config>::CurrencyId,
repay_amount: <T as Config>::Balance,
collateral_asset_id: <T as Config>::CurrencyId
) -> DispatchResultWithPostInfo
pub fn liquidate_borrow( origin: OriginFor<T>, borrower: T::AccountId, liquidation_asset_id: <T as Config>::CurrencyId, repay_amount: <T as Config>::Balance, collateral_asset_id: <T as Config>::CurrencyId ) -> DispatchResultWithPostInfo
The caller liquidates the borrower’s collateral. This extrinsic may need to be called multiple
times to completely clear the borrower’s bad debt, because of the close_factor
parameter in
the market. See the close_factor_may_require_multiple_liquidations_to_clear_bad_debt
unit
test for an example of this.
borrower
: the borrower to be liquidated.liquidation_asset_id
: the underlying asset to be liquidated.repay_amount
: the amount ofliquidation_asset_id
to be repaid. This parameter can only be as large as theclose_factor
market parameter allows (close_factor * borrower_debt_in_liquidation_asset
).collateral_asset_id
: The underlying currency whose lend tokens to seize from the borrower. Note that the liquidator has to redeem the received lend tokens from the market to convert them tocollateral_asset_id
.
sourcepub fn add_reserves(
origin: OriginFor<T>,
payer: <T::Lookup as StaticLookup>::Source,
asset_id: <T as Config>::CurrencyId,
add_amount: <T as Config>::Balance
) -> DispatchResultWithPostInfo
pub fn add_reserves( origin: OriginFor<T>, payer: <T::Lookup as StaticLookup>::Source, asset_id: <T as Config>::CurrencyId, add_amount: <T as Config>::Balance ) -> DispatchResultWithPostInfo
Add reserves by transferring from payer.
TODO: This extrinsic currently does nothing useful. See the TODO comment
of the ensure_enough_cash
function for more details. Based on that
TODO, decide whether this extrinsic should be kept.
May only be called from T::ReserveOrigin
.
payer
: the payer account.asset_id
: the assets to be added.add_amount
: the amount to be added.
sourcepub fn reduce_reserves(
origin: OriginFor<T>,
receiver: <T::Lookup as StaticLookup>::Source,
asset_id: <T as Config>::CurrencyId,
reduce_amount: <T as Config>::Balance
) -> DispatchResultWithPostInfo
pub fn reduce_reserves( origin: OriginFor<T>, receiver: <T::Lookup as StaticLookup>::Source, asset_id: <T as Config>::CurrencyId, reduce_amount: <T as Config>::Balance ) -> DispatchResultWithPostInfo
Reduces reserves (treasury’s share of accrued interest) by transferring to receiver.
May only be called from T::ReserveOrigin
.
receiver
: the receiver account.asset_id
: the assets to be reduced.reduce_amount
: the amount to be reduced.
sourcepub fn reduce_incentive_reserves(
origin: OriginFor<T>,
receiver: <T::Lookup as StaticLookup>::Source,
asset_id: <T as Config>::CurrencyId,
redeem_amount: <T as Config>::Balance
) -> DispatchResultWithPostInfo
pub fn reduce_incentive_reserves( origin: OriginFor<T>, receiver: <T::Lookup as StaticLookup>::Source, asset_id: <T as Config>::CurrencyId, redeem_amount: <T as Config>::Balance ) -> DispatchResultWithPostInfo
Sender redeems some of internal supplies in exchange for the underlying asset.
asset_id
: the asset to be redeemed.redeem_amount
: the amount to be redeemed.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn last_accrued_interest_time<KArg>(k: KArg) -> Timestampwhere
KArg: EncodeLike<<T as Config>::CurrencyId>,
pub fn last_accrued_interest_time<KArg>(k: KArg) -> Timestampwhere KArg: EncodeLike<<T as Config>::CurrencyId>,
An auto-generated getter for LastAccruedInterestTime
.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn account_borrows<KArg1, KArg2>(
k1: KArg1,
k2: KArg2
) -> BorrowSnapshot<<T as Config>::Balance>where
KArg1: EncodeLike<<T as Config>::CurrencyId>,
KArg2: EncodeLike<T::AccountId>,
pub fn account_borrows<KArg1, KArg2>( k1: KArg1, k2: KArg2 ) -> BorrowSnapshot<<T as Config>::Balance>where KArg1: EncodeLike<<T as Config>::CurrencyId>, KArg2: EncodeLike<T::AccountId>,
An auto-generated getter for AccountBorrows
.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn borrow_index<KArg>(k: KArg) -> Ratewhere
KArg: EncodeLike<<T as Config>::CurrencyId>,
pub fn borrow_index<KArg>(k: KArg) -> Ratewhere KArg: EncodeLike<<T as Config>::CurrencyId>,
An auto-generated getter for BorrowIndex
.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn exchange_rate<KArg>(k: KArg) -> Ratewhere
KArg: EncodeLike<<T as Config>::CurrencyId>,
pub fn exchange_rate<KArg>(k: KArg) -> Ratewhere KArg: EncodeLike<<T as Config>::CurrencyId>,
An auto-generated getter for ExchangeRate
.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn borrow_rate<KArg>(k: KArg) -> Ratewhere
KArg: EncodeLike<<T as Config>::CurrencyId>,
pub fn borrow_rate<KArg>(k: KArg) -> Ratewhere KArg: EncodeLike<<T as Config>::CurrencyId>,
An auto-generated getter for BorrowRate
.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn supply_rate<KArg>(k: KArg) -> Ratewhere
KArg: EncodeLike<<T as Config>::CurrencyId>,
pub fn supply_rate<KArg>(k: KArg) -> Ratewhere KArg: EncodeLike<<T as Config>::CurrencyId>,
An auto-generated getter for SupplyRate
.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn utilization_ratio<KArg>(k: KArg) -> Ratiowhere
KArg: EncodeLike<<T as Config>::CurrencyId>,
pub fn utilization_ratio<KArg>(k: KArg) -> Ratiowhere KArg: EncodeLike<<T as Config>::CurrencyId>,
An auto-generated getter for UtilizationRatio
.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn reward_supply_speed<KArg>(k: KArg) -> <T as Config>::Balancewhere
KArg: EncodeLike<<T as Config>::CurrencyId>,
pub fn reward_supply_speed<KArg>(k: KArg) -> <T as Config>::Balancewhere KArg: EncodeLike<<T as Config>::CurrencyId>,
An auto-generated getter for RewardSupplySpeed
.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn reward_borrow_speed<KArg>(k: KArg) -> <T as Config>::Balancewhere
KArg: EncodeLike<<T as Config>::CurrencyId>,
pub fn reward_borrow_speed<KArg>(k: KArg) -> <T as Config>::Balancewhere KArg: EncodeLike<<T as Config>::CurrencyId>,
An auto-generated getter for RewardBorrowSpeed
.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn reward_supply_state<KArg>(
k: KArg
) -> RewardMarketState<BlockNumberFor<T>, <T as Config>::Balance>where
KArg: EncodeLike<<T as Config>::CurrencyId>,
pub fn reward_supply_state<KArg>( k: KArg ) -> RewardMarketState<BlockNumberFor<T>, <T as Config>::Balance>where KArg: EncodeLike<<T as Config>::CurrencyId>,
An auto-generated getter for RewardSupplyState
.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn reward_borrow_state<KArg>(
k: KArg
) -> RewardMarketState<BlockNumberFor<T>, <T as Config>::Balance>where
KArg: EncodeLike<<T as Config>::CurrencyId>,
pub fn reward_borrow_state<KArg>( k: KArg ) -> RewardMarketState<BlockNumberFor<T>, <T as Config>::Balance>where KArg: EncodeLike<<T as Config>::CurrencyId>,
An auto-generated getter for RewardBorrowState
.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn reward_supplier_index<KArg1, KArg2>(
k1: KArg1,
k2: KArg2
) -> <T as Config>::Balancewhere
KArg1: EncodeLike<<T as Config>::CurrencyId>,
KArg2: EncodeLike<T::AccountId>,
pub fn reward_supplier_index<KArg1, KArg2>( k1: KArg1, k2: KArg2 ) -> <T as Config>::Balancewhere KArg1: EncodeLike<<T as Config>::CurrencyId>, KArg2: EncodeLike<T::AccountId>,
An auto-generated getter for RewardSupplierIndex
.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn reward_borrower_index<KArg1, KArg2>(
k1: KArg1,
k2: KArg2
) -> <T as Config>::Balancewhere
KArg1: EncodeLike<<T as Config>::CurrencyId>,
KArg2: EncodeLike<T::AccountId>,
pub fn reward_borrower_index<KArg1, KArg2>( k1: KArg1, k2: KArg2 ) -> <T as Config>::Balancewhere KArg1: EncodeLike<<T as Config>::CurrencyId>, KArg2: EncodeLike<T::AccountId>,
An auto-generated getter for RewardBorrowerIndex
.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn reward_accrued<KArg>(k: KArg) -> <T as Config>::Balancewhere
KArg: EncodeLike<T::AccountId>,
pub fn reward_accrued<KArg>(k: KArg) -> <T as Config>::Balancewhere KArg: EncodeLike<T::AccountId>,
An auto-generated getter for RewardAccrued
.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn max_exchange_rate() -> Rate
pub fn max_exchange_rate() -> Rate
An auto-generated getter for MaxExchangeRate
.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn min_exchange_rate() -> Rate
pub fn min_exchange_rate() -> Rate
An auto-generated getter for MinExchangeRate
.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
pub fn account_deposits( lend_token_id: <T as Config>::CurrencyId, supplier: &T::AccountId ) -> Amount<T>
pub fn total_borrows(asset_id: <T as Config>::CurrencyId) -> Amount<T>
pub fn total_reserves(asset_id: <T as Config>::CurrencyId) -> Amount<T>
pub fn account_id() -> T::AccountId
pub fn get_account_liquidity( account: &T::AccountId ) -> Result<AccountLiquidity<T>, DispatchError>
pub fn get_account_liquidation_threshold_liquidity( account: &T::AccountId ) -> Result<AccountLiquidity<T>, DispatchError>
pub fn current_borrow_balance( who: &T::AccountId, asset_id: <T as Config>::CurrencyId ) -> Result<Amount<T>, DispatchError>
pub fn borrow_balance_from_old_and_new_index( old_index: &FixedU128, new_index: &FixedU128, amount: Amount<T>, rounding: Rounding ) -> Result<Amount<T>, DispatchError>
sourcepub fn do_liquidate_borrow(
liquidator: T::AccountId,
borrower: T::AccountId,
repayment_underlying: &Amount<T>,
collateral_asset_id: <T as Config>::CurrencyId
) -> DispatchResult
pub fn do_liquidate_borrow( liquidator: T::AccountId, borrower: T::AccountId, repayment_underlying: &Amount<T>, collateral_asset_id: <T as Config>::CurrencyId ) -> DispatchResult
Note:
liquidation_asset_id
is borrower’s debt asset.collateral_asset_id
is borrower’s collateral asset.repay_amount
is amount of liquidation_asset_id
The liquidator will repay a certain amount of liquidation_asset_id from own account for borrower. Then the protocol will reduce borrower’s debt and liquidator will receive collateral_asset_id (as voucher amount) from borrower.
pub fn lock_if_account_deposited( account_id: &T::AccountId, lend_tokens: &Amount<T> ) -> DispatchResult
sourcepub fn total_supply(
asset_id: <T as Config>::CurrencyId
) -> Result<Amount<T>, DispatchError>
pub fn total_supply( asset_id: <T as Config>::CurrencyId ) -> Result<Amount<T>, DispatchError>
Total issuance of lending tokens (lend_tokens), given the underlying
sourcepub fn free_lend_tokens(
asset_id: <T as Config>::CurrencyId,
account_id: &T::AccountId
) -> Result<Amount<T>, DispatchError>
pub fn free_lend_tokens( asset_id: <T as Config>::CurrencyId, account_id: &T::AccountId ) -> Result<Amount<T>, DispatchError>
Free lending tokens (lend_tokens) of an account, given the underlying
sourcepub fn reserved_lend_tokens(
asset_id: <T as Config>::CurrencyId,
account_id: &T::AccountId
) -> Result<Amount<T>, DispatchError>
pub fn reserved_lend_tokens( asset_id: <T as Config>::CurrencyId, account_id: &T::AccountId ) -> Result<Amount<T>, DispatchError>
Reserved lending tokens (lend_tokens) of an account, given the underlying
pub fn get_asset_value(asset: &Amount<T>) -> Result<Amount<T>, DispatchError>
pub fn market( asset_id: <T as Config>::CurrencyId ) -> Result<Market<<T as Config>::Balance>, DispatchError>
pub fn lend_token_id( asset_id: <T as Config>::CurrencyId ) -> Result<<T as Config>::CurrencyId, DispatchError>
pub fn incentive_reward_account_id() -> T::AccountId
Trait Implementations§
source§impl<T: Config> GetStorageVersion for Pallet<T>
impl<T: Config> GetStorageVersion for Pallet<T>
§type CurrentStorageVersion = NoStorageVersionSet
type CurrentStorageVersion = NoStorageVersionSet
source§fn current_storage_version() -> Self::CurrentStorageVersion
fn current_storage_version() -> Self::CurrentStorageVersion
source§fn on_chain_storage_version() -> StorageVersion
fn on_chain_storage_version() -> StorageVersion
source§impl<T: Config> Hooks<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> Hooks<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
§fn on_finalize(_n: BlockNumber)
fn on_finalize(_n: BlockNumber)
§fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight
fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight
on_finalize
). Read more§fn on_initialize(_n: BlockNumber) -> Weight
fn on_initialize(_n: BlockNumber) -> Weight
§fn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
§fn offchain_worker(_n: BlockNumber)
fn offchain_worker(_n: BlockNumber)
§fn integrity_test()
fn integrity_test()
source§impl<T: Config> IntegrityTest for Pallet<T>
impl<T: Config> IntegrityTest for Pallet<T>
source§fn integrity_test()
fn integrity_test()
source§impl<T: Config> LoansApi<<T as Config>::CurrencyId, <T as Config>::AccountId, Amount<T>> for Pallet<T>
impl<T: Config> LoansApi<<T as Config>::CurrencyId, <T as Config>::AccountId, Amount<T>> for Pallet<T>
fn do_mint( supplier: &<T as Config>::AccountId, amount: &Amount<T> ) -> Result<(), DispatchError>
fn do_borrow( borrower: &<T as Config>::AccountId, borrow: &Amount<T> ) -> Result<(), DispatchError>
fn do_deposit_collateral( supplier: &<T as Config>::AccountId, lend_token_amount: &Amount<T> ) -> Result<(), DispatchError>
fn do_withdraw_collateral( supplier: &<T as Config>::AccountId, voucher: &Amount<T> ) -> Result<(), DispatchError>
fn do_repay_borrow( borrower: &<T as Config>::AccountId, borrow: &Amount<T> ) -> Result<(), DispatchError>
fn do_redeem( supplier: &<T as Config>::AccountId, underlying: &Amount<T>, voucher: &Amount<T> ) -> Result<(), DispatchError>
fn recompute_underlying_amount( lend_tokens: &Amount<T> ) -> Result<Amount<T>, DispatchError>
fn underlying_id( lend_token_id: <T as Config>::CurrencyId ) -> Result<<T as Config>::CurrencyId, DispatchError>
fn recompute_collateral_amount( underlying: &Amount<T> ) -> Result<Amount<T>, DispatchError>
source§impl<T: Config> LoansMarketDataProvider<<T as Config>::CurrencyId, <T as Config>::Balance> for Pallet<T>
impl<T: Config> LoansMarketDataProvider<<T as Config>::CurrencyId, <T as Config>::Balance> for Pallet<T>
fn get_market_info( asset_id: <T as Config>::CurrencyId ) -> Result<MarketInfo, DispatchError>
fn get_market_status( asset_id: <T as Config>::CurrencyId ) -> Result<MarketStatus<<T as Config>::Balance>, DispatchError>
fn get_full_interest_rate(asset_id: <T as Config>::CurrencyId) -> Option<Rate>
source§impl<T: Config> OffchainWorker<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> OffchainWorker<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
source§fn offchain_worker(n: BlockNumberFor<T>)
fn offchain_worker(n: BlockNumberFor<T>)
source§impl<T: Config> OnExchangeRateChange<<T as Config>::CurrencyId> for Pallet<T>
impl<T: Config> OnExchangeRateChange<<T as Config>::CurrencyId> for Pallet<T>
fn on_exchange_rate_change(currency_id: &<T as Config>::CurrencyId)
source§impl<T: Config> OnFinalize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> OnFinalize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
source§fn on_finalize(n: BlockNumberFor<T>)
fn on_finalize(n: BlockNumberFor<T>)
source§impl<T: Config> OnGenesis for Pallet<T>
impl<T: Config> OnGenesis for Pallet<T>
source§fn on_genesis()
fn on_genesis()
source§impl<T: Config> OnIdle<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> OnIdle<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
source§impl<T: Config> OnInitialize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> OnInitialize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
source§fn on_initialize(n: BlockNumberFor<T>) -> Weight
fn on_initialize(n: BlockNumberFor<T>) -> Weight
source§impl<T: Config> OnRuntimeUpgrade for Pallet<T>
impl<T: Config> OnRuntimeUpgrade for Pallet<T>
source§fn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
source§impl<T: Config> PalletInfoAccess for Pallet<T>
impl<T: Config> PalletInfoAccess for Pallet<T>
source§fn module_name() -> &'static str
fn module_name() -> &'static str
source§fn crate_version() -> CrateVersion
fn crate_version() -> CrateVersion
source§impl<T> PartialEq<Pallet<T>> for Pallet<T>
impl<T> PartialEq<Pallet<T>> for Pallet<T>
source§impl<T: Config> WhitelistedStorageKeys for Pallet<T>
impl<T: Config> WhitelistedStorageKeys for Pallet<T>
source§fn whitelisted_storage_keys() -> Vec<TrackedStorageKey>
fn whitelisted_storage_keys() -> Vec<TrackedStorageKey>
Vec<TrackedStorageKey>
indicating the storage keys that
should be whitelisted during benchmarking. This means that those keys
will be excluded from the benchmarking performance calculation.impl<T> Eq for Pallet<T>
Auto Trait Implementations§
impl<T> RefUnwindSafe for Pallet<T>where T: RefUnwindSafe,
impl<T> Send for Pallet<T>where T: Send,
impl<T> Sync for Pallet<T>where T: Sync,
impl<T> Unpin for Pallet<T>where T: Unpin,
impl<T> UnwindSafe for Pallet<T>where T: UnwindSafe,
Blanket Implementations§
§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
§fn checked_from<T>(t: T) -> Option<Self>where
Self: TryFrom<T>,
fn checked_from<T>(t: T) -> Option<Self>where Self: TryFrom<T>,
§fn checked_into<T>(self) -> Option<T>where
Self: TryInto<T>,
fn checked_into<T>(self) -> Option<T>where Self: TryInto<T>,
§impl<T> Conv for T
impl<T> Conv for T
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where &'a Self: for<'a> IntoIterator,
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IsType<T> for T
impl<T> IsType<T> for T
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere Self: Borrow<B>, B: 'a + ?Sized, R: 'a,
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R ) -> Rwhere Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere Self: AsRef<U>, U: 'a + ?Sized, R: 'a,
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere Self: AsMut<U>, U: 'a + ?Sized, R: 'a,
self
, then passes self.as_mut()
into the pipe
function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere Self: UniqueSaturatedFrom<T>,
§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere Self: UniqueSaturatedInto<T>,
T
. Read more§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere Self: Borrow<B>, B: ?Sized,
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere Self: BorrowMut<B>, B: ?Sized,
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere Self: AsRef<R>, R: ?Sized,
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere Self: AsMut<R>, R: ?Sized,
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere Self: Deref<Target = T>, T: ?Sized,
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere Self: DerefMut<Target = T> + Deref, T: ?Sized,
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere Self: Borrow<B>, B: ?Sized,
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere Self: BorrowMut<B>, B: ?Sized,
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere Self: AsRef<R>, R: ?Sized,
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere Self: AsMut<R>, R: ?Sized,
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§impl<T> TryConv for T
impl<T> TryConv for T
§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere T: UncheckedFrom<S>,
§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from
.§impl<T, S> UniqueSaturatedInto<T> for Swhere
T: Bounded,
S: TryInto<T>,
impl<T, S> UniqueSaturatedInto<T> for Swhere T: Bounded, S: TryInto<T>,
§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.