@xchainjs/xchain-mayachain-query

@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

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

Generated using TypeDoc