0.10.1 • Published 2 days ago

gondi v0.10.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 days ago

Gondi.js

A JavaScript library for crypto-native lending: borrow, lend & refinance NFTs (non-fungible tokens).

Table of Contents

Installation

You can install it via npm:

npm install --save gondi
# or
yarn add gondi

Getting Started

To get started, you need to provide a wallet only.

import { Gondi } from 'gondi';
import { createWalletClient, http } from 'viem';
import { privateKeyToAccount } from 'viem/accounts';
import { mainnet } from 'viem/chains';
const transport = http('https://eth-mainnet.g.alchemy.com/v2/...');

const wallet = createWalletClient({
  account: privateKeyToAccount(privateKey),
  transport,
  chain: mainnet,
});
const gondi = new Gondi({ wallet });

Typescript types are included in the package.

Examples

Getting NFT/Collection ids

We use integer ids to identify collections and NFTs. We provide helper functions to get them:

const nftId = await gondi.nftId({ slug: 'collection-slug', tokenId: 0n });
const collectionId = await gondi.collectionId({ slug: 'collection-slug' });
const collectionId = (
  await gondi.collectionId({
    contractAddress: '0x0000000000000000000000000000000000000000',
  })
)[0]; // It's an array because some collections use same contract (e.g. Artblocks)

Making Offers

Single NFT Offer

const offers = await gondi.makeSingleNftOffer({
    nftId=1,
    principalAddress="0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",  // Principal currency address. (e.g. WETH)
    principalAmount=1_000_000_000_000_000_000n,                     // Principal amount. In units of currency (e.g. WETH is wei)(e.g. 1WETH)
    capacity=1_000_000_000_000_000_000n,                            // How much money do you want to loan in total,
                                                                    // valid for collection offers.
                                                                    // If you want N loans for example, it should be N*principalAmount.
    fee=0n,                                                         // Origination fee.
    aprBps=100n,                                                    // Apr expressed in basis points. (e.g. 1% apr)
    expirationTime=1700000000n,                                     // Expiration time expressed in seconds since epoch. (e.g. 2023/11/14)
    duration=31_536_000n,                                           // Duration expressed in secconds. (e.g. 1 year)
    requiresLiquidation,                                            // Sets the collateral to be liquidated on default.
    borrowerAddress,                                                // Optional: allow only this borrower to accept the offer.
});

Collection Offer

const offer = await gondi.makeCollectionOffer({
    collectionId,
    ... // Same as Single NFT Offer

});

Listing Offers

import { OffersSortField, Ordering } from 'gondi';
const offer = await gondi.offers({
  cusor, // Cursor returned by previous calls.
  limit, // Number results.
  sortBy: {
    // Sort criteria.
    field: OffersSortField.CreatedDate,
    order: Ordering.Asc,
  },
  filterBy, // Filter criteria, result is conjunction of components.
});

Listing Listings

const listings = await gondi.listings({
  cusor, // Cursor returned by previous calls.
  limit, // Number results.
  sortBy, // Sort criteria.
  filterBy, // Filter criteria, result is conjunction of components.
});
0.10.1

2 days ago

0.10.0

3 days ago

0.9.2

4 days ago

0.9.3

4 days ago

0.8.1

13 days ago

0.8.0

13 days ago

0.8.2

13 days ago

0.7.1

19 days ago

0.7.0

20 days ago

0.6.0

2 months ago

0.5.0

2 months ago

0.4.0

2 months ago

0.3.19

4 months ago

0.3.18

4 months ago

0.3.17

5 months ago

0.3.16

5 months ago

0.3.15

5 months ago

0.3.9

6 months ago

0.3.14

6 months ago

0.3.13

6 months ago

0.3.12

6 months ago

0.3.11

6 months ago

0.3.10

6 months ago

0.3.0-b3

7 months ago

0.3.0-b2

7 months ago

0.3.0-b7

6 months ago

0.3.0-b6

6 months ago

0.3.0-b5

7 months ago

0.3.0-b4

7 months ago

0.3.0-b9

6 months ago

0.3.0-b8

6 months ago

0.3.0

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.3.2

6 months ago

0.3.1

6 months ago

0.3.4

6 months ago

0.3.3

6 months ago

0.1.0-b2

7 months ago

0.3.0-b1

7 months ago

0.0.1-b5

8 months ago

0.1.0-b1

7 months ago

0.0.1-b7

8 months ago

0.0.1-b6

8 months ago

0.0.1-b9

8 months ago

0.0.1-b8

8 months ago

0.1.0

8 months ago

0.2.0

7 months ago

0.0.1-b3

9 months ago

0.0.1-b2

9 months ago

0.0.1-b4

9 months ago

0.0.1-b1

9 months ago