> For the complete documentation index, see [llms.txt](https://docs.augmentlabs.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.augmentlabs.io/smart-contracts/uniswap-liquidity-auto-provider.md).

# Uniswap Liquidity Auto Provider

The smart contract that allows user to deposit USC or USDT to provide liquidity to the pool without having to perform manual steps in Uniswap.

## Overview

Contract: [LpAutoProvider.sol](https://github.com/augmentlabs-io/contracts/blob/main/contracts/LpAutoProvider.sol)

LpAutoProvider is an Upgradeable smartcontract that swaps 50% of user's USC or USDT for another, then take both swapped and remaining 50% of the original token to provide liquidity to the position owned by the contract itself.

Augmentlabs will pre-provide a certain amount of liquidity into the USC/USDT pool using UniswapV3 protocol. We need to allow our users to use either USDT or USC to back the liquidity of this pool by performing the swap-and-add-liquidity flow above.

The liquidity pool created on Uniswap: <https://app.uniswap.org/#/pool/450538>

There are some requirements that this smartcontract must satisfy:

* Owner can collect fees but **can't withdraw any liquidity to owner wallet without governance decision of** [**AGC**](/smart-contracts/agc-token.md) **token holders**. This must be enforced that only the `timelock` can call the `withdrawLiquidity` function.
* Should have slippage protection to prevent sandwich attack.

## Dependencies

* **Pausable:** Allows for pausing/unpausing of the smart contract.
* **AccessControl**: Allows for multiple permission roles to exist in the same contract.

## How it works

The Liquidity Auto Provider will swap 50% of the provided token (either USC or USDT) using the Uniswap SwapRouter. After that, both the swapped amount and the remaining token will be used to provide liquidity to the position that Augmentlabs has minted.

## **Roles**

* **Admin (DEFAULT\_ADMIN\_ROLE):** Admin role is able to pause/unpause the smart contract and grant roles to other users.\
  \
  **Admin** role will be held by a gnosis safe address to ensure security.
* **Pauser (PAUSER\_ROLE):** **Pauser** role is able to pause/unpause the contract in case of emergencies. Initially no specific address is the holder of the **Pauser** role other than the **Admin.**
* **Upgrader (UPGRADER\_ROLE):** **Upgrader** role is able to upgrade the smart contract for future phases. Initially no specific address is the holder of the **Upgrader** role other than the **Admin.**
* **Operator (OPERATOR\_ROLE): Operator** role is able to perform the slippage tolerance change or change the contract's position ID should the change is required.
* **Withdrawer (WITHDRAWER\_ROLE): Withdrawer** role is able to withdraw a certain amount of liquidity from the pool to the owner address.

## **Participants**

* Gnosis-safe address as **Admin, Pauser, Upgrader, Operator**: This ensures important roles are secure and doesn't have single-point-of-failure. Also for future extension, Admin can grant roles to other addresses if needed.&#x20;
* Timelock as **Withdrawer**: This ensures that normally all liquidity are locked so the ecosystem is healthy. The withdraw liquidity is only available if it's approved through governance of AGC token holders.
* User: Performs the swap-and-add-liquidity flow using USC/USDT on Uniswap.
