open-index/open-npm huggingface dataset:
npm package: @nftx/abi
Description: This package contains all ABI schemas used by nftx.js and the NFTX v3 ecosystem
Latest version: 4.0.0

# `@nftx/abi`

This package contains all ABI schemas used by nftx.js and the NFTX v3 ecosystem

## Usage

```ts
import { CreateVaultZap, PoolRouter } from '@nftx/abi';
```
npm package: @nftx/api
Description: This package contains methods for fetching various data via the nftx API
Latest version: 4.1.2

# `@nftx/api`

This package contains methods for fetching various data via the nftx API

# Usage

```ts
import { fetchVaults, fetchVaultBuyPrice } from '@nftx/api';

const vaults = await fetchVaults();
const price = await fetchVaultBuyPrice({ vaultId: 0, tokenIds: ['1'] });
```

Many of the api responses are intended to be used with other @nftx libraries:

```ts
import { createPublicClient, createWalletClient } from 'viem';
import { fetchVaultBuyQuote } from '@nftx/api';
import { buy } from '@nftx/trade';

const quote = await fetchVaultBuyQuote({
  vaultId: 0,
  tokenIds: ['1'],
  userAddress,
});

const provider = createPublicClient();
const signer = createWalletClient();

const transaction = await buy({ quote, provider, signer });
```
npm package: @nftx/config
Description: This package contains the config object used across nftx.js.
Latest version: 4.1.1

# `@nftx/config`

This package contains the config object used across nftx.js.

# Usage

```ts
import config from '@nftx/config';

config.configure({
  network: 1,
  keys: {
    NFTX_API: yourNftxApiKey,
  },
});
```
npm package: @nftx/constants
Description: This package contains constant values used by nftx.js, including contract addresses, subgraph urls, tick ranges, and networks.
Latest version: 4.1.1

# `@nftx/constants`

This package contains constant values used by nftx.js, including contract addresses, subgraph urls, tick ranges, and networks.

# Usage

```ts
import { Network, Zero, MaxUint256 } from '@nftx/constants';

const myNetwork = Network.Mainnet;
```
npm package: @nftx/core
Description: This package contains various methods used internally by the nftx ecosystem and is not included in the main nftx.js package.
Latest version: 4.1.2

# `@nftx/core`

This package contains various methods used internally by the nftx ecosystem and is not included in the main nftx.js package.

The core package can be used directly but it is strongly recommended that you use nftx.js and the NFTX API whenever possible. Direct use requires more setup, increased complexity, slower and more resource-intensive responses, and significantly higher subgraph and web3 hits.
npm package: @nftx/errors
Description: This package contains error classes for common usecases.
Latest version: 4.0.0

# `@nftx/errors`

This package contains error classes for common usecases.

Under the hood, the NFTX API will throw serialised versions of these errors, and nftx.js will automatically parse them back into errors.

Each error class includes a unique `code`, a human-readable `message`, and a `toHttpResponse` method that serialises the error.

The package also includes a `hydrate` function that parses a json object and returns an error, and `hydrateResponse` that will hydrate a `toHttpResponse` object.

## Usage

```ts
import { BadRequestError } from '@nftx/errors';

const e = new BadRequestError('This is bad');

console.log(e.code, e.message);

throw e;
```

```ts
const e = new UnknownError('An unknown error happened');

const { status, body } = e.toHttpResponse();

const e2 = hydrateResponse({ status, body });
```
npm package: @nftx/queue
Description: This package is written specifically to allow communication and job running between NFTX-API and NFTX-API-INDEXER
Latest version: 4.1.1

# `@nftx/ queue`

This package is written specifically to allow communication and job running between NFTX-API and NFTX-API-INDEXER

Signals and Messages can be sent and received using this library. Signals are used to trigger an intended action whereas Messages are used to notify of events. They act very differently behind the scenes:

A signal is passed to bullmq which then passes it on to a single worker to process. You can have multiple listeners for a signal, but only 1 listener will be given the signal.

Messages, on the other hand, are broadcast to all listeners.

## Usage

```ts
// Create a listener for the signal
onSignal(async (type, data) => {
  // Dispatch to the network-specific listener
  sendNetworkSignal(data.network, type, data);
});

// Create a listener for mainnet signals
onNetworkSignal(1, (type, data) => {
  switch (type) {
    case 'index-vault':
      // Handle indexing a vault here
      // Broadcast a message when the job is complete
      sendMessage('vault-indexed', {});
      break;
  }
});

// Create multiple listeners for messages
onMessage((type, data) => {
  switch (type) {
    case 'vault-indexed':
      // Do something
      breka;
  }
});

// Emit a signal
sendSignal('index-vault', { vaultId: '0' });
```
npm package: @nftx/react
Description: This package contains utils for nftx.js that are specific to the React ecosystem. It is not included in the main nftx.js package.
Latest version: 4.1.2

# `@nftx/react`

This package contains utils for nftx.js that are specific to the React ecosystem. It is not included in the main nftx.js package.

## NftxProvider

```tsx
const provider = createPublicClient();
const signer = createWalletClient();

return (
  <NftxProvider network={1} provider={provider} signer={signer}>
    <App />
  </NftxProvider>
);
```

## useNftx

`useNftx` will return the provider-based details for you to use throughout your react application.

```ts
const { network, provider, signer } = useNftx();

const onSubmit = () => {
  increaseLiquidity({
    ...params,
    network,
    provider,
    signer,
  });
};
```

## useTransaction

This is similar to react-query's `useMutation` and wagmi's `useTransaction` hooks. It takes a function that then returns an nftx.js-compatible transaction object.

```ts
const [
  write,
  {
    status,
    error,
    data: { transaction, receipt },
  },
] = useTransaction((args) => {
  return increaseLiquidity(args);
});
```
npm package: @nftx/subgraph
Description: This package contains utilities for interacting with subgraphs, built on top of `@nftx/query`
Latest version: 4.1.2

# `@nftx/subgraph`

This package contains utilities for interacting with subgraphs, built on top of `@nftx/query`

```ts
import { createQuery, querySubgraph } from '@nftx/subgraph';
import type { NftxV3 } from '@nftx/types';
import { Network, NFTX_SUBGRAPH } from '@nftx/constants';

const query = createQuery<NftxV3.Query>()
  .vaults.first(1000)
  .where((w) => [w.vaultId.is('0'), w.shutdownDate.is(0)])
  .select((vault) => [
    vault.id,
    vault.vaultId,
    vault.is1155,
    vault.token((token) => [token.id, token.name, token.symbol]),
  ]);

const data = await querySubgraph({
  url: NFTX_SUBGRAPH[Network.Mainnet],
  query,
});
```
npm package: @nftx/trade
Description: This package contains methods for trading with the NFTX protocol:
Latest version: 4.1.2

# `@nftx/trade`

This package contains methods for trading with the NFTX protocol:

- buy
- sell
- swap
- mint
- redeem

You can also trade with the NFTX AMM:

```ts
const quote = await fetchTokenBuyPrice({
  tokenAddress,
  amount: 1000000000000000000n,
  userAddress,
});

const transaction = await tradeErc20({ provider, signer, quote });
```