# @jup-ag/phoenix-sdk

> TypeScript SDK for Phoenix

Latest version **1.4.4** (published 2023-05-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install @jup-ag/phoenix-sdk
pnpm add @jup-ag/phoenix-sdk
yarn add @jup-ag/phoenix-sdk
bun add @jup-ag/phoenix-sdk
```

## 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 | 1.4.4 |
| Published | 2023-05-19 |
| First published | 2023-01-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 8 |
| Unpacked size | 609 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 97 |
| Author | Ellipsis Labs |
| Maintainers | jjsb, hjchan, arowana, siong, dicksonp, zhengyutay |

## Links

- npm: https://www.npmjs.com/package/@jup-ag/phoenix-sdk
- Repository: https://github.com/Ellipsis-Labs/phoenix-sdk
- npm.io page: https://npm.io/package/@jup-ag/phoenix-sdk

## Dependencies (8)

- [bs58](https://npm.io/package/bs58.md) ^5.0.0
- [bn.js](https://npm.io/package/bn.js.md) ^5.2.1
- [borsh](https://npm.io/package/borsh.md) ^0.7.0
- [@types/node](https://npm.io/package/@types/node.md) ^18.11.13
- [@solana/spl-token](https://npm.io/package/@solana/spl-token.md) ^0.3.7
- [@metaplex-foundation/beet](https://npm.io/package/@metaplex-foundation/beet.md) ^0.7.1
- [@metaplex-foundation/solita](https://npm.io/package/@metaplex-foundation/solita.md) ^0.12.2
- [@metaplex-foundation/rustbin](https://npm.io/package/@metaplex-foundation/rustbin.md) ^0.3.1

## Recent versions

- 1.4.4 (latest) — 2023-05-19
- 1.4.3 — 2023-05-19
- 1.0.7 — 2023-02-24
- 1.0.6 — 2023-02-24
- 1.0.5 — 2023-02-19
- 1.0.4 — 2023-01-31
- 1.0.3 — 2023-01-26
- 1.0.2 — 2023-01-25
- 1.0.1 — 2023-01-25
- 1.0.0 — 2023-01-25

## README

# Phoenix Legacy SDK

An SDK for interacting with the Phoenix Legacy program.

We currently support Rust, Typescript, and [Python](https://github.com/Ellipsis-Labs/phoenixpy).

## Rust

To run the sample Rust code, run:

```sh
$ cd rust
$ cargo run --bin sample -- -r $YOUR_DEVNET_RPC_ENDPOINT
```

## TypeScript

```TypeScript
import { ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID } from "@solana/spl-token";
import { Connection, Keypair, PublicKey, Transaction } from "@solana/web3.js";
import base58 from "bs58";

import * as Phoenix from "@ellipsis-labs/phoenix-sdk";

async function simpleSwap() {
  const connection = new Connection("https://api.devnet.solana.com/");
  // DO NOT USE THIS KEYPAIR IN PRODUCTION
  const trader = Keypair.fromSecretKey(
    base58.decode(
      "2PKwbVQ1YMFEexCmUDyxy8cuwb69VWcvoeodZCLegqof84DJSTiEd89Ak3so9CiHycZwynesTt1JUDFAPFWEzvVs"
    )
  );

  // Create a Phoenix Legacy client and select a market
  const phoenix = await Phoenix.Client.create(connection);
  const marketConfig = phoenix.marketConfigs.find((market) => market.name === "SOL/USDC");
  if (!marketConfig) {
    throw new Error("Market config not found");
  }
  const marketState = phoenix.marketStates.get(marketConfig.marketId);
  if (!marketState) {
    throw new Error("Market state not found");
  }

  // Submit a market order buying 100 USDC worth of SOL
  const tx = marketState.getSwapTransaction({
    side: Phoenix.Side.Bid,
    inAmount: 100,
    trader: trader.publicKey,
  });

  const txId = await connection.sendTransaction(tx, [trader]);
  console.log("Transaction ID: ", txId);
}
```

---
_Source: https://npm.io/package/@jup-ag/phoenix-sdk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
