Skip to content

VerisLabs/unlockd-ts

Repository files navigation

Unlockd logo

Unlockd SDK

typescript

The Unlockd SDK is a tool that enables developers to integrate blockchain-based RWA-backed lending and borrowing functionalities into their applications. With the Unlockd SDK, you can easily interact with the Unlockd protocol, which allows users to collateralize their tokenized assets and obtain instant, open-ended loans.

WebsiteAppSDK DocsProtocol DocsDev DocsRisk DocsSocialsDocs

🗂️ Table of Contents

About

Unlockd is a permissionless RWA liquidity protocol powered by advanced AI, enabling users to participate as depositors or borrowers. It provides a secure and cost-effective way to borrow against tokenized Real-World Assets and financial assets with instant loans and auto-compounding yield for lenders. Built on Ethereum and Polygon with plans for expansion to multiple Layer 2 networks, Unlockd offers a Peer-to-Pool model that ensures efficient and fair lending and borrowing.

The Unlockd SDK allows developers to integrate these RWA-backed borrowing functionalities into their applications. It is particularly useful for Unlockd partners with supported and whitelisted assets, enabling them to offer borrowing against assets or portfolios directly within their interfaces and provide financing options at the point of purchase.

Features

  • Create signatures for:
    • Borrow
    • Repay
    • Bid
    • Redeem
    • Sell now
    • Market calls
  • Calculate:
    • Minimum amount to repay a loan
    • Liquidation price of a loan
    • Health factor of a loan
    • Available amount to action

Browser Support

Chrome Firefox Safari Opera Edge IE
Latest ✔ Latest ✔ Latest ✔ Latest ✔ Latest ✔ 11 ✔

Installing

Package manager

Using npm:

$ npm install @verislabs/unlockd-sdk

Using bower:

$ bower install @verislabs/unlockd-sdk

Using yarn:

$ yarn add @verislabs/unlockd-sdk

Using pnpm:

$ pnpm add @verislabs/unlockd-sdk

Example

Fetch prices

import { UnlockdApi} from "@verislabs/unlockd-sdk";

const api= new UnlockdApi()
 const params = {
            "nfts":
                [
                    {
                        "collection": "0x1750d2e6f2fb7fdd6a751833f55007cf76fbb358",
                        "tokenId": "10"
                    }
                ],
            "underlyingAsset": "0x7b79995e5f793a07bc00c21412e50ecae098e7f9"
        }
const response = await api.prices(params.nfts, params.underlyingAsset)

Login

import { UnlockdApi} from "@verislabs/unlockd-sdk";

const api= new UnlockdApi()
const address='0x0000000000000000000000000000000000000000'
const message = await api.signatureMessage(address)
//Sign message from your wallet or with Pk
//...
const signedMessage='...'
const authToken = await api.validateMessage(signedMessage)

Borrow signature

//At least one of the props
import {ActionRequest, UnlockdApi} from "@verislabs/unlockd-sdk";
const api= new UnlockdApi()

const params: ActionRequest = {
  loanId: '0x123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0',//Optional
  nfts: [{collection: '0x1234567890abcdefABCDEF1234567890abcdefAB', tokenId: 'testTokenId'}]//Optional 
}
const authToken = await api.borrowSignature(authToken, params)

Minimum Repay

import {minimumToRepay} from "@verislabs/unlockd-sdk";

const params = {
    initialLoans: [
        {
            valuation: 10000000n,
            ltv: 5000n,
        },
        {
            valuation: 10000000n,
            ltv: 5000n,
        },
    ],
    indicesToDelete: [1],
    totalDebt: 2n,
}
const result = minimumToRepay(params)

Liquidation price

import {liquidationPrice} from "@verislabs/unlockd-sdk";
const oneEth = BigInt(1e18)

const params = {
    debt: (BigInt(50) * oneEth),
    liquidationThreshold: BigInt(8500)
}
const result = liquidationPrice(params)

Health Factor

import {healthFactor} from "@verislabs/unlockd-sdk";
const oneEth = BigInt(1e18)

const params = {
  collateral: (BigInt(100) * oneEth),
  debt: (BigInt(50) * oneEth),
  liquidationThreshold: BigInt(8500)
}
const result = healthFactor(params)

Available to action

import {availableToBorrow} from "@verislabs/unlockd-sdk";

const nfts = [
  {
    valuation: (BigInt(100) * oneEth).toString(),
    ltv: '5000'
  },
  {
    valuation: (BigInt(50) * oneEth).toString(),
    ltv: '3000'
  }
]

const result = availableToBorrow(nfts)

Keywords

  • RWA
  • Real World Assets
  • Tokenization
  • NFT lending
  • Liquidity pool
  • Blockchain
  • Decentralized Finance
  • DeFi
  • Crypto
  • Permissionless
  • Loans

Publish

  1. Click on releases
  2. Write the changes
  3. Create new Tag
  4. Publish

Built With

  • Typescript
  • Love

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

  • Enric Borrallo - Initial work - eborrallo
  • Alejandro Roige - All the other cool stuff - roigecode

See also the list of contributors who participated in this project.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages