open-index/open-npm huggingface dataset:
npm package: @project-serum/serum
Description: Library for interacting with the serum dex
Latest version: 0.13.65

[![npm (scoped)](https://img.shields.io/npm/v/@project-serum/serum)](https://www.npmjs.com/package/@project-serum/serum)
[![Build Status](https://travis-ci.com/project-serum/serum-js.svg?branch=master)](https://travis-ci.com/project-serum/serum-js)

# Serum JS Client Library

JavaScript client library for interacting with the Project Serum DEX.

## Installation

Using npm:

```
npm install @solana/web3.js @project-serum/serum
```

Using yarn:

```
yarn add @solana/web3.js @project-serum/serum
```

## Usage

```js
import { Account, Connection, PublicKey } from '@solana/web3.js';
import { Market } from '@project-serum/serum';

let connection = new Connection('https://testnet.solana.com');
let marketAddress = new PublicKey('...');
let programAddress = new PublicKey("...");
let market = await Market.load(connection, marketAddress, {}, programAddress);

// Fetching orderbooks
let bids = await market.loadBids(connection);
let asks = await market.loadAsks(connection);
// L2 orderbook data
for (let [price, size] of bids.getL2(20)) {
  console.log(price, size);
}
// Full orderbook data
for (let order of asks) {
  console.log(
    order.orderId,
    order.price,
    order.size,
    order.side, // 'buy' or 'sell'
  );
}

// Placing orders
let owner = new Account('...');
let payer = new PublicKey('...'); // spl-token account
await market.placeOrder(connection, {
  owner,
  payer,
  side: 'buy', // 'buy' or 'sell'
  price: 123.45,
  size: 17.0,
  orderType: 'limit', // 'limit', 'ioc', 'postOnly'
});

// Retrieving open orders by owner
let myOrders = await market.loadOrdersForOwner(connection, owner.publicKey);

// Cancelling orders
for (let order of myOrders) {
  await market.cancelOrder(connection, owner, order);
}

// Retrieving fills
for (let fill of await market.loadFills(connection)) {
  console.log(fill.orderId, fill.price, fill.size, fill.side);
}

// Settle funds
for (let openOrders of await market.findOpenOrdersAccountsForOwner(
  connection,
  owner.publicKey,
)) {
  if (openOrders.baseTokenFree > 0 || openOrders.quoteTokenFree > 0) {
    // spl-token accounts to which to send the proceeds from trades
    let baseTokenAccount = new PublicKey('...');
    let quoteTokenAccount = new PublicKey('...');

    await market.settleFunds(
      connection,
      owner,
      openOrders,
      baseTokenAccount,
      quoteTokenAccount,
    );
  }
}
```
npm package: @project-serum/serum-dev-tools
Description: developer tooling suite for building on serum
Author: Sayantan Karmakar
Latest version: 1.0.5

# Serum DevTools 🛠️

A developer tooling SDK for building on [serum-dex](https://github.com/project-serum/serum-dex/).

## Prerequisites

You will need to use the `FileKeypair` class that extends the [`Keypair`](https://solana-labs.github.io/solana-web3.js/classes/Keypair.html) class from [`@solana/web3.js`](https://npmjs.com/package/@solana/web3.js) to provide easy file-based keypair management, which is required for the market making features provided by this package.

```javascript
const owner = FileKeypair.generate("./scripts/keys/owner.json");

const airdropSig = await connection.requestAirdrop(
  owner.keypair.publicKey,
  10 * LAMPORTS_PER_SOL,
);
await connection.confirmTransaction(airdropSig);
```

You need to have a [serum-dex](https://github.com/project-serum/serum-dex/) program deployed on the cluster you wish to interact with.

You can either,

- Use the [serum-dev-tools CLI](https://github.com/project-serum/serum-dev-tools/tree/main/cli) to deploy the program.

- use the already deployed `serum-dex` programs, `9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin` on **mainnet-beta** and `DESVgJVGajEgKGXhb6XmqDHGz3VjdgP7rEVESBgxmroY` on **devnet**.

## Get Started

```
yarn add @project-serum/serum-dev-tools
```

### Initialize a `Dex`

```javascript
const connection = new Connection("http://localhost:8899", "confirmed");

const dexAddress = new PublicKey(
  "7zo7HCQAZPRb4pYiQQ6fLjC8ssN3E8LkavVs8JUA5NMn",
);

const dex = new Dex(dexAddress, connection);
```

### Create `Coin` instances for your `Market`

```javascript
const baseCoin = await dex.createCoin(
  "SAYA",
  9,
  owner.keypair,
  owner.keypair,
  owner.keypair,
);

const quoteCoin = await dex.createCoin(
  "SRM",
  9,
  owner.keypair,
  owner.keypair,
  owner.keypair,
);

// Fund the FileKeypair object to place orders.

await baseCoin.fundAccount(1000000, owner.keypair, connection);

await quoteCoin.fundAccount(2000000, owner.keypair, connection);
```

### Initialize a `Market`

```javascript
const market = await dex.initDexMarket(owner.keypair, baseCoin, quoteCoin, {
  lotSize: 1e-3,
  tickSize: 1e-2,
});
```

### Run a Market Maker

```javascript
dex.runMarketMaker(market, owner, {
  durationInSecs: 30,
  orderCount: 3,
  initialBidSize: 1000,
  baseGeckoSymbol: "solana",
  quoteGeckoSymbol: "usd",
});
```

### Run a crank

```javascript
dex.runCrank(market, owner, {
  durationInSecs: 20,
  verbose: true,
});
```
npm package: @project-serum/swap
Description: Client for swapping on the Serum DEX
Latest version: 0.1.0-alpha.35

# Swap

[![Build Status](https://travis-ci.com/project-serum/serum-ts.svg?branch=master)](https://travis-ci.com/project-serum/serum-ts)
[![npm (scoped)](https://img.shields.io/npm/v/@project-serum/swap)](https://www.npmjs.com/package/@project-serum/swap)
[![Discord Chat](https://img.shields.io/discord/739225212658122886?color=blueviolet)](https://discord.com/channels/739225212658122886)
[![Documentation](https://img.shields.io/badge/typedoc-documentation-blue)](https://project-serum.github.io/serum-ts/swap/classes/swap.html)
[![License](https://img.shields.io/github/license/project-serum/serum-dex?color=blue)](https://opensource.org/licenses/Apache-2.0)

Client library for swapping directly on the serum orderbook.
The Solana program can be found [here](https://github.com/project-serum/swap).

## Installation

Using npm:

```
npm install @project-serum/swap
```

Using yarn:

```
yarn add @project-serum/swap
```

## API Reference

[API Reference](https://project-serum.github.io/serum-ts/swap/classes/swap.html).