pluto-loans-sdk
TypeScript icon, indicating that this package has built-in type declarations

1.2.2 • Public • Published

loans-sdk

loans-sdk is a Javascript library for communicating with the API of loans. It is used to take pluto-loans and/or withdraw the collateral.

See the accepted assets for taking a loan and settle the debt

This project is built using Typescript, and vitest for unit testing

See the examples to use the SDK

Quick start

Install

  1. Install it using npm:
npm i plutodao-loans-sdk
  1. import/require into your project:
import * as loansSdk from 'plutodao-loans-sdk';

SDK

The loans-sdk will export the following functions:

getLoanIntent(server: ApiStellarNetwork, borrower: string, entryBalance: BalanceDto)

Returns a loan intent transaction XDR

getLoanStatus(server: ApiStellarNetwork, borrower: string)

Returns the loan status

getSettleDebtIntent(server: ApiStellarNetwork, borrower: string, debtCancellationAsset: ILoanAssetRequest)

Returns a repay withdraw collateral intent transaction XDR to be signed by the borrower to cancel the remaining debt

getWithdrawCollateralIntent(server: ApiStellarNetwork, borrower: string)

Returns a withdraw collateral intent transaction XDR to be signed by the borrower once the loan has paid itself

sendLoan(server: ApiStellarNetwork, borrower: string, loanSignedTransaction: string)

Submits a signed loan intent transaction XDR to get a loan

sendWithdrawCollateral(server: ApiStellarNetwork, borrower: string, withdrawCollateralSignedXdr: string)

Submits a signed withdraw collateral intent transaction XDR to withdraw the loan collateral

Classes

The loans-sdk will export the following classes:

LoanAssetRequest

A class representing the asset required for the API

class LoanAssetRequest implements ILoanAssetRequest {
    public code?: string;
    public issuer?: string;
    public isNative: boolean;

    constructor(isNative: boolean, assetCode?: string, assetIssuer?: string) {
        this.code = assetCode;
        this.issuer = assetIssuer;
        this.isNative = isNative;
        
        if (isNative) {
            this.code = 'XLM';
        }
    }
}

LoanStatusResponse

A class representing the status of a loan

class LoanStatusResponse implements ILoanStatusResponse {
    public percentagePaid: number;
    public remainingDebt: number;
    public userTotalYusdcInVault: number;

    constructor(
        percentagePaid: number,
        remainingDebt: number,
        userTotalYusdcInVault: number,
    ) {
        this.percentagePaid = percentagePaid;
        this.remainingDebt = remainingDebt;
        this.userTotalYusdcInVault = userTotalYusdcInVault;
    }
}

BalanceDto

A class representing the required info to determine which asset is used to take the loan and how much will be the amount

class BalanceDto implements IBalanceDto {
    public asset: LoanAssetRequest;
    public amount: string;

    constructor(asset: LoanAssetRequest, amount: string) {
        this.asset = asset;
        this.amount = amount;
    }
}

Accepted assets

To take a loan

  • XLM
  • YXLM
  • PUSD
  • USDC
  • YUSDC
  • ARS
  • ARST
  • AQUA
  • BTC
  • ETH

To settle the debt

  • PUSD
  • USDC
  • YUSDC

/pluto-loans-sdk/

    Package Sidebar

    Install

    npm i pluto-loans-sdk

    Weekly Downloads

    0

    Version

    1.2.2

    License

    ISC

    Unpacked Size

    44.8 kB

    Total Files

    40

    Last publish

    Collaborators

    • ja-boop