3.2.19 • Published 14 days ago

juna v3.2.19

Weekly downloads
-
License
-
Repository
github
Last release
14 days ago

JUNA - A cross platform NFT lending client for serious lenders

Setup

For users (not implemented)

npm install juna

For contributors

Clone the repository

git clone https://github.com/swissquant/juna.git

Install bun:

curl -fsSL https://bun.sh/install | bash

Install dependencies:

bun install

You're good to go!

Usage

Client initialization

Platform specific client

To only operate from a specific lending platform.

Please note that privateKey is optional. It is only necessary if you want to create loan offers.

import { NftfiClient, ArcadeClient, GondiClient } from "juna";

// Arcade client
const arcadeClient = new ArcadeClient({ privateKey: PRIVATE_KEY, apiKey: API_KEY });

// Nftfi client
const nftfiClient = new NftfiClient({ privateKey: PRIVATE_KEY, apiKey: API_KEY });

// Gondi client
const gondiClient = new GondiClient({ privateKey: PRIVATE_KEY });

Portfolio client

If you aim to operate seamlessly across various lending platforms simultaneously.

Please note:

  • Addresses should be specified in case you want to retrieve your loan portfolio across different wallets
  • Clients should be initialised with private keys in case you want to publish loan offers
import { PortfolioClient } from "juna";

const portfolioClient = new PortfolioClient([nftfiClient, arcadeClient, gondiClient], [ADDRESS1, ADDRESS2]);

Creating an offer

Collection offer

import { WETH, DAI, USDC } from "juna";

// Works identically for both platform specific and portfolio clients
const offer = await client.createCollectionOffer({
  collectionAddress: "0xed5af388653567af2f388e6224dc7c4b3241c544", // azuki
  currency: WETH,
  principal: 0.1, // 0.1 weth
  apr: 0.15, // 15%
  durationInDays: 30, // 30 days
  expiryInMinutes: 5, // offer expires in 5 minutes
});

Single item offer (not implemented)

import { WETH, DAI, USDC } from "juna";

// Works identically for both platform specific and portfolio clients
const offer = await client.createSingleItemOffer({
  collectionAddress: "0xed5af388653567af2f388e6224dc7c4b3241c544", // azuki
  nftId: 10, // offering only to the nft id 10
  currency: WETH,
  principal: 0.1, // 0.1 weth
  apr: 0.15, // 15%
  durationInDays: 30, // 30 days
  expiryInMinutes: 5, // offer expires in 5 minutes
});

Getting loans

Format

export interface Loan {
  id: string;
  platform: LendingPlatform;
  borrower: `0x${string}`;
  lender: `0x${string}`;
  status: LoanStatus;
  startDate: Date;
  endDate: Date;
  currency: Currency;
  principal: number;
  durationInDays: number;
  apr: number;
  collateral: Collateral[];
}

export interface Collateral {
  collectionAddress: `0x${string}`;
  collectionName: string;
  nftId: number;
}

All historical loans (not implemented)

const loans = await client.getLoans();

By account

For platform specific client

const loans = await client.getLoansForAccount(ACCOUNT_ADDRESS);

For portfolio client (addresses are specified at client initalisation)

const loans = await client.getMyLoans();

By collection (not implemented)

const loans = await client.getLoansForCollection(COLLECTION_ADDRESS);

Getting offers

Format

interface Offer {
  id: string;
  platform: LendingPlatform;
  lender: `0x${string}`;
  offerDate: Date;
  expiryDate: Date;
  type: OfferType;
  currency: Currency;
  principal: number;
  durationInDays: number;
  apr: number;
  collateral: {
    collectionAddress: `0x${string}`;
    collectionName: string;
    nftId: string;
  };
}

export enum OfferType {
  collectionOffer = "collectionOffer",
  singleItemOffer = "singleItemOffer",
}

All offers (not implemented)

const offers = await client.getOffers();

By account (not implemented)

For platform specific clients

const offers = await client.getOffersForAccount(ACCOUNT_ADDRESS);

For portfolio client (addresses are specified at client initalisation)

const loans = await client.getMyOffers();

By collection (not implemented)

const offers = await client.getOffersForCollection(COLLECTION_ADDRESS);

Tests

bun test

Architecture

  • The different clients all implement the interface LendingClient and use the common types in src/types.ts to offer a uniform API.
  • Since the number of currency tokens is limited we export them as pre-defined const objects from src/support/currencies.ts.
  • Each client has an API it interacts with; it uses specific types (e.g. src/arcade/support/types.ts) and uses mappers to transform them in the common types mentioned above.
  • This library relies on Viem to handle Ethereum logic and Bun as runtime; however we don't explicitly use Bun global except for testing so that this can also be run from Node.

Contributors

3.2.17

14 days ago

3.2.19

14 days ago

3.2.18

14 days ago

3.2.15

1 month ago

3.2.16

30 days ago

3.3.7

2 months ago

3.3.6

2 months ago

3.3.4

2 months ago

3.3.2

2 months ago

3.3.0

2 months ago

3.2.14

2 months ago

3.2.13

2 months ago

3.2.11

3 months ago

3.2.9

3 months ago

3.2.10

3 months ago

3.2.8

3 months ago

3.2.2

3 months ago

3.2.1

3 months ago

3.2.6

3 months ago

3.2.4

3 months ago

3.2.3

3 months ago

3.2.7

3 months ago

2.1.2

3 months ago

2.1.1

3 months ago

2.1.4

3 months ago

2.1.3

3 months ago

2.1.0

3 months ago

1.3.0

5 months ago

2.0.0

5 months ago

1.2.2

5 months ago

1.2.0

5 months ago

1.1.1

5 months ago

1.0.2

5 months ago

1.1.0

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago

0.3.9

6 months ago

0.3.17

6 months ago

0.3.16

6 months ago

0.3.15

6 months ago

0.3.14

6 months ago

0.3.13

6 months ago

0.3.12

6 months ago

1.1.3

5 months ago

0.3.11

6 months ago

1.2.1

5 months ago

1.1.2

5 months ago

0.3.10

6 months ago

0.3.6

6 months ago

0.3.5

6 months ago

0.3.8

6 months ago

0.3.7

6 months ago

0.5.0

6 months ago

0.4.1

6 months ago

0.3.2

6 months ago

0.4.0

6 months ago

0.3.1

6 months ago

0.3.4

6 months ago

0.5.1

6 months ago

0.3.3

6 months ago

0.3.0

6 months ago

0.2.1

6 months ago

0.2.2

6 months ago

0.1.5

6 months ago

0.1.4

6 months ago

0.1.3

6 months ago

0.1.2

6 months ago

0.1.1

6 months ago