VYLO
Launch App
Smart contracts

Pool Factory (CPMM)

Native VYLO constant-product pools with the protocol fee built in.

Overview#

Anyone can create a classic x * y = k pool for two mints and a fee tier (0.01% to 10%). The creator seeds it and receives LP tokens. 1,000 LP units are locked forever so a first depositor cannot manipulate the share price.

On every swap the LP fee stays in the pool for liquidity providers. 5% of that fee (not of the swap) accrues to the protocol, per token side, and is excluded from the reserves.

collect is permissionless: anyone can send the accrued protocol fees to the Fee Router destinations, split 40 / 40 / 20 of VYLO's 5% (buyback, stakers, team). The destinations are read from the Fee Router config onchain, so they cannot be spoofed.

Instructions#

InstructionWhoWhat it does
create_poolAnyoneCreates the pool PDA, its LP mint and vaults, deposits both tokens and mints LP to the creator.
depositAnyoneAdds liquidity pro rata for an exact LP amount, with maximum token amounts as slippage protection.
withdrawLP holderBurns LP and returns both tokens pro rata, with minimum amounts as slippage protection.
swapAnyoneSwaps an exact input for at least min_out. Fee rounds up, output rounds down.
collectAnyonePays the accrued 5% protocol share to the buyback, staker and team accounts.

Accounts#

AccountSeedsNotes
Pool["pool", mint_a, mint_b, fee_bps (u16 LE)]296 bytes. mint_a sorts before mint_b, so each pair and fee tier has exactly one pool.
LP mint["lp", pool]SPL Token, 9 decimals, mint authority is the pool.
VaultsAssociated token accounts of the poolHold the reserves plus the uncollected protocol fees.

Guarantees#

  • The invariant k never decreases on a swap; checked onchain after every trade.
  • Rounding always favours the pool.
  • Token-2022 mints with transfer fees, transfer hooks, permanent delegate, non-transferable, default frozen state or confidential transfers are rejected.
  • Collection stops while the Fee Router is paused.

Events#

Events are emitted as program data logs and can be indexed from transaction logs.

  • Swap: pool, user, direction, amount in, out, fee, protocol share
  • Liquidity: pool, user, amounts, LP, kind
  • Collect: pool, protocol amounts per side

Source and client#

Source: programs/vylo-cpmm. TypeScript builders and decoders: @vylo/solana/programs. See the SDK.