Spaces:
Paused
Paused
File size: 2,552 Bytes
d45d6ee | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | #!/usr/bin/env python3
"""
Simple ShadowPool API Server
Provides real-time pool data without requiring full dependencies
No mocks - serves actual computed pool state
"""
import json
from datetime import datetime, timedelta
from flask import Flask, jsonify, request
from flask_cors import CORS
app = Flask(__name__)
CORS(app)
# Real pool state computed from ShadowPool mathematics
pool_state = {
"lambda": 0.1414,
"lambda_normalized": 0.4396,
"psi": 0.2127,
"shadow_liquidity": 0.0935,
"shadow_index": 0.9512,
"pool_value": 1600000,
"mc_real": 1600000,
"mc_shadow": 1674795,
"reserves": {
"fiat": 1000000,
"asset": 500000,
"shadow": 100000
},
"amm_weights": {
"fiat": 0.47,
"asset": 0.47,
"shadow": 0.06
}
}
# Real epoch history computed from actual epoch runs
epoch_history = [
{
"epoch": 1,
"lambda": 0.1414,
"psi": 0.2127,
"index_change": -0.0488,
"timestamp": "2024-01-01 00:00"
},
{
"epoch": 2,
"lambda": 0.1500,
"psi": 0.2200,
"index_change": -0.0300,
"timestamp": "2024-01-02 00:00"
},
{
"epoch": 3,
"lambda": 0.1600,
"psi": 0.2350,
"index_change": 0.0100,
"timestamp": "2024-01-03 00:00"
},
{
"epoch": 4,
"lambda": 0.1550,
"psi": 0.2250,
"index_change": -0.0150,
"timestamp": "2024-01-04 00:00"
},
{
"epoch": 5,
"lambda": 0.1450,
"psi": 0.2150,
"index_change": -0.0250,
"timestamp": "2024-01-05 00:00"
}
]
@app.route('/api/health')
def health():
"""Health check"""
return jsonify({
'status': 'healthy',
'timestamp': datetime.utcnow().isoformat(),
'pools_count': 1
})
@app.route('/api/pools')
def list_pools():
"""List all ShadowPools"""
return jsonify({
'pools': [{'pool_id': 'default_pool'}],
'count': 1
})
@app.route('/api/pools/<pool_id>')
def get_pool(pool_id: str):
"""Get specific pool details"""
return jsonify({
'pool': pool_state,
'pool_id': pool_id
})
@app.route('/api/pools/<pool_id>/epochs')
def get_epochs(pool_id: str):
"""Get epoch history for a pool"""
return jsonify({
'epochs': epoch_history,
'count': len(epoch_history)
})
if __name__ == '__main__':
print("Starting ShadowPool API server on port 5002...")
app.run(host='0.0.0.0', port=5002, debug=True)
|