Supply and Borrow
Last updated
Last updated
Suppliers can deposit their assets to Parallel Finance. For providing liquidity, in return, they will receive some of the borrower's interests.
Suppliers can also choose to collateralize their assets for borrowing other currencies. This is useful when the price of a certain currency fluctuates significantly and you want to borrow another currency for hedging. This also solves the liquidity of your cryptocurrency.
Currencies have different Collateral Rate
which reflects the stability of their price. The more stable the currency's price, the higher the collateral rate. Stable coins USDT
will have a higher Collateral Rate
.
After the deposit, users will be given some deposit certificates
so that they can redeem the underlying assets. The number of issued deposited certificate is determined by the Exchange Rate
Supply Interest Rate
is proportional to Utilization Rate
and Borrow Interest Rate
The timestamp of the previous block or defaults to timestamp at genesis.
Total number of collateral tokens in circulation, CollateralType -> Balance
Key Name
Type
Description
currency_id
CurrencyId
The currency's Id
Tip: Follow the link to know more about 'CurrencyId'.
The total amount of outstanding borrows of the underlying in this market, CurrencyType -> Balance
Key Name
Type
Description
currency_id
CurrencyId
The currency's Id
Total amount of reserves of the underlying held in this market, CurrencyType -> Balance
Key Name
Type
Description
currency_id
CurrencyId
The currency's Id
Mapping of account addresses to outstanding borrow balances, CurrencyType -> Owner -> BorrowSnapshot
Key Name
Type
Description
currency_id
CurrencyId
The currency's Id
account_id
T::AccountId
The borrower's account id
Mapping of account addresses to deposit details, CollateralType -> Owner -> Deposits
Key Name
Type
Description
currency_id
CurrencyId
The currency's Id
account_id
T::AccountId
The depositor's account id
Mapping of account addresses to total deposit interest accrual, CurrencyType -> Owner -> EarnedSnapshot
Key Name
Type
Description
currency_id
CurrencyId
The currency's Id
account_id
T::AccountId
The depositor's account id
Accumulator of the total earned interest rate since the opening of the market, CurrencyType -> u128
Key Name
Type
Description
currency_id
CurrencyId
The currency's Id
The currency types support on lending markets
The exchange rate from the underlying to the internal collateral
Key Name
Type
Description
currency_id
CurrencyId
The currency's Id
The utilization point at which the jump multiplier is applied
Key Name
Type
Description
currency_id
CurrencyId
The currency's Id
Mapping of borrow rate to currency type
Key Name
Type
Description
currency_id
CurrencyId
The currency's Id
Mapping of supply rate to currency type
Key Name
Type
Description
currency_id
CurrencyId
The currency's Id
The collateral utilization ratio
Key Name
Type
Description
currency_id
CurrencyId
The currency's Id
The collateral utilization ratio
Key Name
Type
Description
currency_id
CurrencyId
The currency's Id
Fraction of interest currently set aside for reserves
Key Name
Type
Description
currency_id
CurrencyId
The currency's Id
Liquidation incentive ratio
Key Name
Type
Description
currency_id
CurrencyId
The currency's Id
The percent, ranging from 0% to 100%, of a liquidatable account's borrow that can be repaid in a single liquidate transaction.
Key Name
Type
Description
currency_id
CurrencyId
The currency's Id
Sender supplies assets into the market and receives internal supplies in exchange.
Name
Substrate Config
Runtime Type
Description
origin
T::Origin
RawOrigin
The account signed this transaction
currency_id
-
CurrencyId
the asset to be deposited
mint_amount
T::Balance
u128
the amount to be deposited
RETURN: Returns Ok() when mint succeeds, otherwise return a substrate error type.
Tip: Follow the link to know more about 'RawOrigin', 'CurrencyId'.
Sender redeems some of internal supplies in exchange for the underlying asset.
Name
Substrate Config
Runtime Type
Description
origin
T::Origin
RawOrigin
The account signed this transaction
currency_id
-
CurrencyId
the asset to be redeemed
redeem_amount
T::Balance
u128
the amount to be redeemed
RETURN: Returns Ok() when redeem succeeds, otherwise return a substrate error type.
Senders redeem all internal supplies in exchange for the underlying asset.
Name
Substrate Config
Runtime Type
Description
origin
T::Origin
RawOrigin
The account signed this transaction
currency_id
-
CurrencyId
the asset to be redeemed
RETURN: Returns Ok() when redeem_all succeeds, otherwise return a substrate error type.
Sender borrows assets from the protocol to their own address.
Name
Substrate Config
Runtime Type
Description
origin
T::Origin
RawOrigin
The account signed this transaction
currency_id
-
CurrencyId
the asset to be borrowed
borrow_amount
T::Balance
u128
the amount to be borrowed
RETURN: Returns Ok() when borrow succeeds, otherwise return a substrate error type.
Sender repays some of their debts.
Name
Substrate Config
Runtime Type
Description
origin
T::Origin
RawOrigin
The account signed this transaction
currency_id
-
CurrencyId
the asset to be repaid
repay_amount
T::Balance
u128
the amount to be repaid
RETURN: Returns Ok() when repay_borrow succeeds, otherwise return a substrate error type.
Sender repays all of their debts.
Name
Substrate Config
Runtime Type
Description
origin
T::Origin
RawOrigin
The account signed this transaction
currency_id
-
CurrencyId
the asset to be repaid
RETURN: Returns Ok() when repay_borrow_all succeeds, otherwise return a substrate error type.
Sets a new liquidation incentive percentage for currency_id
. Returns Err
if the provided asset is not attached to an existent incentive.
Name
Substrate Config
Runtime Type
Description
origin
T::Origin
RawOrigin
The account signed this transaction
currency_id
-
CurrencyId
the asset that is going to be modified
liquidate_incentive
-
Rate
FixedU128 type that represents liquidate incentive rate
RETURN: Returns Ok() when set_liquidation_incentive succeeds, otherwise return a substrate error type.
Tip: Follow the link to know more about 'FixedU128'.
Using for development
Name
Substrate Config
Runtime Type
Description
origin
T::Origin
RawOrigin
The account signed this transaction
to
T::AccountId
AccountId
The received account
currency_id
-
CurrencyId
The transferred asset
amount
T::Balance
u128
The number of transfer assets
RETURN: Returns Ok() when transfer_token succeeds, otherwise return a substrate error type.
Set the collateral asset.
Name
Substrate Config
Runtime Type
Description
origin
T::Origin
RawOrigin
The account signed this transaction
currency_id
-
CurrencyId
the asset to be set
enable
-
bool
Turn on/off the collateral option.
RETURN: Returns Ok() when collateral_asset succeeds, otherwise return a substrate error type.
The sender liquidates the borrower's collateral.
Name
Substrate Config
Runtime Type
Description
origin
T::Origin
RawOrigin
The account signed this transaction
borrower
T::AccountId
AccountId
The borrower to be liquidated
liquidate_token
-
CurrencyId
The asset to be liquidated
repay_amount
T::Balance
u128
The amount to be repaid borrow
collateral_token
-
CurrencyId
The collateral to seize from the borrower
RETURN: Returns Ok() when liquidate_borrow succeeds, otherwise return a substrate error type.
Update the interest rate model for a given asset. May only be called from T::UpdateOrigin
.
Name
Substrate Config
Runtime Type
Description
origin
T::Origin
RawOrigin
The account signed this transaction
currency_id
-
CurrencyId
the asset to be set
new_model
-
InterestRateModel
The interest rate model to be set
RETURN: Returns Ok() when set_rate_model succeeds, otherwise return a substrate error type.
Tip: Follow the link to know more about 'InterestRateModel'.
Add reserves by transferring from the payer. May only be called from T::ReserveOrigin
.
Name
Substrate Config
Runtime Type
Description
origin
T::Origin
RawOrigin
The account signed this transaction
payer
T::Lookup::Source
MultiAddress
The payer account
currency_id
-
CurrencyId
The assets to be added
add_amount
T::Balance
u128
The amount to be added
RETURN: Returns Ok() when add_reserves succeeds, otherwise return a substrate error type.
Tip: Follow the link to know more about 'MultiAddress'.
Reduces reserves by transferring to receiver. May only be called from T::ReserveOrigin
.
Name
Substrate Config
Runtime Type
Description
origin
T::Origin
RawOrigin
The account signed this transaction
receiver
T::Lookup::Source
MultiAddress
The receiver account
currency_id
-
CurrencyId
The assets to be reduced
reduce_amount
T::Balance
u128
The amount to be reduced
RETURN: Returns Ok() when reduce_reserves succeeds, otherwise return a substrate error type.
Enable collateral for certain asset, [sender, currency_id]
CollateralAssetAdded(T::AccountId, CurrencyId)
Disable collateral for a certain asset, [sender, currency_id]
CollateralAssetRemoved(T::AccountId, CurrencyId)
Event emitted when assets are deposited, [sender, currency_id, amount]
Deposited(T::AccountId, CurrencyId, Balance)
Event emitted when assets are redeemed, [sender, currency_id, amount]
Redeemed(T::AccountId, CurrencyId, Balance)
Event emitted when cash is borrowed, [sender, currency_id, amount]
Borrowed(T::AccountId, CurrencyId, Balance)
Event emitted when a borrow is repaid, [sender, currency_id, amount]
RepaidBorrow(T::AccountId, CurrencyId, Balance)
Event emitted when a borrow is liquidated,
[liquidator, borrower, liquidate_token, collateral_token, repay_amount, collateral_amount]
LiquidatedBorrow( T::AccountId, T::AccountId, CurrencyId, CurrencyId, Balance, Balance, )
New interest rate model is set, [new_interest_rate_model]
NewInterestRateModel(InterestRateModel)
Event emitted when the reserves are reduced, [admin, currency_id, reduced_amount, total_reserves]
ReservesReduced(T::AccountId, CurrencyId, Balance, Balance)
Event emitted when the reserves are added, [admin, currency_id, added_amount, total_reserves]
ReservesAdded(T::AccountId, CurrencyId, Balance, Balance)
Name
Description
InsufficientLiquidity
Insufficient liquidity to borrow more or disable collateral
InsufficientDeposit
Insufficient deposit to redeem
RepayAmountExceedsCloseFactor
Repay amount greater than borrow balance
DuplicateOperation
Asset already enabled/disabled collateral
NoDeposit
No deposit asset
RepayValueGreaterThanCollateral
Repay amount more than collateral amount
LiquidatorIsBorrower
Liquidator is same as borrower
NoBorrowBalance
There is no borrow balance
LiquidateValueOverflow
Liquidate value overflow
InsufficientReserves
Insufficient reserves
InvalidRateModelParam
Invalid rate model params
CurrencyNotEnabled
Currency not enabled
PriceOracleNotReady
Currency's oracle price not ready