The Autonomous Creator Fee Pipeline
Stonkerage turns onchain meme and stock coin trading fees into a perpetual capital flywheel. Every swap on StonkFun generates trading fees that are automatically swept, converted, bridged cross-chain to HyperCore, and deployed into an isolated leveraged perpetual position with automated take-profit harvesting.
Visual Execution Flow
1. StonkFun Fee Accrual
Tokens launched on Stonkerage run on StonkFun LaunchLab utilizing Raydium Token-2022 pools. Each pool incurs a flat trading fee on every swap:
The keeper polls StonkFun's public API (/api/public/v1/tokens/:mint/fees).
For auto-forwarding pools, balances landing in the creator's wallet are automatically detected and staged.
2. Gas & Operational Reserves
Autonomous agents often fail because cross-chain bridging or transaction fees exhaust the operator's native balance. Stonkerage prevents this with strict mathematical reserve invariants:
50,000,000 lamports (0.05 SOL) plus a 0.005 SOL per-transaction gas buffer.
Any incoming swap proceeds first refill any deficit in this gas reserve before a single lamport is allocated for cross-chain bridging.
const deficit = Math.max(0n, SOL_MIN_OPERATIONAL_RESERVE - currentBalance);
const refill = BigInt(Math.min(Number(deficit), Number(incomingLamports)));
const bridgeLamports = incomingLamports - refill;
3. Jupiter Auto-Swap Routing
When launched tokens are paired against xStocks, USDC, or third-party SPL tokens, the keeper routes the accrued quote tokens through Jupiter Ultra v6 DEX aggregator to swap into native SOL or USDC.
4. Mayan Cross-Chain Bridge to HyperCore
Mayan Finance connects Solana liquidity directly to HyperCore L1 (Hyperliquid). Fees leaving Solana are converted into spot USDC credited directly to the coin's derived EVM clearinghouse account.
- Destination Floor: Expected net output must be ≥ $10.00 USDC.
- Maximum Fee Ratio: Total bridging and relayer fees must not exceed 15% of the input value.
5. HyperCore Spot Transfer (usdClassTransfer)
Bridged funds arrive on HyperCore as spot USDC. On Hyperliquid, spot balances do not automatically back perpetual positions.
The keeper issues an authenticated usdClassTransfer action signed by the token's isolated EVM key:
const spotUsdc = await hlClient.getSpotUsdcBalance(evmAccount.address);
if (spotUsdc >= 1.00) {
await hlClient.usdClassTransfer(evmAccount, spotUsdc, true);
tpStore.addContribution(mint, spotUsdc);
}
6. Leverage Snapping & Top-Up Sizing
When new margin arrives, the keeper calculates the exact size to add so that the position snaps precisely to the target leverage ratio without ever exceeding it.
targetEquity = currentEquity + usableMargin
desiredSizeBase = (targetEquity × targetLeverage) / markPrice
additionalSizeBase = Math.max(0, desiredSizeBase - currentSizeBase)
marginFeeBufferBps = 200 (2.0%) is withheld as liquid buffer to absorb Hyperliquid taker fees (0.035%) and order slippage.
Multi-Hop Fee Reservation Matrix
Summary of all safety buffers reserved across each hop in the pipeline:
| Stage | Mechanism | Reserved Amount | Safety Guarantee |
|---|---|---|---|
| Solana Keeper Gas | calculateSolGasReserve() | 0.05 SOL permanent | Keeper never runs out of gas |
| Solana Tx Fees | SOLANA_MIN_TX_LAMPORTS | 0.005 SOL buffer | Priority fee spike absorption |
| Jupiter DEX Swap | swapTokenToSol() | 1.5% max slippage | Prevents sandwich / MEV attacks |
| Mayan Bridge | validateMayanBridgeFees() | ≤ 15% fee ratio | Rejects uneconomic bridge quotes |
| HyperCore Sweep | usdClassTransfer() | ≥ $1.00 floor | Prevents zero-value API calls |
| Perp Execution | computeTopUp() | 2.0% fee margin | Covers 0.035% taker fee & slippage |
Take-Profit Engine (Autonomous Flywheel)
Stonkerage integrates an autonomous mathematical take-profit flywheel. Positions are not held indefinitely; as positions gain value, profit milestones trigger automated profit-taking.
Frozen Milestone Basis
When a milestone is active, activeMilestoneBasisUsd freezes the dollar capital basis.
If ongoing StonkFun trading volume injects additional fee margin into the position while a milestone is in progress,
the profit goalpost is not pushed further away. Only true trading profit satisfies the target.
Deterministic CLOID & Idempotency
Each milestone derives a unique deterministic Client Order ID:
deriveTakeProfitCloid(mint, completedMilestones).
If the keeper restarts or retries during an order execution, it checks the exchange status of that CLOID. If already filled,
it simply advances the milestone state without placing a duplicate order.
Withdrawable Delta Measurement
To avoid rounding or pricing discrepancies, the keeper brackets the reduce-only close order with reads of
getWithdrawable() before and after.
The diff represents the exact dollar proceeds freed up and recorded as realized profit.
Non-Custodial Design & Key Derivation
Tokens are created directly by the user's connected wallet (Phantom, Solflare) using Solana Token-2022. Raydium CP-Swap pool instructions are partially signed by the user and finalized onchain without any custodial intermediaries.
Each token mint address generates a distinct, non-overlapping Hyperliquid EVM private key using HMAC-SHA256:
evmAccount = privateKeyToAccount(privKey)
Because each token trades under its own isolated clearinghouse account, a liquidation in one token's position can never affect or cross-collateralize any other token.