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

@xchainjs/xchain-mayachain-query

v0.1.15

Published

Mayachain query module that is responsible for estimating swap calculations and add/remove liquidity for thorchain

Downloads

519

Readme

@xchainjs/xchain-mayachain-query

Mayachain-query module to query mayachain for estimation of swaps/ add and remove Liquidity and checking a transaction stage. Returns a TxDetail object with all the information needed to conduct a swap, or add liquidity. This includes estimateAddSavers()

Installation

yarn add @xchainjs/xchain-maychain-query

Following peer dependencies have to be installed into your project. These are not included in @xchainjs/xchain-maychain-query.

yarn add @xchainjs/xchain-client @xchainjs/xchain-util @xchainjs/xchain-midgard @xchainjs/xchain-mayanode axios

Examples

Estimation example from a swap of 2 BTC to CACAO

{
  memo: '=:CACAO.CACAO::2071168559999',
  expiry: 2022-09-07T02:16:45.732Z,
  toAddress: '',
  txEstimate: {
    input: '₿ 2',
    totalFees: {
      // @@@ Update icons
      inboundFee: 'ᚱ 0.02',
      swapFee: 'ᚱ 52.85380999',
      outboundFee: 'ᚱ 0.06',
      affiliateFee: 'ᚱ 0'
    },
    slipPercentage: '0.00246920801878638026',
    netOutput: 'ᚱ 21,352.25318742',
    waitTimeSeconds: '1248',
    canSwap: true,
    errors: []
  }
}

Estimation of add symetric liquidity

{
  rune: 'ᚱ 12,000',
  asset: '⚡ 0',
  slipPercent: '0.0747',
  lpUnits: '154224962883',
  runeToAssetRatio: '20064.69985077',
  // @@@ Update references to rune
  transactionFee: { assetFee: '⚡ 0', runeFee: 'ᚱ 0.02', totalFees: 'ᚱ 0.02' },
  estimatedWaitSeconds: 6,
  errors: [],
  canAdd: true
}

Estimation of remove Liquidity

{
  asset: { chain: 'BTC', symbol: 'BTC', ticker: 'BTC', synth: false },
  percentage: 100,
  assetAddress: 'bc1qufc5hvfvszphksqawadpc63ujarhjpn26je2jn',
  runeAddress: ''
}
{
  slipPercent: '0.0000',
  runeAmount: 'ᚱ 1,664,891.55918601',
  assetAmount: '₿ 83.01517361',
  inbound: {
    assetFee: '⚡ 10,000',
    runeFee: 'ᚱ 0.02',
    totalFees: 'ᚱ 2.02552681'
  },
  impermanentLossProtection: {
    ILProtection: CryptoAmount { asset: [Object], baseAmount: [Object] },
    totalDays: '346.62'
  },
  estimatedWaitSeconds: 8400
}

Estimation of Add Saver

{
  assetAmount: '₿ 0.5',
  estimatedDepositValue: '₿ 0.49937395',
  fee: {
    affiliateFee: '⚡ 0',
    asset: { chain: 'BTC', symbol: 'BTC', ticker: 'BTC', synth: true },
    outbound: '⚡ 0'
  },
  expiry: 2023-03-29T05:58:34.415Z,
  toAddress: 'bc1qucjrczghvwl5d66klz6npv7tshkpwpzlw0zzj8',
  memo: '+:BTC/BTC',
  estimateWaitTime: 600,
  saverCapFilledPercent: 266.3662135203711,
  slipBasisPoints: 12,
  canAdd: true,
  errors: []
}

Documentation

Overview

For bash exmples, see example folder at the base of this repository xchainjs/xchainjs-lib/examples/liquidity.

xchain-mayachain-query

How xchain-mayachain-query works: http://docs.xchainjs.org/xchain-mayachain-query/how-it-works.html
How to use xchain-mayachain-query: http://docs.xchainjs.org/xchain-mayachain-query/how-to-use.html

For Live examples

// @@@ Check if we have an equivalent Estimate swap: https://replit.com/@thorchain/estimateSwap#index.ts
Estimate add: https://replit.com/@thorchain/estimateAddliquidity
Estimate withdraw: https://replit.com/@thorchain/estimateWithdrawLiquidity
Check liquidity: https://replit.com/@thorchain/checkLiquidity
List pools: https://replit.com/@thorchain/listPools#package.json
Get Network Values: https://replit.com/@thorchain/networkValues#index.ts\

Estimate AddSaver() & WithdrawSaver() & getSaverPosition() https://replit.com/@thorchain/quoteDepositTS#index.ts

Check transaction Stage

Setting Headers for Nine Realms endpoints

If you plan on using the publically accessible endpoints provided by Nine Realms(listed below), ensure that you add a valid 'x-client-id' to all requests

  • https://midgard.ninerealms.com
  • https://haskoin.ninerealms.com (BTC/BCH/LTC)
  • https://thornode.ninerealms.com

Example

import cosmosclient from '@cosmos-client/core'
import axios from 'axios'
import { register9Rheader } from '@xchainjs/xchain-util'

register9Rheader(axios)
register9Rheader(cosmosclient.config.globalAxios)

For a complete example please see this test