0.7.10 • Published 10 days ago

@xchainjs/xchain-thorchain-query v0.7.10

Weekly downloads
-
License
MIT
Repository
github
Last release
10 days ago

@xchainjs/xchain-thorchain-query

Thorchain-query module to query thorchain 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-thorchain-query

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

yarn add @xchainjs/xchain-client @xchainjs/xchain-util @xchainjs/xchain-midgard-query @xchainjs/xchain-thornode axios

Examples

Estimation example from a swap of 2 BTC to RUNE

{
  memo: '=:THOR.RUNE::2071168559999',
  expiry: 2022-09-07T02:16:45.732Z,
  toAddress: '',
  txEstimate: {
    input: '₿ 2',
    totalFees: {
      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',
  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-thorchain-query

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

For Live examples

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

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

0.7.10

10 days ago

0.7.9

17 days ago

0.7.8

1 month ago

0.7.7

2 months ago

0.7.6

2 months ago

0.7.5

2 months ago

0.7.4

2 months ago

0.7.3

4 months ago

0.7.2

4 months ago

0.7.1

4 months ago

0.7.0

5 months ago

0.6.15

5 months ago

0.4.9

9 months ago

0.6.6

6 months ago

0.4.8

9 months ago

0.6.9

6 months ago

0.6.8

6 months ago

0.6.10

6 months ago

0.6.12

6 months ago

0.6.11

6 months ago

0.6.13

5 months ago

0.5.0

8 months ago

0.6.3

7 months ago

0.4.5

10 months ago

0.6.2

7 months ago

0.6.5

7 months ago

0.4.7

9 months ago

0.6.4

7 months ago

0.4.6

9 months ago

0.6.1

8 months ago

0.6.0

8 months ago

0.4.4

11 months ago

0.4.1

12 months ago

0.4.0

1 year ago

0.4.3

12 months ago

0.4.2

12 months ago

0.3.0

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.2.6

1 year ago

0.1.19

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.5

1 year ago

0.2.4

1 year ago

0.1.18

1 year ago

0.1.17

1 year ago

0.1.16

1 year ago

0.1.15

1 year ago

0.1.14

1 year ago

0.1.13

1 year ago

0.1.12

1 year ago

0.1.11

1 year ago

0.1.10

1 year ago

0.1.9

1 year ago

0.1.8

1 year ago

0.1.7

1 year ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.0

2 years ago

0.1.0-beta2

2 years ago

0.1.0-beta1

2 years ago

0.1.0-beta

2 years ago

0.1.0-alpha1

2 years ago

0.1.0-alpha

2 years ago