npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@compolabs/spark-orderbook-ts-sdk

v1.3.8

Published

> [!IMPORTANT] > Please note that the current version of the Spark SDK is a beta release. This version is still under active development and may not be stable. Users should expect frequent updates and changes as we work to improve functionality and addres

Downloads

65

Readme

spark-orderbook-ts-sdk

[!IMPORTANT] Please note that the current version of the Spark SDK is a beta release. This version is still under active development and may not be stable. Users should expect frequent updates and changes as we work to improve functionality and address issues. As a beta product, this version is intended for testing and feedback purposes only. We encourage users to provide feedback as it will help us refine and enhance the SDK in preparation for a more stable release.

Introduction

The spark-orderbook-ts-sdk is a comprehensive solution for interacting with financial markets, offering spot trading functionality. It's built on the Fuels platform, utilizing smart contracts for decentralized transaction processing. This library provides easy-to-use methods for creating and managing orders, handling tokens, and retrieving market data.

Installation

To install the spark-orderbook-ts-sdk, follow these steps:

npm i @compolabs/spark-orderbook-ts-sdk

Usage

To use the spark-orderbook-ts-sdk, you'll need to set up a Spark instance with the appropriate configuration:

import Spark, { TESTNET_NETWORK, BETA_CONTRACT_ADDRESSES, TESTNET_INDEXER_URL } from "spark-orderbook-ts-sdk";

// Create a wallet instance
const provider = await Provider.create(TESTNET_NETWORK.url);
const wallet = Wallet.fromPrivateKey(/* PRIVATE KEY */, provider);

const spark = new Spark({
  networkUrl: TESTNET_NETWORK.url,
  contractAddresses: BETA_CONTRACT_ADDRESSES,
  indexerApiUrl: TESTNET_INDEXER_URL,
  wallet,
});
// Now you can use `spark` to interact with the library methods

Available Methods

Below is a list of all the available methods in the spark-orderbook-ts-sdk. These methods enable interaction with spot market:

  1. setActiveWallet(wallet?: WalletLocked | WalletUnlocked) - Updates the active wallet used in the library.
  2. createOrder(baseToken: Asset, quoteToken: Asset, size: string, price: string) - Creates an order with the specified parameters.
  3. cancelOrder(orderId: string) - Cancels a specified order.
  4. matchOrders(sellOrderId: string, buyOrderId: string) - Matches a sell order with a buy order.
  5. mintToken(token: Asset, amount: string) - Mints the specified amount of a token.
  6. fetchMarkets(limit: number) - Retrieves a list of markets up to the specified limit.
  7. fetchMarketPrice(baseToken: Asset) - Fetches the current market price for a given market token.
  8. fetchOrders(params: FetchOrdersParams) - Fetches orders based on the specified parameters.
  9. fetchTrades(params: FetchTradesParams) - Retrieves trades for markets based on provided parameters.
  10. fetchVolume() - Retrieves the trading volume for markets.
  11. fetchOrderById(orderId: string) - Retrieves details of a specific order by its ID.
  12. fetchWalletBalance(asset: Asset) - Fetches the balance of a specified asset in the wallet.
  13. getProviderWallet() - Retrieves the wallet associated with the provider.
  14. getProvider() - Retrieves the provider used by the library.

Contributing

Contributions to improve the spark-orderbook-ts-sdk are welcome. Please feel free to fork the repository, make your changes, and submit a pull request.