Options
All
  • Public
  • Public/Protected
  • All
Menu

An entry point for interacting with the SDK.

Exposes convenience methods for fetching assets and pools and provides PoolCreator, which can be used to create new pools in Pact.

Example usage:

import algosdk from "algosdk";
import pactsdk from "@pactfi/pactsdk";

const algod = new algosdk.Algodv2(token, url, port);
const pact = new pactsdk.PactClient(algod, {network: "testnet"});

const algo = await pact.fetchAsset(0);
const otherCoin = await pact.fetchAsset(12345678);

const pools = await pact.fetchPoolsByAssets(algo, otherCoin);

Hierarchy

  • PactClient

Index

Constructors

  • Parameters

    • algod: default

      Algorand client to work with.

    • options: Partial<Config & { network: Network }> = {}

      Use it to overwrite configuration parameters.

    Returns PactClient

Properties

algod: default

Algorand client to work with.

config: Config

Client configuration with global contracts ids etc.

Methods

  • fetchAsset(assetIndex: number): Promise<Asset>
  • A convenient method for fetching ASAs (Algorand Standard Asset).

    This will return an Asset class with the relevant data about the asset if the asset index is valid. Note that an index of zero (0) will return the Algo asset.

    throws

    PactSdkError If the asset does not exist.

    Parameters

    • assetIndex: number

      The id of the asset.

    Returns Promise<Asset>

    Promise that will return an Asset object for the id.

  • fetchPoolById(appId: number): Promise<Pool>
  • Fetches the pool by the application id. It uses algod client to fetch the data directly from the blockchain.

    Parameters

    • appId: number

      The application id of pool to return.

    Returns Promise<Pool>

    The pool for the application id.

  • fetchPoolsByAssets(primaryAsset: number | Asset, secondaryAsset: number | Asset): Promise<Pool[]>
  • Returns a list of liquidity pools on Pact that are across the primary and secondary assets.

    First, it uses Pact API retrieve app ids matching the provided assets and then uses algod client to fetch contracts data from the blockchain.

    Parameters

    • primaryAsset: number | Asset

      Primary asset or the asset id for the pool to find.

    • secondaryAsset: number | Asset

      Secondary asset or the asset id for the pool to find.

    Returns Promise<Pool[]>

    List of Pool for the two assets, the list may be empty.

  • Returns a list of pools according to the pool options passed in. Uses Pact API for fetching the data.

    This method is deprecated but is kept for backward compatibility. Pact is in the process of changing the way the pools are created. In the future, all pools will be created using a pool factory contract which allows for an on-chain discoverability of pools.

    Parameters

    Returns Promise<ApiListPoolsResponse>

    Paginated list of pools.

Generated using TypeDoc