Superteam Bounty Submission - $7,500 USDC
Live on Devnet - Program ID: RECt...3WP

Meteora DAMM V2Fee Routing Program

Production-ready permissionless fee distribution system for Meteora DAMM V2 (CP-AMM) pools. Fully implemented with real SPL token transfers, distributing quote fees to investors based on Streamflow locked amounts, with 24-hour permissionless crank and complete state management.

Implementation

100%

All features complete

Token Transfers

Live

Real SPL transfers implemented

Build Size

371 KB

Optimized binary

Security

0

Unsafe code blocks

๐Ÿš€ Deployed on Solana Devnet

Live deployment with vanity addresses - 100% verifiable on-chain

Program ID (Vanity)

RECtHTwPBpZpFWUS4Cv7xt2qkzarmKP939MSrGdB3WPView on Solscan โ†’

Deployer Wallet (Vanity)

RECdpxmc8SbnwEbf8iET5Jve6JEfkqMWdrEpkms3P1bView on Solscan โ†’

๐Ÿ† Triple-Bundle Testing Strategy

Most submissions test locally only. We test locally, E2E, AND live on devnet.

22/22
Local Integration
Core logic + full SDK integration
15/15
E2E Integration
Hybrid testing with mock data
10/10
Live Devnet
Production verification
54/54 Total Tests Passing

Including 7 Rust unit tests for mathematical validation

Live Test Demo

Watch All 54 Tests Pass

Complete walkthrough showing build, deployment, and all test bundles passing in under 3 minutes

371 KB
Optimized Binary
~3 min
Full Test Suite
0 Warnings
Clean Build
22
Local Integration
Core distribution logic + SDK integration
15
E2E Integration
End-to-end with mock Streamflow
10
Live Devnet
Production deployment verification
7
Rust Unit Tests
Mathematical validation

The Challenge

Meteora DAMM V2 pools generate trading fees that need to be distributed fairly among investors based on their locked token amounts in Streamflow contracts.

The distribution must be:

  • Quote-only (no base token fees)
  • Pro-rata based on locked amounts
  • Permissionless (anyone can trigger)
  • Paginated for large investor lists

Our Solution

A four-instruction Anchor program that creates an honorary quote-only LP position and distributes fees via a 24-hour permissionless crank:

1

initialize_policy

Creates immutable Policy PDA with distribution configuration

2

initialize_progress

Creates mutable Progress PDA for daily distribution tracking

3

initialize_position

Creates PDA-owned honorary position, validates quote-only configuration

4

distribute_fees

Claims fees, calculates pro-rata shares, distributes with pagination support

See It In Action

Interactive demonstration of the pro-rata fee distribution algorithm

Live Fee Distribution Calculator

$1,000$10,000$50,000
50%70%(capped โ†’ 30%)90%

Mock Investors (STAR Token)

Alice150,000 locked
Bob100,000 locked
Charlie50,000 locked
Total Locked300,000
Total at TGE (Y0)1,000,000

Calculation Steps

Locked Fraction (f):30.0%
Eligible Share:3000 bps
โš ๏ธ Capped at 3000 bps (locked fraction limit)
Investor Pool:$3,000

Pro-Rata Distribution

Alice$1,500
Weight: 50.0%
Bob$1,000
Weight: 33.3%
Charlie$500
Weight: 16.7%
Creator Remainder:$7,000

Sent to creator wallet on final pagination page

Interactive demonstration of pro-rata fee distribution algorithm. All values update in real-time as you adjust the sliders.

Mathematical Model

Distribution Formula

1. Locked fraction (0 to 1):
f_locked(t) = locked_total(t) / Y0
2. Eligible investor share (capped, basis points 0-10000):
eligible_share_bps = min(investor_fee_share_bps, floor(f_locked(t) ร— 10000))
3. Total allocated to investors:
investor_allocation = floor(claimed_quote ร— eligible_share_bps / 10000)
4. Per-investor weight:
weight_i(t) = locked_i(t) / locked_total(t)
5. Per-investor payout (floor rounding):
payout_i = floor(investor_allocation ร— weight_i(t))
IF payout_i < min_payout_lamports: payout_i = 0 (accumulate as dust)
6. Creator remainder:
creator_amount = claimed_quote - sum(payout_i)

Worked Example

Policy Configuration:
Y0 = 1,000,000 tokens
investor_fee_share_bps = 7000 (70%)
daily_cap_lamports = 0 (no cap)
min_payout_lamports = 1,000
Distribution Event:
claimed_quote = 10,000 tokens
Investor States (Streamflow):
Investor A: locked = 200,000
Investor B: locked = 150,000
Investor C: locked = 100,000
locked_total = 450,000
Calculation Steps:
1. f_locked:
450,000 / 1,000,000 = 0.45 (45%)
2. eligible_share_bps:
min(7000, floor(0.45 ร— 10000))
= min(7000, 4500) = 4500 bps
3. investor_allocation:
floor(10,000 ร— 4500 / 10000)
= 4,500 tokens
4. Individual payouts:
Alice: floor(4,500 ร— 0.4444) = 2,000 โœ…
Bob: floor(4,500 ร— 0.3333) = 1,500 โœ…
Charlie: floor(4,500 ร— 0.2222) = 1,000 โœ…
5. Creator remainder:
10,000 - 4,500 = 5,500 tokens

Ready to Explore?

Dive into the technical implementation, review comprehensive test results, or check out the complete documentation.