Capital Allocation
Every deposit into StableFX is governed by the 50/50 capital allocation model. Half of each deposit is allocated to active trading capital, and the other half is distributed across the three liquidity pools (clearing, hedging, insurance) to maintain settlement guarantees.
FOREX_CAPITAL_SPLIT Constant
import { FOREX_CAPITAL_SPLIT } from '@one_deploy/sdk';
// FOREX_CAPITAL_SPLIT = 0.5
// This means 50% trading, 50% pool reserves
The constant is a number between 0 and 1 representing the fraction allocated to pool reserves. The remainder (1 - FOREX_CAPITAL_SPLIT) goes to active trading capital.
const deposit = 10_000; // $10,000 USDC
const tradingCapital = deposit * (1 - FOREX_CAPITAL_SPLIT);
// tradingCapital = 5,000
const poolReserves = deposit * FOREX_CAPITAL_SPLIT;
// poolReserves = 5,000
computePoolAllocations Utility
The computePoolAllocations function takes a total deposit amount and returns the exact allocation for each pool and the trading capital portion.
Function Signature
import { computePoolAllocations } from '@one_deploy/sdk';
interface PoolAllocations {
/** Amount allocated to active trading. */
tradingCapital: number;
/** Amount allocated to the clearing pool. */
clearingPool: number;
/** Amount allocated to the hedging pool. */
hedgingPool: number;
/** Amount allocated to the insurance pool. */
insurancePool: number;
/** Total pool reserves (clearing + hedging + insurance). */
totalReserves: number;
/** The original deposit amount. */
totalDeposit: number;
}
function computePoolAllocations(deposit: number): PoolAllocations;
Pool Reserve Distribution
The 50% pool reserve portion is further split across the three pools with fixed weights:
| Pool | Weight | Share of Reserves |
|---|---|---|
| Clearing | 50% | 25% of total deposit |
| Hedging | 30% | 15% of total deposit |
| Insurance | 20% | 10% of total deposit |
Basic Example
import { computePoolAllocations } from '@one_deploy/sdk';
const allocations = computePoolAllocations(10_000);
console.log(allocations);
// {
// tradingCapital: 5000,
// clearingPool: 2500, // 50% of reserves
// hedgingPool: 1500, // 30% of reserves
// insurancePool: 1000, // 20% of reserves
// totalReserves: 5000,
// totalDeposit: 10000,
// }
React Native -- Display Allocations
import React from 'react';
import { View, Text, StyleSheet } from 'react-native';
import { computePoolAllocations, FOREX_CAPITAL_SPLIT } from '@one_deploy/sdk';
interface AllocationDisplayProps {
depositAmount: number;
}
function AllocationDisplay({ depositAmount }: AllocationDisplayProps) {
const alloc = computePoolAllocations(depositAmount);
return (
<View style={styles.container}>
<Text style={styles.header}>Capital Allocation</Text>
<Text style={styles.subtitle}>
Split ratio: {((1 - FOREX_CAPITAL_SPLIT) * 100).toFixed(0)}% trading
/ {(FOREX_CAPITAL_SPLIT * 100).toFixed(0)}% reserves
</Text>
<View style={styles.row}>
<Text style={styles.label}>Total Deposit</Text>
<Text style={styles.value}>${alloc.totalDeposit.toLocaleString()}</Text>
</View>
<View style={styles.divider} />
<View style={styles.row}>
<Text style={styles.label}>Trading Capital</Text>
<Text style={styles.value}>${alloc.tradingCapital.toLocaleString()}</Text>
</View>
<View style={styles.divider} />
<Text style={styles.sectionTitle}>Pool Reserves</Text>
<View style={styles.row}>
<Text style={styles.label}>Clearing Pool (50%)</Text>
<Text style={styles.value}>${alloc.clearingPool.toLocaleString()}</Text>
</View>
<View style={styles.row}>
<Text style={styles.label}>Hedging Pool (30%)</Text>
<Text style={styles.value}>${alloc.hedgingPool.toLocaleString()}</Text>
</View>
<View style={styles.row}>
<Text style={styles.label}>Insurance Pool (20%)</Text>
<Text style={styles.value}>${alloc.insurancePool.toLocaleString()}</Text>
</View>
<View style={styles.divider} />
<View style={styles.row}>
<Text style={[styles.label, styles.bold]}>Total Reserves</Text>
<Text style={[styles.value, styles.bold]}>
${alloc.totalReserves.toLocaleString()}
</Text>
</View>
</View>
);
}
const styles = StyleSheet.create({
container: { padding: 16, backgroundColor: '#1a1a2e', borderRadius: 12 },
header: { fontSize: 18, fontWeight: '700', color: '#ffffff', marginBottom: 4 },
subtitle: { fontSize: 13, color: '#8888aa', marginBottom: 16 },
sectionTitle: { fontSize: 14, fontWeight: '600', color: '#ccccdd', marginBottom: 8 },
row: { flexDirection: 'row', justifyContent: 'space-between', marginBottom: 8 },
label: { fontSize: 14, color: '#aaaacc' },
value: { fontSize: 14, color: '#ffffff', fontFamily: 'monospace' },
bold: { fontWeight: '700' },
divider: { height: 1, backgroundColor: '#2a2a4e', marginVertical: 12 },
});
Allocation Calculation -- Step by Step
For a deposit of $20,000 USDC:
Step 1: Apply FOREX_CAPITAL_SPLIT (0.5)
Trading capital = $20,000 * (1 - 0.5) = $10,000
Pool reserves = $20,000 * 0.5 = $10,000
Step 2: Distribute pool reserves
Clearing pool = $10,000 * 0.50 = $5,000
Hedging pool = $10,000 * 0.30 = $3,000
Insurance pool = $10,000 * 0.20 = $2,000
Verification:
$10,000 + $5,000 + $3,000 + $2,000 = $20,000 (matches deposit)
Using Allocations with Investments
When creating a forex investment, the allocation is computed automatically. You can preview the allocation before the user confirms:
import React, { useState } from 'react';
import { View, Text, TextInput, TouchableOpacity } from 'react-native';
import {
computePoolAllocations,
useForexInvestments,
} from '@one_deploy/sdk';
function InvestmentPreview() {
const [amount, setAmount] = useState('');
const { createInvestment } = useForexInvestments();
const deposit = parseFloat(amount) || 0;
const alloc = computePoolAllocations(deposit);
const handleConfirm = async () => {
if (deposit <= 0) return;
await createInvestment({
amount: deposit,
currencyPair: 'EUR/USD',
cycle: '7d',
});
};
return (
<View>
<TextInput
value={amount}
onChangeText={setAmount}
placeholder="Enter deposit amount (USDC)"
keyboardType="numeric"
/>
{deposit > 0 && (
<View style={{ marginTop: 16 }}>
<Text>Trading: ${alloc.tradingCapital.toLocaleString()}</Text>
<Text>Clearing: ${alloc.clearingPool.toLocaleString()}</Text>
<Text>Hedging: ${alloc.hedgingPool.toLocaleString()}</Text>
<Text>Insurance: ${alloc.insurancePool.toLocaleString()}</Text>
</View>
)}
<TouchableOpacity onPress={handleConfirm}>
<Text>Confirm Investment</Text>
</TouchableOpacity>
</View>
);
}
Edge Cases
| Scenario | Behavior |
|---|---|
deposit = 0 | All allocations return 0. |
deposit < 0 | Throws an Error('Deposit amount must be non-negative'). |
| Very small deposits (< $1) | Allocations are computed with full floating-point precision. |
| Non-numeric input | TypeScript compiler prevents this; runtime throws if coercion fails. |
Next Steps
- Pool System -- understand how each pool uses its allocated capital.
- Creating Investments -- create positions with automatic allocation.
- Pool Metrics -- track how pool reserves perform over time.