Getting the pool state

Function Signature

function getPoolState(xfai: Xfai, pool: Pool): PoolState;

type PoolState = {
  reserve: BigNumber;
  ethReserve: BigNumber;
};

Description

The getPoolState function takes in a Pool object and returns a PoolState.

Parameters

  • xfai: The xfai class

  • pool: The Pool object

Example Usage

import { Token, getPoolFromToken, getPoolState, Xfai} from '@xfai-labs/sdk';

// initialize the Xfai Object
const xfai = new Xfai(...);


// Get the pool that holds the usdc token
const pool = getPoolFromToken(xfai, Token('0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'));

const poolAddress = pool.address;

// Get the state of the pool
const { reserve, ethReserve } = await getPoolState(xfai, pool);

Last updated