nectarengine.poolobject module

class nectarengine.poolobject.Pool(token_pair: str | Dict[str, Any], api: Api | None = None)

Bases: dict

hive-engine liquidity pool dict

Parameters:

token_pair (str) – Token pair in the format ‘TOKEN1:TOKEN2’

calculate_price() Decimal

Calculate the current price based on the pool reserves

calculate_tokens_in(token_symbol: str, token_amount_out: float) str

Calculate the required input amount for an exactOutput swap

Parameters:
  • token_symbol (str) – Symbol of the output token

  • token_amount_out (float) – Amount of output tokens desired

Returns:

Required input amount as a string

Return type:

str

calculate_tokens_out(token_symbol: str, token_amount_in: float) str

Calculate the expected output amount for an exactInput swap

Parameters:
  • token_symbol (str) – Symbol of the input token

  • token_amount_in (float) – Amount of input tokens

Returns:

Expected output amount as a string

Return type:

str

get_all_liquidity_positions(account: str | None = None) List[Dict[str, Any]]

Returns all liquidity positions for this pool by looping through all pages

Parameters:

account (str) – Optional account name to filter positions

get_base_price() Decimal | None

Returns the ‘basePrice’ from the pool data as a Decimal. ‘basePrice’ typically represents the price of the base token in terms of the quote token. E.g., for ‘SWAP.HIVE:SIM’, it’s SIM per SWAP.HIVE. Returns None if ‘basePrice’ is not available or cannot be converted.

get_info() Dict[str, Any] | None

Returns information about the liquidity pool

get_liquidity_positions(account: str | None = None, limit: int = 100, offset: int = 0) List[Dict[str, Any]]

Returns liquidity positions for this pool

Parameters:

account (str) – Optional account name to filter positions

get_quote_price() Decimal | None

Returns the ‘quotePrice’ from the pool data as a Decimal. ‘quotePrice’ typically represents the price of the quote token in terms of the base token. E.g., for ‘SWAP.HIVE:SIM’, it’s SWAP.HIVE per SIM. Returns None if ‘quotePrice’ is not available or cannot be converted.

get_reward_pools() List[Dict[str, Any]]

Returns reward pools for this liquidity pool

get_tokens() List[str]

Returns the tokens in this pool as a list [base_token, quote_token]

Returns:

List of token symbols in the pool

Return type:

list

property positions: List[Dict[str, Any]]

Returns all liquidity positions for this pool (property wrapper for get_all_liquidity_positions with account=None).

refresh() None