Options
All
  • Public
  • Public/Protected
  • All
Menu
class

Swapable.CreatePool

package

Swapable

subpackage

Commands

since

v1.0.0

description

Class that describes a command for creating automated liquidity pools.

summary

This automated pool command accepts the following arguments:

Argument Description Example
provider Liquidity provider new PublicAccount(...)
input_x Amount and asset identifier of x (first in pair) new AssetAmount(...)
input_y Amount and asset identifier of y (second in pair) new AssetAmount(...)

The execution of this command results in the creation of the following list of transactions with their respective signer and a description:

Sequence Type Signer Description
01 AccountMetadataTransaction Target Account Assigns the Pool_Id metadata value to the target account.
02 MosaicDefinitionTransaction Target Account Creates the automated pool shares mosaic. Automated pool shares are distributed at pro-rata rates amongst liquidity providers. There is one automated pool shares mosaic per each automated liquidity pool.
03 MosaicSupplyChangeTransaction Target Account Creates the initial supply of automated pool shares for a liquidity pool pairing cryptocurrencies x (left-side input) and y (right-side input). The added amount is equal to sqrt(x * y).
04 MosaicMetadataTransaction Target Account Assigns the Pool_Id metadata value to the automated pool shares mosaic.
05 MosaicMetadataTransaction Target Account Assigns the X_Id metadata value to the automated pool shares mosaic.
06 MosaicMetadataTransaction Target Account Assigns the Y_Id metadata value to the automated pool shares mosaic.
07 AccountMosaicRestrictionTransaction Target Account Restricts the target account such that it can only hold the concerned mosaics (i.e.: the automated pool shares mosaic, the network fee mosaic, the x mosaic and the y mosaic). :warning: This transaction protects the target account from SPAM transactions/mosaics.
08 TransferTransaction Target Account Transfers the initially created supply of automated pool shares to the liquidity provider.
09 TransferTransaction Provider Account Transfers the initially added liquidity of x and y to the target account.
10 TransferTransaction Provider Account Adds an execution proof message sent to the target account.

Hierarchy

Implements

Index

Constructors

constructor

Properties

arguments

arguments: string[] = ['provider','input_x','input_y',]
access

public

description

The list of required arguments to execute this automated pool command.

context

context: Context

The execution context.

Protected identifier

identifier: AssetIdentifier

The automated pool shares asset identifier.

mosaicInfo

mosaicInfo: MosaicInfo | undefined
access

public

description

Mosaic information for the network-wide created automated pool shares of an automated liquidity pool.

reserveInfo

reserveInfo: AccountInfo | undefined
access

public

description

Account information for the network-wide target public account. This variable holds balances of reserves under the mosaics field.

target

target: PublicAccount
access

public

description

The deterministic public account which owns an automated liquidity pool. This account is used to issue the automated pool shares mosaic.

Accessors

descriptor

  • get descriptor(): string
  • This method MUST return a unique automated pool command descriptor which includes:

    • the open standard descriptor (e.g.: "Swapable") ;
    • the open standard revision (e.g.: 1) ;
    • the kebab-case command name (e.g.: "create-pool") ;
    • and the automated pool shares asset identifier.

    Items are joined with the : operator and attached to a so-called execution proof transaction.

    access

    public

    Returns string

name

  • get name(): string

Protected transactions

  • get transactions(): Transaction[]
  • This method returns a list of unsigned transactions in a sequencial order of execution. The resulting transaction array is later wrapped inside a digital contract that is executed atomically such that either all transactions do succeed or all transactions are cancelled.

    :warning: This method creates at least one- or more than one - network-wide account restriction. Restrictions can potentially lock you out of your account, please use this only with caution and if you understand the risks.

    see

    {execute()}

    access

    public

    Returns Transaction[]

    Given the execution of a command, returns a list of unsigned transactions.

Methods

Protected assertExecutionAllowance

  • assertExecutionAllowance(actor: PublicAccount, argv: CommandOption[] | undefined): boolean

Protected assertHasMandatoryArguments

  • assertHasMandatoryArguments(argv: CommandOption[] | undefined, fields: string[]): boolean

canExecute

  • Verifies allowance of \a actor to execute a command with arguments \a argv. This method returns true if all required arguments are present.

    This method asserts the presence of mandatory arguments.

    access

    public

    throws

    {FailureMissingArgument} On missing mandatory argument(s).

    Parameters

    • actor: PublicAccount

      The actor is whom executes the command.

    • Optional argv: CommandOption[]

      The command options (arguments).

    Returns AllowanceResult

    Returns whether an actor is authorized to execute this command.

execute

  • execute(actor: PublicAccount, argv?: CommandOption[]): TransactionURI<Transaction>
  • Executes an automated pool command with \a actor given \a argv command options.

    access

    public

    throws

    {FailureMissingArgument} On missing mandatory argument(s).

    throws

    {FailureOperationForbidden} On denial of authorization.

    Parameters

    • actor: PublicAccount

      The actor is whom executes the command.

    • Optional argv: CommandOption[]

      The command options (arguments).

    Returns TransactionURI<Transaction>

    Returns one transaction URI with all transactions.

Protected prepare

  • prepare(): AggregateTransaction | Transaction

Protected reserveOf

  • Returns the available reserve of asset \a r. This method is used internally to determine the available balance in the automated pool and calculate the liquidity shares ratio.

    access

    protected

    Parameters

    • r: AssetIdentifier

      The asset identifier (i.e. for which to check reserves).

    Returns number

    number The total balance (reserve) available.

Generated using TypeDoc