Principal-protected crypto products, autocallables, shark notes, and bonus certificates — priced and settled on-chain via Purple Flea Escrow.
From simple capital protection to complex barrier mechanics — every payoff is programmable and settled via Escrow API.
Understand exactly how each note behaves across the range of underlying asset prices at maturity.
When issuing structured notes, the issuing agent takes on option risk. Purple Flea's Trading API provides the perp instruments needed to hedge continuously.
A principal-protected note contains an embedded long call option on the underlying. The issuing agent is effectively short this call. To remain delta-neutral, the agent must continuously maintain a position in the underlying asset proportional to the option's current delta (Δ = ∂V/∂S). As S moves, delta changes and the hedge must be rebalanced.
| Event | Action | Urgency |
|---|---|---|
| Delta drift > ±0.05 | Buy/sell perp | High |
| Observation date | Full recalculation | Medium |
| Volatility spike >20% | Recalc vega hedge | High |
| Barrier within 5% | Gamma hedge addition | Critical |
| Daily time decay | Theta adjustment | Low |
| Greek | Meaning | Tool |
|---|---|---|
| Delta (Δ) | Price sensitivity | Spot / perp |
| Gamma (Γ) | Delta curvature | Options on perp |
| Vega (ν) | Vol sensitivity | Variance swaps |
| Theta (Θ) | Time decay | Calendar spread |
| Rho (ρ) | Rate sensitivity | Interest rate swap |
Four endpoints to template, price, issue, and monitor structured notes. All settled on-chain via Escrow API.
# Response { "templates": [ { "id": "ppn-v1", "name": "Principal Protected Note", "participation": 0.80, "protection": 1.00, "min_term_days": 90, "max_term_days": 365 }, { "id": "autocall-v2", "name": "Autocallable Note", "coupon_pa": 0.18, "knock_in_barrier": 0.60, "call_barrier": 1.00, "observation_freq": "monthly" } ] }
# Request params: template_id, notional, underlying, term_days, vol GET /notes/pricing?template_id=autocall-v2¬ional=1000&underlying=BTC&term_days=90&vol=0.65 # Response { "fair_value": 97.23, // per 100 notional "delta": 0.43, "gamma": 0.018, "vega": 12.4, "theta": -0.82, "implied_vol": 0.65, "breakeven_price": 97230, // USD "max_loss": 400, // USDC (barrier breach scenario) "max_gain": 135 // USDC (3 early calls) }
# Body { "template_id": "autocall-v2", "notional": 1000, "underlying": "BTC-USD", "term_days": 90, "issuer_wallet": "0xISSUER...", "investor_wallet": "0xINVESTOR...", "referral_code": "agt_7f2c" } # Response — escrow created, note live { "note_id": "note_4Xk9pQ", "escrow_id": "esc_8mT3nR", "status": "active", "start_date": "2026-03-06", "maturity_date": "2026-06-04", "next_observation": "2026-04-06", "initial_spot": 88420.50, "fee_paid": 10 // 1% escrow fee }
# GET /notes/lifecycle?note_id=note_4Xk9pQ { "note_id": "note_4Xk9pQ", "status": "active", "days_remaining": 47, "current_spot": 91200.00, "pnl": +28.50, "current_delta": 0.51, "hedge_position": -0.0056, // BTC short perp "rebalance_needed": false, "knock_in_distance": 34.5, // % above barrier "next_observation": "2026-04-06" }
A complete agent that prices, issues, and delta-hedges structured notes on-chain using the Purple Flea API.
import requests import time from dataclasses import dataclass BASE = "https://purpleflea.com/api/v1" ESCROW = "https://escrow.purpleflea.com" API_KEY = "pf_live_your_key_here" HEADERS = {"Authorization": f"Bearer {API_KEY}"} DELTA_THRESHOLD = 0.05 # rebalance if drift exceeds 5% @dataclass class NotePosition: note_id: str escrow_id: str template: str notional: float underlying: str target_delta: float = 0.0 hedge_size: float = 0.0 class StructuredNoteAgent: def __init__(self, wallet: str): self.wallet = wallet self.positions: list[NotePosition] = [] def price_note(self, template_id: str, notional: float, underlying: str, term_days: int, vol: float) -> dict: """Price a structured note before issuance.""" r = requests.get( f"{BASE}/notes/pricing", params={ "template_id": template_id, "notional": notional, "underlying": underlying, "term_days": term_days, "vol": vol }, headers=HEADERS ) pricing = r.json() print(f"Fair value: {pricing['fair_value']:.2f}/100 notional") print(f"Delta: {pricing['delta']:.3f} | Max loss: {pricing['max_loss']} USDC") return pricing def issue_note(self, template_id: str, notional: float, underlying: str, term_days: int, investor_wallet: str) -> NotePosition: """Issue a structured note — creates escrow on-chain.""" r = requests.post( f"{BASE}/notes/issue", json={ "template_id": template_id, "notional": notional, "underlying": underlying, "term_days": term_days, "issuer_wallet": self.wallet, "investor_wallet": investor_wallet }, headers=HEADERS ) data = r.json() pos = NotePosition( note_id=data["note_id"], escrow_id=data["escrow_id"], template=template_id, notional=notional, underlying=underlying ) self.positions.append(pos) print(f"Note issued: {pos.note_id} | Escrow: {pos.escrow_id}") print(f"Maturity: {data['maturity_date']} | Fee paid: {data['fee_paid']} USDC") return pos def hedge_delta(self, pos: NotePosition): """Rebalance delta hedge via Trading API perps.""" lifecycle = requests.get( f"{BASE}/notes/lifecycle", params={"note_id": pos.note_id}, headers=HEADERS ).json() current_delta = lifecycle["current_delta"] drift = abs(current_delta - pos.target_delta) if drift < DELTA_THRESHOLD: print(f"[{pos.note_id}] Delta OK (drift={drift:.3f})") return # Calculate hedge size in underlying units spot = lifecycle["current_spot"] hedge_notional = (current_delta - pos.target_delta) * pos.notional hedge_size = hedge_notional / spot # Short perp via Trading API to neutralize delta side = "sell" if hedge_size > 0 else "buy" requests.post( f"{BASE}/trading/order", json={ "market": f"{pos.underlying}-PERP", "side": side, "size": abs(hedge_size), "type": "market" }, headers=HEADERS ) pos.hedge_size = hedge_size pos.target_delta = current_delta print(f"[{pos.note_id}] Hedged: {side} {abs(hedge_size):.6f} {pos.underlying}") def run(self, interval_s: int = 300): """Main loop: monitor all notes and hedge as needed.""" while True: for pos in self.positions: self.hedge_delta(pos) time.sleep(interval_s) # Example usage if __name__ == "__main__": agent = StructuredNoteAgent(wallet="0xYOUR_WALLET") # Price first pricing = agent.price_note( template_id="autocall-v2", notional=1000, underlying="BTC", term_days=90, vol=0.65 ) # Issue if pricing looks good if pricing["fair_value"] < 98: pos = agent.issue_note( template_id="autocall-v2", notional=1000, underlying="BTC-USD", term_days=90, investor_wallet="0xINVESTOR_WALLET" ) agent.run() # start hedging loop
Get free USDC from the faucet, claim your API key, and issue a structured note in under 5 minutes.