Poolpair#

class defichain.node.Poolpair(node)#
addpoolliquidity(_from: str, shareAddress: str, inputs: [{}] = None) str#

Creates (and submits to local node and network) a add pool liquidity transaction.

The last optional argument (may be empty array) is an array of specific UTXOs to spend.

Requires wallet passphrase to be set with walletpassphrase call.

Parameters:
  • _from (str) –

    (required) The defi address(es) is the key(s), the value(s) is amount in amount@token format. You should provide exectly two types of tokens for pool’s ‘token A’ and ‘token B’ in any combinations.If multiple tokens from one address are to be transferred, specify an array [”amount1@t1”, “amount2@t2”]

    If “from” obj contain only one amount entry with address-key: “*” (star), it’s means auto-selection accounts from wallet.

  • shareAddress (str) – (required) The defi address for crediting tokens

  • inputs (json array) – (optional) Inputs

Returns:

“hash” (string) – The hex-encoded hash of broadcasted transaction

Example:
>>> node.poolpair.addpoolliquidity({"df1qpsg2v3fajhwfrc3dchsqpcwqfegdxpncwpcda2": ["1.0@BTC", "1.0@DFI"]}, "df1qpsg2v3fajhwfrc3dchsqpcwqfegdxpncwpcda2")
compositeswap(_from: str, tokenFrom: str, amountFrom: float, to: str, tokenTo: str, maxPrice: float = None, inputs: [{}] = None) str#

Creates (and submits to local node and network) a composite swap (swap between multiple poolpairs) transaction with given metadata.

Parameters:
  • _from (str) – (required) Address of the owner of tokenA

  • tokenFrom (str) – (required) One of the keys may be specified (id/symbol)

  • amountFrom (float) – (required) tokenFrom coins amount

  • to (str) – (required) Address of the owner of tokenB

  • tokenTo (str) – (required) One of the keys may be specified (id/symbol)

  • maxPrice (float) – (optional) Maximum acceptable price

  • inputs (json array) – (optional) Inputs

Returns:

“hash” (string) – The hex-encoded hash of broadcasted transaction

Example:
>>> node.poolpair.compositeswap("df1qpsg2v3fajhwfrc3dchsqpcwqfegdxpncwpcda2", "BTC", 1, "df1qpsg2v3fajhwfrc3dchsqpcwqfegdxpncwpcda2", "DFI")
createpoolpair(tokenA: str, tokenB: str, commission: float, status: bool, ownerAddress: str, customRewards: str = None, pairSymbol: str = None, inputs: [{}] = None) str#

Creates (and submits to local node and network) a poolpair transaction with given metadata.

Parameters:
  • tokenA (str) – (required) One of the keys may be specified (id/symbol)

  • tokenB (str) – (required) One of the keys may be specified (id/symbol)

  • commission (float) – (required) Pool commission, up to 10^-8

  • status (bool) – (required) Pool Status: True is Active, False is Restricted

  • ownerAddress (str) – (required) Address of the pool owner

  • customRewards (str) – (optional) Token reward to be paid on each block, multiple can be specified

  • pairSymbol (str) – (optional) Pair symbol (unique), no longer than 8

  • inputs (json array) – (optional) Inputs

Returns:

“hash” (string) – The hex-encoded hash of broadcasted transaction

Example:
>>> node.poolpair.createpoolpair("BTC", "USDC", 0.5, True, "df1qpsg2v3fajhwfrc3dchsqpcwqfegdxpncwpcda2")
getpoolpair(key: str, verbose: bool = True) {}#

Returns information about pool.

Parameters:
  • key (str) – (required) One of the keys may be specified (id/symbol/creationTx)

  • verbose (bool) – (optional) Flag for verbose list (default = true), otherwise limited objects are listed

Returns:

{id:{…}} (json) – Json object with pool information

Example:
>>> node.poolpair.getpoolpair(4)
listpoolpairs(start: int | None = None, including_start: bool | None = None, limit: int = 100, verbose: bool = True) {}#

Returns information about pools

Parameters:
  • start (int) – (optional) Optional first key to iterate from, in lexicographical order. Typically it’s set to last ID from previous request

  • including_start (bool) – (optional) If true, then iterate including starting position

  • limit (int) – (optional) Maximum number of pools to return, 100 by default

  • verbose (bool) – (optional) Flag for verbose list (default = true), otherwise only ids, symbols and names are listed

Returns:

{id:{…}} (json) – Json object with pool information

Example:
>>> node.poolpair.listpoolpairs()
listpoolshares(start: int | None = None, including_start: bool | None = None, limit: int = 100, verbose: bool = True, is_mine_only: bool = False) {}#

Returns information about pool shares

Parameters:
  • start (int) – (optional) Optional first key to iterate from, in lexicographical order

  • including_start (bool) – (optional) If true, then iterate including starting position

  • limit (int) – (optional) Maximum number of pools to return

  • verbose (bool) – (optional) Flag for verbose list (default = true), otherwise only % are shown

  • is_mine_only (bool) – (optional) Flag for verbose list (default = true), otherwise only % are shown

Returns:

{id:{…}} (json) – Json object with pool information

Example:
>>> node.poolpair.listpoolshares()
poolswap(_from: str, tokenFrom: str, amountFrom: float, to: str, tokenTo: str, maxPrice: float = None, inputs: [{}] = None) str#

Creates (and submits to local node and network) a poolswap transaction with given metadata

Parameters:
  • _from (str) – (required) Address of the owner of tokenA

  • tokenFrom (str) – (required) One of the keys may be specified (id/symbol)

  • amountFrom (float) – (required) tokenFrom coins amount

  • to (str) – (required) Address of the owner of tokenB

  • tokenTo (str) – (required) One of the keys may be specified (id/symbol)

  • maxPrice (float) – (optional) Maximum acceptable price

  • inputs (json array) – (optional) Inputs

Returns:

“hash” (string) – The hex-encoded hash of broadcasted transaction

Example:
>>> node.poolpair.poolswap("df1qpsg2v3fajhwfrc3dchsqpcwqfegdxpncwpcda2", "BTC", 1, "df1qpsg2v3fajhwfrc3dchsqpcwqfegdxpncwpcda2", "DFI")
removepoolliquidity(_from: str, amount: str, inputs: [{}] = None) str#

Creates (and submits to local node and network) a remove pool liquidity transaction

Parameters:
  • _from (str) – (required) The defi address which has tokens

  • amount (str) – (required) Amounts

  • inputs (json array) – (optional) Inputs

Returns:

“hash” (string) – The hex-encoded hash of broadcasted transaction

Example:
>>> node.poolpair.removepoolliquidity("df1qpsg2v3fajhwfrc3dchsqpcwqfegdxpncwpcda2", "1.0@BTC-DFI")
testpoolswap(_from: str, tokenFrom: str, amountFrom: float, to: str, tokenTo: str, maxPrice: float | None = None, path: str = 'direct', verbose: bool = False) str#

Tests a poolswap transaction with given metadata and returns poolswap result

Parameters:
  • _from (str) – (required) Address of the owner of tokenA

  • tokenFrom (str) – (required) One of the keys may be specified (id/symbol)

  • amountFrom (float) – (required) tokenFrom coins amount

  • to (str) – (required) Address of the owner of tokenB

  • tokenTo (str) – (required) One of the keys may be specified (id/symbol)

  • maxPrice (float) – (optional) Maximum acceptable price

  • path (str) –

    (optional) One of auto/direct

    auto - automatically use composite swap or direct swap as needed
    direct - uses direct path only or fails
    composite - uses composite path only or fails
    

  • verbose (bool) – (optional) Returns estimated composite path when true

Returns:

amount@tokenId” (string) – The string with amount result of poolswap in format AMOUNT@TOKENID

Example:
>>> node.poolpair.testpoolswap("df1qpsg2v3fajhwfrc3dchsqpcwqfegdxpncwpcda2", "BTC", 1, "df1qpsg2v3fajhwfrc3dchsqpcwqfegdxpncwpcda2", "DFI")
updatepoolpair(pool: str, status: bool = None, commission: float = None, ownerAddress: str = None, customRewards: str = None, inputs: [{}] = None) str#

Creates (and submits to local node and network) a pool status update transaction

Parameters:
  • pool (str) – (required) The pool’s symbol, id or creation tx

  • status (bool) – (optional) Pool Status new property

  • commission (float) – (optional) Pool commission, up to 10^-8

  • ownerAddress (str) – (optional) Address of the pool owner

  • customRewards (str) – (optional) Token reward to be paid on each block, multiple can be specified

  • inputs (json array) – (optional) Inputs

Returns:

“hash” (string) – The hex-encoded hash of broadcasted transaction

Example:
>>> node.poolpair.updatepoolpair("BTC-DFI", True, "0.5")