<template>
  <div>
    <h1>Liquidity Management</h1>

    <p>
      The liquidity of $KRK tokens is fully managed by an immutable Liquidity Manager (LM) contract. This contract governs the minting,
      burning, and allocation of liquidity to ensure market stability, efficient trading, and adaptive responses to market dynamics. The LM
      operates through three distinct liquidity positions: Floor, Anchor, and Discovery (inspired by
      <a href="https://docs.baseline.markets/btokenomics/dynamic_liquidity#protocol-owned-liquidity-positions">Baseline</a>). Each serves a
      specific role in maintaining a balanced and resilient ecosystem.
    </p>

    <p>
      The Liquidity Manager operates exclusively on a Uniswap V3 pool on the Base network with a tick spacing of 200, equivalent to 1% fee
      tier. Other liquidity pools on different networks will only receive liquidity indirectly through arbitrage.
    </p>

    <br />
    <pre>
   ▲                                          ┌─────────────┐              
   │                                          │ ┌─┐         │              
   │ Floor                                    │ │%│  $ETH   │              
   │  ┌─┐                                     │ └─┘         │              
   │  │%│                                     │ ┌─┐         │              
   │  │%│                                     │ │+│  $KRK   │              
   │  │%│                                     │ └─┘         │              
   │  │%│                                     └─────────────┘              
   │  │%│                                                                  
   │  │%│                                                                  
   │  │%│                                                                  
 L │  │%│                                                                  
 i │  │%│                                                                  
 q │  │%│                                 Discovery                        
 u │  │%│                                                                  
 i │  │%│                     ┌─┐┌─┐┌─┐┌─┐┌─┐┌─┐┌─┐┌─┐┌─┐┌─┐┌─┐┌─┐         
 d │  │%│                     │+││+││+││+││+││+││+││+││+││+││+││+│         
 i │  │%│                     │+││+││+││+││+││+││+││+││+││+││+││+│         
 t │  │%│                     │+││+││+││+││+││+││+││+││+││+││+││+│         
 y │  │%│      Anchor         │+││+││+││+││+││+││+││+││+││+││+││+│         
   │  │%│                     │+││+││+││+││+││+││+││+││+││+││+││+│         
   │  │%│┌─┐┌─┐┌─┐┌─┐┌─┐┌─┐┌─┐│+││+││+││+││+││+││+││+││+││+││+││+│         
   │  │%││%││%││%││+││+││+││+││+││+││+││+││+││+││+││+││+││+││+││+│         
   │  │%││%││%││%││+││+││+││+││+││+││+││+││+││+││+││+││+││+││+││+│         
   │  │%││%││%││%││+││+││+││+││+││+││+││+││+││+││+││+││+││+││+││+│         
   │  │%││%││%││%││%││+││+││+││+││+││+││+││+││+││+││+││+││+││+││+│         
   │  │%││%││%││%││%││+││+││+││+││+││+││+││+││+││+││+││+││+││+││+│         
   │  │%││%││%││%││%││+││+││+││+││+││+││+││+││+││+││+││+││+││+││+│         
   │  └─┘└─┘└─┘└─┘└─┘└─┘└─┘└─┘└─┘└─┘└─┘└─┘└─┘└─┘└─┘└─┘└─┘└─┘└─┘└─┘         
  ─┼─────────────────────────────────────────────────────────────────►     
                   ▲                                         Price         
            current Price                                                  
</pre
    >
    <h2>Floor Position</h2>

    <p>
      The Floor is a highly concentrated liquidity position within a narrow price range. Its primary function is to provide a guaranteed
      minimum buyback price for $KRK tokens. This reserve stabilizes the protocol by ensuring that token holders always have a predictable
      exit value. As the protocol grows, the LM allocates more $ETH to the Floor, increasing its depth and reliability. Between 75% and 95%
      of all $ETH managed by the protocol is typically held in the Floor position.
    </p>

    <p>
      A critical aspect of the Floor position is its use of Volume Weighted Average Price (VWAP) to determine its pricing strategy. VWAP
      represents the average sale price of $KRK tokens weighted by trading volume, providing a kind of approximate and compressed memory
      over historic sales of tokens from its liquidity. The LM calculates the VWAP using cumulative trade data, ensuring that on average
      tokens are bought back for cheaper than they were sold for. By anchoring the protocol's liquidity to a VWAP-adjusted price, the system
      retains a sober approach to Floor positioning while allowing for market-responsive adjustments of Anchor and Discovery.
    </p>

    <p>
      The VWAP also serves as a <strong>dormant whale defense</strong>. Because the VWAP only records prices during buying activity (ETH
      inflow), an attacker who sells heavily cannot dilute the VWAP downward. The Floor uses the VWAP as a mirror &mdash; during sell
      pressure, the growing distance between the current price and the VWAP automatically pushes the Floor further away, making it
      progressively harder to drain. This "price memory" mechanism provides passive protection against coordinated sell attacks without
      requiring any external intervention.
    </p>

    <h2>Anchor Position</h2>

    <p>
      The Anchor position offers less liquidity depth than the Floor but spans a broader price range. It is always positioned at the current
      market price, ensuring its relevance to active trading. The size and width of the Anchor adapt based on the market regime determined by
      the Optimizer, which reads Harberger staking sentiment to classify conditions as <strong>bear</strong> or <strong>bull</strong>. In
      bear mode, the Anchor is conservative (30% of ETH, wide range) to minimize exposure. In bull mode, triggered only when staking
      signals indicate genuine community euphoria, the Anchor becomes aggressive (up to 100% of ETH, narrow range) to maximize fee capture.
      This adaptive strategy puts more capital at risk during confirmed uptrends while maintaining a defensive posture by default. For more
      on staking signals, visit the "Staking" chapter, and for details about the Optimizer, see the "AI-Agent" chapter.
    </p>

    <h2>Discovery Position</h2>

    <p>
      The Discovery position provides the broadest price coverage and greater liquidity depth compared to the Anchor. It is designed for
      price exploration beyond the current range, supporting efficient trading during periods of high demand or significant market growth.
      Discovery covers a price range up to three times the current price, and holds liquidity at a depth twice as concentrated as the Anchor
      position. This ensures robust liquidity for price exploration while incentivizing trading activity in less active price ranges. $ETH
      accumulated in the Discovery position is periodically redistributed to the Floor and Anchor positions.
    </p>

    <h2>Rebalancing Mechanism</h2>

    <p>
      The Liquidity Manager rebalances the Floor, Anchor, and Discovery positions based on market price movements. This process is triggered
      through an open contract call that anyone can execute at any time. Before rebalancing occurs, the function ensures a key condition is
      met: the price must have moved significantly, surpassing a minimum amplitude threshold of twice the tick spacing (2%).
    </p>

    <p>When the token price moves:</p>

    <ul>
      <li>
        <strong>Upwards:</strong> The Liquidity Manager reallocates more $ETH to the Floor position to enhance its stability and increases
        the size of the Discovery position for further price exploration. New $KRK tokens are minted to support this growth.
      </li>
      <li>
        <strong>Downwards:</strong> The Liquidity Manager reduces the Anchor and Discovery positions proportionally and burns excess tokens,
        maintaining equilibrium and reducing supply pressure.
      </li>
    </ul>

    <p>
      This dynamic system ensures that the protocol responds effectively to market conditions while safeguarding token holders and traders.
      The contract is immutable, guaranteeing that neither the team nor any other entity can access or control the liquidity. Users are
      encouraged to review the code to understand the mechanics before participating.
    </p>

    <h2>Risk Profile</h2>

    <p>
      While the Liquidity Manager offers a "guaranteed minimum buyback" through the Floor position, the price is dynamic because some $ETH
      is always allocated to the Anchor position for active trading. This ensures efficient price discovery and liquidity optimization but
      also introduces variability in the Floor’s backing. Compared to systems like Baseline, which use similar Floor, Anchor, and Discovery
      positions, Kraiken operates with a more dynamic and risk-tolerant approach. This allows for potentially higher rewards but comes with
      increased exposure to market fluctuations.
    </p>
  </div>
</template>

<script setup lang="ts">
import { onMounted } from 'vue';

interface LiquidityManagementEmits {
  (event: 'onmounted'): void;
}

const emit = defineEmits<LiquidityManagementEmits>();

onMounted(() => {
  emit('onmounted');
});
</script>
