Skip to content

User flows

Pool Creation

  1. The Pool Operator(PO) deploys the Potentia Pool using the Potentia Factory. The PO calls the createPool function on the PoolFactory.sol contract which further deploys the pool using CREATE method.
  2. In the same atomic transaction, the PotentiaPool.sol deploys 3 PToken.sol contracts i.e LpPtoken, LongPToken, and ShortPToken.
  3. Once the pool is deployed, the PO calls initializePool on the pool to initialise the pool with some initial liquidity.

Add Liquidity

  1. The Liquidity Provider(LP) calls the addLiquidity function on the Potentia Pool.
  2. Potentia Pool interacts with the underlying asset's contract (denoted as underlying) by calling safeTransferFrom, which transfers the specified amount of the underlying asset from the LP to the pool.
  3. Potentia Pool then mints LpPToken (representing the LP's share in the pool) by calling the mint function.

Remove Liquidity

  1. The LP calls the removeLiquidity function on the pool.
  2. Pool calls the burn function on the LpPToken's PToken.sol to burn the specified LP shares.
  3. Pool then transfers the underlying asset from the pool to the LP.

Open Position

Consider opening a Long Position.

  1. The trader calls the openPosition function on the Pool.
  2. Pool interacts with the underlying asset's smart contract by calling the safeTransferFrom, that transfers the approved amount from trader to the pool.
  3. Pool then mints the LongPToken by calling the mint function on the LongPToken contract.

Close Position

Consider closing a Short Position.

  1. The trader calls the closePosition function on the Pool.
  2. Pool interacts with the ShortPToken contract by calling the burn function, that burns the specified amount of ShortPTokens.
  3. Pool then transfers the underlying asset from the pool to the trader.