Volume-Sensitive Limit Orders for AMM Liquidity Pools
ProfitMaxi is a novel order type that enables large position exits with minimal price impact by matching sell execution proportionally to incoming buy volume.
Traditional limit orders execute based on price or time. ProfitMaxi orders execute based on volume.
Traditional Market Sell (50 SOL position):
├── Single transaction
├── Price impact: -25%
└── Loss: 12.5 SOL
ProfitMaxi Exit (50 SOL position, r=1.0):
├── Multiple shards matched to buys
├── Price impact: -1%
└── Loss: 0.5 SOL
└── Savings: 12 SOL (96% reduction)
| Delta Ratio | Behavior | Use Case |
|---|---|---|
| r = 1.0 (100%) | Price neutral | Stealth exit, minimal chart impact |
| r = 0.8 (80%) | +6% positive drift | Balanced approach |
| r = 0.5 (50%) | +22% positive drift | Strong price support |
| r = 0.3 (30%) | +53% positive drift | Maximum pump while exiting |
For each qualifying buy of size B:
sell_amount = min(B × r, remaining_order)
Where:
B= incoming buy volumer= delta ratio (0.01 to 1.0)remaining= unfilled order size
profitmaxi-sol/
├── programs/profitmaxi/ # Anchor smart contract
│ └── src/
│ ├── lib.rs # Program entry point
│ ├── state.rs # Account structures
│ ├── instructions/ # Instruction handlers
│ └── utils.rs # Math utilities
├── sdk/ # TypeScript SDK
│ └── src/
│ ├── client.ts # Main client
│ ├── amm/ # Multi-DEX adapters
│ │ ├── raydium.ts # Raydium V4/CPMM
│ │ ├── pumpswap.ts # PumpSwap (pump.fun)
│ │ ├── meteora.ts # Meteora DLMM
│ │ └── aggregator.ts # Pool discovery & ranking
│ └── types.ts
└── keeper/ # Keeper service
└── src/
└── multi-dex-keeper.ts
ProfitMaxi monitors and executes across multiple AMMs:
| Protocol | Type | Fee | Status |
|---|---|---|---|
| Raydium V4 | CPMM | 0.25% | ✅ Supported |
| Raydium CPMM | CPMM | 0.25% | ✅ Supported |
| PumpSwap | CPMM | 1.0% | ✅ Supported |
| Meteora DLMM | DLMM | Variable | ✅ Supported |
| Orca Whirlpool | CLMM | Variable | 🔜 Coming |
For each token, ProfitMaxi automatically selects the primary pool based on:
- Liquidity (40% weight) - Higher liquidity = better execution
- Age (30% weight) - Older pools = more established
- Volume (20% weight) - Higher volume = more active
- Fees (10% weight) - Lower fees = better returns
- Rust 1.70+
- Solana CLI 1.17+
- Anchor 0.29+
- Node.js 18+
# Clone repository
git clone https://github.com/mezzanine-dao/profitmaxi-sol
cd profitmaxi-sol
# Build Anchor program
anchor build
# Install SDK dependencies
cd sdk && npm install && npm run build
# Install keeper dependencies
cd ../keeper && npm install && npm run build# Deploy to devnet
anchor deploy --provider.cluster devnet
# Deploy to mainnet
anchor deploy --provider.cluster mainnetimport { ProfitMaxiClient } from '@profitmaxi/sdk';
import { Connection, Keypair } from '@solana/web3.js';
import BN from 'bn.js';
const connection = new Connection('https://api.mainnet-beta.solana.com');
const client = new ProfitMaxiClient({ connection });
// Create a volume-sensitive limit order
const tx = await client.createOrder({
totalSize: new BN(50_000_000_000), // 50 SOL worth
deltaRatioBps: 8000, // 80% (r=0.8)
minThreshold: new BN(100_000_000), // 0.1 SOL minimum buy
tokenMint: TOKEN_MINT,
quoteMint: WSOL_MINT,
ammPool: POOL_ADDRESS,
ammProgram: RAYDIUM_PROGRAM_ID,
});# Set environment variables
export RPC_ENDPOINT="https://your-rpc-endpoint.com"
export KEEPER_PRIVATE_KEY="[your,keypair,bytes]"
export DRY_RUN="true" # Set to false for live execution
# Start keeper
cd keeper && npm run start# .env
RPC_ENDPOINT=https://api.mainnet-beta.solana.com
KEEPER_PRIVATE_KEY=[...]
POLL_INTERVAL=1000
MIN_PROFIT=10000
DRY_RUN=true
MIN_POOL_LIQUIDITY=100000000000
JITO_ENDPOINT=https://mainnet.block-engine.jito.wtfFor delta ratio r = 1.0, the net price impact approaches zero:
ΔP/P₀ = O(ε²)
Where ε = B/y₀ (trade size / pool depth).
For r = 1 - δ where δ > 0:
ΔP/P₀ ≈ (1-r) × B/y₀ > 0
Lower delta ratios create sustained upward price pressure.
Given Poisson buy arrivals (rate λ > 0, mean size B̄ > 0), order fills with probability 1:
E[t_fill] = T / (r × λ × B̄_θ)
- MEV Protection: Use Jito bundles for execution
- Slippage: Dynamic slippage based on pool depth
- Oracle Risk: No oracle dependency (uses AMM reserves)
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
# Run tests
anchor test
# Run SDK tests
cd sdk && npm test
# Lint
npm run lintMIT License - see LICENSE
- Whitepaper - Full technical specification
- API Reference - SDK documentation
- Keeper Guide - Running a keeper node
- Built on Anchor
- Inspired by TradFi POV algorithms
- Community feedback from Mezzanine DAO
Author: Justin Liverman
Twitter: @_d3f4ult
Organization: @MezzanineDAO
Contact: d3f4ult@apolloalgo.ai