Pool#

class defichain.transactions.builder.modules.Pool(builder)#

The methods of this module create pool transactions

  1. poolswap: create a pool swap transaction

  2. compositeswap: create a composite swap transaction

  3. addpoolliquidity: create an add pool liquidity transaction

  4. removepoolliquidity: create a remove pool liquidity transaction

poolswap(addressFrom: str, tokenFrom: str | int, amountFrom: float | int, addressTo: str, tokenTo: str | int, maxPrice: float | int, inputs=[]) Transaction#

Creates a pool swap transaction with the specified data

>>> builder.pool.poolswap("df1qm8fgh8l9sa336jrdf40sghgthvsmagagc4tq9x", "BTC", 0.00001, "df1qm8fgh8l9sa336jrdf40sghgthvsmagagc4tq9x", "DFI", 9999999999) # create a poolswap transaction
Parameters:
  • addressFrom (str) – (required) the address where the tokens are located

  • tokenFrom (str | int) – (required) the token that should be exchanged

  • amountFrom (float | int) – (required) the amount that should be exchanged

  • addressTo (str) – (required) the address where the exchanged tokens are sent to

  • tokenTo (str | int) – (required) the token to change into

  • maxPrice (float | int) – (required) maximum acceptable price

  • inputs ([TxInput]) – (optional) additional inputs to spend

Returns:

Transaction

compositeswap(addressFrom: str, tokenFrom: str | int, amountFrom: float | int, addressTo: str, tokenTo: str | int, maxPrice: float | int, pools: [], inputs=[]) Transaction#

Creates a composite swap transaction with the specified data

>>> builder.pool.compositeswap("df1qm8fgh8l9sa336jrdf40sghgthvsmagagc4tq9x", "BTC", 0.00001, "df1qm8fgh8l9sa336jrdf40sghgthvsmagagc4tq9x", "TSLA", 9999999999, ["BTC-DFI", "DUSD-DFI", "TSLA-DUSD"]) # create a compositeswap transaction
Parameters:
  • addressFrom (str) – (required) the address where the tokens are located

  • tokenFrom (str | int) – (required) the token that should be exchanged

  • amountFrom (float | int) – (required) the amount that should be exchanged

  • addressTo (str) – (required) the address where the exchanged tokens are sent to

  • tokenTo (str | int) – (required) the token to change into

  • maxPrice (float | int) – (required) maximum acceptable price

  • pools ([str]) – (required) specification of all pools through which the swap should take place

  • inputs ([TxInput]) – (optional) additional inputs to spend

Returns:

Transaction

addpoolliquidity(addressAmountFrom: {}, shareAddress: str, inputs=[]) Transaction#

Creates an add pool liquidity transaction with the specified data

>>> builder.pool.addpoolliquidity({"df1qw8c57c3c4u7k2h4gv2d5x4jr4qgq6cugg33g6e": ["1@DFI", "0.0001@BTC"]}, "df1qw8c57c3c4u7k2h4gv2d5x4jr4qgq6cugg33g6e") # creates a add pool liquidity transaction
Parameters:
  • addressAmountFrom (Address Amounts) – (required) json with specified address and amount to send

  • shareAddress (str) – (required) the address where the pool tokens are sent to

  • inputs ([TxInput]) – (optional) additional inputs to spend

Returns:

Transaction

removepoolliquidity(addressFrom: str, amount: str, inputs=[]) Transaction#

Creates a remove pool liquidity transaction with the specified data

>>> builder.pool.removepoolliquidity("df1qw8c57c3c4u7k2h4gv2d5x4jr4qgq6cugg33g6e", "0.0001@BTC-DFI") # creates a remove pool liquidity transaction
Parameters:
  • addressFrom (str) – (required) the address to remove the pool tokens from

  • amount (Amounts) – (required) string with amount and token separated by an @

  • inputs ([TxInput]) – (optional) additional inputs to spend

Returns:

Transaction