Most DeFi projects try to sell directly to retail users. DeFiKit took a different bet: sell the trading infrastructure underneath — the strategy execution engine, the Solana on-chain settlement, the real-time signal streaming — as a white-label API that exchanges, fintech apps, and trading platforms can license and resell to their own users. The result is a B2B sales channel that generates recurring API revenue while distributing DeFiKit's trading capabilities through every partner's existing user base.
The Problem
Every trading platform wants to offer automated trading strategies to its users — stop-loss automation, grid trading, DCA bots, arbitrage signals. But building a reliable on-chain execution engine requires deep Solana expertise, constant mainnet monitoring, robust retry logic, and integration with Jupiter, Drift, and every major Solana DEX. Most platforms don't have the resources or risk tolerance to build this in-house.
The alternatives are worse. Licensing a whitelabel solution typically means locking into a single vendor's brand and infrastructure. Building via smart contract templates alone misses the off-chain infrastructure — WebSocket signal delivery, latency-optimized order routing, comprehensive rate limiting, and per-user usage metering. The gap between "a smart contract that trades" and "a production automated trading service" is enormous.
DeFiKit recognized this gap as a sales channel opportunity. Instead of competing with every platform for retail users, DeFiKit could become the infrastructure layer that powers their automated trading features.
The Solution
DeFiKit's Institutional API Partnership Program lets exchanges, fintech apps, and trading platforms license the full trading strategy execution engine via API. Partners get:
- **White-label interface**: The trading dashboard, strategy builder, and portfolio view are fully reskinnable — no DeFiKit branding unless desired.
- **API-first execution**: REST endpoints for strategy creation, modification, and cancellation, plus real-time WebSocket streams for price signals and order status.
- **On-chain settlement**: Every executed strategy settles through DeFiKit's Solana programs, with partner-specific program IDs for auditability and revenue attribution.
- **Revenue share billing**: Metered usage billed to the partner, who sets their own pricing for end users. DeFiKit handles the infrastructure, the partner handles the go-to-market.
Partners integrate once via API key and immediately offer automated trading to their user base. DeFiKit gains distribution through every partner's marketing, support, and onboarding flows — a true B2B sales channel with zero customer acquisition cost on DeFiKit's side.
Architecture
The infrastructure is designed for multi-tenant isolation at every layer. Here's the component breakdown:
| Layer | Component | Technology | Purpose |
|---|---|---|---|
| Gateway | API Gateway | Cloudflare Workers | Auth, rate limiting, request routing, tier enforcement |
| Auth | API Key Validation | Cloudflare Workers + D1 | Key lookup, permission scoping, partner-level tier checks |
| Execution | Strategy Engine | Cloudflare Workers + durable objects | Strategy lifecycle: create, monitor, execute, cancel |
| Streaming | Real-time Signals | Cloudflare Workers + WebSocket | Push price data, strategy triggers, order confirmations |
| Storage | Partner Config | D1 (SQLite on SQLite-backed Workers) | Per-partner settings: program IDs, fee schedules, whitelist rules |
| On-chain | Settlement | Solana Program (Rust) | Trade execution, position management, revenue split |
| Metering | Usage Tracking | D1 + Cloudflare Cron Triggers | Per-API-key call volume, duration, compute cost attribution |
**Data flow**: Partner client → Cloudflare Worker (API key check + rate limit) → Strategy Execution Worker → On-chain signal via Solana RPC → Order execution confirmed → WebSocket push back to partner's user → Usage record written to D1 → Monthly billing reconciliation.
Implementation
Deploying the API partnership program follows four steps.
Step 1: API Key Authentication
Every partner receives a unique API key. All requests must pass the `X-DeFiKit-API-Key` header. Cloudflare Workers validate the key against D1 on every request, checking key status (active/suspended), tier limits, and expiration.
```bash
curl -X POST https://api.defikit.io/v1/strategies \
-H "X-DeFiKit-API-Key: dk_partner_abc123def456" \
-H "Content-Type: application/json" \
-d '{
"type": "grid_trading",
"pair": "SOL-USDC",
"upper_price": 180.50,
"lower_price": 150.00,
"grid_count": 10,
"total_investment": "1000"
}'
```
Step 2: Real-Time Signal Streaming via WebSocket
Partners subscribe to real-time trading signals and strategy status updates. The WebSocket endpoint authenticates on connect using the API key as a query parameter, then streams JSON-encoded events.
```javascript
const ws = new WebSocket(
"wss://stream.defikit.io/v1/signals?api_key=dk_partner_abc123def456"
);
ws.onopen = () => {
console.log("Connected to DeFiKit signal stream");
ws.send(JSON.stringify({
action: "subscribe",
channel: "strategies",
program_id: "DeFiKitABC123..."
}));
};
ws.onmessage = (event) => {
const signal = JSON.parse(event.data);
// signal.type: "trigger", "execution", "confirmation", "error"
// signal.payload: contains order details, prices, tx signatures
console.log("Strategy signal received:", signal);
routeToPartnerUser(signal.partner_user_id, signal);
};
ws.onerror = (err) => {
console.error("Stream error, reconnecting in 1s...", err);
setTimeout(() => reconnect(), 1000);
};
```
Step 3: Usage Metering with D1
Every API call, WebSocket connection minute, and on-chain transaction is metered and stored in D1. This powers per-partner billing, rate limit enforcement, and partner analytics dashboards.
```sql
-- D1 usage metering query: aggregate monthly usage per partner
SELECT
p.partner_id,
p.name,
DATE_TRUNC('month', u.timestamp) AS billing_month,
COUNT(DISTINCT u.api_key_id) AS active_api_keys,
SUM(u.request_count) AS total_api_calls,
SUM(u.ws_duration_seconds) / 3600 AS total_ws_hours,
SUM(u.tx_count) AS onchain_transactions,
SUM(u.tx_count * p.tx_fee_lamports) / 1e9 AS total_tx_fees_sol
FROM usage_records u
JOIN partners p ON u.partner_id = p.partner_id
WHERE u.timestamp >= datetime('now', '-30 days')
GROUP BY p.partner_id, billing_month
ORDER BY total_api_calls DESC;
```
Step 4: Rate Limiting Middleware
Each partner tier (Starter, Growth, Enterprise) has configurable rate limits. The Cloudflare Worker middleware checks usage against limits from D1 before proxying requests.
```javascript
// Cloudflare Worker rate limiting middleware
export default {
async fetch(request, env) {
const apiKey = request.headers.get("X-DeFiKit-API-Key");
if (!apiKey) {
return new Response(JSON.stringify({ error: "Missing API key" }), {
status: 401,
headers: { "Content-Type": "application/json" }
});
}
// Look up partner config from D1
const partner = await env.DB.prepare(
"SELECT * FROM partners WHERE api_key = ? AND status = 'active'"
).bind(apiKey).first();
if (!partner) {
return new Response(JSON.stringify({ error: "Invalid or inactive API key" }), {
status: 403,
headers: { "Content-Type": "application/json" }
});
}
// Check rate limit for this partner's tier
const windowKey = `ratelimit:${partner.tier}:${apiKey}`;
const current = await env.KV.get(windowKey) || "0";
const limits = { starter: 100, growth: 1000, enterprise: 10000 };
const limit = limits[partner.tier] || 100;
if (parseInt(current) >= limit) {
return new Response(JSON.stringify({
error: "Rate limit exceeded",
tier: partner.tier,
limit,
retry_after: 60
}), {
status: 429,
headers: { "Content-Type": "application/json", "Retry-After": "60" }
});
}
// Increment counter with 60-second TTL
await env.KV.put(windowKey, String(parseInt(current) + 1), { expirationTtl: 60 });
// Forward to strategy execution handler with partner context
request.partner = partner;
return await handleStrategyRequest(request, env);
}
};
```
Results
DeFiKit launched the API Partnership Program in Q1 2025 with three pilot partners. After six months of operation, the results validate the B2B infrastructure-as-a-service model:
| Metric | Baseline (Pre-Program) | Current | Growth |
|---|---|---|---|
| Active partners | 0 | 17 | — |
| Partner onboarding velocity | — | 2.8 partners/month | Accelerating (3.7 in Q3) |
| Total API call volume | 0 | 4.2M requests/month | 37% MoM |
| WebSocket connections (peak) | 0 | 8,400 concurrent | 52% MoM |
| On-chain strategies executed | 0 | 214,000/month | 41% MoM |
| Revenue per partner (avg) | $0 | $12,400/month | Up 28% QoQ |
| Enterprise partners ($50k+/mo) | 0 | 4 | — |
| Partner churn | — | 0% (0 partners lost) | — |
The revenue contribution is particularly significant. At $12,400 average monthly revenue per partner and 17 partners, the program generates approximately $210,800/month in recurring API revenue — with gross margins above 85% since the marginal cost of additional API calls is negligible on Cloudflare Workers and Solana compute.
Partner acquisition velocity continues to increase. The program closed 3 new partners in Q2 and is on track for 5 in Q3, driven by referrals from existing partners and growing awareness of white-label DeFi infrastructure as a distribution strategy.
Key Takeaways
1. **Infrastructure is a sales channel.** When your product is hard to build and easy to integrate, license it. Each partner's user base becomes your distribution without marketing spend.
2. **Multi-tenant isolation at the Worker level works.** Cloudflare Workers with D1 per-partner config storage gives each partner their own virtual instance without the operational overhead of per-partner deployments.
3. **Revenue share aligns incentives.** Partners set their own pricing and keep the margin above DeFiKit's usage-based billing. This removes price resistance and encourages partners to aggressively promote automated trading to their users.
4. **Program IDs create auditability.** Each partner gets unique Solana program IDs, making on-chain revenue attribution trivial and building trust with compliance-conscious institutional partners.
5. **Zero churn is achievable with infrastructure licensing.** Once a partner integrates the API and their users depend on the strategy engine, switching costs are high. The 0% churn rate after six months confirms that infrastructure stickiness outlasts feature-based differentiation.