Documentation complète pour utiliser l'API Obelisk et les fonctionnalités avancées
| Plan | Icon | Description | Coût |
|---|---|---|---|
basic |
🔔 | Alerte seulement à 80% du seuil de liquidation | Gratuit |
standard |
🛡️ | Ajout automatique de collateral à 85% | 0.2%/mois |
premium |
👑 | Fermeture automatique à 90% + garantie remboursement | 0.5%/mois |
// Via l'API JavaScript
PerpsModule.api.enableProtection('pos-123456', 'standard');
// Ou directement
PerpsModule.setPositionProtection('pos-123456', true, 'premium');
// Via l'API
PerpsModule.api.disableProtection('pos-123456');
// Ou directement
PerpsModule.setPositionProtection('pos-123456', false);
// Upgrade vers Premium
PerpsModule.api.changePlan('pos-123456', 'premium');
// Downgrade vers Basic
PerpsModule.upgradeProtectionPlan('pos-123456', 'basic');
// Activer protection sur TOUTES les positions
PerpsModule.api.enableAllProtection('standard');
// Désactiver sur toutes les positions
PerpsModule.api.disableAllProtection();
// Liste des positions avec protection active
const protected = PerpsModule.api.getProtected();
console.log(protected);
// Résultat:
// [{ id: 'pos-123', symbol: 'BTC/USDC', liqProtection: true, liqProtectionPlan: 'standard', ... }]
// Position avec protection activée
const result = await PerpsModule.openPosition('BTC/USDC', 'long', 0.01, 10, {
takeProfit: 100000,
stopLoss: 90000,
liqProtection: true,
liqProtectionPlan: 'standard'
});
console.log(result);
// { success: true, position: {...}, action: 'opened' }
PerpsModule.closePosition('pos-123456');
// Notification: "Position closed: +$123.45 (15.2% ROE)"
const positions = PerpsModule.api.getPositions();
// ou
const positions = PerpsModule.positions;
const pos = PerpsModule.api.getPosition('pos-123456');
API REST disponible sur http://localhost:3001. Permet l'intégration de bots externes et le trading programmatique via le moteur de perps interne.
| Méthode | Endpoint | Description |
|---|---|---|
| POST | /api/trade/order |
Placer un ordre (market/limit) |
| GET | /api/trade/positions |
Lister les positions ouvertes |
| GET | /api/trade/fees |
Frais par venue |
| GET | /api/trade/route |
Smart routing - meilleure venue pour un trade |
| GET | /api/trade/history |
Historique des trades |
| GET | /api/markets |
Prix et marchés disponibles (36 coins) |
| GET | /health |
Santé du serveur |
// POST /api/trade/order
const res = await fetch('http://localhost:3001/api/trade/order', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
symbol: 'BTC/USDC',
side: 'buy', // 'buy' ou 'sell'
size: 5, // Taille en $
leverage: 2, // Levier (max 3x pour bots)
type: 'market', // 'market' ou 'limit'
sl: 0, // Stop loss (0 = désactivé)
tp: 0, // Take profit (0 = désactivé)
source: 'mixbot', // Identifiant du bot (route vers perps interne)
strategy: 'momentum', // Nom de la stratégie
})
});
const data = await res.json();
// { success: true, orderId: "PERP_...", exchange: "obelisk-internal", price: 63057.45 }
// GET /api/trade/positions
const res = await fetch('http://localhost:3001/api/trade/positions');
const data = await res.json();
// { positions: [{ coin: "BTC", side: "buy", size: 5, entryPrice: 63057, pnl: {...} }] }
// GET /api/markets
const res = await fetch('http://localhost:3001/api/markets');
const data = await res.json();
// { markets: [{ pair: "BTC/USDC", price: 97250.50 }, { pair: "ETH/USDC", price: 2650.30 }, ...] }
Les ordres avec source: 'mixbot' sont automatiquement routés vers le moteur de perps interne (ObeliskPerps). Les autres ordres utilisent le smart router vers les venues externes (GMX, dYdX, Morpher, etc.) basé sur les frais les plus bas.
Système de capital dédié pour bots externes. Chaque bot a son propre compte avec equity, marge et suivi PnL en temps réel.
Le moteur interne ObeliskPerps dispose d'un pool de liquidité de $100K USDC avec 36 coins supportés. Les bots tradent contre cette liquidité avec des prix réels (Binance WebSocket).
| Paramètre | Valeur |
|---|---|
| Pool de liquidité | $100,000 USDC |
| Coins supportés | 36 (BTC, ETH, SOL, ARB, OP, AVAX, LINK, ...) |
| Leverage max bots | 3x |
| Prix | Temps réel via Binance WebSocket |
| Frais | 0.04% taker |
| Funding rate | Calculé toutes les 8h |
| Méthode | Endpoint | Description |
|---|---|---|
| GET | /api/trade/equity?venue=mixbot |
Equity, marge disponible, positions, PnL total |
| GET | /api/trade/venue/positions?venue=mixbot |
Positions ouvertes avec PnL temps réel |
| POST | /api/trade/venue/close |
Fermer une position venue |
| POST | /api/trade/venue/deposit |
Déposer du capital |
| GET | /api/trade/venue/stats |
Statistiques du venue (ROI, trades, fees) |
// GET /api/trade/equity?venue=mixbot
const res = await fetch('http://localhost:3001/api/trade/equity?venue=mixbot');
const data = await res.json();
// Réponse:
// {
// "equity": 5.00,
// "freeCollateral": 5.00,
// "positions": [],
// "totalPnl": 0,
// "totalFees": 0.002,
// "totalTrades": 12,
// "initialCapital": 5,
// "dailyDrawdown": 0.5
// }
// POST /api/trade/venue/close
const res = await fetch('http://localhost:3001/api/trade/venue/close', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
venue: 'mixbot',
coin: 'BTC',
side: 'sell', // Côté inverse pour fermer
size: 5
})
});
const data = await res.json();
// { success: true, exchange: "obelisk-internal", price: 97300.50, pnl: 0.23, fee: 0.002 }
// POST /api/trade/venue/deposit
const res = await fetch('http://localhost:3001/api/trade/venue/deposit', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
venue: 'mixbot',
amount: 10 // Ajouter $10 au capital
})
});
// { success: true, equity: 15.00 }
// GET /api/trade/venue/stats?venue=mixbot
const res = await fetch('http://localhost:3001/api/trade/venue/stats?venue=mixbot');
const data = await res.json();
// {
// "id": "mixbot",
// "name": "MixBot",
// "equity": 5.23,
// "initialCapital": 5,
// "totalPnl": 0.23,
// "totalFees": 0.04,
// "totalTrades": 12,
// "openPositions": 0,
// "roi": "4.60%"
// }
// Exemple: bot qui trade via l'API REST Obelisk
const API = 'http://localhost:3001';
async function botTrade() {
// 1. Vérifier l'equity
const equity = await fetch(`${API}/api/trade/equity?venue=mixbot`).then(r => r.json());
console.log(`Equity: $${equity.equity} | Free: $${equity.freeCollateral}`);
if (equity.freeCollateral < 3) {
console.log('Marge insuffisante, skip');
return;
}
// 2. Ouvrir un trade
const order = await fetch(`${API}/api/trade/order`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
symbol: 'ETH/USDC', side: 'buy', size: 5,
leverage: 2, source: 'mixbot', strategy: 'momentum'
})
}).then(r => r.json());
if (order.success) {
console.log(`Opened ETH LONG @ $${order.price} via ${order.exchange}`);
}
// 3. Attendre... puis fermer
const close = await fetch(`${API}/api/trade/venue/close`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ venue: 'mixbot', coin: 'ETH', side: 'sell', size: 5 })
}).then(r => r.json());
console.log(`Closed ETH | PnL: $${close.pnl?.toFixed(2)}`);
}
botTrade();
| Protection | Description |
|---|---|
| Equity minimum | Bloque les trades si equity < $3 |
| Max positions | 1 position ouverte par venue (configurable) |
| Max leverage | 3x maximum pour les bots |
| Daily drawdown | Coupe le trading si perte > 3% du capital journalier |
| Anti-race lock | Empêche les ordres simultanés sur le même venue |
| Marge requise | Vérifie que la marge est disponible avant chaque trade |
| Module | Description |
|---|---|
PerpsModule | Trading perpetuals |
DCAVaultModule | Dollar Cost Average automatique |
WhaleTrackerModule | Tracker les gros portefeuilles |
AirdropHunterModule | Tracker les airdrops |
CryptoPayroll | Paiements B2B/B2C |
LiquidationProtectionModule | Protection standalone |
SmartYieldRouterModule | Auto-routage yield |
NFTCollateralModule | Prêts contre NFTs |
GasOptimizerModule | Optimisation gas |
AutoRebalancerModule | Rééquilibrage portfolio |
DCAVaultModule.createPlan({
asset: 'BTC',
amount: 100, // $100 par exécution
frequency: 'weekly' // daily, weekly, biweekly, monthly
});
// Exécuter manuellement
DCAVaultModule.executeDCA('dca-123456');
CryptoPayroll.addRecipient('company-123', {
name: 'John Doe',
wallet: '0x123...',
salary: 5000,
type: 'b2c', // b2b ou b2c
frequency: 'weekly', // daily, weekly, biweekly, monthly
paymentCurrency: 'USDC'
});
window.addEventListener('obelisk:protection-changed', (e) => {
console.log('Protection changed:', e.detail);
// { positionId, enabled, plan, position }
});
// Observer les changements dans PerpsModule.positions
const observer = setInterval(() => {
const positions = PerpsModule.positions;
// Votre logique ici
}, 1000);
// Surveiller et protéger automatiquement
let lastCount = PerpsModule.positions.length;
setInterval(() => {
const currentCount = PerpsModule.positions.length;
if (currentCount > lastCount) {
// Nouvelle position détectée
const newPos = PerpsModule.positions[PerpsModule.positions.length - 1];
if (!newPos.liqProtection) {
PerpsModule.setPositionProtection(newPos.id, true, 'standard');
console.log(`🛡️ Auto-protected: ${newPos.symbol}`);
}
}
lastCount = currentCount;
}, 1000);
function generateProtectionReport() {
const positions = PerpsModule.positions;
const protected = positions.filter(p => p.liqProtection);
const unprotected = positions.filter(p => !p.liqProtection);
console.log('=== PROTECTION REPORT ===');
console.log(`Total positions: ${positions.length}`);
console.log(`Protected: ${protected.length}`);
console.log(`Unprotected: ${unprotected.length}`);
console.log('\n📋 Protected positions:');
protected.forEach(p => {
console.log(` ${p.liqProtectionPlan === 'basic' ? '🔔' : p.liqProtectionPlan === 'standard' ? '🛡️' : '👑'} ${p.symbol} - ${p.liqProtectionPlan}`);
});
if (unprotected.length > 0) {
console.log('\n⚠️ Unprotected positions:');
unprotected.forEach(p => {
console.log(` ❌ ${p.symbol} - Liq: $${p.liquidationPrice.toFixed(2)}`);
});
}
}
generateProtectionReport();
// Si vous avez un serveur backend, exposez l'API
// Côté client - Envoyer l'état au backend
async function syncToBackend() {
const data = {
positions: PerpsModule.positions,
protected: PerpsModule.api.getProtected()
};
await fetch('https://your-api.com/sync', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data)
});
}
// Webhook sur changement de protection
window.addEventListener('obelisk:protection-changed', async (e) => {
await fetch('https://your-api.com/webhook/protection', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(e.detail)
});
});
# Vérifier la santé du serveur
curl http://localhost:3001/health
# Equity MixBot
curl http://localhost:3001/api/trade/equity?venue=mixbot
# Positions ouvertes
curl http://localhost:3001/api/trade/venue/positions?venue=mixbot
# Prix des marchés
curl http://localhost:3001/api/markets
# Ouvrir un trade BTC LONG $5 x2
curl -X POST http://localhost:3001/api/trade/order \
-H "Content-Type: application/json" \
-d '{"symbol":"BTC/USDC","side":"buy","size":5,"leverage":2,"source":"mixbot","strategy":"test"}'
# Fermer le trade
curl -X POST http://localhost:3001/api/trade/venue/close \
-H "Content-Type: application/json" \
-d '{"venue":"mixbot","coin":"BTC","side":"sell","size":5}'
# Stats du venue
curl http://localhost:3001/api/trade/venue/stats?venue=mixbot
Ouvrez la console du navigateur (F12) et testez les commandes!