factories
- pactsdk.factories.base_factory.get_contract_deploy_cost(extra_pages, num_byte_slices, num_uint, is_algo)
- class pactsdk.factories.base_factory.PoolParams(primary_asset_id, secondary_asset_id, fee_bps, version)
Bases:
object
- primary_asset_id: int
- secondary_asset_id: int
- fee_bps: int
- version: int
- abi = <algosdk.abi.array_static_type.ArrayStaticType object>
- as_tuple()
- to_box_name()
- Return type
bytes
- classmethod from_box_name(name)
- class pactsdk.factories.base_factory.PoolBuildParams(primary_asset_id, secondary_asset_id, fee_bps)
Bases:
object
- primary_asset_id: int
- secondary_asset_id: int
- fee_bps: int
- class pactsdk.factories.base_factory.FactoryState(pool_version, allowed_fee_bps)
Bases:
object
- pool_version: int
- allowed_fee_bps: list[int]
- pactsdk.factories.base_factory.parse_global_factory_state(raw_state)
- Parameters
raw_state (
list
) – The contract’s global state retrieved from algosdk.- Return type
- pactsdk.factories.base_factory.list_pools(algod, factory_id)
- Return type
list
[PoolParams
]
- pactsdk.factories.base_factory.fetch_pool_id(algod, factory_id, pool_params)
- Return type
int
- class pactsdk.factories.base_factory.PoolFactory(algod, app_id, state)
Bases:
object
Abstract class for pool factories.
The pool factory allows decentralization of pools creation and discoverability. Each pool type has a separate factory contract that deploys the pool. Every pool created by the pool factory can be trusted as a valid Pact pool.
The factory ensures pools uniqueness meaning you can’t create two pools with the same parameters using a single factory contract.
- algod: algosdk.v2client.algod.AlgodClient
- app_id: int
- list_pools()
Lists all pools created by this factory. It works by reading the boxes created by this factory. The boxes serve as a hash map of unlimited size. The box name stores pool parameters and the box content stores pool id.
This method returns only pool parameters without the application id. You have to call fetch_pool to fetch the actual pool e.g.
pool_params = factory.list_pools() pool = factory.fetch_pool(pool_params[0])
- Return type
list
[PoolParams
]- Returns
List of pool parameters.
- fetch_pool_id(pool_params)
- Return type
int
- fetch_pool(pool_params)
Fetches the pool for the given params.
- Parameters
pool_params (
PoolParams
) – Parameters of the pool with are looking for.- Return type
Optional
[Pool
]- Returns
A pool if pool with given parameters exists, None otherwise.
- build(sender, pool_build_params, signer)
Deploys a new pool to the network.
- Parameters
sender (
str
) – The address that is going to send the transactions.pool_build_params (
PoolBuildParams
) – Parameters of the pool that is going to be created.signer (
Callable
[[TransactionGroup
],list
[SignedTransaction
]]) – A callback that allows signing the transaction.
- Return type
- Returns
The created pool instance.
- build_or_get(sender, pool_build_params, signer)
Deploys a new pool to the network if the pool with the specified params does not exist yet. Otherwise, it returns the existing pool.
- Parameters
sender (
str
) – The address that is going to send the transactions.pool_build_params (
PoolBuildParams
) – Parameters of the pool that is going to be created.signer (
Callable
[[TransactionGroup
],list
[SignedTransaction
]]) – A callback that allows signing the transaction.
- Return type
tuple
[Pool
,bool
]- Returns
The two items tuple. The first item is the created or existing pool. The second item is True if a new pool is created or False if an existing pool is returned.
- build_tx_group(sender, sp, pool_build_params)
- pactsdk.factories.constant_product.build_constant_product_tx_group(factory_id, sender, sp, pool_params)
- Return type
- class pactsdk.factories.constant_product.ConstantProductFactory(algod, app_id, state)
Bases:
pactsdk.factories.base_factory.PoolFactory
- build_tx_group(sender, sp, pool_build_params)
- pactsdk.factories.get_pool_factory.get_pool_factory(algod, pool_type, config)
- Return type