import { Fixed18 } from './fixed-18'; import { Codec } from '@polkadot/types/types'; /** * @name debitToStableCoin * @description transform debit to stable coin * @param {Fixed18} quantity - user loan debit quantity * @param {Fixed18} debitExchangeRate - loan debit exchange rate * @returns {Fixed18} return the stable coin quantity */ export declare function debitToStableCoin(quantity: Fixed18, debitExchangeRate: Fixed18): Fixed18; /** * @name stableCoinToDebit * @description transform stable coin to debit * @param {Fixed18} amount - stable coin amount * @param {Fixed18} debitExchangeRate - loan debit exchange rate * @returns {Fixed18} return the debit quantity */ export declare function stableCoinToDebit(amount: Fixed18, debitExchangeRate: Fixed18): Fixed18; /** * @name debitToUSD * @description transform debit to USD * @param {Fixed18} quantity - user loan debit quantity * @param {Fixed18} debitExchangeRate - loan debit exchange rate * @param {Fixed18} stableCoinPrice - stable coin price * @returns {Fixed18} return the debit amount denominated in USD */ export declare function debitToUSD(quantity: Fixed18, debitExchangeRate: Fixed18, stableCoinPrice: Fixed18): Fixed18; /** * @name USDToDebit * @description transform USD to debit * @param {Fixed18} amount - USD amount * @param {Fixed18} debitExchangeRate - loan debit exchange rate * @param {Fixed18} stableCoinPrice - stable coin price * @returns {Fixed18} return the debit quantity */ export declare function USDToDebit(amount: Fixed18, debitExchangeRate: Fixed18, stableCoinPrice: Fixed18): Fixed18; /** * @name collateralToUSD * @description transform collateral to USD * @param {Fixed18} quantity - collateral quantity * @param {Fixed18} collateralPrice - collateral price * @returns {Fixed18} return the collateral amount denominated in USD */ export declare function collateralToUSD(quantity: Fixed18, collateralPrice: Fixed18): Fixed18; /** * @name USDToCollateral * @description transform USD to collateral * @param {Fixed18} amount - USD amount * @param {Fixed18} collateralPrice - collateral price * @returns {Fixed18} return the collateral quantity */ export declare function USDToCollateral(amount: Fixed18, collateralPrice: Fixed18): Fixed18; /** * @name calcCollateralRatio * @description calculate collateral ratio. Equation: collateralRatio = collateralAmount / debitAmount * @param {Fixed18} collateralAmount - collateral amount (USD) * @param {Fixed18} debitAmount - debit amount (USD) * @returns {Fixed18} return collateral ratio */ export declare function calcCollateralRatio(collateralAmount: Fixed18, debitAmount: Fixed18): Fixed18; /** * @name calcStableFeeAPR * @description calculate stable fee annual percentage rate. Equation: stableFee = (1 + stableFee) ** (yearSecond * 1000 / expectedBlockTime) - 1 * @param {Fixed18} stableFee - loan stable fee on the chain config * @param {number} expectedBlockTime - expected block time on the chain config (precision in milliseconds) * @return {Fixed18} return stable fee annual percentage rate */ export declare function calcStableFeeAPR(stableFee: Fixed18, blockTime: number): Fixed18; /** * @name calcRequiredCollateral * @description calculate how many collateral needs. Equation: requiredColalteral = debitAmount * requiredCollateralRatio / collateralPrice * the function always returns a nonnegative number * @param {Fixed18} debitAmount - debit amount (USD) * @param {Fixed18} requiredCollateralRatio - required collateral ratio * @param {Fixed18} collateralPrice - collateral price * @returns {Fixed18} return the collateral quantity which is required */ export declare function calcRequiredCollateral(debitAmount: Fixed18, requiredCollateralRatio: Fixed18, collateralPrice: Fixed18): Fixed18; /** * @name calcLiquidationPrice * @description calculate liquidation price. Equation: liquidatioPrice = debitAmount * liquidatioRatio / collateralQuantity * the function always returns a positive number or NaN * @param {Fixed18} collateralQuantity - collateral quantity * @param {Fixed18} debitAmount - debit amount (USD) * @param {Fixed18} liquidationRatio - required liquidation ratio on the chain config * @returns {Fixed18} return liquidation price */ export declare function calcLiquidationPrice(collateralQuantity: Fixed18, debitAmount: Fixed18, liquidationRatio: Fixed18): Fixed18; /** * @name calcCanGenerate * @description calculate how many stable coins can generate. Equation: canGenerate = (collateralAmount / requiredCollateralRatio - currentDebitAmount) / stableCoinPrice * the function always returns a nonnegative number * @param {Fixed18} collateralAmount - collateral amount (USD) * @param {Fixed18} currentDebitAmount - current debit amount in the loan (USD) * @param {Fixed18} requiredCollateralRatio - loan required collateral ratio on the chain config * @param {Fixed18} stableCoinPrice - stable coin price * @param {Fixed18} [slippage=0] - slippage amount, because canGenerate amount is reduce every block time. * @returns {Fixed18} return stable coin quantity which can be generated */ export declare function calcCanGenerate(collateralAmount: Fixed18, currentDebitAmount: Fixed18, requiredCollateralRatio: Fixed18, stableCoinPrice: Fixed18, slippage?: Fixed18): Fixed18; interface LoanParams { debits: Fixed18 | Codec; collaterals: Fixed18 | Codec; requiredCollateralRatio: Fixed18 | Codec; stableFee: Fixed18 | Codec; globalStableFee: Fixed18 | Codec; expectedBlockTime: number; liquidationRatio: Fixed18 | Codec; collateralPrice: Fixed18 | Codec; stableCoinPrice: Fixed18 | Codec; debitExchangeRate: Fixed18 | Codec; } /** * @class LoanHelper * @classdesc support more structured api, include loan properties and derived properties */ export declare class LoanHelper { debits: Fixed18; collaterals: Fixed18; requiredCollateralRatio: Fixed18; stableFee: Fixed18; globalStableFee: Fixed18; expectedBlockTime: number; liquidationRatio: Fixed18; collateralPrice: Fixed18; stableCoinPrice: Fixed18; debitExchangeRate: Fixed18; constructor(params: LoanParams); /** * @property {Fixed18} debitAmount */ get debitAmount(): Fixed18; /** * @property {Fixed18} collateralAmount */ get collateralAmount(): Fixed18; /** * @property {Fixed18} collateralRatio */ get collateralRatio(): Fixed18; /** * @property {Fixed18} requiredCollateral */ get requiredCollateral(): Fixed18; /** * @property {Fixed18} stableFeAPR */ get stableFeeAPR(): Fixed18; /** * @property {Fixed18} liquidationPrice */ get liquidationPrice(): Fixed18; /** * @property {Fixed18} canGenerate */ get canGenerate(): Fixed18; /** * @property {Fixed18} canPayback */ get canPayBack(): Fixed18; } export {};