Options
All
  • Public
  • Public/Protected
  • All
Menu

PoolCreator class, used to create, deploy and fund a new pool in Pact.

In order to properly create a new pool, functions must be run in this exact order:

This class records the order of executed functions and will throw an error if any of them is triggered in the wrong order.

Hierarchy

  • PoolCreator

Index

Constructors

Properties

pactApiUrl: string

Pact API URL to use.

poolId: null | number = null

An Id of created pool. Will be assigned automatically on deployPool function.

poolParams: NewPoolParams

Params required in new pool creation.

Methods

  • buildFundingTxs(address: string): Promise<Transaction[]>
  • Builds three transactions:

    • Fund pool with ALGO required to perform basic smart-contract operations.
    • Noop transaction that creates liquidity tokens.
    • Noop transaction that performs an opt-in to pool's primary and secondary assets.

    IMPORTANT!: Signed transactions must be send by sendFundingTxs function in order to save all required data in Pact's database.

    throws

    PactSdkError if poolId was not generated yet.

    throws

    PactApiError if something wrong occurs during sending data to Pact API.

    Parameters

    • address: string

      Sender account address.

    Returns Promise<Transaction[]>

    Array of described transactions.

  • deployPool(txBlob: string): Promise<number>
  • Deploys a pool created from the transaction in preparePoolCreationTx to the Pact database. If successful, PoolCreator will store the new pool id in a poolId.

    throws

    PactApiError if something wrong occurs during sending data to Pact API.

    Parameters

    • txBlob: string

      Signed transaction blob.

    Returns Promise<number>

    An Id of the newly deployed pool.

  • makeAppCreateTx(accountAddress: string, poolData: CompiledContract): Transaction
  • makeNewAppFundTx(accountAddress: string, newAppID: number, txnData: CompiledAppFundTxn): Transaction
  • makeNewAppNoopTx(accountAddress: string, txnData: CompiledNoopTxn, encodedAppArgs?: Uint8Array[]): Transaction
  • Creates the transactions needed for pool to work properly and returns them as a transaction group ready to be signed and committed.

    throws

    PactSdkError if poolId was not generated yet.

    throws

    PactApiError if something wrong occurs during sending data to Pact API.

    Parameters

    • address: string

      Sender account address.

    Returns Promise<TransactionGroup>

    A transaction group that when executed will fund the pool, create liquidity tokens and opt-in assets.

  • preparePoolCreationTx(address: string): Promise<Transaction>
  • Creates a transaction needed to perform pool creation ready to be signed and committed.

    IMPORTANT!: Signed transaction must be send by deployPool function in order to save the pool in Pact's database.

    throws

    PactSdkError if any pool param is missing or wrong.

    throws

    PactApiError if something wrong occurs during sending data to Pact API.

    Parameters

    • address: string

      Sender account address.

    Returns Promise<Transaction>

    A transaction that when executed will create a new pool.

  • Sends signed transactions created in buildFundingTxs to the Pact's database. If successful, the new pool will become visible in the Pact UI. It is strongly advised to immediately add the first liquidity to the pool after this step, as it will determine the future ratio of assets.

    throws

    PactSdkError if the number of provided blobs is not correct, or if poolId was not generated yet.

    throws

    PactApiError if something wrong occurs during sending data to Pact API.

    Parameters

    • blobs: TxnBlob[]

      Signed transaction blobs. The number of blobs must be equal to 3.

    Returns Promise<ApiPool>

    A new Pool object.

Generated using TypeDoc