A Novel Order Type for Minimizing Price Impact in Thin Liquidity Markets
Version: 1.0
Author: Justin Liverman (d3f4ult)
Organization: Mezzanine DAO
Date: December 2024
We introduce ProfitMaxi, a volume-sensitive limit order mechanism designed for automated market maker (AMM) liquidity pools. Unlike traditional limit orders that trigger on price, or time-weighted average price (TWAP) orders that distribute execution over time, ProfitMaxi orders respond dynamically to incoming buy volume, matching sell execution proportionally to market demand. This approach enables large position exits with minimal price impact, configurable positive price drift, and guaranteed fill completion given non-zero market activity.
We present the mathematical foundations, prove key theorems regarding price preservation and positive drift, validate the model through Monte Carlo simulation, and provide a complete Solana program architecture for on-chain implementation.
- Introduction
- Problem Statement
- Related Work
- Mathematical Framework
- Theoretical Analysis
- Empirical Validation
- Protocol Design
- Implementation Architecture
- Economic Analysis
- Security Considerations
- Conclusion
- References
The proliferation of decentralized exchanges (DEXs) built on automated market maker (AMM) architecture has democratized market making and liquidity provision. However, AMMs present unique challenges for large position management that remain largely unsolved in the retail trading context.
Traditional financial markets offer sophisticated order types—participation rate algorithms, VWAP (Volume Weighted Average Price) orders, and iceberg orders—that allow institutional traders to minimize market impact when executing large positions. These tools are essentially unavailable to participants in decentralized finance (DeFi), particularly on newly launched tokens with thin liquidity.
ProfitMaxi addresses this gap by introducing a volume-sensitive limit order that:
- Reacts to incoming buy volume rather than price or time
- Allows configurable participation through a delta ratio parameter
- Provides mathematical guarantees on price impact
- Operates trustlessly on-chain via keeper networks
Consider a holder of 3% of a token's supply in an AMM pool with $100,000 total liquidity. Executing a market sell of the entire position would result in:
- Direct price impact: 40-60% price decline (depending on pool curve)
- Chart damage: Visible "dump" candle discouraging other buyers
- Cascade effects: Triggering stop losses and panic selling
- Reputation damage: Perceived as "rugging" by the community
| Solution | Mechanism | Limitations |
|---|---|---|
| Manual DCA | User manually sells small amounts | Requires constant attention, inconsistent execution |
| TWAP | Time-based distribution | Ignores market conditions, may sell into weakness |
| Limit Orders | Price-triggered | Doesn't address volume/impact concerns |
| OTC Desks | Off-chain negotiation | Requires counterparty, not decentralized |
| Dark Pools | Hidden liquidity | Doesn't exist for most tokens |
An ideal large-exit mechanism should:
- Minimize price impact through intelligent order splitting
- Respond to market demand rather than arbitrary schedules
- Maintain positive chart dynamics or at minimum neutrality
- Operate autonomously without constant user intervention
- Be trustless and verifiable on-chain
- Be configurable to user risk preferences
Participation Rate (POV) Algorithms execute trades as a percentage of market volume, typically used by institutional investors to minimize footprint. ProfitMaxi adapts this concept for AMM mechanics.
VWAP Algorithms aim to achieve execution at the volume-weighted average price, distributing trades over time. While effective in traditional markets, VWAP is suboptimal for AMMs where price is determined algorithmically rather than by order book dynamics.
Gelato Network and Chainlink Keepers enable conditional order execution but lack native volume-sensitivity logic.
Jupiter Limit Orders on Solana provide price-triggered execution but don't address the large-exit problem.
Raydium AcceleRaytor offers launchpad mechanics but not exit management.
Relevant academic work includes:
- Angeris et al. (2020): "An analysis of Uniswap markets" - Foundational AMM theory
- Adams et al. (2021): "Uniswap v3 Core" - Concentrated liquidity mechanics
- Daian et al. (2020): "Flash Boys 2.0" - MEV and transaction ordering
ProfitMaxi builds on this foundation to create a novel execution primitive.
We consider a constant product market maker (CPMM) with reserves
-
$x$ = token reserve -
$y$ = quote reserve (e.g., SOL, ETH) -
$k$ = invariant constant
Spot Price:
A ProfitMaxi order
Where:
-
$T$ = Total order size in quote currency -
$r \in (0, 1]$ = Delta ratio (participation rate) -
$\theta$ = Minimum buy threshold (filters noise) -
$S(t)$ = Remaining unfilled amount at time$t$
For each incoming buy order
The order completes when
The net buying pressure remaining after each ProfitMaxi response:
This preserved buying pressure drives the positive drift property.
Statement: For a ProfitMaxi order with
Proof:
Let initial reserves be
After buy of
Taylor expansion for small
Result: Price change is second-order negligible.
Statement: For
Proof:
For delta ratio
Result:
Statement: Given buy arrivals as a Poisson process with rate
Proof:
By the Strong Law of Large Numbers, cumulative matched volume:
Since this limit is positive:
Expected Fill Time:
| Delta Ratio |
Price Impact | Fill Time | Use Case |
|---|---|---|---|
| 1.0 | Minimal (~0%) | Fastest | Stealth exit |
| 0.8 | +6% drift | 1.25x slower | Balanced |
| 0.5 | +22% drift | 2x slower | Price support |
| 0.3 | +53% drift | 3.3x slower | Maximum support |
We conducted Monte Carlo simulation with 500 iterations per delta ratio, modeling:
- Pool: 1B tokens / 500 SOL (~$100k liquidity)
- Order: 50 SOL exit (5% of liquidity)
- Buy Flow: Poisson process, λ=5 buys/step, mean 0.5 SOL
- Threshold: 0.05 SOL minimum
| Delta Ratio | Mean Price Δ | Std Dev | Fill Time | Fill Rate |
|---|---|---|---|---|
| r = 1.0 | +1.02% | 0.80% | 15.2 steps | 100% |
| r = 0.8 | +6.02% | 0.70% | 18.7 steps | 100% |
| r = 0.5 | +22.07% | 0.83% | 29.9 steps | 100% |
| r = 0.3 | +53.36% | 1.04% | 49.1 steps | 100% |
The empirical results confirm all three theorems:
- Theorem 1: r=1.0 shows near-zero impact (1.02% residual from execution sequencing)
- Theorem 2: Price drift scales nonlinearly with (1-r) due to compounding
- Theorem 3: 100% fill rate achieved across all configurations
┌─────────────────────────────────────────────────────────────┐
│ ORDER LIFECYCLE │
├─────────────────────────────────────────────────────────────┤
│ │
│ CREATE ACTIVE EXECUTING COMPLETE │
│ ┌──────┐ ┌──────┐ ┌──────┐ ┌──────┐ │
│ │ User │──────▶│Escrow│────────▶│Shards│──────▶│Filled│ │
│ │ Init │ │Tokens│ │ N │ │ │ │
│ └──────┘ └──────┘ └──────┘ └──────┘ │
│ │ │ │ │ │
│ │ │ │ │ │
│ │ ▼ │ │ │
│ │ ┌──────┐ │ │ │
│ └────────▶│Cancel│◀────────────┘ │ │
│ │Return│ │ │
│ └──────┘ │ │
└─────────────────────────────────────────────────────────────┘
| Parameter | Type | Description |
|---|---|---|
total_size |
u64 | Total order value in quote lamports |
delta_ratio_bps |
u16 | Participation rate (1-10000 bps) |
min_threshold |
u64 | Minimum buy size to trigger |
status |
enum | Active / Filled / Cancelled |
- Trigger Detection: Keeper monitors AMM for buys ≥ threshold
- Shard Calculation:
sell_amount = min(r × buy_amount, remaining) - Atomic Execution: CPI swap from escrow via AMM program
- State Update: Decrement remaining, emit event
- Repeat: Continue until remaining = 0
┌─────────────────────────────────────────────────────────────┐
│ SYSTEM ARCHITECTURE │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌────────────────┐ ┌────────────────┐ │
│ │ USER WALLET │ │ PROFITMAXI │ │
│ │ │───────▶│ PROGRAM │ │
│ │ - Create │ │ │ │
│ │ - Cancel │ │ - Order PDAs │ │
│ │ - Update │ │ - Escrow ATAs │ │
│ └────────────────┘ │ - Execution │ │
│ └───────┬────────┘ │
│ │ │
│ ┌────────────────┐ │ │
│ │ KEEPER NETWORK │ │ │
│ │ │◀──────────────┘ │
│ │ - Monitor AMM │ │
│ │ - Detect Buys │ ┌────────────────┐ │
│ │ - Execute CPI │───────▶│ AMM POOLS │ │
│ │ │ │ (Raydium/Orca)│ │
│ └────────────────┘ └────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘
Account Structure:
pub struct Order {
pub owner: Pubkey, // 32 bytes
pub token_mint: Pubkey, // 32 bytes
pub total_size: u64, // 8 bytes
pub remaining: u64, // 8 bytes
pub delta_ratio_bps: u16, // 2 bytes
pub min_threshold: u64, // 8 bytes
pub escrow_ata: Pubkey, // 32 bytes
pub status: OrderStatus, // 1 byte
pub bump: u8, // 1 byte
}Instructions:
create_order: Initialize order, escrow tokensexecute_shard: Keeper-triggered partial fillcancel_order: Return escrowed tokensupdate_order: Modify parameters
Keepers monitor AMM pools and trigger execution. Multiple strategies:
- Websocket Monitoring: Real-time account subscriptions
- Log Parsing: Subscribe to AMM program logs
- Geyser Plugins: Direct node access (institutional)
- Clockwork: Decentralized on-chain automation
Execution submitted via Jito bundles to prevent:
- Front-running by other keepers
- Sandwich attacks on ProfitMaxi sells
- Failed transaction spam
| Fee Type | Amount | Recipient |
|---|---|---|
| Order Creation | 0.01 SOL | Protocol |
| Execution (per shard) | 0.1% of sell | Keeper |
| Cancellation | Free | - |
Keeper profitability depends on:
- Volume: Higher AMM volume = more triggers
- Competition: More keepers = faster execution but lower individual rewards
- Gas Costs: ~5000 lamports per execution
Expected Keeper Revenue:
At scale, protocol revenue from creation fees:
Without ProfitMaxi:
- 50 SOL position exit → ~25% price impact → 12.5 SOL lost to slippage
With ProfitMaxi (r=1.0):
- 50 SOL position exit → ~1% price impact → 0.5 SOL lost
- Savings: 12 SOL (96% reduction in impact)
| Risk | Mitigation |
|---|---|
| Escrow theft | PDA-controlled ATAs, owner-only cancel |
| Reentrancy | Checks-effects-interactions pattern |
| Integer overflow | Checked math, Rust safety |
| Oracle manipulation | No external price oracle dependency |
Griefing Attack: Malicious actor sends many small buys to trigger execution.
- Mitigation:
min_thresholdparameter filters dust
Keeper Collusion: Keepers front-run or delay execution.
- Mitigation: Jito bundles, multiple competing keepers
AMM Manipulation: Attacker manipulates pool before execution.
- Mitigation: Atomic execution within same block
- Keeper Liveness: Orders depend on active keepers
- Network Congestion: May delay execution during high load
- AMM Changes: Protocol upgrades may break CPI
ProfitMaxi introduces a novel order type that addresses a critical gap in decentralized finance: the ability to exit large positions without destroying price. By responding to market demand rather than arbitrary schedules, ProfitMaxi enables:
- Stealth Exits: Minimal chart impact for sellers
- Price Support: Configurable positive drift for projects
- Trustless Execution: Fully on-chain, keeper-incentivized
- Retail Accessibility: Institutional-grade execution for all
The mathematical foundations are sound, empirically validated, and the architecture is implementable with current Solana primitives. We anticipate significant adoption among:
- Project teams managing treasury/team allocations
- Early investors seeking low-impact exits
- Market makers managing inventory
- DAOs liquidating holdings
- Multi-pool support (cross-DEX execution)
- Dynamic delta ratio adjustment based on conditions
- Integration with token launch platforms
- Governance token for protocol upgrades
-
Angeris, G., Kao, H. T., Chiang, R., Noyes, C., & Chitra, T. (2020). An analysis of Uniswap markets.
-
Adams, H., Zinsmeister, N., Salem, M., Keefer, R., & Robinson, D. (2021). Uniswap v3 Core.
-
Daian, P., Goldfeder, S., Kell, T., Li, Y., Zhao, X., Bentov, I., ... & Juels, A. (2020). Flash boys 2.0: Frontrunning in decentralized exchanges, miner extractable value, and consensus instability.
-
Moallemi, C. C., & Roughgarden, T. (2023). Optimal Execution in Decentralized Finance.
-
Park, A. (2021). The Conceptual Flaws of Constant Product Automated Market Making.
Full simulation code available at: [GitHub Repository]
Complete program interface available at: [GitHub Repository]
TypeScript keeper service reference at: [GitHub Repository]
Contact:
Justin Liverman (d3f4ult)
Mezzanine DAO
[Website] | [Twitter] | [Discord]
This document is provided for informational purposes only and does not constitute financial advice. Smart contract interactions carry inherent risks.