@descent-protocol/sdk
Version:
A Typescript library for interacting with the Descent Protocol
119 lines (118 loc) • 3.92 kB
TypeScript
import { Eip1193Provider, SigningKey } from 'ethers';
import { ICollateral, IMode } from './types';
import { Signer, Provider } from 'ethers';
import { Transaction } from './libs/transactions';
import { Internal } from './libs/internal';
export declare class DescentClass {
signer: Signer;
protected provider: Provider;
private collateral;
configMode: IMode | string;
chainId: string;
readonly internal: Internal;
readonly transaction: Transaction;
constructor(signer: Signer, provider: Provider, collateral: ICollateral, configMode: IMode | string, chainId: string);
/**
* @dev Gets a vault detail by it's ID
* @param ownerAddress Vault owner
* @returns The Vault information
*/
getVaultInfo(ownerAddress: string): Promise<{
healthFactor: string;
depositedCollateral: any;
collateralLocked: bigint;
borrowedAmount: any;
accruedFees: any;
currentCollateralRatio: any;
availableCollateral: any;
availablexNGN: any;
}>;
/**
* @dev Gets the information of collateral initialized in `create()`
* @returns The collateral information
*/
getCollateralInfo(): Promise<{
totalDepositedCollateral: any;
totalBorrowedAmount: any;
liquidationThreshold: any;
debtCeiling: any;
rate: any;
minDeposit: any;
collateralPrice: any;
}>;
/**
* @dev borrow xNGN against deposited USDC
* @param amount amount of xNGN to borrow
* @returns transaction obj
*/
borrowCurrency(borrowAmount: string): Promise<string>;
/**
* @dev repay borrowed xNGN for a particular vault
* @param amount amount of xNGN to repay
* @returns transaction obj
*/
repayCurrency(amount: string): Promise<string>;
/**
* @dev withdraw usdc for a particular vault
* @param collateralAmount amount of unlocked collateral to withdraw
* @returns transaction obj
*/
withdrawCollateral(collateralAmount: string): Promise<string>;
/**
* @dev deposit usdc for a particular vault
* @param collateralAmount amount of unlocked collateral to withdraw
* @param ownerAddress owner of the vault which should be the caller
* @returns transaction obj
*/
depositCollateral(collateralAmount: string): Promise<string>;
/**
* @dev initializes a vault for a an address
* @returns transaction obj
*/
setupVault(): Promise<string>;
/**
* @dev Check if a vault has been initialized
* @returns boolean
*/
getVaultSetupStatus(): Promise<any>;
/**
* @dev gets the collateral token balance of an address
* @param owner address of the owner
* @returns balance
*/
getCollateralTokenBalance(owner: string): Promise<string>;
/**
* @dev approve the vault to take a certain amount of collateral
* @param amount amount of allowance
* @returns tx object
*/
approveCollateral(amount: string): Promise<string>;
/**
* @dev approve the vault to take a certain amount of collateral
* @param amount amount of allowance
* @returns tx object
*/
collateralTokenAllowance(approver: string): Promise<string>;
/**
* @dev gets the xNGN balalnce of an address
* @param owner address of the owner
* @returns balance
*/
getxNGNBalance(owner: string): Promise<string>;
/**
* @dev approve the vault to take a certain amount of xNGN
* @param amount amount of allowance
* @returns tx object
*/
approvexNGN(amount: string): Promise<string>;
}
declare function create(mode: string, options: {
ethereum?: Eip1193Provider | any;
rpcUrl?: string;
privateKey?: any | SigningKey;
collateral: ICollateral;
}): Promise<DescentClass>;
declare const Descent: {
create: typeof create;
};
export default Descent;