0.18.8 • Published 4 months ago

gondi v0.18.8

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months 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.15.0-b5

7 months ago

0.15.0-b6

6 months ago

0.15.0-b7

6 months ago

0.15.0-b8

6 months ago

0.15.0-b2

7 months ago

0.15.0-b3

7 months ago

0.15.0-b4

7 months ago

0.17.2

5 months ago

0.17.3

5 months ago

0.17.0

5 months ago

0.17.1

5 months ago

0.14.0-b1

8 months ago

0.14.0-b0

8 months ago

0.18.1

5 months ago

0.18.2

5 months ago

0.18.3

5 months ago

0.18.4

5 months ago

0.18.5

4 months ago

0.18.6

4 months ago

0.18.7

4 months ago

0.18.8

4 months ago

0.14.0

8 months ago

0.14.1

8 months ago

0.14.2

8 months ago

0.16.1

6 months ago

0.18.0

5 months ago

0.16.2

5 months ago

0.16.0-b1

6 months ago

0.13.0

10 months ago

0.11.0

1 year ago

0.13.0-b3

12 months ago

0.13.0-b2

12 months ago

0.13.0-b1

1 year ago

0.12.0

1 year ago

0.10.2

1 year ago

0.10.1

1 year ago

0.10.0

1 year ago

0.9.2

1 year ago

0.9.3

1 year ago

0.8.1

1 year ago

0.8.0

1 year ago

0.8.2

1 year ago

0.7.1

1 year ago

0.7.0

1 year ago

0.6.0

1 year ago

0.5.0

1 year ago

0.4.0

1 year ago

0.3.19

1 year ago

0.3.18

1 year ago

0.3.17

2 years ago

0.3.16

2 years ago

0.3.15

2 years ago

0.3.9

2 years ago

0.3.14

2 years ago

0.3.13

2 years ago

0.3.12

2 years ago

0.3.11

2 years ago

0.3.10

2 years ago

0.3.0-b3

2 years ago

0.3.0-b2

2 years ago

0.3.0-b7

2 years ago

0.3.0-b6

2 years ago

0.3.0-b5

2 years ago

0.3.0-b4

2 years ago

0.3.0-b9

2 years ago

0.3.0-b8

2 years ago

0.3.0

2 years ago

0.3.6

2 years ago

0.3.5

2 years ago

0.3.8

2 years ago

0.3.7

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.3.4

2 years ago

0.3.3

2 years ago

0.1.0-b2

2 years ago

0.3.0-b1

2 years ago

0.0.1-b5

2 years ago

0.1.0-b1

2 years ago

0.0.1-b7

2 years ago

0.0.1-b6

2 years ago

0.0.1-b9

2 years ago

0.0.1-b8

2 years ago

0.1.0

2 years ago

0.2.0

2 years ago

0.0.1-b3

2 years ago

0.0.1-b2

2 years ago

0.0.1-b4

2 years ago

0.0.1-b1

2 years ago