Packages Breakdown

How xChainjs is constructed

xchain-[chain] clients

Each blockchain that is integrated into MAYAChain has a corresponding xchain client with a suite of functionality to work with that chain. They all extend the xchain-client class.

xchain-mayachain-amm

MAYAChain automatic market maker that uses MAYANode & Midgard Api's AMM functions like swapping, adding and removing liquidity. It wraps xchain clients and creates a new wallet class and balance collection.

xchain-mayachain-query

Uses midgard and mayanode Api's to query MAYAChain for information. This module should be used as the starting place get any MAYAChain information that resides in MAYANode or Midgard as it does the heaving lifting and configuration.

Default endpoints are provided with redundancy, custom MAYANode or Midgard endpoints can be provided in the constructor.

xchain-midgard

This package is built from OpenAPI-generator. It is used by the mayachain-query.

Thorchain-query contains midgard class that uses xchain-midgard and the following end points:

  • /v2/mayachain/mimir

  • /v2/mayachain/inbound_addresses

  • /v2/mayachain/constants

  • /v2/mayachain/queue

For simplicity, is recommended to use the midgard class within mayachain-query instead of using the midgard package directly.

Midgard Configuration in mayachain-query

Default endpoints defaultMidgardConfig are provided with redundancy within the Midgard class.

Custom Midgard endpoints can be provided in the constructor using the MidgardConfig type.

See ListPools for a working example.

xchain-mayanode

This package is built from OpenAPI-generator and is also used by the thorchain-query. The design is similar to the midgard. MAYANode should only be used when time-sensitive data is required else midgard should be used.

MAYANode Configuration in mayachain-query

As with the midgard package, MAYANode can also be given custom end points via theMayanodeConfig type.

xchain-util

A helper packager used by all the other packages. It has the following modules:

  • asset - Utilities for handling assets

  • async - Utitilies for async handling

  • bn - Utitilies for using bignumber.js

  • chain - Utilities for multi-chain

  • string - Utilities for strings

Last updated

Was this helpful?