> For the complete documentation index, see [llms.txt](https://docs.pearl.exchange/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pearl.exchange/dex-operations/technical/smart-contracts.md).

# Smart Contracts

<mark style="background-color:red;">New to Pearl V2:</mark>

* **Pool Deployer:** Gives a very simple and easy way to deploy new pools with a single high-level function call.
* **Factory.sol:** Low level api to deploy new pools with configurable options.
* **NonfungibleTokenPositionDescriptor.sol:** Manages \*\*\*\*detail for URI (Unique Resource Identifier) which represents all the information attached to an NFT.
* **NonfungiblePositionManager.sol**
  1. Adding, removing, and modifying liquidity positions in any V2 pool.
  2. Representing those liquidity positions as NFTs
* **SwapRouter:** Serves as an on-chain interface point for swaps. Pass a token or series of tokens, to swap between, and it will handle the low-level swap calls and funds transfer to make it all happen.
* **Quoter.sol:** Get token quotes from the pool

### **Pool Deployment Action:**

<figure><img src="https://891818000-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDgktmZua4rPhhucHUEqq%2Fuploads%2F33cwRUYiUc7rbHOMhHxI%2Fimage.png?alt=media&amp;token=b2b9ebb1-a2e7-4484-8114-dbcc1c000b53" alt=""><figcaption></figcaption></figure>

### Position Management

<figure><img src="https://891818000-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDgktmZua4rPhhucHUEqq%2Fuploads%2FyrGgGtTFbJRAG6QIwYp3%2Fimage.png?alt=media&amp;token=ee4d955f-4e5e-47b5-9412-6811977e79ce" alt=""><figcaption></figcaption></figure>

### Overview

<figure><img src="https://891818000-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDgktmZua4rPhhucHUEqq%2Fuploads%2Ft5f1vU3GGU9Zo8xpJjoP%2Fimage.png?alt=media&amp;token=1bc0bced-adc4-4d22-b4cd-979c3e1e2c03" alt=""><figcaption></figcaption></figure>

### Contracts Global State

<figure><img src="https://891818000-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDgktmZua4rPhhucHUEqq%2Fuploads%2FKkx3jySrkGnq2ynFvMlQ%2Fimage.png?alt=media&amp;token=d6f01447-fbba-45cd-882c-02e6fd09328a" alt="" width="563"><figcaption></figcaption></figure>

* The reason for a signed integer `int` instead of an `uint` is that negative power represents **prices less than 1 but greater than 0.**
* 24 bits can cover the range between `1.0001 ^ (2²³ — 1)` and `1.0001 ^ -(2)²³`. Even Google cannot calculate such numbers, so allow me to offer smaller values to have a rough idea of the whole price range:

  `1.0001 ^ (2¹⁸) = 242,214,459,604.341`

  `1.0001 ^ -(2¹⁷) = 0.000002031888943`
