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