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

xrpl-dex-sdk

v1.0.1

Published

TypeScript SDK for interacting with the XRPL decentralized exchange

Downloads

9

Readme

XRPL Decentralized Exchange SDK

This TypeScript SDK provides a CCXT-compatible API for interacting with the XRPL decentralized exchange.

A Python version of this SDK is available here.

Installation

This package requires NodeJS v16 or later.

NOTE: We recommend using nvm to manage your NodeJS installations. If nvm is installed, type nvm use in the SDK's root folder to automatically switch to the proper Node version.

From NPM

Add the SDK package to your project:

Using NPM

$ npm install -S xrpl-dex-sdk

Using Yarn

$ yarn add xrpl-dex-sdk

From Source

Make sure you have the following installed on your system:

  • NodeJS v16 (lts/gallium)
  • Yarn

Clone the repo, install dependencies, and build the SDK:

$ git clone https://github.com/AktaryTech/xrpl-dex-sdk.git
$ cd xrpl-dex-sdk
$ yarn
$ yarn build

The compiled SDK will be in the /dist folder.

Usage

To use the SDK, import it into your script and create a new SDK instance:

import { SDK, OrderSide, OrderType, Wallet } from 'xrpl-dex-sdk';

const sdk = new SDK({
  network: 'testnet',
  privateKey: /* Your XRPL wallet's private key */,
  publicKey: /* Your XRPL wallet's public key */,
});

await sdk.client.connect();

Currencies, MarketSymbols, and ID Formatting

Currency codes, market symbols, and Order/Trade IDs are strings that follow the following formats:

| Type | Format | Example | | ---------------- | -------------------------------- | --------------------------------------------- | | CurrencyCode | [Currency]+[IssuerAddress] | USD+rhub8VRN55s94qWKDv6jmDy1pUykJzF3wq | | MarketSymbol | [BaseCurrency]/[QuoteCurrency] | XRP/USD+rhub8VRN55s94qWKDv6jmDy1pUykJzF3wq | | OrderId, TradeId | [AccountAddress]/[Sequence] | rpkeJcxB2y5BeAFyycuWwdTTcR3og2a3SR:30419065 |

Examples

Placing an Order

The following example places an Order to buy 20 TST tokens, issued by the account at rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd, at a price of 1.5 XRP each:

import { SDK, OrderSide, OrderType, Wallet } from 'xrpl-dex-sdk';

const example = async () => {
  const wallet = Wallet.generate();

  const sdk = new SDK({
    network: 'testnet',
    privateKey: wallet.privateKey,
    publicKey: wallet.publicKey,
  });

  await sdk.client.connect();

  const orderId = await sdk.createOrder(
    'TST+rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd/XRP',
    OrderSide.Buy,
    OrderType.Limit,
    '20',
    '1.5'
  );

  const order = await sdk.fetchOrder(orderId);

  console.log(order);
};

example();

It produces the following output:

{
  ...,
  "status": "open",
  "symbol": "TST+rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd/XRP",
  "type": "limit",
  "timeInForce": "GTC",
  "side": "buy",
  "amount": "20",
  "price": "1.5",
  "average": "0",
  "filled": "0",
  "remaining": "20",
  "cost": "0",
  "trades": [],
  "info": {
    // ... raw response from XRPL server
  }
}

Methods

For full SDK documentation, see the docs folder. To re-generate documentation, run yarn docs:build.

Further Reading

CCXT (CryptoCurrency eXchange Trading Library)

XRP Ledger

Contributing

Pull requests, issues and comments are welcome! Make sure to add tests for new features and bug fixes.

Contact

For questions, suggestions, etc, you can reach the maintainer at [email protected].

License

The software is distributed under the MIT license. See LICENSE for details.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this library by you, as defined in the MIT license, shall be licensed as above, without any additional terms or conditions.

Disclaimer

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright

Copyright © 2022 Ripple Labs, Inc.