Options
All
  • Public
  • Public/Protected
  • All
Menu

@pactfi/pactsdk - v0.8.1

Index

Namespaces

Classes

Interfaces

Type aliases

Functions

Type aliases

AddLendingLiquidityTxOptions: { address: string; liquidityAddition: LendingLiquidityAddition }

Type declaration

  • address: string

    Account address that will deposit the primary and secondary assets and receive the LP token.

  • liquidityAddition: LendingLiquidityAddition
AddLiquidityEffect: { amplifier: number; bonusPct: number; minimumMintedLiquidityTokens: number; mintedLiquidityTokens: number; txFee: number }

The effect of adding liquidity to the pool.

Type declaration

  • amplifier: number

    Current stableswap amplifier. Zero for constant product pools.

  • bonusPct: number

    Only for stableswaps. Zero for constant product pools.

    A positive bonus means that after removing all the liquidity the user will end up with more tokens than he provided. This can happen when providing liquidity in a way that improves the pool balance.

    If adding the liquidity increases the pool imbalance, the bonus will be negative (a penalty).

    Also, a fee is subtracted from each liquidity addition. This negatively impacts the bonus.

  • minimumMintedLiquidityTokens: number

    Amount of minimum liquidity tokens received. The transaction will fail if the real value will be lower than this.

  • mintedLiquidityTokens: number

    Amount of new liquidity tokens minted when adding the liquidity. All the minted tokens will be received by the liquidity provider except of first 1000 minted tokens which are permanently locked in the contract.

  • txFee: number

    App call transaction fee.

AddLiquidityOptions: { primaryAssetAmount: number; secondaryAssetAmount: number; slippagePct: number }

The arguments to add liquidity to the pool.

Type declaration

  • primaryAssetAmount: number

    The amount of primary asset to deposit.

  • secondaryAssetAmount: number

    The amount of secondary asset to deposit.

  • slippagePct: number

    The maximum allowed slippage in percents e.g. 10 is 10%. Adding liquidity will fail if slippage will be higher.

AddLiquidityTxOptions: { address: string; liquidityAddition: LiquidityAddition }

Type declaration

  • address: string

    Account address that will deposit the primary and secondary assets and receive the LP token.

  • liquidityAddition: LiquidityAddition
ApiAsset: { decimals: number; id: number; is_liquidity_token: boolean; is_verified: boolean; name: string; on_chain_id: string; total_amount: string; tvl_usd: string; unit_name: string; volume_24h: string; volume_7d: string }

Details about the liquidity pool assets returned from the asset pool.

Type declaration

  • decimals: number
  • id: number
  • is_liquidity_token: boolean
  • is_verified: boolean
  • name: string
  • on_chain_id: string
  • total_amount: string
  • tvl_usd: string
  • unit_name: string
  • volume_24h: string
  • volume_7d: string
ApiListPoolsResponse: { count: number; limit: number; offset: number; results: ApiPool[] }

Response from listPools function containing pagination information and results.

Type declaration

  • count: number
  • limit: number
  • offset: number
  • results: ApiPool[]
ApiPool: { address: string; apr_7d: string; confirmed_round: number; creator: string; fee_amount_24h: string; fee_amount_7d: string; fee_bps: number; fee_usd_24h: string; fee_usd_7d: string; id: number; is_deprecated: boolean; is_verified: boolean; on_chain_id: string; pool_asset: ApiAsset; primary_asset: ApiAsset; secondary_asset: ApiAsset; tvl_usd: string; version: number; volume_24h: string; volume_7d: string }

The individual pool information returned from listPools, this contains the basic pool information.

Type declaration

  • address: string
  • apr_7d: string
  • confirmed_round: number
  • creator: string
  • fee_amount_24h: string
  • fee_amount_7d: string
  • fee_bps: number
  • fee_usd_24h: string
  • fee_usd_7d: string
  • id: number
  • is_deprecated: boolean
  • is_verified: boolean
  • on_chain_id: string
  • pool_asset: ApiAsset
  • primary_asset: ApiAsset
  • secondary_asset: ApiAsset
  • tvl_usd: string
  • version: number
  • volume_24h: string
  • volume_7d: string
AppGlobals: { nbs: number; nui: number }

Global data for contracts.

Type declaration

  • nbs: number
  • nui: number
AppInternalState: { A: number; ADMIN?: string; ASSET_A: number; ASSET_B: number; B: number; CONTRACT_NAME?: "PACT AMM" | "[SI] PACT AMM" | "PACT AMM [NFT]"; FEE_BPS: number; FUTURE_A?: number; FUTURE_ADMIN?: string; FUTURE_A_TIME?: number; INITIAL_A?: number; INITIAL_A_TIME?: number; L: number; LTID: number; PACT_FEE_BPS?: number; PRECISION?: number; PRIMARY_FEES?: number; SECONDARY_FEES?: number; TREASURY?: string; VERSION?: number }

The one to one representation of pool's global state. The optional properties are used only by stableswaps and should not be relevant to the users.

Type declaration

  • A: number
  • Optional ADMIN?: string
  • ASSET_A: number
  • ASSET_B: number
  • B: number
  • Optional CONTRACT_NAME?: "PACT AMM" | "[SI] PACT AMM" | "PACT AMM [NFT]"
  • FEE_BPS: number
  • Optional FUTURE_A?: number
  • Optional FUTURE_ADMIN?: string
  • Optional FUTURE_A_TIME?: number
  • Optional INITIAL_A?: number
  • Optional INITIAL_A_TIME?: number
  • L: number
  • LTID: number
  • Optional PACT_FEE_BPS?: number
  • Optional PRECISION?: number
  • Optional PRIMARY_FEES?: number
  • Optional SECONDARY_FEES?: number
  • Optional TREASURY?: string
  • Optional VERSION?: number
CompileContractParams: { fee_bps: number; pool_type?: PoolType; primary_asset_id: string; secondary_asset_id: string; sender: string }

Params for calling the compileContract function.

Type declaration

  • fee_bps: number

    An integer between 1 and 10_000.

  • Optional pool_type?: PoolType
  • primary_asset_id: string
  • secondary_asset_id: string
  • sender: string
CompiledAppFundTxn: CompiledTxn & { amt: number; fee: number; grp: number[]; rcv: number[] }

Compiled funding transaction. Used to provide first funds into the newly created pool.

CompiledContract: CompiledTxn & { apan: number; apap: number[]; apas: number[]; apep: number; apgs: AppGlobals; apsu: number[]; fee: number }

Response from compileContract function containing information about pool that is going to be created.

CompiledNoopTxn: CompiledTxn & { apaa: string[]; apan: number; apas: number[]; apat?: string[]; apid: number; fee: number; grp: number[] }

Compiled Noop transaction. Used to optin to assets in the newly created pool.

CompiledTxn: { fv: number; gen: string; gh: number[]; lv: number; snd: number[]; type: TxnType }

Basic fields in compiled transaction.

Type declaration

  • fv: number
  • gen: string
  • gh: number[]
  • lv: number
  • snd: number[]
  • type: TxnType
Config: { apiUrl: string; factoryConstantProductId: number; factoryNftConstantProductId: number; folksLendingPoolAdapterId: number; gasStationId: number }

Type declaration

  • apiUrl: string
  • factoryConstantProductId: number
  • factoryNftConstantProductId: number
  • folksLendingPoolAdapterId: number
  • gasStationId: number
ConstantProductPoolParams: { feeBps: number; pactFeeBps: number }

Type declaration

  • feeBps: number
  • pactFeeBps: number
ContractTxnsParams: { appid: number; fee_bps: number; primary_asset_id: string; secondary_asset_id: string; sender: string }

Params for calling the prepareContractTxns function.

Type declaration

  • appid: number
  • fee_bps: number
  • primary_asset_id: string
  • secondary_asset_id: string
  • sender: string
DeployedContract: { appid: number }

Contains appid of the newly created & deployed pool.

Type declaration

  • appid: number
EscrowInternalState: { masterApp: number }

Type declaration

  • masterApp: number
FactoryState: { allowedFeeBps: number[]; poolVersion: number }

Type declaration

  • allowedFeeBps: number[]
  • poolVersion: number
FarmInternalState: { admin: string; claimedRewards: number[]; distributedRewards: number[]; duration: number; nextDuration: number; nextRewards: number[]; numStakers: number; pendingRewards: number[]; rewardAssetIds: number[]; rpt: number[]; rptFrac: number[]; stakedAssetId: number; totalStaked: number; updatedAt: number; updater: string; version: number }

Type declaration

  • admin: string
  • claimedRewards: number[]
  • distributedRewards: number[]
  • duration: number
  • nextDuration: number
  • nextRewards: number[]
  • numStakers: number
  • pendingRewards: number[]
  • rewardAssetIds: number[]
  • rpt: number[]
  • rptFrac: number[]
  • stakedAssetId: number
  • totalStaked: number
  • updatedAt: number
  • updater: string
  • version: number
FarmState: { admin: string; claimedRewards: FarmingRewards; distributedRewards: FarmingRewards; duration: number; nextDuration: number; nextRewards: FarmingRewards; numStakers: number; pendingRewards: FarmingRewards; rewardAssets: Asset[]; rpt: FarmingRewards; stakedAsset: Asset; totalStaked: number; updatedAt: Date; updater: string; version: number }

Type declaration

  • admin: string

    The address of the farm's admin account. The admin can deposit new rewards and destroy the farm after it is deprecated.

  • claimedRewards: FarmingRewards

    Amounts of assets claimed by users so far.

  • distributedRewards: FarmingRewards

    Amounts of assets distributed so far. This includes tokens that are already claimed and tokens which are accrued and are awaiting claim.

  • duration: number

    Time in seconds until current cycle ends. This is the time at which the rewards are depleted. Next cycle is automatically picked up if next_rewards are deposited.

  • nextDuration: number

    The duration of the next cycle.

  • nextRewards: FarmingRewards

    Amounts of rewards deposited for the next cycle.

  • numStakers: number

    The number of active stakers. Active staker stakes at least 1 token.

  • pendingRewards: FarmingRewards

    Amounts of not yet distributed rewards in the farm.

  • rewardAssets: Asset[]

    Assets that are distributed as rewards in the farm.

  • rpt: FarmingRewards

    Current rate per token for each asset.

  • stakedAsset: Asset

    The asset the users are going to stake in the farm.

  • totalStaked: number

    The sum of all stakers deposits.

  • updatedAt: Date

    The time the farm was last updated.

  • updater: string

    The address of farm's updater. The updater can update the farm's contract to a new version.

  • version: number

    Contract version.

FarmUserState: { accruedRewards: FarmingRewards; claimedRewards: FarmingRewards; escrowId: number; rpt: FarmingRewards; staked: number }

Type declaration

  • accruedRewards: FarmingRewards

    Amounts of rewards the user has accrued and can claim.

  • claimedRewards: FarmingRewards

    Amounts of rewards the user has already claimed.

  • escrowId: number

    The app id of the user's escrow contract.

  • rpt: FarmingRewards

    Current rate per token for each asset.

  • staked: number

    The amount of staked asset the user has deposited in the escrow.

FarmingRewards: Record<number, number>
FolksLendingPoolAdapterOptions: { pactPool: Pool; primaryLendingPool: FolksLendingPool; secondaryLendingPool: FolksLendingPool }

Type declaration

  • pactPool: Pool

    The Pact pool between two fAssets tokens.

  • primaryLendingPool: FolksLendingPool

    The Folks Finance pool for the primary fAsset.

  • secondaryLendingPool: FolksLendingPool

    The Folks Finance pool for the secondary fAsset.

LendingSwap: { amountDeposited: number; amountReceived: number; assetDeposited: Asset; assetReceived: Asset; fSwap: Swap; minimumAmountReceived: number; txFee: number }

A wrapper around Swap object that adds some lending specific information.

Type declaration

  • amountDeposited: number

    Amount of original asset deposited by the user.

  • amountReceived: number

    Amount of original asset received by the user.

  • assetDeposited: Asset
  • assetReceived: Asset
  • fSwap: Swap

    Information about the actual swap on the Pact pool.

  • minimumAmountReceived: number

    Minimal amount of original asset received by the user after the slippage.

  • txFee: number
LendingSwapTxOptions: { address: string; swap: LendingSwap }

Type declaration

ListPoolsOptions: { creator?: string; is_verified?: string; limit?: string; offset?: string; primary_asset__name?: string; primary_asset__on_chain_id?: string; primary_asset__unit_name?: string; secondary_asset__name?: string; secondary_asset__on_chain_id?: string; secondary_asset__unit_name?: string }

Options for calling the listPools function.

Type declaration

  • Optional creator?: string
  • Optional is_verified?: string
  • Optional limit?: string
  • Optional offset?: string
  • Optional primary_asset__name?: string
  • Optional primary_asset__on_chain_id?: string
  • Optional primary_asset__unit_name?: string
  • Optional secondary_asset__name?: string
  • Optional secondary_asset__on_chain_id?: string
  • Optional secondary_asset__unit_name?: string
MakeDepositTxOptions: { address: string; amount: number; asset: Asset; note: Uint8Array; suggestedParams: algosdk.SuggestedParams }

Type declaration

  • address: string
  • amount: number
  • asset: Asset
  • note: Uint8Array
  • suggestedParams: algosdk.SuggestedParams
MakeNoopTxOptions: { address: string; args: (OperationType | number)[]; extraAsset?: Asset; fee: number; note?: Uint8Array; suggestedParams: algosdk.SuggestedParams }

Type declaration

  • address: string
  • args: (OperationType | number)[]
  • Optional extraAsset?: Asset
  • fee: number
  • Optional note?: Uint8Array
  • suggestedParams: algosdk.SuggestedParams
Network: "mainnet" | "testnet" | "dev"
NewPoolParams: Omit<CompileContractParams, "sender">
OperationType: "SWAP" | "ADDLIQ" | "REMLIQ"

The basic three operation types in a PACT liquidity pool, namely Add Liquidity (ADDLIQ), Remove Liquidity (REMLIQ) and making a swap (SWAP).

OptInAssetToAdapterTxOptions: { address: string; assetIds: number[] }

Type declaration

  • address: string
  • assetIds: number[]
PoolBuildParams: { feeBps: number; primaryAssetId: number; secondaryAssetId: number }

Type declaration

  • feeBps: number
  • primaryAssetId: number
  • secondaryAssetId: number
PoolParams: PoolBuildParams & { version: number }
PoolState: { primaryAssetPrice: number; secondaryAssetPrice: number; totalLiquidity: number; totalPrimary: number; totalSecondary: number }

A user friendly representation of pool's global state.

Type declaration

  • primaryAssetPrice: number
  • secondaryAssetPrice: number
  • totalLiquidity: number
  • totalPrimary: number
  • totalSecondary: number
PoolType: "CONSTANT_PRODUCT" | "STABLESWAP" | "NFT_CONSTANT_PRODUCT"
RawAddLiquidityTxOptions: AddLiquidityOptions & { address: string; fee: number; minimumMintedLiquidityTokens: number; note?: Uint8Array; suggestedParams: SuggestedParams }
RemoveLiquidityOptions: { address: string; amount: number }

The arguments for removing liquidity from the pool.

Type declaration

  • address: string

    Account address that will return the LP token and receive the primary and secondary assets.

  • amount: number

    The amount of the LP token to return to the pool.

Signer: (group: TransactionGroup) => Promise<Uint8Array[]>

Type declaration

StableswapPoolParams: { feeBps: number; futureA: number; futureATime: number; initialA: number; initialATime: number; pactFeeBps: number; precision: number }

Type declaration

  • feeBps: number
  • futureA: number
  • futureATime: number
  • initialA: number
  • initialATime: number
  • pactFeeBps: number
  • precision: number
SuggestedParamsOption: { suggestedParams: algosdk.SuggestedParams }

Type declaration

  • suggestedParams: algosdk.SuggestedParams
SwapEffect: { amountDeposited: number; amountReceived: number; amplifier: number; fee: number; minimumAmountReceived: number; price: number; primaryAssetPriceAfterSwap: number; primaryAssetPriceImpactPct: number; secondaryAssetPriceAfterSwap: number; secondaryAssetPriceImpactPct: number; txFee: number }

Swap Effect are the basic details of the effect on the pool of performing the swap.

Type declaration

  • amountDeposited: number
  • amountReceived: number
  • amplifier: number

    Stableswap only. Zero otherwise.

  • fee: number
  • minimumAmountReceived: number
  • price: number
  • primaryAssetPriceAfterSwap: number
  • primaryAssetPriceImpactPct: number
  • secondaryAssetPriceAfterSwap: number
  • secondaryAssetPriceImpactPct: number
  • txFee: number
SwapOptions: { amount: number; asset: Asset; slippagePct: number; swapForExact?: boolean }

Options for creating a Swap.

Type declaration

  • amount: number

    Amount to swap or to receive. Look at swapForExact flag for details.

  • asset: Asset

    The asset to swap.

  • slippagePct: number

    The maximum allowed slippage in percents e.g. 10 is 10%. The swap will fail if slippage will be higher.

  • Optional swapForExact?: boolean

    If false or not provided, the amount is the amount to swap (deposit in the contract). If true, the amount is the amount to receive from the swap.

SwapTxOptions: { address: string; swap: Swap }

The arguments used to generate the swap.

Type declaration

  • address: string
  • swap: Swap
TxnBlob: { blob: string }

A blob from a signed transaction.

Type declaration

  • blob: string
TxnType: "acfg" | "afrz" | "appl" | "axfer" | "keyreg" | "pay"

Possible transaction types.

ZapOptions: { amount: number; asset: Asset; slippagePct: number }

The arguments to add liquidity to the pool using zap.

Type declaration

  • amount: number

    Amount used for the zap.

  • asset: Asset

    Asset provided for the zap.

  • slippagePct: number

    The maximum allowed slippage in percents e.g. 10 is 10%. The swap will fail if slippage will be higher.

ZapParams: { primaryAddLiq: bigint; secondaryAddLiq: bigint; swapDeposited: bigint }

All amounts that should be used in swap and add liquidity transactions.

Type declaration

  • primaryAddLiq: bigint
  • secondaryAddLiq: bigint
  • swapDeposited: bigint
ZapTxOptions: { address: string; zap: Zap }

The options for building zap transactions.

Type declaration

  • address: string
  • zap: Zap

Functions

  • buildDeployEscrowTxs(sender: string, farmAppId: number, stakedAssetId: number, suggestedParams: SuggestedParams): algosdk.Transaction[]
  • Parameters

    • sender: string
    • farmAppId: number
    • stakedAssetId: number
    • suggestedParams: SuggestedParams

    Returns algosdk.Transaction[]

  • Compiles contract data.

    Parameters

    • pactApiUrl: string

      The API URL.

    • params: CompileContractParams

      Information about sender, assets ids and desired fee bps.

    Returns Promise<CompiledContract>

    Compiled contract data, to be used in transaction creation.

  • decode(s: Uint8Array): string
  • decodeAddressFromGlobalState(encoded: string): string
  • decodeBase64(encoded: string): string
  • decodeUint64Array(data: string): number[]
  • Deploys contract to the blockchain.

    Parameters

    • pactApiUrl: string

      The API URL.

    • params: TxnBlob

      Signed transaction blob.

    Returns Promise<DeployedContract>

    The id of the newly deployed contract.

  • encode(s: string): Uint8Array
  • encodeArray(arr: any[]): Uint8Array[]
  • Fetches the global state of the of an application.

    Parameters

    • algod: default

      The algo client to query the app in.

    • appId: number

      The application id to fetch the state of.

    Returns Promise<AppInternalState>

    The global state of the application.

  • fetchAssetByIndex(algod: default, index: number): Promise<Asset>
  • Fetches an Asset class with the details about the asset for a given id number.

    The function uses an internal cache so as to minimize the number of times the actual Algorand client is used to look up the asset. This function is used through out the pact sdk to query asset information.

    Parameters

    • algod: default

      An Algorand client to query about the asset.

    • index: number

      An Algorand Asset number to look up.

    Returns Promise<Asset>

    An Asset instance for the asset number passed in.

  • fetchEscrowApprovalProgram(algod: default, farmAppId: number): Promise<Uint8Array>
  • fetchEscrowById(algod: default, appId: number, options?: { farm?: Farm }): Promise<Escrow>
  • fetchFarmById(algod: default, appId: number): Promise<Farm>
  • fetchFarmRawStateById(algod: default, appId: number): Promise<any>
  • Fetches Folks lending pool application info from the algod, parses the global state and builds FolksLendingPool object.

    Parameters

    • algod: default
    • appId: number

    Returns Promise<FolksLendingPool>

  • fetchPoolById(algod: default, appId: number): Promise<Pool>
  • Fetches the pool from the blockchain using the provided algod client.

    Parameters

    • algod: default

      The algo client to use.

    • appId: number

      The application id to fetch.

    Returns Promise<Pool>

    The pool object for the application id passed in.

  • fetchPoolsByAssets(algod: default, assetA: number | Asset, assetB: number | Asset, pactApiUrl: string): Promise<Pool[]>
  • Returns the list of Pool for the assets passed in. There can be zero pools if there are no pools matching the assets, or multiple if there are multiple at different fees. The order of assets that you provide is irrelevant.

    Parameters

    • algod: default

      The algo client to use.

    • assetA: number | Asset

      One of the assets in the pool (asset id or Asset).

    • assetB: number | Asset

      The other asset in the pool (asset id or Asset).

    • pactApiUrl: string

      The API url to use.

    Returns Promise<Pool[]>

    A list of pools matching the provided assets.

  • getAddLiquidityBonusPct(addedPrimary: bigint, addedSecondary: bigint, totalPrimary: bigint, totalSecondary: bigint, feeBps: bigint, amplifier: bigint, precision: bigint): number
  • Parameters

    • addedPrimary: bigint
    • addedSecondary: bigint
    • totalPrimary: bigint
    • totalSecondary: bigint
    • feeBps: bigint
    • amplifier: bigint
    • precision: bigint

    Returns number

  • getAddLiquidityFees(initialTotals: [bigint, bigint], updatedTotals: [bigint, bigint], feeBps: bigint, amplifier: bigint, precision: bigint): [[bigint, bigint], bigint, number]
  • Parameters

    • initialTotals: [bigint, bigint]
    • updatedTotals: [bigint, bigint]
    • feeBps: bigint
    • amplifier: bigint
    • precision: bigint

    Returns [[bigint, bigint], bigint, number]

  • getAlgo(algod: default): Asset
  • getAmplifier(timestampInSeconds: number, initialA: number, initialATime: number, futureA: number, futureATime: number): bigint
  • Parameters

    • timestampInSeconds: number
    • initialA: number
    • initialATime: number
    • futureA: number
    • futureATime: number

    Returns bigint

  • getAppIdsFromAssets(pactApiUrl: string, primaryAssetIndex: number, secondaryAssetIndex: number): Promise<number[]>
  • Returns the application ids for any pools that match the primary and secondary asset.

    This function finds any pools using the pactApiUrl passed in that match the asset ids passed in.

    Parameters

    • pactApiUrl: string

      The API url to use.

    • primaryAssetIndex: number

      The algorand asset id for the primary asset of the pool.

    • secondaryAssetIndex: number

      The algorand asset id for the secondary asset of the pool.

    Returns Promise<number[]>

    Array of asset ids.

  • getCachedAsset(algod: default, index: number, decimals: number): Asset
  • getConstantProductMintedLiquidityTokens(addedPrimary: bigint, addedSecondary: bigint, totalPrimary: bigint, totalSecondary: bigint, totalLiquidity: bigint): bigint
  • Parameters

    • addedPrimary: bigint
    • addedSecondary: bigint
    • totalPrimary: bigint
    • totalSecondary: bigint
    • totalLiquidity: bigint

    Returns bigint

  • getConstantProductSwapAmountDeposited(liqA: bigint, liqB: bigint, grossAmountReceived: bigint): bigint
  • getConstantProductSwapGrossAmountReceived(liqA: bigint, liqB: bigint, amountDeposited: bigint): bigint
  • getConstantProductZapParams(liqA: bigint, liqB: bigint, zapAmount: bigint, feeBps: bigint, pactFeeBps: bigint): ZapParams
  • Parameters

    • liqA: bigint
    • liqB: bigint
    • zapAmount: bigint
    • feeBps: bigint
    • pactFeeBps: bigint

    Returns ZapParams

  • getInvariant(liqA: bigint, liqB: bigint, amp: bigint, precision: bigint): [bigint, number]
  • Uses a Newton-Raphson method to calculate the pool invariant.

    Parameters

    • liqA: bigint
    • liqB: bigint
    • amp: bigint
    • precision: bigint

    Returns [bigint, number]

    A tuple of invariant and number of iterations required to calculate the invariant.

  • getNewLiq(liqOther: bigint, amplifier: bigint, inv: bigint, precision: bigint): bigint
  • getSecondaryAddedLiquidityFromZapping(swapDeposited: bigint, totalPrimary: bigint, totalSecondary: bigint, feeBps: bigint): bigint
  • Parameters

    • swapDeposited: bigint
    • totalPrimary: bigint
    • totalSecondary: bigint
    • feeBps: bigint

    Returns bigint

  • getStableswapAmountDeposited(liqA: bigint, liqB: bigint, grossAmountReceived: bigint, amplifier: bigint, precision: bigint): [bigint, number]
  • Parameters

    • liqA: bigint
    • liqB: bigint
    • grossAmountReceived: bigint
    • amplifier: bigint
    • precision: bigint

    Returns [bigint, number]

  • getStableswapGrossAmountReceived(liqA: bigint, liqB: bigint, amountDeposited: bigint, amplifier: bigint, precision: bigint): [bigint, number]
  • Parameters

    • liqA: bigint
    • liqB: bigint
    • amountDeposited: bigint
    • amplifier: bigint
    • precision: bigint

    Returns [bigint, number]

  • getStableswapMintedLiquidityTokens(addedPrimary: bigint, addedSecondary: bigint, totalPrimary: bigint, totalSecondary: bigint, totalLiquidity: bigint, amplifier: bigint, precision: bigint, feeBps: bigint): [bigint, number]
  • Returns a tuple of minted tokens and total Newton-Raphson iterations (needed for tx fee calculations).

    Parameters

    • addedPrimary: bigint
    • addedSecondary: bigint
    • totalPrimary: bigint
    • totalSecondary: bigint
    • totalLiquidity: bigint
    • amplifier: bigint
    • precision: bigint
    • feeBps: bigint

    Returns [bigint, number]

  • getSwapAmountDepositedFromZapping(zapAmount: bigint, totalAmount: bigint, feeBps: bigint, pactFeeBps: bigint): bigint
  • Parameters

    • zapAmount: bigint
    • totalAmount: bigint
    • feeBps: bigint
    • pactFeeBps: bigint

    Returns bigint

  • getSwapAmountWithoutTax(swapDeposited: bigint, totalPrimary: bigint, totalSecondary: bigint): bigint
  • Parameters

    • swapDeposited: bigint
    • totalPrimary: bigint
    • totalSecondary: bigint

    Returns bigint

  • getTxFee(invariantIterations: number, extraMargin: number): number
  • To calculate the pool invariant, a Newton-Raphson method is used in both - the SDK and the smart contract. Algorand has a limit of the number of operations available in a single app call. To increase the limit, an additional empty inner transaction have to be created. Each extra tx increases tx fee. This functions calculates the fee needed for a swap transaction.

    Parameters

    • invariantIterations: number

      Number of iterations of Newton-Raphson interpolation.

    • extraMargin: number

      Number of extra inner transactions needed in case of slippage.

    Returns number

    The required fee.

  • Finds all the pools that match the pool options passed in.

    Parameters

    • pactApiUrl: string

      The API URL to query the list of pools.

    • options: ListPoolsOptions

      List of options for querying the pools.

    Returns Promise<ApiListPoolsResponse>

    Pool data for all pools in the Pact that meets the pool options.

  • makeFarmFromRawState(algod: default, appId: number, rawState: any): Farm
  • sendContractTxns(pactApiUrl: string, txs: TxnBlob[]): Promise<ApiPool>
  • Sends all initial contract transactions prepared in prepareContractTxns function.

    Parameters

    • pactApiUrl: string

      The API URL.

    • txs: TxnBlob[]

      An array of three transaction blobs.

    Returns Promise<ApiPool>

    Pool data of successfully created, deployed and prepared contract.

  • setGasStation(appId: number): void

Generated using TypeDoc