interbtc-api

@interlay/interbtc-api / Exports / LoansAPI

Interface: LoansAPI

Implemented by

Table of contents

Methods

Methods

borrow

borrow(underlyingCurrency, amount): Promise<ExtrinsicData>

Borrow currency from the protocol.

Parameters

Name Type Description
underlyingCurrency CurrencyExt Currency to borrow.
amount MonetaryAmount<CurrencyExt> Amount of currency to borrow.

Returns

Promise<ExtrinsicData>

A submittable extrinsic and an event that is emitted when extrinsic is submitted.

Throws

If there is no active market for underlyingCurrency.

Throws

If there is not enough collateral provided by account for amount of underlyingCurrency.

Throws

If amount is higher than available amount of underlyingCurrency in the protocol.

Defined in

src/parachain/loans.ts:181


claimAllSubsidyRewards

claimAllSubsidyRewards(): ExtrinsicData

Claim subsidy rewards for all markets available for account.

Returns

ExtrinsicData

A submittable extrinsic and an event that is emitted when extrinsic is submitted.

Defined in

src/parachain/loans.ts:167


disableAsCollateral

disableAsCollateral(underlyingCurrency): Promise<ExtrinsicData>

Enable lend position of account as collateral for borrowing.

Parameters

Name Type Description
underlyingCurrency CurrencyExt Currency to enable as collateral.

Returns

Promise<ExtrinsicData>

A submittable extrinsic and an event that is emitted when extrinsic is submitted.

Throws

If there is no existing lend position for currency.

Throws

If disabling lend position of currency would bring account under collateral threshold.

Defined in

src/parachain/loans.ts:161


enableAsCollateral

enableAsCollateral(underlyingCurrency): Promise<ExtrinsicData>

Enable lend position of account as collateral for borrowing.

Parameters

Name Type Description
underlyingCurrency CurrencyExt Currency to enable as collateral.

Returns

Promise<ExtrinsicData>

A submittable extrinsic and an event that is emitted when extrinsic is submitted.

Throws

If there is no existing lend position for currency.

Defined in

src/parachain/loans.ts:150


getAccruedRewardsOfAccount

getAccruedRewardsOfAccount(accountId): Promise<AccruedRewards>

Get accrued subsidy rewards amounts for the account.

Parameters

Name Type Description
accountId AccountId Account to get rewards for

Returns

Promise<AccruedRewards>

Total amount how much rewards the account can claim and rewards per market.

Defined in

src/parachain/loans.ts:107


getBorrowPositionsOfAccount

getBorrowPositionsOfAccount(accountId): Promise<BorrowPosition[]>

Get the borrow positions for given account.

Parameters

Name Type Description
accountId AccountId the account Id for which to get borrow positions

Returns

Promise<BorrowPosition[]>

Array of borrow positions of account.

Defined in

src/parachain/loans.ts:61


getBorrowerAccountIds

getBorrowerAccountIds(): Promise<AccountId[]>

Returns

Promise<AccountId[]>

An array of AccountIds which historically borrowed from the lending protocol. This includes accounts with zero outstanding debt.

Defined in

src/parachain/loans.ts:228


getLendPositionsOfAccount

getLendPositionsOfAccount(accountId): Promise<CollateralPosition[]>

Get the lend positions for given account.

Parameters

Name Type Description
accountId AccountId the account Id for which to get supply positions

Returns

Promise<CollateralPosition[]>

Array of lend positions of account.

Defined in

src/parachain/loans.ts:53


getLendTokenExchangeRates

getLendTokenExchangeRates(): Promise<TickerToData<Big>>

Returns

Promise<TickerToData<Big>>

Exchange rates for underlying currency -> lend token. Representing amount of lend token equal to 1 of underlying currency.

Defined in

src/parachain/loans.ts:99


getLendTokens

getLendTokens(): Promise<LendToken[]>

Get all lend token currencies.

Returns

Promise<LendToken[]>

Array of all LendToken currencies.

Defined in

src/parachain/loans.ts:93


getLendingStats

getLendingStats(lendPositions, borrowPositions, loanAssets): undefined | LendingStats

Get collateralization information about account’s loans.

Parameters

Name Type Description
lendPositions CollateralPosition[] Lend positions of account.
borrowPositions BorrowPosition[] Borrow positions of account.
loanAssets TickerToData<LoanAsset> All loan assets data in TickerToData structure.

Returns

undefined | LendingStats

Collateral information about account based on passed positions.

Throws

When loanAssets does not contain all of the loan positions currencies.

Defined in

src/parachain/loans.ts:72


getLiquidationThresholdLiquidity

getLiquidationThresholdLiquidity(accountId): Promise<AccountLiquidity>

Parameters

Name Type Description
accountId AccountId The account whose liquidity to query from the chain

Returns

Promise<AccountLiquidity>

An AccountLiquidity object, which is valid even for accounts that didn’t use the loans pallet at all

Defined in

src/parachain/loans.ts:233


getLoanAssets

getLoanAssets(): Promise<TickerToData<LoanAsset>>

Get all loan assets.

Returns

Promise<TickerToData<LoanAsset>>

Array of all assets that can be lent and borrowed.

Remarks

Method could be refactored to compute APR in lib if we can get underlyingCurrency/rewardCurrency exchange rate, but is it safe to assume that exchange rate for btc/underlyingCurrency will be always fed to the oracle and available?

Defined in

src/parachain/loans.ts:86


getLoansMarkets

getLoansMarkets(): Promise<[CurrencyExt, LoansMarket][]>

Returns

Promise<[CurrencyExt, LoansMarket][]>

An array of tuples denoting the underlying currency of a market, and the configuration of that market

Defined in

src/parachain/loans.ts:237


getUndercollateralizedBorrowers

getUndercollateralizedBorrowers(): Promise<UndercollateralizedPosition[]>

Returns

Promise<UndercollateralizedPosition[]>

An array of UndercollateralizedPositions, with all details needed to liquidate them (accountId, shortfall - expressed in the wrapped currency, open borrow positions, collateral deposits).

Defined in

src/parachain/loans.ts:223


lend

lend(underlyingCurrency, amount): Promise<ExtrinsicData>

Lend currency to protocol for borrowing.

Parameters

Name Type Description
underlyingCurrency CurrencyExt Currency to lend.
amount MonetaryAmount<CurrencyExt> Amount of currency to lend.

Returns

Promise<ExtrinsicData>

A submittable extrinsic and an event that is emitted when extrinsic is submitted.

Throws

If there is not active market for underlyingCurrency.

Throws

If amount is exceeding available balance of account.

Defined in

src/parachain/loans.ts:118


liquidateBorrowPosition

liquidateBorrowPosition(borrower, liquidationCurrency, repayAmount, collateralCurrency): ExtrinsicData

Liquidates borrow position for exchange of collateral.

Parameters

Name Type Description
borrower AccountId AccountId of borrower whose position will be liquidated.
liquidationCurrency CurrencyExt Currency of position that will be liquidated.
repayAmount MonetaryAmount<CurrencyExt> Amount to be repaid.
collateralCurrency CurrencyExt Collateral currency which will be claimed by liquidator.

Returns

ExtrinsicData

A submittable extrinsic and an event that is emitted when extrinsic is submitted.

Defined in

src/parachain/loans.ts:212


repay

repay(underlyingCurrency, amount): Promise<ExtrinsicData>

Repay borrowed loan.

Parameters

Name Type Description
underlyingCurrency CurrencyExt Currency to repay.
amount MonetaryAmount<CurrencyExt> Amount of currency to repay.

Returns

Promise<ExtrinsicData>

A submittable extrinsic and an event that is emitted when extrinsic is submitted.

Throws

If there is no active market for underlyingCurrency.

Throws

If amount is higher than available balance of account.

Throws

If amount is higher than outstanding loan.

Defined in

src/parachain/loans.ts:193


repayAll

repayAll(underlyingCurrency): Promise<ExtrinsicData>

Same as repay, but repays full loan.

Parameters

Name Type Description
underlyingCurrency CurrencyExt Currency to repay.

Returns

Promise<ExtrinsicData>

A submittable extrinsic and an event that is emitted when extrinsic is submitted.

Defined in

src/parachain/loans.ts:201


withdraw

withdraw(underlyingCurrency, amount): Promise<ExtrinsicData>

Withdraw previously lent currency from protocol.

Parameters

Name Type Description
underlyingCurrency CurrencyExt Currency to witdhraw.
amount MonetaryAmount<CurrencyExt> Amount of currency to withdraw.

Returns

Promise<ExtrinsicData>

A submittable extrinsic and an event that is emitted when extrinsic is submitted.

Throws

If there is not active market for underlyingCurrency.

Throws

If amount is exceeding lent amount of account.

Throws

If underlyingCurrency is used as collateral and withdrawal of amount would bring account under collateral threshold.

Throws

If there is not enough of underlying currency currently available in the protocol.

Defined in

src/parachain/loans.ts:133


withdrawAll

withdrawAll(underlyingCurrency): Promise<ExtrinsicData>

Same as withdraw, but exits full position.

Parameters

Name Type Description
underlyingCurrency CurrencyExt Currency to fully withdraw.

Returns

Promise<ExtrinsicData>

A submittable extrinsic and an event that is emitted when extrinsic is submitted.

Defined in

src/parachain/loans.ts:141