# ⚙️ How It Works

KaspaFinance is built on top of the Kaspa EVM (Kasplex L2), a smart contract execution environment that brings full Ethereum compatibility to the high-speed, parallelized **blockDAG** architecture of the Kaspa Layer 1 blockchain.

While traditional blockchains follow a single-chain structure, **Kaspa's DAG** allows multiple blocks to be created and confirmed simultaneously, resulting in significantly faster throughput, lower latency, and higher security without compromising decentralization.

KaspaFinance leverages this foundation to build an integrated, high-performance DeFi ecosystem — seamlessly combining AMM swaps, staking, farming, lending, and AI-driven trading into a unified protocol.

***

#### 🧱 What's Under the Hood - Why Kaspa EVM (Kasplex L2) ?

Here’s a breakdown of how KaspaFinance works at the protocol level:

***

#### 🛠️ 1. Kaspa EVM (Kasplex L2)**: Execution Layer**

* Kaspa EVM (Kasplex L2) is a fully compatible execution environment on the Kaspa blockchain.
* It supports **Solidity smart contracts.**
* Transactions are validated via Kaspa’s blockDAG consensus, enabling **parallel execution**, **instant finality**, and **high throughput**.
* Developers can use familiar tools (e.g. Hardhat, Remix, MetaMask) with Kaspa-native performance.

***

#### 🔄 2. **Kaspa DAG: Consensus Layer**

* Kaspa uses a **GHOSTDAG protocol**, allowing multiple blocks per second with no orphan blocks.
* Each transaction is confirmed within **seconds**, even during network congestion.
* This parallel block processing is what gives KaspaFinance an edge in **speed-sensitive use cases** like:
  * Automated trading
  * High-frequency swaps
  * On-chain bot deployment

***

#### ⚙️ 3. **KaspaFinance Protocol Stack**

| Layer               | Description                                                                     |
| ------------------- | ------------------------------------------------------------------------------- |
| **Frontend**        | Built with React/Next.js, optimized for low-latency user interaction            |
| **Smart Contracts** | Written in Solidity, deployed to Kaspa EVM (Kasplex L2)                         |
| **Oracles**         | Pulls price data from DEXs + CEXs to ensure reliable execution for bots/lending |
| **KasBot Engine**   | AI/ML models running off-chain, interacting via signed orders and triggers      |
| **Liquidity Pools** | Deployed as  V3-style pools with concentrated liquidity                         |
| **Emission Engine** | Dynamically distributes KFC rewards via farming/staking schedules               |

***

#### 🧠 4. **KasBot Integration**

* KasBot trading bots connect off-chain AI logic with on-chain smart contracts.
* Bots monitor market conditions and generate signed trade instructions.
* These are submitted and executed like standard swaps.
* Premium bots are unlocked based on KFC stake tiers and can adapt strategies based on DAO-configured parameters.

***

#### 🔗 5. **Composable DeFi Apps**

Each core module of KaspaFinance is designed to **interact with other modules**:

* Staked tokens can be used as collateral in lending pools.
* LP tokens can be staked for farming rewards or loaned for leverage.
* Governance and bot logic can be upgraded via DAO votes over time.

This modular architecture ensures flexibility for future features like:

* NFT collaterals
* Synthetic assets
* Advanced order types (TWAP, batch auctions) - future iterations

***

#### 🧬 How It All Connects

At every level, KaspaFinance is built to:

* Use **Kaspa’s speed** to eliminate DeFi friction
* Use **EVM compatibility** to attract devs and migrate liquidity
* Use **AI automation** to level the playing field for traders
* Use **on-chain composability** to empower new DeFi primitives

<figure><img src="broken-reference" alt=""><figcaption></figcaption></figure>
