Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@project-serum/serum

Package Overview
Dependencies
Maintainers
1
Versions
135
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@project-serum/serum

Library for interacting with the serum dex

  • 0.3.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.5K
decreased by-82.8%
Maintainers
1
Weekly downloads
 
Created
Source

npm (scoped) Build Status

Serum JS Client Library

WIP

yarn add @project-serum/serum

import { 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 market = await Market.load(connection, marketAddress);
let bids = await market.loadBids(connection);
let asks = await market.loadAsks(connection);
for (let [price, size] of bids.getL2(20)) {
  console.log(price, size);
}
for (let order of asks) {
  console.log(
    order.orderId,
    order.owner.toBase58(),
    order.price,
    order.size,
    order.side,
  );
}

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

for (let order of await market.loadBids(connection)) {
  if (order.owner.equals(owner.publicKey)) {
    await market.cancelOrder(connection, owner, order);
  }
}

FAQs

Package last updated on 13 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc