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

zilswap-sdk

v1.3.26

Published

Zilswap TypeScript SDK

Downloads

175

Readme

Zilswap Typescript SDK

Setup

Install from npm:

npm install zilswap-sdk

SDK Usage

Initialize the sdk based on the required network, then call the required methods which will automatically map and call the corresponding smart contract correct transitions.

  import { Zilswap } from 'zilswap-sdk'

  (async () => {
    const zilswap = new Zilswap(Network.TestNet)
    await zilswap.initialize()
    await zilswap.addLiquidity('SWTH', '42', '42')
    await zilswap.teardown()
  })()

Methods

All public Zilswap methods can be found on the Zilswap SDK object.

All public Zilo methods can be found on the Zilo SDK object.

Full typescript definitions can also be found in the Modules.

The following is a list of methods to quickly get you started:

Swap & Liquidity

  • approveTokenTransferIfRequired - approves transfers to zilswap for the given token contract, if the current approval amount is insufficient.
  • addLiquidity - adds liquidity to the pool
  • removeLiquidity - removes liquidity to the pool
  • swapWithExactInput - swaps a token for another token, specifying the exact amount that should be given.
  • swapWithExactOutput - swaps a token for another token, specifying the exact amount that should be received.

Getters

  • getAppState - gets the current dApp state
  • getPool - gets the reserve values for a pool
  • getObservedTxs - gets the txs that the SDK is observing

Configuration

  • addToken - adds a token that is not in the pre-built list
  • observeTx - observe a zilliqa blockchain tx
  • setDeadlineBlocks - set the number of blocks before a transition sent by the SDK to expires

Helpers

  • toUnitless - converts a human amount into a unitless integer that is used by Scilla.
  • toUnit - converts a unitless integer used by scilla into a human readable amount.
  • getRatesForInput - get the current exchange rates for a pool by giving an input amount.
  • getRatesForOutput - get the current exchange rates for a pool by giving an output amount.

Test Usage

  1. Ensure enough tokens minted to your address on testnet
  2. Run PRIVATE_KEY=xxx yarn run test

Developing

Generate documentation with typedoc. Install with:

npm i typedoc typedoc-plugin-markdown --global

then run:

typedoc --out ./doc ./src --excludePrivate --excludeNotExported --plugin typedoc-plugin-markdown

Contributing

Please review the contribution guidelines before contributing or opening pull requests.