# Aquarius AMM: Token Address Migration Limitations and Mitigation Strategy

#### **1. Introduction**

In **decentralized finance (DeFi)** platforms, token contracts occasionally undergo **migrations to new addresses** due to **upgrades, bug fixes, or protocol changes**. While these migrations are essential for improving security and functionality, they present challenges for **Automated Market Makers (AMMs)** like **Aquarius**.

Aquarius liquidity pools are **initialized with fixed token addresses**, meaning they **cannot automatically adapt** when a token’s contract migrates. This document outlines the **limitations of Aquarius AMM regarding token address migrations** and provides a **mitigation strategy** for handling such cases.

***

#### **2. System Limitations: Token Address Migration**

**2.1 Fixed Token Addresses in Liquidity Pools**

When an **Aquarius liquidity pool** is created, the token addresses involved are **hardcoded into the pool’s structure**. The pool's **unique address** is derived from a **hash of these token addresses**, ensuring efficient tracking and liquidity management. However, this also means:

* **Token addresses cannot be changed** once a pool is created.
* If a token undergoes **a migration to a new contract address**, the pool **cannot automatically recognize or switch** to the new token.

**2.2 Risks to Liquidity Providers (LPs)**

Token migrations pose **several risks** to liquidity providers:

* **Locked Liquidity:** Liquidity associated with a migrated token may become **inaccessible**, as the token is no longer recognized within the ecosystem.
* **Depreciation of Value:** While withdrawals may still be possible, the **old token may lose value or utility**.
* **Potential Financial Loss:** LPs who do not **react promptly** to a migration may suffer losses if their deposited tokens become obsolete.

**2.3 Impact on Users**

* **Liquidity Disruptions:** LPs must manually **withdraw and redeploy liquidity** into a new pool with the updated token address.
* **Trading Interruptions:** Pools with migrated tokens may experience **reduced liquidity** and **trading disruptions** as funds are withdrawn.

***

#### **3. Mitigation Strategy: Handling Token Migrations**

Since **Aquarius AMM does not support automatic token address migration**, the following **mitigation strategies** can help LPs **minimize risks** and **ensure smooth transitions** when token migrations occur.

**3.1 Communication and Alerts for Token Migrations**

To mitigate risks, **Aquarius will provide timely notifications** when a token migration is detected or announced. This includes:

* **Alerts and Notifications:** LPs will receive **UI prompts, email updates, or social media announcements** regarding pending or completed migrations.
* **Warnings on Pool Creation:** If a token is known to have **frequent upgrades or planned migrations**, users may receive a **warning** before creating or adding liquidity to a pool.

**3.2 Manual Withdrawal and Redeployment of Liquidity**

If a token migration occurs:

* **Pool Pause Option:** The pool admin can **pause the affected pool**, preventing further deposits or trades involving the obsolete token.
  * *Example:* The admin issues a command to pause the pool once a token migration is detected.
* **Liquidity Withdrawal:** LPs must **manually withdraw liquidity** from the old pool. Withdrawals will remain functional even if the token is no longer in circulation.
  * *Example:* An LP who deposited **Token A (old)** and **Token B** can still withdraw them even after **Token A migrates**.
* **New Pool Creation:** A **new liquidity pool** can be created using the **updated token address**. LPs can then **redeposit their liquidity** into the new pool.
  * *Example:* Once **Token A migrates to Token A (new)**, a new **Token A (new) + Token B** pool can be established.

**3.3 Migration Assistance via Smart Contracts**

To simplify the migration process, **Aquarius may introduce a migration contract** that:

* **Automatically withdraws liquidity** from the old pool.
* **Deposits the equivalent liquidity** into the new pool with updated token addresses.
* **Issues new LP tokens** for the redeposited liquidity.

**Example Pseudo-code for Migration Contract:**

```rust
rustCopyEditfn migrate_liquidity(user: Address, old_pool: Address, new_pool: Address) -> Result<(), Error> {
    // Step 1: Check user’s LP balance in old pool
    let lp_balance = old_pool.share_id().balance(user);
    
    // Step 2: Withdraw user's liquidity from old pool
    let withdrawn_tokens = old_pool.withdraw(user, lp_balance)?;
    
    // Step 3: Deposit liquidity into new pool with updated token addresses
    new_pool.deposit(user, withdrawn_tokens, lp_balance)?;
    
    Ok(())
}
```

This contract **automates the migration process**, reducing **manual effort** and ensuring a **seamless transition** for LPs.

**3.4 Coordination with Token Issuers**

To further improve the migration process, the **Aquarius team** will collaborate with token issuers to:

* **Plan migration events in advance.**
* **Notify LPs early** and provide step-by-step migration instructions.
* **Coordinate on migration strategies** to minimize disruptions and losses.

***

#### **4. Recommendations for Liquidity Providers (LPs)**

**4.1 Stay Informed About Token Migrations**

To protect against losses, LPs should:

* Monitor **official communication channels** for updates from the token issuer and Aquarius protocol team.
* Be aware of tokens that are **likely to migrate** due to **frequent upgrades** or **protocol changes**.

**4.2 Act Quickly During Token Migrations**

* **Withdraw Liquidity Promptly:** Once a migration is announced, LPs should **immediately withdraw** liquidity from the affected pool.
* **Redeploy Liquidity:** LPs can **redeposit** their funds into **new pools** with the updated token address to continue earning rewards.

**4.3 Assess Migration Risks Before Providing Liquidity**

When adding liquidity to a pool, LPs should:

* **Evaluate the likelihood of token migrations.**
* **Understand potential risks and necessary actions** in case of migration.
* **Plan ahead** for possible liquidity redeployment.

***

#### **Conclusion**

Token migrations are **an inevitable part of DeFi**, but their impact on **AMMs like Aquarius** can be minimized through **proactive communication, manual migration strategies, and smart contract automation**. By staying informed and acting promptly, **LPs can safeguard their assets and maintain liquidity participation** with minimal disruption. 🚀


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.aqua.network/amm-and-pools/system-limitations/aquarius-amm-token-address-migration-limitations-and-mitigation-strategy.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
