# Kelly Allocation Strategy

Zap Pilot uses the **Kelly Criterion** as the foundation for allocating user funds across multiple DeFi protocols. While the original Kelly formula is mathematical in nature, our implementation includes several real-world risk modifiers to make it suitable for on-chain asset management.

This page explains how we calculate vault allocations, and how we adjust raw Kelly outputs to reflect on-chain risk, liquidity, and maturity.

***

### 🔍 1. What is the Kelly Criterion?

The **Kelly Criterion** is a position sizing strategy that maximizes the long-term growth rate of capital by balancing return and risk. It’s widely used in both gambling and portfolio theory.

In its basic form, the Kelly formula computes:

```
iniCopyEditallocation_weight = expected_return / variance
```

In Zap Pilot, we treat each DeFi pool as a "bet" with an expected APY and risk profile. The higher the return and the lower the volatility, the more capital it deserves.

***

### ⚙️ 2. Implementation in Zap Pilot

We apply a simplified and normalized version of the Kelly formula across all eligible pools within a vault. The steps are as follows:

1. **Input Metrics for Each Pool**:
   * Estimated annual return (APY)
   * Risk estimate (variance, derived from APY history or modeled)
2. **Compute Raw Kelly Weights**:

   ```python
   pythonCopyEditraw_weight = apy / variance
   ```
3. **Normalize All Weights**:\
   Ensure that all final weights sum to 1:

   ```python
   pythonCopyEditnormalized_weight = raw_weight / sum(raw_weights)
   ```
4. **Post-Processing Filters**:
   * Pools with **negative weights** are excluded
   * Pools with extremely small weights (e.g. <1%) may be filtered out to reduce gas overhead or dust allocation

You can review the full implementation in our GitHub repo:\
👉 [kelly\_allocation.py](https://github.com/zapPilot/Index500/blob/main/scripts/kelly_allocation.py)

***

### 🧱 3. Real-World Adjustments: Risk Modifiers

Although the core Kelly formula relies on return and risk, Zap Pilot integrates additional **risk modifiers** to improve safety and reliability in live DeFi environments.

**📦 TVL (Total Value Locked)**

* Pools or protocols with very low TVL may be excluded or capped
* Rationale: Low TVL implies poor liquidity, higher slippage, or lack of market trust

**🕰 Protocol Age**

* Newly launched protocols (e.g. <3 months) are treated conservatively
* Rationale: Even if APY is high, new protocols may lack audits, community, or security track records

**💡 How We Apply These**

* As **filters** before allocation: pools below a minimum TVL or age threshold may be removed entirely
* As **weight multipliers**: risky pools may receive only partial allocation (e.g. 50% discount)
* As **rules for upper/lower bounds** per pool

These mechanisms ensure that Zap Pilot’s Kelly-based logic reflects not only numbers, but also DeFi-specific trust and safety concerns.

***

### 📊 4. Sample Output

A typical Kelly-weighted allocation for a Stablecoin Vault might look like this:

```
javaCopyEditAave USDC (Optimism):         35%
Pendle sDAI (Arbitrum):       42%
Compound USDT (Ethereum):     23%
```

When a user zaps in, their funds will be split and bridged to match this portfolio allocation.

***

### 🔁 5. Rebalancing Model

* Allocation weights are recalculated **quarterly**
* Users receive an **email notification** with updated strategy suggestions
* Users can **one-click rebalance** via the frontend (executed from their own AA wallet)

Note: Zap Pilot is fully non-custodial, so all rebalancing must be signed and initiated by the user.

***

### 🚀 6. Future Improvements

We are actively expanding the allocation engine with more inputs and flexibility:

* Off-chain oracle feeds for APY and volatility
* Risk scoring based on governance, tokenomics, and code audits
* User-defined Kelly curves (adjusted for personal risk preferences)
* Vault-specific override logic (e.g. capital caps, slippage modeling)

***

### ✅ Summary

Zap Pilot uses the Kelly Criterion not as a static formula, but as a **dynamic, risk-aware allocation engine**, adapted for the complexity of multi-chain DeFi. By combining return-risk optimization with practical filters like TVL and protocol age, we aim to deliver robust, long-term portfolio growth while minimizing unnecessary exposure.


---

# 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://zap-pilot.gitbook.io/zap-pilot/product/protocol-mechanics/kelly-allocation-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.
