# invisible-sdk

> sdk for interacting with invisible exchange

Latest version **1.5.11** (published 2024-03-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install invisible-sdk
pnpm add invisible-sdk
yarn add invisible-sdk
bun add invisible-sdk
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.5.11 |
| Published | 2024-03-27 |
| First published | 2023-11-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 14 |
| Unpacked size | 511.1 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Snojj25 |
| Maintainers | snojj25 |

## Links

- npm: https://www.npmjs.com/package/invisible-sdk
- npm.io page: https://npm.io/package/invisible-sdk

## Dependencies (14)

- [ws](https://npm.io/package/ws.md) ^8.11.0
- [axios](https://npm.io/package/axios.md) ^1.1.2
- [eslint](https://npm.io/package/eslint.md) 8.30.0
- [ethers](https://npm.io/package/ethers.md) ^5.7.2
- [sqlite3](https://npm.io/package/sqlite3.md) ^5.1.6
- [firebase](https://npm.io/package/firebase.md) ^9.8.1
- [ref-napi](https://npm.io/package/ref-napi.md) ^3.0.3
- [starknet](https://npm.io/package/starknet.md) ^4.5.0
- [websocket](https://npm.io/package/websocket.md) ^1.0.34
- [big-integer](https://npm.io/package/big-integer.md) ^1.6.51
- [firebase-admin](https://npm.io/package/firebase-admin.md) ^11.9.0
- [ref-array-napi](https://npm.io/package/ref-array-napi.md) ^1.2.2
- [ref-struct-napi](https://npm.io/package/ref-struct-napi.md) ^1.1.1
- [@starkware-industries/starkware-crypto-utils](https://npm.io/package/@starkware-industries/starkware-crypto-utils.md) ^0.0.2

## Recent versions

- 1.5.11 (latest) — 2024-03-27
- 1.5.10 — 2024-02-17
- 1.5.9 — 2024-02-17
- 1.5.8 — 2024-02-17
- 1.5.7 — 2024-02-17
- 1.5.6 — 2024-02-17
- 1.5.5 — 2024-01-02
- 1.5.4 — 2023-12-31
- 1.5.3 — 2023-12-31
- 1.5.2 — 2023-12-31
- 1.5.1 — 2023-12-31
- 1.5.0 — 2023-12-27
- 1.4.20 — 2023-12-23
- 1.4.19 — 2023-12-23
- 1.4.18 — 2023-12-17
- … 30 more at https://npm.io/package/invisible-sdk/versions

## README

# invisible-sdk

The market maker code for invisible Exchange.

<img height=250 src="https://github.com/InvisibleExchange/frontend/blob/main/public/Invisible-full.png"> </img>

## Description

This ipackage includes all the logic to create and run your own mm strategies on Invisible L2.
More examples can be found here: [Examples](./examples/)

## Order Examples

Examples of how to send send orders.

### Spot orders

```js
let privKey = "0x1234";
let marketMaker = await UserState.loginUser(privKey);

/// Send a spot Limit Order
let assetId = SYMBOLS_TO_IDS["ETH"];
let side = "Buy";
let expirationTime = 3600_000; // in seconds
let baseToken = assetId;
let quoteToken = COLLATERAL_TOKEN;
let baseAmount = null; // Used for sell order
let quoteAmount = 100; // User for buy order
let price = 1950.0;
let feeLimit = 0.1;
let tabAddress = null; // Address of the orderTab to use (notes if null)
let slippage = 0.01; // only for market order
let isMarket = false;
let ACTIVE_ORDERS = null;

let response = await sendSpotOrder(
  marketMaker,
  side,
  expirationTime,
  baseToken,
  quoteToken,
  baseAmount,
  quoteAmount,
  price,
  feeLimit,
  tabAddress,
  slippage,
  isMarket,
  ACTIVE_ORDERS
);
```

---

### Perpetual orders

```js
let privKey = "0x1234";
let marketMaker = await UserState.loginUser(privKey);

/// Send a spot Limit Order
let side = "Long";
let expirationTime = 3600_000; // in seconds
let positionEffectType = "Open"; // "Open"/"Modify"/"Close"
let positionAddress = null; // Used for modify/close orders
let syntheticToken = SYMBOLS_TO_IDS["BTC"];
let syntheticAmount = 0.1; // Used for sell order
let price = 37359.1;
let intialMargin = 2500.0;
let feeLimit = 0.1;
let slippage = 0.01;
let isMarket = false;
let ACTIVE_ORDERS = null;

let response = await sendPerpOrder(
  marketMaker,
  side,
  expirationTime,
  positionEffectType,
  positionAddress,
  syntheticToken,
  syntheticAmount,
  price,
  intialMargin,
  feeLimit,
  slippage,
  isMarket,
  ACTIVE_ORDERS
);
```

---

### Modify orders

```js
let privKey = "0x1234";
let marketMaker = await UserState.loginUser(privKey);

/// Send a Cancel Order
let orderId = 123;
let isBid = true; // true for bid, false for ask
let isPerp = true;
let assetId = SYMBOLS_TO_IDS["ETH"];
let marketId = SPOT_MARKET_IDS[assetId];
let res = await sendCancelOrder(marketMaker, orderId, isBid, isPerp, marketId);

/// Send an Amend Order
let newPrice = 1950.0;
let newExpirationTime = 3600_000; // in seconds
let tabAddress = null;
let match_only = false; // This will only match the orders within the new price range without updating them
let ACTIVE_ORDERS = null;
res = await sendAmendOrder(
  marketMaker,
  orderId,
  isBid,
  isPerp,
  marketId,
  newPrice,
  newExpirationTime,
  tabAddress,
  match_only,
  ACTIVE_ORDERS
);
```

---

### All order types:

```js
{
  sendSpotOrder,
  sendPerpOrder,
  sendCancelOrder,
  sendDeposit,
  sendWithdrawal,
  sendAmendOrder,
  sendSplitOrder,
  sendChangeMargin,
  sendLiquidationOrder,
  sendOpenOrderTab,
  sendCloseOrderTab,
  sendModifyOrderTab,
  sendRegisterMm,
  sendAddLiquidityUser,
  sendOnChainAddLiquidityMM,
  sendOnChainRemoveLiquidityUser,
  sendOnChainRemoveLiquidityMM,
}
```

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