open-index/open-npm huggingface dataset:
npm package: @moxie-markets/sdk
Description: TypeScript SDK for Moxie Markets Prediction Perp DEX
Latest version: 0.1.0

# Prediction Perp DEX SDK

The TypeScript SDK for interacting with the Moxie Markets Prediction Perp DEX on Solana. This SDK provides a comprehensive interface for traders, keepers, and protocol administrators.

## Features

- **Protocol Management**: Initialize protocol, add markets, update global state
- **User Operations**: Deposit/withdraw collateral, place orders (limit/market), manage positions
- **Polymarket Integration**: Fetch real-world prediction markets and prices
- **Keeper Services**: Automated price updates, liquidations, funding rate updates, and order matching

## Installation

```bash
npm install @moxie-markets/sdk
```

## Prerequisites

Before running any tests or scripts, ensure you have a local Solana validator running and the program deployed.

1. **Start Local Validator**:
   ```bash
   solana-test-validator
   ```

2. **Deploy Program**:
   In the root of the project (parent directory):
   ```bash
   anchor build
   anchor deploy
   ```

## Testing Guide

We provide several scripts to test different parts of the system.

### 🚀 End-to-End Test (Recommended)

The best way to see the system in action. This script fetches live data from Polymarket, creates a corresponding market on Solana, and performs a full lifecycle test (deposit, trade, settle).

```bash
npm run test:e2e
# or
npx ts-node test-e2e-polymarket.ts
```

### 🤖 Keeper Service Test

Tests the automated keeper functionality including price updates, liquidations, and order filling.

```bash
npm run test:keeper
# or
npx ts-node test-keeper.ts
```

### 🔮 Polymarket Data Test

Fetches popular markets from Polymarket to verify API connectivity and data format.

```bash
npm run test:polymarket
# or
npx ts-node test-polymarket.ts
```

### 🛠️ Basic SDK Integration

Simple test for basic protocol initialization and user operations (deposit/withdraw) without external dependencies.

```bash
npm run test:integration
# or
npx ts-node test-sdk.ts
```

## Usage Example

```typescript
import { Connection, Keypair } from "@solana/web3.js";
import { PredictionClient, IWallet } from "@pred-perp-dex/sdk";

// 1. Setup connection
const connection = new Connection("http://127.0.0.1:8899", "confirmed");

// 2. Initialize Client
const client = new PredictionClient({
  connection,
  wallet: myWallet, // IWallet interface
});

// 3. User Operations
await client.initializeUser();
await client.deposit(solToLamports(1));

// 4. Place Order
await client.placeOrder({
  marketIndex: 0,
  direction: PositionDirection.Long,
  orderType: OrderType.Limit,
  baseAssetAmount: new BN(10_000_000), // 0.1 units
  price: new BN(500_000), // $0.50
  reduceOnly: false,
  postOnly: false,
});
```

## Protocol Initialization

To initialize the protocol on a new network (localnet or devnet):

```bash
# For localnet
npm run init:localnet

# For devnet
npm run init:devnet
```
## Extensive Docs/Guide

Coming soon...
npm package: @moxiekit/moxie-react-demo
Description: This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
Latest version: 0.0.13

# React + TypeScript + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

## Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:

- Configure the top-level `parserOptions` property like this:

```js
export default {
  // other rules...
  parserOptions: {
    ecmaVersion: 'latest',
    sourceType: 'module',
    project: ['./tsconfig.json', './tsconfig.node.json'],
    tsconfigRootDir: __dirname,
  },
}
```

- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list
npm package: @moxiesolar/react-scripts
Description: Configuration and scripts for Create React App.
Latest version: 4.0.3

# react-scripts

This package includes scripts and configuration used by [Create React App](https://github.com/facebook/create-react-app).<br>
Please refer to its documentation:

- [Getting Started](https://facebook.github.io/create-react-app/docs/getting-started) – How to create a new app.
- [User Guide](https://facebook.github.io/create-react-app/) – How to develop apps bootstrapped with Create React App.
npm package: @moxiesuite/meta-pkgs
Description: Package management plugin for meta
Author: g. nicholas d'andrea
Latest version: 0.2.0

meta-pkgs
=========

Plugin for [meta](https://github.com/mateodelnorte/meta).

Utility functions for juggling parts of your packages' dependency graph.


Installation
------------

In a `meta` project (root repo):

    $ npm install --save-dev meta-pkgs


Usage
-----

Sub-command                                           | Description
----------------------------------------------------- | -------------
[`meta pkgs do`](#meta-pkgs-do-pkg-cmd)               | Run a command for a given package
[`meta pkgs checkout`](#meta-pkgs-checkout-terms)     | Checkout specific branches for packages and dependencies
[`meta pkgs test`](#meta-pkgs-test-parents--children) | Run tests against a slice of the dependency graph


### `meta pkgs do <pkg> <cmd>`

Runs `<cmd>` in the repository directory for package `<pkg>`.


### `meta pkgs checkout <terms...>`

Runs `git checkout` for packages/branches specified by terms.

Each term should conform to `<pkg><selector><branch>`, where:
  - `<pkg>` is the name of a managed package (base or dependent)
  - `<selector>` is either `@`, to specify only that package, or `:`, to
      specify that package and all its descendent dependencies
  - `<branch>` is a branch name or a remote + branch.

Later terms specified override earlier terms.

For example:

    $ meta pkgs checkout base:develop util:cool-feature subutil@someone/fix-bug

Checks out:
  - `subutil` to branch `fix-bug`, tracking `someone/fix-bug`
  - `util` and all managed dependencies to `cool-feature` (except `subutil`)
  - `base` and all managed dependencies to `develop` (except dependencies of `util`)

Options:
  - `--strict` to fail if a given branch is missing (default is ignore)
  - `--greedy` to continue searching descendent dependencies if a branch is
      missing (default is to stop traversal)


### `meta pkgs test <parents...> :: <children...>`

Runs `npm test` for packages in dependency graph between parents and children.

Parents/children should be separated by `::`.

For example:

    $ meta pkgs test base :: util lib

Runs tests for all packages `base` depends on that also depend on either `util`
or `lib`.

Options:
  - `--strict=<parents|children|both>` to omit specified parents, children, or
      both from testing (default runs tests for packages specified)