New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@silvana-one/orderbook

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@silvana-one/orderbook

Silvana Orderbook Client

latest
Source
npmnpm
Version
1.1.41
Version published
Maintainers
1
Created
Source

@silvana-one/orderbook

TypeScript client library for the Silvana orderbook. Works in Node.js and Browser environments. Wraps 5 gRPC services via Connect RPC.

Installation

npm install @silvana-one/orderbook

For Node.js:

npm install @connectrpc/connect-node

For Browser:

npm install @connectrpc/connect-web

Usage

Node.js

import { createGrpcTransport } from "@connectrpc/connect-node";
import {
  OrderbookClient,
  OrderType,
  TimeInForce,
} from "@silvana-one/orderbook";

const transport = createGrpcTransport({
  baseUrl: "https://your-orderbook-server:port",
});

const client = new OrderbookClient({
  transport,
  token: "your-jwt-token",
});

// Get markets
const markets = await client.getMarkets();
console.log(markets.markets);

// Submit an order
const order = await client.submitOrder({
  marketId: "BTC-USD",
  orderType: OrderType.BID,
  price: "50000.00",
  quantity: "0.1",
  timeInForce: TimeInForce.GTC,
});

Browser

import { createGrpcWebTransport } from "@connectrpc/connect-web";
import {
  OrderbookClient,
  OrderType,
  TimeInForce,
} from "@silvana-one/orderbook";

const transport = createGrpcWebTransport({
  baseUrl: "https://your-orderbook-server:port",
});

const client = new OrderbookClient({
  transport,
  token: "your-jwt-token",
});

// Same API as Node.js
const markets = await client.getMarkets();

Clients

OrderbookClient

Trading operations, order management, market data, and RFQ. Requires JWT authentication.

import { OrderbookClient } from "@silvana-one/orderbook";

const client = new OrderbookClient({ transport, token });

// Trading
await client.submitOrder({ ... });
await client.cancelOrder({ orderId: 123n });
await client.getOrders({ marketId: "BTC-USD" });

// Market data
await client.getOrderbookDepth({ marketId: "BTC-USD", depth: 10 });
await client.getMarketData({ marketIds: ["BTC-USD"] });

// RFQ
const quotes = await client.requestQuotes({ marketId: "BTC-USD", direction: "buy", quantity: "0.5" });
await client.acceptQuote({ rfqId: quotes.rfqId, quoteId: quotes.quotes[0].quoteId });

// Streaming
for await (const update of client.subscribeOrderbook({ marketId: "BTC-USD" })) {
  console.log(update);
}

SettlementClient

DVP settlement orchestration and RFQ handling. Requires JWT authentication.

import { SettlementClient } from "@silvana-one/orderbook";

const client = new SettlementClient({ transport, token });

await client.getPendingProposals({ partyId: "party-1" });
await client.getSettlementStatus({ settlementId: "settlement-1" });

// Bidirectional streaming for settlement flow and RFQ
const stream = client.settlementStream(messages);

LedgerClient

Two-phase transaction signing, balance/contract queries, and cloud agent onboarding. JWT authentication for most RPCs; onboarding RPCs use message-level Ed25519 signing.

import { LedgerClient } from "@silvana-one/orderbook";

const client = new LedgerClient({ transport, token });

// Queries
await client.getBalances();
await client.getDsoRates();
await client.getServiceInfo();

// Two-phase transaction
const prepared = await client.prepareTransaction({ operation, params });
// ... sign hash locally ...
await client.executeTransaction({
  transactionId: prepared.transactionId,
  signature,
});

// Onboarding (no JWT needed)
const unauthClient = new LedgerClient({ transport });
await unauthClient.getAgentConfig();
await unauthClient.registerAgent({ publicKey, requestSignature });

// Streaming
for await (const contract of client.getActiveContracts({
  templateFilters: ["..."],
})) {
  console.log(contract);
}

PricingClient

External price feeds (Binance, ByBit, CoinGecko). No authentication needed.

import { PricingClient } from "@silvana-one/orderbook";

const client = new PricingClient({ transport });

await client.getPrice({ marketId: "BTC-USD" });
await client.getKlines({ marketId: "BTC-USD", interval: "1h", limit: 100 });

// Streaming
for await (const update of client.streamPrices({ marketIds: ["BTC-USD"] })) {
  console.log(update);
}

gRPC Services

The library wraps 5 gRPC services:

ServiceClientAuthStreaming
OrderbookServiceOrderbookClientJWTServer-streaming (subscribeOrderbook, subscribeOrders, subscribeSettlements)
SettlementServiceSettlementClientJWTBidirectional (settlementStream)
DAppProviderServiceLedgerClientJWT / Message signingServer-streaming (getActiveContracts, getUpdates)
PricingServicePricingClientNoneServer-streaming (streamPrices)

Two-Phase Transaction Flow

All ledger-mutating operations use a two-phase signing protocol via LedgerClient:

  • Call prepareTransaction with an operation type and parameters
  • Server returns the full prepared_transaction bytes and a hash
  • Verify the transaction matches the requested operation (correct template, parties, amounts)
  • Sign the hash locally with Ed25519 private key
  • Call executeTransaction with the signature
  • Server submits the signed transaction to the Canton ledger

Operation types:

OperationDescription
TRANSFER_CCSend Canton Coin
TRANSFER_CIP56Send CIP-56 token
ACCEPT_CIP56Accept incoming CIP-56 transfer
PAY_DVP_FEEPay DVP processing fee
PROPOSE_DVPCreate DVP proposal
ACCEPT_DVPAccept DVP proposal
PAY_ALLOC_FEEPay allocation processing fee
ALLOCATEAllocate tokens to DVP
REQUEST_PREAPPROVALRequest TransferPreapproval
REQUEST_RECURRING_PREPAIDRequest prepaid subscription
REQUEST_RECURRING_PAYASYOUGORequest pay-as-you-go subscription
REQUEST_USER_SERVICERequest UserService (onboarding)

Settlement Stream (Bidirectional)

SettlementClient.settlementStream() opens a long-lived bidirectional gRPC stream for RFQ handling and settlement lifecycle coordination.

Client sends: handshake, heartbeats, preconfirmation decisions, DVP lifecycle events, RFQ quotes/rejections

Server sends: handshake acknowledgement, heartbeats, settlement proposals, preconfirmation requests, RFQ requests

Key Query RPCs

MethodClientReturns
getBalances()LedgerToken balances (total, locked, unlocked)
getActiveContracts()LedgerStream of active contracts by template filter
getUpdates()LedgerStream of ledger transactions from a given offset
getPrice()PricingBid, ask, last price for a market
getKlines()PricingOHLCV candlestick data (1m to 1w intervals)
getOrders()OrderbookOrders with status and type filters
getOrderbookDepth()OrderbookAggregated bid/offer price levels
getSettlementProposals()OrderbookSettlement proposals with status filter
getSettlementStatus()SettlementStep-by-step DVP status with buyer/seller next actions
getMarkets()OrderbookAvailable markets and their configuration
getMarketData()OrderbookBest bid/ask, last price, 24h volume
requestQuotes()OrderbookRFQ quotes from connected liquidity providers
acceptQuote()OrderbookAccept an LP quote, creating a settlement proposal

Server-Streaming Subscriptions

MethodClientPayload
getActiveContracts()LedgerActive contracts matching template filter
getUpdates()LedgerLedger transaction stream from a given offset
subscribeOrderbook()OrderbookOrderbook snapshots and deltas
subscribeOrders()OrderbookOrder lifecycle events (created, filled, cancelled)
subscribeSettlements()OrderbookSettlement status change events
streamPrices()PricingReal-time price ticks with optional orderbook and trade data

Authentication

  • JWT — Self-describing Ed25519 JWT (RFC 8037) with automatic refresh. Used for Orderbook, Pricing, and Settlement RPCs. The token embeds the Ed25519 public key; the server verifies it matches the registered party.
  • Message signing — Per-request Ed25519 signature on the canonical request payload, used for Ledger two-phase transactions. Server responses are also signed and should be verified using the ledger service public key.

Types

All protobuf types are exported from the package:

import {
  Order,
  OrderType,
  OrderStatus,
  TimeInForce,
  MarketType,
  SettlementStatus,
  Market,
  Instrument,
  TransactionOperation,
  TransactionStatus,
  RfqAuditEventType,
  RfqDirection,
  RfqRejectionReason,
} from "@silvana-one/orderbook";

License

Apache-2.0

Keywords

cloud

FAQs

Package last updated on 25 Mar 2026

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