thorswap-lib-midgard
v0.0.1
Published
API service for THORChain Midgard
Downloads
2
Readme
@thorswap-lib/midgard-api
API helper for THORChain midgard service
Usage
Create and Initialize Midgard Client
import { Midgard } from '@thorswap-lib/midgard-api'
const midgardApi = new Midgard({ network: 'mainnet' }) // use default baseurl for mainnet
const midgardApi = new Midgard({ network: 'stagenet' }) // use default baseurl for stagenet
const midgardApi = new Midgard({ baseUrl: 'https://midgard.thorswap.net' }) // use custom baseurl
Midgard api functions
setBaseUrl: (baseUrl: string) => void
getBaseUrl: () => string
getHealth: () => Promise<Health>
getPools: (status?: PoolStatus) => Promise<PoolDetail[]>
getPoolDetail: (asset: string) => Promise<PoolDetail>
getPoolStats: (param: { asset: string; period: StatsPeriod }) => Promise<PoolStatsDetail>
getDepthHistory: (param: { pool: string; query?: HistoryQuery }) => Promise<DepthHistory>
getEarningsHistory: (query: HistoryQuery) => Promise<EarningsHistory>
getTVLHistory: (query: HistoryQuery) => Promise<TVLHistory>
getSwapHistory: (param: { pool?: string; query?: HistoryQuery }) => Promise<SwapHistory>
getLiquidityHistory: (param: { pool?: string; query?: HistoryQuery }) => Promise<LiquidityHistory>
getNodes: () => Promise<THORNode[]>
getNetworkData: () => Promise<Network>
getActions: (params: ActionListParams) => Promise<ActionsList>
getMembersAddresses: () => Promise<string[]>
getMemberDetail: (address: string) => Promise<MemberDetails>
getStats: () => Promise<StatsData>
getConstants: () => Promise<Constants>
getInboundAddresses: () => Promise<InboundAddressesItem[]>
getInboundAddressByChain: (chain: string) => Promise<PoolAddress>
getInboundDataByChain: (chain: string) => Promise<InboundAddressesItem>
getLastblock: () => Promise<LastblockItem[]>
getQueue: () => Promise<Queue>
// THORName
getTHORNameDetail: (name: string) => Promise<THORNameDetails>
getTHORNamesByAddress: (address: string) => Promise<string[]>
Default Midgard URLs
MIDGARD_MAINNET_URL = 'https://midgard.thorchain.info'
MIDGARD_STAGENET_URL = 'https://stagenet-midgard.ninerealms.com'
MIDGARD_TESTNET_URL = 'https://testnet.midgard.thorchain.info'