# @0x/asset-swapper

> Convenience package for discovering and buying assets on-chain and off-chain.

Latest version **16.66.4** (published 2022-08-22) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @0x/asset-swapper
pnpm add @0x/asset-swapper
yarn add @0x/asset-swapper
bun add @0x/asset-swapper
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 16.66.4 |
| Published | 2022-08-22 |
| First published | 2019-07-13 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=6.12 |
| Dependencies | 31 |
| Unpacked size | 3.4 MB |
| Known vulnerabilities | 0 (+23 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 406 |
| Author | David Sun |
| Maintainers | aeph4muh, idokleinman, jadetran, kyuc, henryzhu, tobernguyen, dex_tracker, dekz, amirbandeali, phil-ociraptor |

## Links

- npm: https://www.npmjs.com/package/@0x/asset-swapper
- Repository: https://github.com/0xProject/protocol
- Homepage: https://0x.org/asset-swapper
- Issues: https://github.com/0xProject/protocol/issues
- npm.io page: https://npm.io/package/@0x/asset-swapper

## Dependencies (31)

- [msw](https://npm.io/package/msw.md) ^0.44.2
- [axios](https://npm.io/package/axios.md) ^0.21.1
- [lodash](https://npm.io/package/lodash.md) ^4.17.15
- [graphql](https://npm.io/package/graphql.md) ^15.4.0
- [@0x/types](https://npm.io/package/@0x/types.md) ^3.3.6
- [@0x/utils](https://npm.io/package/@0x/utils.md) ^7.0.0
- [@0x/assert](https://npm.io/package/@0x/assert.md) ^3.0.35
- [heartbeats](https://npm.io/package/heartbeats.md) ^5.0.1
- [@bancor/sdk](https://npm.io/package/@bancor/sdk.md) 0.2.9
- [@0x/fast-abi](https://npm.io/package/@0x/fast-abi.md) ^0.0.5
- [@0x/dev-utils](https://npm.io/package/@0x/dev-utils.md) ^5.0.0
- [ethereum-types](https://npm.io/package/ethereum-types.md) ^3.7.1
- [@0x/neon-router](https://npm.io/package/@0x/neon-router.md) ^0.3.5
- [graphql-request](https://npm.io/package/graphql-request.md) ^3.4.0
- [@0x/json-schemas](https://npm.io/package/@0x/json-schemas.md) ^6.4.4
- [@0x/quote-server](https://npm.io/package/@0x/quote-server.md) ^8.0.0
- [@0x/web3-wrapper](https://npm.io/package/@0x/web3-wrapper.md) ^8.0.0
- [@0x/base-contract](https://npm.io/package/@0x/base-contract.md) ^7.0.0
- [@0x/protocol-utils](https://npm.io/package/@0x/protocol-utils.md) ^11.16.4
- [@balancer-labs/sdk](https://npm.io/package/@balancer-labs/sdk.md) 0.1.6
- [@ethersproject/abi](https://npm.io/package/@ethersproject/abi.md) ^5.0.1
- [axios-mock-adapter](https://npm.io/package/axios-mock-adapter.md) ^1.19.0
- [@0x/contracts-erc20](https://npm.io/package/@0x/contracts-erc20.md) ^3.3.37
- [balancer-labs-sor-v1](https://npm.io/package/balancer-labs-sor-v1.md) npm:@balancer-labs/sor@0.3.2
- [@0x/contract-wrappers](https://npm.io/package/@0x/contract-wrappers.md) ^13.21.1
- [@0x/contracts-zero-ex](https://npm.io/package/@0x/contracts-zero-ex.md) ^0.36.4
- [@0x/contract-addresses](https://npm.io/package/@0x/contract-addresses.md) ^6.20.1
- [@ethersproject/address](https://npm.io/package/@ethersproject/address.md) ^5.0.1
- [@ethersproject/strings](https://npm.io/package/@ethersproject/strings.md) ^5.0.10
- [@ethersproject/contracts](https://npm.io/package/@ethersproject/contracts.md) ^5.0.1
- [@ethersproject/providers](https://npm.io/package/@ethersproject/providers.md) ^5.0.4

## Recent versions

- 16.66.4 (latest) — 2022-08-22
- 6.3.0-multiplex (multiplex) — 2021-03-16
- 2.1.0-beta.4 (protocolV3) — 2019-12-02
- 16.66.3 — 2022-08-10
- 16.66.2 — 2022-08-09
- 16.66.1 — 2022-08-08
- 16.66.0 — 2022-08-06
- 16.65.0 — 2022-08-01
- 16.64.0 — 2022-07-27
- 16.63.1 — 2022-07-12
- 16.63.0 — 2022-06-29
- 16.62.1 — 2022-06-15
- 16.62.0 — 2022-06-14
- 16.61.0 — 2022-06-03
- 16.60.1 — 2022-05-19
- … 152 more at https://npm.io/package/@0x/asset-swapper/versions

## README

## @0x/asset-swapper

Convenience package for swapping assets represented on the Ethereum blockchain using 0x. The package helps to perform all the off-chain computations to execute a marketBuy or marketSell function execution with 0x exchange contracts, or 0x extension contracts. Given some liquidity (0x signed orders), it helps estimate the cost of buying or selling a certain asset (giving a range) and then provide varying consumable outputs to execute the buy or sell.

Asset-swapper integrates with the [Standard Relayer API](https://github.com/0xProject/standard-relayer-api)(in the future Mesh as well) and takes care of sourcing liquidity, order-pruning, and order-validation. The final result is a library that tells you what assets are available, provides a quote based on specified assets, and provide varying consumable metadata that can be used both on-chain in smart contracts or off-chain through web3 to swap a desired amount of ERC20 for another ERC20 asset.

## Installation

```bash
yarn add @0x/asset-swapper
```

**Import**

```typescript
import { SwapQuoter } from '@0x/asset-swapper';
```

or

```javascript
var SwapQuoter = require('@0x/asset-swapper').SwapQuoter;
var SwapQuoteConsumer = require('@0x/asset-swapper').SwapQuoteConsumer;
```

If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`:

```json
"compilerOptions": {
    "typeRoots": ["node_modules/@0x/typescript-typings/types", "node_modules/@types"],
}
```

## Contributing

We welcome improvements and fixes from the wider community! To report bugs within this package, please create an issue in this repository.

Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.

### Install dependencies

If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:

```bash
yarn config set workspaces-experimental true
```

Then install dependencies

```bash
yarn install
```

### Build

To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory:

```bash
PKG=@0x/asset-swapper yarn build
```

Or continuously rebuild on change:

```bash
PKG=@0x/asset-swapper yarn watch
```

### Clean

```bash
yarn clean
```

### Lint

```bash
yarn lint
```

### Run Tests

```bash
yarn test
```

---
_Source: https://npm.io/package/@0x/asset-swapper · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
