> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vita.finance/llms.txt
> Use this file to discover all available pages before exploring further.

# Key Concepts

> Understanding the core concepts behind Vita Finance

export const TradingFlow = ({type = 'both'}) => {
  const [activeStep, setActiveStep] = useState(null);
  const [showComparison, setShowComparison] = useState(true);
  const handleStepClick = (flowType, stepNumber) => {
    const key = `${flowType}-${stepNumber}`;
    setActiveStep(activeStep === key ? null : key);
  };
  const AMMFlow = () => <div className="p-6 border-2 border-[#fb8f5a] rounded-sm bg-gray-50 dark:bg-gray-900">
      <h5 className="font-bold mb-4 text-[#fb8f5a] text-lg">AMM Swap Flow</h5>
      <div className="space-y-3" role="list">
        <div className={`flex items-start cursor-pointer transition-all ${activeStep === 'amm-1' ? 'bg-[#fb8f5a]/10 p-2 rounded-sm' : ''}`} onClick={() => handleStepClick('amm', 1)} onKeyPress={e => (e.key === 'Enter' || e.key === ' ') && handleStepClick('amm', 1)} role="listitem" tabIndex={0} aria-expanded={activeStep === 'amm-1'}>
          <span className="w-8 h-8 rounded-full bg-[#fb8f5a] text-white flex items-center justify-center font-bold flex-shrink-0" aria-label="Step 1">1</span>
          <div className="ml-4">
            <p className="font-medium text-gray-900 dark:text-white">User submits swap request</p>
            <p className="text-sm text-gray-600 dark:text-gray-400">Specify input token and amount</p>
            {activeStep === 'amm-1' && <div className="mt-2 p-2 bg-gray-100 dark:bg-gray-800 rounded-sm text-xs text-gray-600 dark:text-gray-400">
                Example: Swap 100 NEAR for USDC at current market rate
              </div>}
          </div>
        </div>
        <div className={`flex items-start cursor-pointer transition-all ${activeStep === 'amm-2' ? 'bg-[#fb8f5a]/10 p-2 rounded-sm' : ''}`} onClick={() => handleStepClick('amm', 2)} onKeyPress={e => (e.key === 'Enter' || e.key === ' ') && handleStepClick('amm', 2)} role="listitem" tabIndex={0} aria-expanded={activeStep === 'amm-2'}>
          <span className="w-8 h-8 rounded-full bg-[#fb8f5a] text-white flex items-center justify-center font-bold flex-shrink-0" aria-label="Step 2">2</span>
          <div className="ml-4">
            <p className="font-medium text-gray-900 dark:text-white">Calculate output using x*y=k formula</p>
            <p className="text-sm text-gray-600 dark:text-gray-400">Price determined by pool reserves</p>
            {activeStep === 'amm-2' && <div className="mt-2 p-2 bg-gray-100 dark:bg-gray-800 rounded-sm text-xs text-gray-600 dark:text-gray-400">
                Formula: outputAmount = (inputAmount * reserveOut) / (reserveIn + inputAmount)
              </div>}
          </div>
        </div>
        <div className={`flex items-start cursor-pointer transition-all ${activeStep === 'amm-3' ? 'bg-[#fb8f5a]/10 p-2 rounded-sm' : ''}`} onClick={() => handleStepClick('amm', 3)} onKeyPress={e => (e.key === 'Enter' || e.key === ' ') && handleStepClick('amm', 3)} role="listitem" tabIndex={0} aria-expanded={activeStep === 'amm-3'}>
          <span className="w-8 h-8 rounded-full bg-[#fb8f5a] text-white flex items-center justify-center font-bold flex-shrink-0" aria-label="Step 3">3</span>
          <div className="ml-4">
            <p className="font-medium text-gray-900 dark:text-white">Apply 0.30% trading fee</p>
            <p className="text-sm text-gray-600 dark:text-gray-400">35% goes to LPs, 65% to protocol</p>
            {activeStep === 'amm-3' && <div className="mt-2 p-2 bg-gray-100 dark:bg-gray-800 rounded-sm text-xs text-gray-600 dark:text-gray-400">
                On $1,000 trade: $3 fee → $1.05 to LPs, $1.95 to protocol
              </div>}
          </div>
        </div>
        <div className={`flex items-start cursor-pointer transition-all ${activeStep === 'amm-4' ? 'bg-[#fb8f5a]/10 p-2 rounded-sm' : ''}`} onClick={() => handleStepClick('amm', 4)} onKeyPress={e => (e.key === 'Enter' || e.key === ' ') && handleStepClick('amm', 4)} role="listitem" tabIndex={0} aria-expanded={activeStep === 'amm-4'}>
          <span className="w-8 h-8 rounded-full bg-[#fb8f5a] text-white flex items-center justify-center font-bold flex-shrink-0" aria-label="Step 4">4</span>
          <div className="ml-4">
            <p className="font-medium text-gray-900 dark:text-white">Execute swap instantly</p>
            <p className="text-sm text-gray-600 dark:text-gray-400">Update pool reserves and user balances</p>
            {activeStep === 'amm-4' && <div className="mt-2 p-2 bg-gray-100 dark:bg-gray-800 rounded-sm text-xs text-gray-600 dark:text-gray-400">
                Transaction completes in ~1-2 seconds on NEAR
              </div>}
          </div>
        </div>
      </div>
      
      {}
      <div className="mt-4 p-3 bg-gray-100 dark:bg-gray-950 rounded-sm">
        <p className="text-sm font-semibold mb-2 text-gray-900 dark:text-white">Key Characteristics:</p>
        <ul className="text-sm text-gray-600 dark:text-gray-400 space-y-1" role="list">
          <li role="listitem">• Always available liquidity</li>
          <li role="listitem">• Price slippage on large trades</li>
          <li role="listitem">• No order matching needed</li>
          <li role="listitem">• Instant execution</li>
        </ul>
      </div>
    </div>;
  const CLOBFlow = () => <div className="p-6 border-2 border-green-600 rounded-sm bg-gray-50 dark:bg-gray-900">
      <h5 className="font-bold mb-4 text-green-600 dark:text-green-400 text-lg">CLOB Trade Flow</h5>
      <div className="space-y-3" role="list">
        <div className={`flex items-start cursor-pointer transition-all ${activeStep === 'clob-1' ? 'bg-green-600/10 p-2 rounded-sm' : ''}`} onClick={() => handleStepClick('clob', 1)} onKeyPress={e => (e.key === 'Enter' || e.key === ' ') && handleStepClick('clob', 1)} role="listitem" tabIndex={0} aria-expanded={activeStep === 'clob-1'}>
          <span className="w-8 h-8 rounded-full bg-green-100 dark:bg-green-900 text-green-800 dark:text-green-200 flex items-center justify-center font-bold flex-shrink-0" aria-label="Step 1">1</span>
          <div className="ml-4">
            <p className="font-medium text-gray-900 dark:text-white">Place limit or market order</p>
            <p className="text-sm text-gray-600 dark:text-gray-400">Set price and size for limit orders</p>
            {activeStep === 'clob-1' && <div className="mt-2 p-2 bg-gray-100 dark:bg-gray-800 rounded-sm text-xs text-gray-600 dark:text-gray-400">
                Example: Buy 1000 VITA at $5.00 or better (limit order)
              </div>}
          </div>
        </div>
        <div className={`flex items-start cursor-pointer transition-all ${activeStep === 'clob-2' ? 'bg-green-600/10 p-2 rounded-sm' : ''}`} onClick={() => handleStepClick('clob', 2)} onKeyPress={e => (e.key === 'Enter' || e.key === ' ') && handleStepClick('clob', 2)} role="listitem" tabIndex={0} aria-expanded={activeStep === 'clob-2'}>
          <span className="w-8 h-8 rounded-full bg-green-100 dark:bg-green-900 text-green-800 dark:text-green-200 flex items-center justify-center font-bold flex-shrink-0" aria-label="Step 2">2</span>
          <div className="ml-4">
            <p className="font-medium text-gray-900 dark:text-white">Match with existing orders</p>
            <p className="text-sm text-gray-600 dark:text-gray-400">Price-time priority matching</p>
            {activeStep === 'clob-2' && <div className="mt-2 p-2 bg-gray-100 dark:bg-gray-800 rounded-sm text-xs text-gray-600 dark:text-gray-400">
                Orders at same price: first come, first served
              </div>}
          </div>
        </div>
        <div className={`flex items-start cursor-pointer transition-all ${activeStep === 'clob-3' ? 'bg-green-600/10 p-2 rounded-sm' : ''}`} onClick={() => handleStepClick('clob', 3)} onKeyPress={e => (e.key === 'Enter' || e.key === ' ') && handleStepClick('clob', 3)} role="listitem" tabIndex={0} aria-expanded={activeStep === 'clob-3'}>
          <span className="w-8 h-8 rounded-full bg-green-100 dark:bg-green-900 text-green-800 dark:text-green-200 flex items-center justify-center font-bold flex-shrink-0" aria-label="Step 3">3</span>
          <div className="ml-4">
            <p className="font-medium text-gray-900 dark:text-white">Apply maker/taker fees</p>
            <p className="text-sm text-gray-600 dark:text-gray-400">Makers: 0.02%, Takers: 0.05%</p>
            {activeStep === 'clob-3' && <div className="mt-2 p-2 bg-gray-100 dark:bg-gray-800 rounded-sm text-xs text-gray-600 dark:text-gray-400">
                Maker adds liquidity (limit order), Taker removes it (market order)
              </div>}
          </div>
        </div>
        <div className={`flex items-start cursor-pointer transition-all ${activeStep === 'clob-4' ? 'bg-green-600/10 p-2 rounded-sm' : ''}`} onClick={() => handleStepClick('clob', 4)} onKeyPress={e => (e.key === 'Enter' || e.key === ' ') && handleStepClick('clob', 4)} role="listitem" tabIndex={0} aria-expanded={activeStep === 'clob-4'}>
          <span className="w-8 h-8 rounded-full bg-green-100 dark:bg-green-900 text-green-800 dark:text-green-200 flex items-center justify-center font-bold flex-shrink-0" aria-label="Step 4">4</span>
          <div className="ml-4">
            <p className="font-medium text-gray-900 dark:text-white">Settle matched trades</p>
            <p className="text-sm text-gray-600 dark:text-gray-400">Update balances for all parties</p>
            {activeStep === 'clob-4' && <div className="mt-2 p-2 bg-gray-100 dark:bg-gray-800 rounded-sm text-xs text-gray-600 dark:text-gray-400">
                Both buyer and seller receive their assets instantly
              </div>}
          </div>
        </div>
      </div>
      
      {}
      <div className="mt-4 p-3 bg-gray-100 dark:bg-gray-950 rounded-sm">
        <p className="text-sm font-semibold mb-2 text-gray-900 dark:text-white">Key Characteristics:</p>
        <ul className="text-sm text-gray-600 dark:text-gray-400 space-y-1" role="list">
          <li role="listitem">• Best price discovery</li>
          <li role="listitem">• No slippage on limit orders</li>
          <li role="listitem">• Requires counterparty</li>
          <li role="listitem">• Professional trading features</li>
        </ul>
      </div>
    </div>;
  if (type === 'amm') {
    return <AMMFlow />;
  }
  if (type === 'clob') {
    return <CLOBFlow />;
  }
  return <div className="space-y-6">
      <div className="flex items-center justify-between mb-4">
        <h4 className="text-lg font-semibold text-gray-900 dark:text-white">Trading Flow Comparison</h4>
        <button onClick={() => setShowComparison(!showComparison)} className="text-sm text-[#fb8f5a] hover:text-[#ffaf85] transition-colors" aria-label={`${showComparison ? 'Hide' : 'Show'} detailed comparison`}>
          {showComparison ? 'Hide' : 'Show'} Comparison
        </button>
      </div>
      
      <div className="grid grid-cols-1 lg:grid-cols-2 gap-6">
        <AMMFlow />
        <CLOBFlow />
      </div>
      
      {}
      {showComparison && <div className="bg-blue-500/10 border border-blue-500/30 p-4 rounded-sm" role="region" aria-label="Trading method comparison">
          <h5 className="font-semibold mb-3 text-gray-900 dark:text-white">Quick Comparison</h5>
          <div className="grid grid-cols-1 md:grid-cols-2 gap-4 text-sm">
            <div>
              <p className="font-medium text-[#fb8f5a] mb-1">AMM Best For:</p>
              <ul className="text-gray-600 dark:text-gray-400 space-y-1" role="list">
                <li role="listitem">• Quick swaps</li>
                <li role="listitem">• Small to medium trades</li>
                <li role="listitem">• Guaranteed execution</li>
                <li role="listitem">• New traders</li>
              </ul>
            </div>
            <div>
              <p className="font-medium text-green-600 dark:text-green-400 mb-1">CLOB Best For:</p>
              <ul className="text-gray-600 dark:text-gray-400 space-y-1" role="list">
                <li role="listitem">• Large trades</li>
                <li role="listitem">• Price-sensitive orders</li>
                <li role="listitem">• Professional traders</li>
                <li role="listitem">• Advanced strategies</li>
              </ul>
            </div>
          </div>
          
          <div className="mt-4 pt-4 border-t border-blue-500/30">
            <p className="text-xs text-gray-500 dark:text-gray-500">
              <strong>Pro tip:</strong> Start with AMM for simplicity, graduate to CLOB for advanced trading.
            </p>
          </div>
        </div>}
    </div>;
};

<Info>
  This guide explains the fundamental concepts of Vita Finance. If you're already familiar with DeFi, jump to our [technical docs](/developers/overview).
</Info>

## Core Concepts Overview

<CardGroup cols={2}>
  <Card title="Concentrated Liquidity" icon="droplet" href="/guides/provide-liquidity">
    Deploy capital within specific price ranges for maximum efficiency
  </Card>

  <Card title="Order Book (CLOB)" icon="chart-line" href="/clob/overview">
    Trade with limit orders on our central limit order book
  </Card>

  <Card title="NFT Positions" icon="image" href="/guides/provide-liquidity">
    Each liquidity position is a unique, tradeable NFT
  </Card>

  <Card title="xVITA Staking" icon="coins" href="/concepts/xvita-staking">
    Stake VITA tokens to earn protocol revenue and governance rights
  </Card>

  <Card title="Session Rewards" icon="calendar" href="/concepts/session-rewards">
    Weekly reward distribution based on time-weighted contributions
  </Card>

  <Card title="USDC Markets" icon="dollar-sign" href="/clob/overview">
    All CLOB pairs quoted in USDC for stable trading
  </Card>
</CardGroup>

## 1. Two Independent Trading Systems

### AMM vs CLOB

Vita Finance offers two separate and independent trading systems:

<Tabs>
  <Tab title="AMM (Concentrated Liquidity)">
    **Type:** Automated Market Maker\
    **Execution:** Instant\
    **Pricing:** Algorithmic (x\*y=k curve)\
    **Liquidity:** Provided by LPs in pools

    **Best for:**

    * Quick swaps
    * Small to medium trades
    * Passive liquidity provision
  </Tab>

  <Tab title="CLOB (Order Book)">
    **Type:** Central Limit Order Book\
    **Execution:** When orders match\
    **Pricing:** Order-driven\
    **Liquidity:** Individual maker orders

    **Best for:**

    * Large trades
    * Precise price execution
    * Professional trading
  </Tab>
</Tabs>

<Warning>
  AMM and CLOB are completely separate systems with no shared liquidity. They operate independently with their own pricing mechanisms.
</Warning>

### Trading Flow Diagram

<TradingFlow />

## 2. Automated Market Maker (AMM)

### How Swaps Work

**Swap Process Flow**

1. **User** → Sends Token A
2. **Vita Pool** → Calculates Rate
3. **Vita Pool** → Sends Token B
4. **LPs + Protocol** → Collects Fee

<Note>
  Each swap incurs a default 0.3% fee. The distribution is configurable through protocol\_fee\_rate and community\_fee\_rate parameters.
</Note>

## 3. Central Limit Order Book (CLOB)

### Order Types

<AccordionGroup>
  <Accordion title="Limit Orders">
    Set your exact buy or sell price:

    * Order executes only at your price or better
    * No slippage
    * May not execute immediately
  </Accordion>

  <Accordion title="Market Orders">
    Execute immediately at best available price:

    * Instant execution
    * Takes liquidity from order book
    * Subject to slippage on large orders
  </Accordion>

  <Accordion title="USDC Quote Currency">
    All CLOB pairs are quoted in USDC:

    `NEAR/USDC` `VITA/USDC` `BTC/USDC` `ETH/USDC`

    This provides stable pricing and easy comparison across markets.
  </Accordion>
</AccordionGroup>

### CLOB vs AMM Comparison

| Feature   | AMM            | CLOB                 |
| --------- | -------------- | -------------------- |
| Execution | Instant        | When orders match    |
| Pricing   | Algorithmic    | Order-driven         |
| Slippage  | Always present | None on limit orders |
| Liquidity | Pooled         | Individual orders    |
| Best for  | Quick trades   | Precise execution    |

## 4. Liquidity Provision

### Understanding Ticks

Vita uses a **tick-based system** where each tick represents a 0.01% price change:

<CodeGroup>
  ```javascript Price Formula theme={null}
  price = 1.0001^tick
  ```

  ```javascript Valid Range theme={null}
  MIN_TICK = -665454
  MAX_TICK = 831818
  ```
</CodeGroup>

### Price Ranges Explained

<AccordionGroup>
  <Accordion title="In-Range Positions">
    When current price is within your range:

    * ✓ Earning trading fees
    * ✓ Holding both tokens
    * ✓ Exposed to impermanent loss
  </Accordion>

  <Accordion title="Out-of-Range Positions">
    When price moves outside your range:

    * ✗ Not earning fees
    * ✗ Holding only one token
    * ✗ No additional IL until back in range
  </Accordion>
</AccordionGroup>

### Capital Efficiency Calculation

<Note>
  ### Example: NEAR/USDC pool at \$5.00

  * **Wide range** ($1-$25): \~4x efficiency
  * **Medium range** ($4-$6): \~25x efficiency
  * **Narrow range** ($4.90-$5.10): \~100x efficiency
  * **Ultra narrow** ($4.99-$5.01): Very high efficiency
</Note>

<Warning>
  Narrower ranges offer higher efficiency but require more active management and carry higher impermanent loss risk.
</Warning>

## 5. VITA & xVITA Tokens

### VITA Token

The native governance and utility token of Vita Finance:

<Steps>
  <Step title="Utility">
    * Pay for protocol services
    * Governance voting
    * Liquidity mining rewards
    * Fee discounts
  </Step>

  <Step title="Technical Details">
    **Decimals:** 18 (not 24 like NEAR)\
    **Total Supply:** 100,000,000 VITA\
    **Contract:** \[TBD]
  </Step>
</Steps>

### xVITA Token

xVITA represents staked VITA with additional benefits:

```javascript theme={null}
// xVITA characteristics
{
  revenueShare: "Protocol and community vault distributions",
  governanceWeight: "1 xVITA = 1 vote",
  farmingBoost: "Up to 2.5x maximum boost",
  redemptionOptions: "15-180 days",
  decimals: 18 // Same as VITA
}
```

### Redemption Mechanics

The redemption rate follows a linear curve:

| Period   | Return               |
| -------- | -------------------- |
| 15 days  | 50% (emergency exit) |
| 180 days | 100% (maximum value) |

**Formula:** `50% + (days - 15) / 165 × 50%`

## 6. Fee Structure

### Trading Fees

All AMM pools use a default **0.3% trading fee** (3000 in basis points):

<Note>
  ### Fee Distribution

  Fees are distributed through configurable parameters:

  * **protocol\_fee\_rate:** Protocol treasury portion
  * **community\_fee\_rate:** Community vault portion
  * **Remaining:** Liquidity providers

  FEE\_RATE\_DENOMINATOR\_VALUE = 1,000,000 (for precise calculations)
</Note>

## 7. Session-Based Rewards

### How Sessions Work

<Info>
  Vita uses a **7-day session system** for fair reward distribution
</Info>

```javascript theme={null}
// Session timeline
const session = {
  duration: 7 * 24 * 60 * 60, // 7 days in seconds
  startTime: "Monday 00:00 UTC",
  endTime: "Sunday 23:59 UTC",
  claimPeriod: "Anytime after session ends"
};
```

### Reward Calculation

Your rewards depend on:

<CardGroup cols={3}>
  <Card title="1" icon="clock">
    **Time-weighted balance**\
    How long you held positions
  </Card>

  <Card title="2" icon="chart-line">
    **Session performance**\
    Total fees generated
  </Card>

  <Card title="3" icon="percent">
    **Your share**\
    Your proportion of total liquidity
  </Card>
</CardGroup>

```javascript theme={null}
// Simplified reward formula
userReward = (userLiquidity * timeInSession * sessionFees) / totalLiquidity
```

## 8. NFT Position System

### Why NFTs?

Each liquidity position is an NFT because:

<CardGroup cols={2}>
  <Card title="Uniqueness" icon="fingerprint">
    Every position has unique parameters (range, liquidity, fees)
  </Card>

  <Card title="Transferability" icon="right-left">
    Positions can be sold or transferred without closing
  </Card>

  <Card title="Composability" icon="layer-group">
    Use positions as collateral in other DeFi protocols
  </Card>

  <Card title="Management" icon="wrench">
    Easy tracking and management of multiple positions
  </Card>
</CardGroup>

### Position Metadata

```json theme={null}
{
  "tokenId": 12345,
  "pool": "NEAR-USDC",
  "owner": "alice.near",
  "tickLower": -665454,  // MIN_TICK
  "tickUpper": 831818,   // MAX_TICK
  "liquidity": "1000000000000000000",
  "feeGrowthInside0": "500000",
  "feeGrowthInside1": "300000",
  "tokensOwed0": "50",
  "tokensOwed1": "10"
}
```

## 9. Boost Mechanics

### Advanced Boosting System

<Note>
  ### xVITA Boost System

  **xVITA Boost**\
  Sigmoid curve function based on your xVITA holdings

  **Maximum boost:** Up to 2.5x

  The boost depends on your share of total xVITA in the protocol

  Boost calculation uses a complex sigmoid function that considers:

  * Your xVITA balance
  * Total xVITA supply
  * Your proportional share
  * Time-weighted average balance

  The maximum achievable boost is 2.5x. This applies to farming rewards and is calculated per session.
</Note>

## 10. Impermanent Loss

### Understanding IL in Concentrated Positions

<Warning>
  Concentrated liquidity can amplify impermanent loss. The narrower your range, the higher the potential IL.
</Warning>

### IL Scenarios

<Tabs>
  <Tab title="Price Stays in Range">
    * Normal IL applies (same as traditional AMM)
    * Offset by higher fee earnings
    * Generally profitable if volume is high
  </Tab>

  <Tab title="Price Exits Range Up">
    * Position converts to 100% quote token
    * IL is "locked in" at range boundary
    * No further IL until price returns
  </Tab>

  <Tab title="Price Exits Range Down">
    * Position converts to 100% base token
    * IL is "locked in" at range boundary
    * No further IL until price returns
  </Tab>
</Tabs>

## Interactive Tools

### Explore Our Tools

<CardGroup cols={2}>
  <Card title="Fee Calculator" icon="calculator" href="/tools/fee-calculator">
    Calculate your expected returns based on liquidity and volume
  </Card>

  <Card title="Price Range Simulator" icon="chart-line" href="/tools/price-range-simulator">
    Visualize different price ranges and their efficiency
  </Card>

  <Card title="Expected Returns Calculator" icon="coins" href="/tools/expected-returns">
    Estimate your APR including fees and rewards
  </Card>

  <Card title="Interactive Concepts" icon="graduation-cap" href="/tools/interactive-concepts">
    Learn concepts through interactive visualizations
  </Card>
</CardGroup>

## Next Steps

Now that you understand the core concepts:

<CardGroup cols={2}>
  <Card title="Start Trading" icon="right-left" href="/quickstart">
    Put your knowledge into practice
  </Card>

  <Card title="Deep Dive: Liquidity" icon="droplet" href="/guides/provide-liquidity">
    Master concentrated liquidity strategies
  </Card>

  <Card title="Explore xVITA" icon="coins" href="/concepts/xvita-staking">
    Learn about staking and governance
  </Card>

  <Card title="Developer Docs" icon="code" href="/api-reference">
    Build on top of Vita
  </Card>
</CardGroup>

<Note>
  **Questions?** Join our [Discord](https://discord.gg/vitafinance) where our community and team are happy to help!
</Note>
