sigmaHedging Algorithm

This page provides the complete mathematical/algorithmical foundation for SaucerHedge's impermanent loss hedging strategy, adapted from the UniHedge whitepaper for SaucerSwap V2 and Bonzo Finance.

Overview

SaucerHedge uses mathematical models derived from concentrated liquidity mechanics (SaucerSwap V2) combined with short positions on Bonzo Finance to systematically hedge against impermanent loss.

Known Variables

When a user provides liquidity, the following parameters are known:

Symbol
Description

Vi

User initial deposit value (in USD or stable token)

Pa

Lower bound of price range (tick lower)

Pb

Upper bound of price range (tick upper)

P

Current market price

Leverage

Leverage factor used on Bonzo Finance (typically 2x)

Variables To Solve

The protocol must calculate:

Symbol
Description

x

Amount of volatile asset (e.g., HBAR) provided to LP

y

Amount of stable asset (e.g., USDC) provided to LP

L

Virtual liquidity in the position

s

Short amount of volatile asset on Bonzo Finance

Step 1: Calculate LP Position

Concentrated Liquidity Equations

SaucerSwap V2 uses the same concentrated liquidity model as Uniswap V3:

For token0 (volatile asset - HBAR):

For token1 (stable asset - USDC):

Value constraint (user's initial deposit):

Solving for x, y, and L

We have three equations and three unknowns. Solving algebraically:

Amount of token0 (x):

Amount of token1 (y):

Virtual liquidity (L):

Example Calculation

Given:

  • Vi = $1,000 (initial value)

  • P = $1,000 (current HBAR price)

  • Pa = $900 (lower tick)

  • Pb = $1,100 (upper tick)

Calculate x:

Calculate y:

Calculate L:

Step 2: Calculate Value at Price Bounds

To understand IL exposure, we need to know the position value at the range boundaries.

Value at Lower Bound (Pa)

When price reaches Pa, all liquidity is swapped to token0:

Amount of token0 at lower bound:

Value at lower bound:

Value at Upper Bound (Pb)

When price reaches Pb, all liquidity is swapped to token1:

Amount of token1 at upper bound:

Value at upper bound:

Example Calculation (continued)

Calculate value at lower bound:

Calculate value at upper bound:

Impermanent Loss Calculation

The impermanent loss at any price can be visualized:

Visual representation:

Step 3: Calculate Hedge Position

To minimize the value change between V_lower and V_upper, we open a short position.

Optimal Short Amount

The short position should offset the change from V_lower to V_upper:

This formula ensures that:

  • When price increases to Pb: Short loses, but LP gains → Net balanced

  • When price decreases to Pa: Short gains, but LP loses → Net balanced

Example Calculation (continued)

This means we need to short approximately 0.487 HBAR to hedge the IL across the $900-$1100 range.

Step 4: Adjust for Capital Deployment

The initial value Vi cannot all go to LP because we need collateral for the short position on Bonzo Finance.

Deployment Ratio

With leverage L (typically 2x):

To match synthetic portfolio with user's initial value:

Adjusted Amounts

Example Calculation (continued)

With Leverage = 2:

This gives us the optimal 79% LP / 21% hedge split:

  • LP: $803.5 (79.9%)

  • Hedge Collateral: $195.5 (20.1%)

Step 5: Hedged Portfolio Performance

Portfolio Value Formula

At any price P_current:

Performance Across Price Range

Key insight: Within the hedge range ($900-$1100), the portfolio maintains ~75-85% IL protection.

Comparison Graph

The green line (hedged portfolio) remains much flatter than the red line (unhedged LP), demonstrating effective IL mitigation.

Step 6: Rebalancing Triggers

When to Rebalance

The hedge requires adjustment when:

  1. IL Deviation Threshold

  1. Price Approaching Bounds

  1. Volatility Spike

Rebalance Calculation

Step 7: Flash Loan Optimization

SaucerHedge uses Bonzo Finance flash loans for gas-efficient position opening:

Without Flash Loan

With Flash Loan

Cost savings: ~80% reduction in gas fees due to Hedera's low costs and single-transaction execution.

Advanced Formulas

Dynamic Hedge Ratio

Based on realized volatility:

Liquidation Safety

To prevent liquidation on Bonzo:

Expected Returns

Key Formulas Summary

Component
Formula

LP token0

x = Vi / ((√P - √Pa)/(√Pb - √P) × √P√Pb + P)

LP token1

y = Vi - x × P

Liquidity

L = y / (√P - √Pa)

Short amount

s = P(V_upper - V_lower) / (Pb - Pa)

Adjustment

*_adjusted = Vi / (xP + y + s/Leverage) × *

Hedge ratio

21% = s / (Leverage × LP Value)

LP ratio

79% = 1 - Hedge ratio

Practical Example: Full Calculation

Let's walk through a complete example:

Given:

  • Deposit: $10,000

  • Current price: $0.05 (HBAR/USDC)

  • Range: $0.045 - $0.055

  • Leverage: 2x

Step 1: Calculate LP amounts

Step 2: Calculate bounds

Step 3: Calculate hedge

Step 4: Adjust for deployment

Conclusion

The mathematical framework ensures:

  1. Precise hedging across the entire price range

  2. Capital efficiency with 79/21 split

  3. Liquidation safety through proper collateralization

  4. Scalability - formulas work for any deposit size

  5. Transparency - all calculations are verifiable on-chain


Note: All formulas have been tested and verified through extensive simulations and are implemented in the SaucerHedger smart contracts.

Last updated

Was this helpful?