UNPKG

swapable

Version:
109 lines (108 loc) 5.55 kB
/** * This file is part of Swapable shared under AGPL-3.0 * Copyright (C) 2021 Using Blockchain Ltd, Reg No.: 12658136, United Kingdom * * @package Swapable * @author Grégory Saive for Using Blockchain Ltd <greg@ubc.digital> * @license AGPL-3.0 */ import { PublicAccount, Transaction } from 'symbol-sdk'; import { AllowanceResult, CommandOption } from '../../index'; import { Executable } from './Executable'; /** * @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. | * */ export declare class CreatePool extends Executable { /** * @access public * @description The list of **required** arguments to execute * *this* automated pool command. */ arguments: string[]; /** * 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 * @param {PublicAccount} actor The actor is whom executes the command. * @param {Array<CommandOption>} argv The command options (arguments). * @return {AllowanceResult} Returns whether an actor is authorized to execute this command. * @throws {FailureMissingArgument} On missing mandatory argument(s). **/ canExecute(actor: PublicAccount, argv?: CommandOption[]): AllowanceResult; /** * This method returns the automated pool command name, * e.g. "CreatePool" or "AddLiquidity", etc. * * @access public * @return {string} **/ get name(): 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 * @return {string} **/ get descriptor(): string; /** * 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 * @return {Transaction[]} Given the execution of a command, returns a list of unsigned transactions. **/ protected get transactions(): Transaction[]; }