# Shadow Liquidity

{% hint style="info" %}
**Shadow Liquidity** is a virtual AMM that simulates token reserves without requiring real capital. It enables permissionless market creation by bootstrapping liquidity through user participation.
{% endhint %}

## The Core Concept

Traditional AMMs require **locked liquidity**—real tokens sitting in a contract. Shadow Liquidity uses **virtual reserves** that exist only as mathematical constructs:

{% @mermaid/diagram content="flowchart LR
subgraph Traditional\["Traditional AMM"]
T1\["Real Pool"]
T2\["1000 ETH + $2M USDC"]
T3\["Requires: $4M+ capital"]
T4\["High barrier"]
end

```
subgraph Shadow["Shadow Liquidity"]
    S1["Virtual Pool"]
    S2["1k vYES + 1k vNO"]
    S3["Requires: $0 capital"]
    S4["Anyone can create"]
end

style Traditional fill:#fef2f2,stroke:#ef4444,stroke-width:2px,color:#000000
style Shadow fill:#f0fdf4,stroke:#22c55e,stroke-width:2px,color:#000000
style T1 fill:transparent,color:#000000,stroke:none
style T2 fill:transparent,color:#000000,stroke:none
style T3 fill:transparent,color:#000000,stroke:none
style T4 fill:transparent,color:#000000,stroke:none
style S1 fill:transparent,color:#000000,stroke:none
style S2 fill:transparent,color:#000000,stroke:none
style S3 fill:transparent,color:#000000,stroke:none
style S4 fill:transparent,color:#000000,stroke:none" %}
```

***

## How It Works

### Initial State

Every market starts with identical virtual reserves:

| Component      | Initial Value | Purpose                   |
| -------------- | ------------- | ------------------------- |
| `virtualYES`   | 1,000         | Virtual YES token reserve |
| `virtualNO`    | 1,000         | Virtual NO token reserve  |
| `k` (constant) | 1,000,000     | CPMM invariant            |
| `vaultBalance` | 0             | Real USDC from users      |
| `yesPrice`     | 50%           | Starting probability      |
| `noPrice`      | 50%           | Starting probability      |

***

### The CPMM Formula

Prices are determined by the **Constant Product Market Maker** equation:

$$
virtualYES \times virtualNO = k
$$

When someone buys YES:

1. **virtualYES decreases** (user "receives" virtual tokens)
2. **virtualNO increases** (to maintain k)
3. **YES price rises** (less supply = higher price)

{% tabs %}
{% tab title="Pricing Formula" %}

```
Price(YES) = virtualNO / (virtualYES + virtualNO)
Price(NO)  = virtualYES / (virtualYES + virtualNO)

// Example after buying YES:
virtualYES = 909
virtualNO  = 1,100
Price(YES) = 1,100 / 2,009 = 54.8%
Price(NO)  = 909 / 2,009 = 45.2%
```

{% endtab %}

{% tab title="Share Calculation" %}

```javascript
function buyShadowShares(side, usdcAmount) {
    // No fees during bonding phase!
    const netAmount = usdcAmount;
    
    if (side === 'yes') {
        // Buy YES = sell vYES to user
        const newVirtualNo = current.virtualNo + netAmount;
        const newVirtualYes = k / newVirtualNo;
        const sharesReceived = current.virtualYes - newVirtualYes;
        return sharesReceived;
    }
}
```

{% endtab %}

{% tab title="Slippage Example" %}
A $100 trade at different price points:

| Current Price | Shares Received | Avg Price | Slippage |
| ------------- | --------------- | --------- | -------- |
| 50%           | \~196 shares    | 51.0%     | 1.0%     |
| 60%           | \~163 shares    | 61.3%     | 1.3%     |
| 80%           | \~122 shares    | 82.0%     | 2.0%     |
| 90%           | \~109 shares    | 91.7%     | 1.7%     |

Slippage increases as you move the market more.
{% endtab %}
{% endtabs %}

***

## The Vault & Solvency

### What Happens to Your USDC?

{% @mermaid/diagram content="graph LR
A\[User: $100 USDC] -->|Buy YES| B\[Protocol]
B -->|$100| D\[Vault]
D -->|At Graduation| E\[2% Fee<br>to Protocol/Stakers/Creator]
D -->|At Resolution| F\[Pay Winners<br>Pro-rata split]" %}

All user deposits flow into a single **vault**. This vault pays out winners at resolution.

### Solvency Equation

The protocol tracks **solvency**—the ratio of vault balance to maximum liability:

$$
\text{Solvency} = \frac{\text{VaultBalance}}{\max(\text{TotalShadowYES}, \text{TotalShadowNO})} \times 100%
$$

{% hint style="success" %}
**Graduation Threshold:** Markets graduate when:

1. Vault balance reaches **bonding target** (default $1,000, admin-configurable), AND
2. Solvency reaches **100%** (vault can cover max payout), AND
3. Both sides have **≥20%** of total shares (ensures two-sided market)
   {% endhint %}

***

## Example Walkthrough

Let's trace a complete buy transaction:

{% stepper %}
{% step %}

#### Start State

```
virtualYES: 1,000
virtualNO: 1,000
vaultBalance: 0 USDC
yesPrice: 50%
```

{% endstep %}

{% step %}

#### User Buys $100 YES

```
Fee: $0 (no fees during bonding!)
Net to vault: $100
```

{% endstep %}

{% step %}

#### Update Virtual Reserves

The Protocol calculates the new reserves and shares issued based on the Constant Product Formula ($x \times y = k$):

```
newVirtualNo = 1,000 + 100 = 1,100
newVirtualYes = 1M / 1,100 = 909.09

sharesReceived = 1,000 - 909.09 = 90.91 shares
avgPrice = $100 / 90.91 = $1.10
```

The price has effectively moved from 50% to 54.8%, reflecting the price impact of this trade.
{% endstep %}

{% step %}

#### Larger Trade Example ($1000 YES)

To better illustrate price impact and slippage, consider a larger purchase:

```
Fee: $0 (no fees during bonding)
Net Investment: $1000

newVirtualNo = 1,000 + 1,000 = 2,000
newVirtualYes = 1M / 2,000 = 500

Shares Issued = 1,000 - 500 = 500 shares
Avg Price = $1000 / 500 = $2.00 per share
New YES Price = 2,000 / 2,500 = 80%
```

{% endstep %}

{% step %}

#### Solvency Check

```
vaultBalance = $980
totalShadowYes = 971
totalShadowNo = 0
maxLiability = max(971, 0) = 971

Solvency = $980 / 971 = 100.9% ✓
```

Already solvent! Small trades graduate quickly.
{% endstep %}
{% endstepper %}

***

## Why It Works

<details>

<summary><strong>🔐 Mathematical Solvency Guarantee</strong></summary>

The CPMM formula creates a natural solvency buffer:

1. Users pay for shares
2. Slippage protects against one-sided markets
3. 20% minimum on each side ensures balance
4. Winners receive $1/share + OG bonus (Winner Profit Guarantee)

</details>

<details>

<summary><strong>⚡ Zero Capital Barrier</strong></summary>

No one needs to provide initial liquidity:

* Protocol initializes virtual reserves
* First trader sets the initial price movement
* Market naturally bootstraps through participation
* Creator pays nothing to launch

</details>

<details>

<summary><strong>📈 Fair Price Discovery</strong></summary>

CPMM ensures fair pricing:

* Large trades have proportionally more slippage
* Price converges to consensus probability
* No single actor can easily manipulate
* Arbitrage opportunities self-correct

</details>

***

## Next Steps

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>📈 Bonding Curve Deep Dive</strong></td><td>Advanced pricing mechanics and slippage analysis</td><td><a href="/pages/s5Du9i1bSFSTILey7736">/pages/s5Du9i1bSFSTILey7736</a></td></tr><tr><td><strong>🎓 Graduation Process</strong></td><td>How markets transition to full trading</td><td><a href="/pages/f8VBme4C9IiRQa6ge6Z1">/pages/f8VBme4C9IiRQa6ge6Z1</a></td></tr></tbody></table>


---

# 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.basecase.gg/core-concepts/shadow-liquidity.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.
