Credit Swaps: Building Multi-Currency Economies
How to use credit swaps to enable users to exchange between different credit types, creating rich in-app economies.
By cred.diy Team

Most applications start with a single credit type. But as your platform grows, you may need multiple currencies – compute credits, storage credits, premium tokens. Credit swaps let users exchange between these types, creating a dynamic internal economy.
Why Multiple Credit Types?
Use Cases
- AI Platform: Separate credits for text generation, image creation, and embeddings
- Gaming: Gold coins, gems, and energy tokens with different acquisition paths
- Marketplace: Seller credits, buyer credits, and promotional tokens
- SaaS: API credits, storage credits, and support tokens
Benefits
- Granular pricing – charge differently for different resource types
- Promotional flexibility – give free credits for one type without affecting others
- Revenue optimization – premium credit types can have higher margins
- User choice – let users allocate resources to what matters to them
Setting Up Swap Pairs
Create Your Credit Types
First, define the credit types you'll support:
const creditTypes = [
{ name: "Compute Credits", symbol: "CC", exchange_rate: 0.01 },
{ name: "Storage Credits", symbol: "SC", exchange_rate: 0.005 },
{ name: "Premium Tokens", symbol: "PT", exchange_rate: 0.05 }
];
Configure Swap Pairs
Create swap pairs in Dashboard → Swaps: pick the source and target credit types, the exchange rate, an optional fee, minimum and maximum amounts, and whether the pair works in both directions. Your app then discovers them through the API:
const listSwapPairs = async (sourceType) => {
const response = await fetch(
`https://eutdgemlrpvnxfkkpvlu.supabase.co/functions/v1/credits-api/swap-pairs?source_credit_type_id=${sourceType}`,
{
headers: { 'x-api-key': process.env.CRED_API_KEY }
}
);
const { swap_pairs } = await response.json();
return swap_pairs;
// [{ id, exchange_rate, fee_percent, min_swap_amount, max_swap_amount, is_bidirectional, ... }]
};
Exchange Rate Types
| Type | Description | Best For |
|---|---|---|
| Fixed | Constant rate (e.g., 1:2) | Stable, predictable economies |
| Dynamic | Rates adjust based on supply/demand | Gaming, marketplaces |
Executing Swaps
Basic Swap
const executeSwap = async (userId, swapPairId, sourceAmount) => {
const response = await fetch(
'https://eutdgemlrpvnxfkkpvlu.supabase.co/functions/v1/credits-api/swap',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': process.env.CRED_API_KEY
},
body: JSON.stringify({
user_id: userId,
swap_pair_id: swapPairId,
source_amount: sourceAmount
})
}
);
return response.json();
// { success: true, source_amount: 100, target_amount: 195, exchange_rate: 2, fee_amount: 5, ... }
};;
Preview Swap (Get Quote)
Let users see what they'll receive before confirming:
// No API call needed: the pair from GET /swap-pairs has everything
const previewSwap = (pair, sourceAmount) => {
const gross = sourceAmount * pair.exchange_rate;
const fee = gross * (pair.fee_percent / 100);
return { you_receive: gross - fee, fee_amount: fee };
// previewSwap({ exchange_rate: 2, fee_percent: 2.5 }, 100)
// → { you_receive: 195, fee_amount: 5 }
};;
Designing Your Economy
Setting Exchange Rates
Consider the real cost behind each credit type:
Compute Credits: $0.01 each (backed by GPU costs)
Storage Credits: $0.005 each (backed by disk costs)
Exchange rate: 1 CC = 2 SC (reflecting cost ratio)
Swap Fees
Fees serve multiple purposes:
- Revenue generation: Earn on every swap transaction
- Economy stabilization: Discourage excessive arbitrage
- Behavioral nudging: Higher fees on premium→basic swaps
Recommended Fee Ranges
| Swap Direction | Fee | Reasoning |
|---|---|---|
| Basic → Basic | 1-3% | Encourage flexibility |
| Basic → Premium | 3-5% | Moderate friction |
| Premium → Basic | 5-10% | Discourage downgrading |
Building a Swap UI
Key Components
- Source selector: Choose which credits to swap from
- Amount input: How many credits to swap
- Rate display: Show the current exchange rate
- Fee breakdown: Transparent fee calculation
- Target preview: Show expected received amount
- Confirm button: Execute the swap
UX Best Practices
- Show real-time balance updates
- Display the exchange rate prominently
- Warn when swapping will deplete a balance
- Add a confirmation step for large swaps
- Show transaction history for past swaps
Monitoring Your Economy
Track these metrics to keep your economy healthy:
- Swap volume: Total swaps per day/week
- Popular pairs: Which swaps happen most
- Fee revenue: Income from swap fees
- Balance distribution: How users allocate across types
- Arbitrage detection: Unusual circular swap patterns
Conclusion
Credit swaps transform a simple credit system into a rich, flexible economy. By letting users exchange between credit types, you create a more engaging platform while generating additional revenue through swap fees.
Set up your first swap pair in the dashboard.

What Does One Credit Buy? Design Packages Customers Can Actually Compare
A Q4 2026 pricing guide to clear usage units, honest package comparisons, sustainable volume discounts, and fewer surprises at checkout.

Monthly Credits or Pay As You Go? Build Both Without Two Billing Systems
An October 2026 guide to combining recurring credit allowances with one-off top-ups, explicit cancellation, and invoice-based renewals in Cred.