0.18.8 • Published 9 months ago

gondi v0.18.8

Weekly downloads
-
License
MIT
Repository
github
Last release
9 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

1 year ago

0.15.0-b6

12 months ago

0.15.0-b7

11 months ago

0.15.0-b8

11 months ago

0.15.0-b2

1 year ago

0.15.0-b3

1 year ago

0.15.0-b4

1 year ago

0.17.2

10 months ago

0.17.3

10 months ago

0.17.0

11 months ago

0.17.1

10 months ago

0.14.0-b1

1 year ago

0.14.0-b0

1 year ago

0.18.1

10 months ago

0.18.2

10 months ago

0.18.3

10 months ago

0.18.4

10 months ago

0.18.5

10 months ago

0.18.6

10 months ago

0.18.7

10 months ago

0.18.8

9 months ago

0.14.0

1 year ago

0.14.1

1 year ago

0.14.2

1 year ago

0.16.1

11 months ago

0.18.0

10 months ago

0.16.2

11 months ago

0.16.0-b1

11 months ago

0.13.0

1 year ago

0.11.0

2 years ago

0.13.0-b3

1 year ago

0.13.0-b2

1 year ago

0.13.0-b1

1 year ago

0.12.0

2 years ago

0.10.2

2 years ago

0.10.1

2 years ago

0.10.0

2 years ago

0.9.2

2 years ago

0.9.3

2 years ago

0.8.1

2 years ago

0.8.0

2 years ago

0.8.2

2 years ago

0.7.1

2 years ago

0.7.0

2 years ago

0.6.0

2 years ago

0.5.0

2 years ago

0.4.0

2 years ago

0.3.19

2 years ago

0.3.18

2 years 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