Supply and Borrow
Overview
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
Supply and Borrow Process
View Data Storage
LastBlockTimestamp
The timestamp of the previous block or defaults to timestamp at genesis.
TotalSupply
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'.
TotalBorrows
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 |
TotalReserves
Total amount of reserves of the underlying held in this market, CurrencyType -> Balance
Key Name | Type | Description |
currency_id | CurrencyId | The currency's Id |
AccountBorrows
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 |
AccountDeposits
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 |
AccountEarned
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 |
BorrowIndex
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 |
Currencies
The currency types support on lending markets
ExchangeRate
The exchange rate from the underlying to the internal collateral
Key Name | Type | Description |
currency_id | CurrencyId | The currency's Id |
CurrencyInterestModel
The utilization point at which the jump multiplier is applied
Key Name | Type | Description |
currency_id | CurrencyId | The currency's Id |
BorrowRate
Mapping of borrow rate to currency type
Key Name | Type | Description |
currency_id | CurrencyId | The currency's Id |
SupplyRate
Mapping of supply rate to currency type
Key Name | Type | Description |
currency_id | CurrencyId | The currency's Id |
UtilizationRatio
The collateral utilization ratio
Key Name | Type | Description |
currency_id | CurrencyId | The currency's Id |
CollateralFactor
The collateral utilization ratio
Key Name | Type | Description |
currency_id | CurrencyId | The currency's Id |
ReserveFactor
Fraction of interest currently set aside for reserves
Key Name | Type | Description |
currency_id | CurrencyId | The currency's Id |
LiquidationIncentive
Liquidation incentive ratio
Key Name | Type | Description |
currency_id | CurrencyId | The currency's Id |
CloseFactor
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 |
View Methods
Mint()
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'.
Redeem()
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.
Redeem_all()
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.
Borrow()
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.
Repay_borrow()
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.
Repay_borrow_all()
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.
Set_liquidation_incentive()
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'.
Transfer_token()
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.
Collateral_asset()
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.
Liquidate_borrow()
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.
Set_rate_model()
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()
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'.
Reduce_reserves()
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.
View Event
CollateralAssetAdded
Enable collateral for certain asset, [sender, currency_id]
CollateralAssetAdded(T::AccountId, CurrencyId)
CollateralAssetRemoved
Disable collateral for a certain asset, [sender, currency_id]
CollateralAssetRemoved(T::AccountId, CurrencyId)
Deposited
Event emitted when assets are deposited, [sender, currency_id, amount]
Deposited(T::AccountId, CurrencyId, Balance)
Redeemed
Event emitted when assets are redeemed, [sender, currency_id, amount]
Redeemed(T::AccountId, CurrencyId, Balance)
Borrowed
Event emitted when cash is borrowed, [sender, currency_id, amount]
Borrowed(T::AccountId, CurrencyId, Balance)
RepaidBorrow
Event emitted when a borrow is repaid, [sender, currency_id, amount]
RepaidBorrow(T::AccountId, CurrencyId, Balance)
LiquidatedBorrow
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, )
NewInterestRateModel
New interest rate model is set, [new_interest_rate_model]
NewInterestRateModel(InterestRateModel)
ReservesReduced
Event emitted when the reserves are reduced, [admin, currency_id, reduced_amount, total_reserves]
ReservesReduced(T::AccountId, CurrencyId, Balance, Balance)
ReservesAdded
Event emitted when the reserves are added, [admin, currency_id, added_amount, total_reserves]
ReservesAdded(T::AccountId, CurrencyId, Balance, Balance)
View Error
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 |
Last updated