Querying MAYAChain

How to Query MAYAChain

Getting the Asgard Vault

Vaults are fetched from the /inbound_addresses :

https://mayanode.mayachain.info/mayachain/inbound_addresses

You need to select the address of the Chain the inbound transaction will go to.

The address will be the current active Asgard Address that accepts inbounds. Do not cache these address as they change regularly. Do not delay inbound transactions (e.g. do not use future timeLocks).

Example Output, each connected chain will be displayed.

[
  {
		"address": "bc1qqtemwlu9ju3ts3da5l82qejnzdl3xfs3lcl4wg",
		"chain": "BTC",
		"chain_lp_actions_paused": false,
		"chain_trading_paused": false,
		"gas_rate": "390",
		"gas_rate_units": "satsperbyte",
		"global_trading_paused": false,
		"halted": false,
		"outbound_fee": "390000",
		"outbound_tx_size": "1000",
		"pub_key": "mayapub1addwnpepqvz6vkw4nzcp5sl9ktx63kz7v0n754r99uehfnzv42eauc644yzgvmuun3k"
	},
      ...
  • Chain: Chain Name

  • Address: Asgard Vault inbound address for that chain.,

  • Halted: Boolean, if the chain is halted. This should be monitored.

  • gas_rate: rate to be used, e.g. in Stats or GWei. See Fees.

Displaying available pairs

Use the /pools endpoint of Midgard to retrieve all swappable assets on MAYAChain. The response will be an array of objects like this:

{
		"annualPercentageRate": "0.1653348126078579",
		"asset": "KUJI.KUJI",
		"assetDepth": "22781179322318",
		"assetPrice": "3.621027920713548",
		"assetPriceUSD": "3.498740619649093",
		"liquidityUnits": "5385277119677037",
		"poolAPY": "0.1653348126078579",
		"runeDepth": "8249128639289561",
		"status": "available",
		"synthSupply": "31040367",
		"synthUnits": "3668841935",
		"units": "5385280788518972",
		"volume24h": "561310885869971"
	}

Only pools with "status": "available" are available to trade

Make sure to manually add Native $CACAO as a swappable asset.

"assetPrice" tells you the asset's price in CACAO (RUNE Depth/AssetDepth ). In the above example

1 KUJI.KUJI = 3.62 RUNE

Decimals and Base Units

All values on MAYAChain (MAYANode and Midgard) are given in 1e8 eg, 100000000 base units (like Bitcoin), and unless postpended by "USD", they are in units of RUNE. Even 1e18 assets, such as ETH.ETH, are shortened to 1e8. 1e6 Assets like ETH.USDC, are padded to 1e8. MAYANode will tell you the decimals for each asset, giving you the opportunity to convert back to native units in your interface.

See code examples using the MAYAChain xchain package here https://github.com/xchainjs/xchainjs-lib/tree/master/packages/xchain-mayachain

Finding Chain Status

There are two ways to see if a Chain is halted.

  1. Looking at the /inbound_addresses endpoint and inspecting the halted flag.

  2. Looking at Mimir and inspecting the HALT[Chain]TRADING setting. See Network Halts for more details.

Last updated

Was this helpful?