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

sdk-quantum-layer

v1.1.9

Published

A simple SDK for interacting with quantum layer contract, indexer and API

Downloads

506

Readme

Quantum Layer SDK

The Quantum Layer SDK is a comprehensive toolkit designed for interacting with Central Layer Order Book Model Contracts and Indexer. It simplifies the process of making transactions, querying blockchain data, interacting with smart contracts and fetching data using APIs.

Getting Started

This guide will walk you through the process of setting up and using the Quantum Layer SDK in your projects.

Prerequisites

  • Node.js installed on your machine
  • Access to an RPC for squid indexer

Installation

To use the Quantum Layer SDK, first install it via npm:

npm i
npm install sdk-quantum-layer

Run Tests

npm run test

Usage

Initialization

To start using the SDK, you need to import it and create an instance with your Ethereum JSON RPC provider URL and the factory address of the contracts you'll be interacting with:

import { ethers } from "ethers";
import MyFinalSDK from "sdk-quantum-layer";


const sdk = new MyFinalSDK(signer);

Making Transactions

Create a Pair:

To create a pair, use the createPair method with the tokenA, tokenB, and feeRate addresses as arguments.


await sdk.exchangeSDK.createPair(tokenA, tokenB)
  .then(() => console.log("Pair Created Sucessfully"))
  .catch(error => console.error("Error Creating Pair:", error));

Place a Sell Order:

To place a sell order, use the placeSellOrder method with the price, amount, and token addresses as arguments.

Price must be in wei

await sdk.exchangeSDK.placeSellOrder(price, amount, "tokenAAddress", "tokenBAddress")
  .then(() => console.log("Sell Order placed successfully"))
  .catch(error => console.error("Error placing sell order:", error));

Place a Buy Order:

To place a buy order, use the placeBuyOrder method similarly.

Price must be in wei

await sdk.exchangeSDK.placeBuyOrder(price, amount, "tokenAAddress", "tokenBAddress")
  .then(() => console.log("Buy Order placed successfully"))
  .catch(error => console.error("Error placing buy order:", error));

Delete a Buy Order:

To delete a buy order, use the deleteBuyOrder method similarly.

await sdk.exchangeSDK.deleteBuyOrder(tokenAAddress, tokenBAddress, price, orderId)
  .then(() => console.log("Buy Order deleted successfully"))
  .catch(error => console.error("Error deleting buy order:", error));

Delete a Sell Order:

To delete a sell order, use the deleteSellOrder method similarly.

await sdk.exchangeSDK.deleteSellOrder(tokenAAddress, tokenBAddress, price, orderId)
  .then(() => console.log("Sell Order deleted successfully"))
  .catch(error => console.error("Error deleting Sell order:", error));

Querying Data

Fetch Orders

You can fetch prices in a particular contract address, helps us in price graphs

await sdk.myAPI.fetchTradeHistory('startTime', 'endTime', 'contractAddress')
  .then(data => console.log('Orders:', data))
  .catch(error => console.error("Error fetching orders:", error));

Additional API Methods

The SDK provides several methods to interact with the blockchain and fetch data. Below are some additional methods you might find useful:

  • Fetch Market Details: Fetches the price data of different currencies listed by their pair address
await sdk.myAPI.fetchMarketDetails('contractAddress')
  .then(data => console.log('fetchMarketDetails:', data.data))
  .catch(error => console.error("Error fetching fetchMarketDetails:", error));
  • Fetch Pairs:: Fetch trading pairs within a specific time range.
await sdk.myAPI.fetchPairs('startTime', 'endTime')
  .then(data => console.log('Pairs:', data))
  .catch(error => console.error("Error fetching pairs:", error));
  • Fetch Orders:: Fetch orders within a specific time range.
await sdk.myAPI.fetchOrders('startTime', 'endTime', 'seller')
  .then(data => console.log('Orders:', data.orders))
  .catch(error => console.error("Error fetching deleted sell orders:", error));
  • Fetch Deleted Buy Orders:: Fetch executed trades of a pair including buy sell deleted
await sdk.myAPI.fetchTrades('startTime', 'endTime', 'buyer')
  .then(data => console.log('Deleted Buy Orders:', data.orders))
  .catch(error => console.error("Error fetching deleted buy orders:", error));