zap
Set of utility classes for managing and performing zaps.
- class pactsdk.zap.ZapParams(swap_deposited, primary_add_liq, secondary_add_liq)
Bases:
object
All amounts that should be used in swap and add liquidity transactions.
- swap_deposited: int
- primary_add_liq: int
- secondary_add_liq: int
- pactsdk.zap.get_constant_product_zap_params(liq_a, liq_b, zap_amount, fee_bps, pact_fee_bps)
- Return type
- pactsdk.zap.get_swap_amount_deposited_from_zapping(zap_amount, total_amount, fee_bps, pact_fee_bps)
- Return type
int
- pactsdk.zap.get_secondary_added_liquidity_from_zapping(swap_deposited, total_primary, total_secondary, fee_bps)
- Return type
int
- class pactsdk.zap.Zap(pool, asset, amount, slippage_pct)
Bases:
object
Zap class represents a zap trade on a particular pool, which allows to exchange single asset for PLP token.
Zap performs a swap to get second asset from the pool and then adds liquidity using both of those assets. Users may be left with some leftovers due to rounding and slippage settings.
Zaps are meant only for Constant Product pools; For Stableswaps, adding only one asset works out of the box.
Typically, users don’t have to manually instantiate this class. Use
pactsdk.pool.Pool.prepare_zap()
instead.- pool: pactsdk.pool.Pool
The pool the zap is going to be performed in.
- asset: pactsdk.asset.Asset
The asset that will be used in zap.
- amount: int
Amount to be used in zap.
- slippage_pct: float
The maximum amount of slippage allowed in performing the swap.
- swap: pactsdk.swap.Swap
The swap object that will be executed during the zap.
- liquidity_addition: pactsdk.add_liquidity.LiquidityAddition
Liquidity Addition object that will be executed during the zap.
- params: pactsdk.zap.ZapParams
All amounts used in swap and add liquidity transactions.
- prepare_tx_group(address)
Creates the transactions needed to perform zap and returns them as a transaction group ready to be signed and committed.
- Parameters
address (
str
) – The account that will be performing the zap.- Return type
- Returns
A transaction group that when executed will perform the zap.
- prepare_add_liq()