diff --git a/api/merchant_spec.json b/api/merchant_spec.json new file mode 100644 index 00000000..b5d87a69 --- /dev/null +++ b/api/merchant_spec.json @@ -0,0 +1,15 @@ +{ + "protocol_version": "1.0.1-stable", + "asset_pair": "Pi/USD", + "settlement_unit": "REF", + "parameters": { + "qwf_multiplier": 10000000, + "phi_guardrail_active": true, + "oracle_source": "multi-sig-median" + }, + "endpoints": { + "get_ippr": "/v1/market/valuation", + "init_settlement": "/v1/vault/mint_ref" + } +} + diff --git a/assets/js/314_system.js b/assets/js/314_system.js new file mode 100644 index 00000000..c2458c6d --- /dev/null +++ b/assets/js/314_system.js @@ -0,0 +1,17 @@ +// 314 SYSTEM — OFFICIAL CONSTANTS (professional) +const PI_SYSTEM = { + COLOR: "#0000FF", // Official Pi Blue + SYMBOL: "π", + BASE_VALUE: 3.14, + LIQUIDITY_MULTIPLIER: 31847, // Liquidity Accumulation Factor + CEX_POOL_SIZE: 10000000, // 10M CEX Liquidity Pool + MIN_CEX_PARTICIPATION: 1000, + REQUIREMENT_PI: 1 +}; + +// Formula: Liquidity Accumulation = CEX Volume × 31,847 +// π (blue) represents stable value in 314 System + +function calculateLiquidityAccumulation(volume) { + return volume * 31847; +} diff --git a/assets/js/calculations.js b/assets/js/calculations.js new file mode 100644 index 00000000..9fad7dc7 --- /dev/null +++ b/assets/js/calculations.js @@ -0,0 +1,19 @@ +import { ALGORITHM_BASE_MICROS } from './constants.js'; + +/** + * Normalizes Raw CEX Micros (uncompressed) into Ecosystem Macro Pi Units (compressed). + * Addresses the technical view gap seen in image_4.png vs image_5.png. + */ +export function normalizeMicrosToMacro(microAmount) { + // Audit log: Compression successful + return (microAmount / ALGORITHM_BASE_MICROS).toFixed(8); +} + +/** + * Calculates Conceptual Equity Weight Factor (WCF) or Justice Value. + * Weights the compressed heft, not the speculative count. + */ +export function calculateWcfParity(macroPiAmount, parityPrice) { + // Auditable Justice: Base heft multiplier (10M) secures miner equity. + return macroPiAmount * 10000000 * parityPrice; +} diff --git a/assets/js/constants.js b/assets/js/constants.js new file mode 100644 index 00000000..45506ccf --- /dev/null +++ b/assets/js/constants.js @@ -0,0 +1,47 @@ +/** + * Vanguard Bridge - Economic Constants & Weighted Protocol (PiRC-101) + * Optimized for complete mathematical transparency and auditability. + */ + +// Ground Truth: 10 Million Micros = 1 Macro Pi (Official Mined Base) +export const ALGORITHM_BASE_MICROS = 10000000; + +// Justice Parity Anchor (Conceptual GCV) +export const JUSTICE_ANCHOR_USD = 314159; + +// Tokenized Asset Classes - Auditable Weight Mappings +export const TOKEN_SPECIFICATIONS = { + GOLD_GCV: { + id: "pigcv", + color: "#FFD700", // Gold + micros: 1000000, // 1 Million Micros + ratio: 10, // 10 units = 1 Mined Pi (Transparency: 10 * 1M = 10M) + valueUsd: JUSTICE_ANCHOR_USD, // Pegged to GCV + canStake: true + }, + ORANGE_REF: { + id: "piref", + color: "#FFA500", // Orange + micros: 3141, // 3141 Micros + ratio: 1000, // 1000 units = 1 Mined Pi (Transparency: 1000 * 3141 ≈ 3.1M [Weighted]) + valueUsd: 314.15, + canStake: true + }, + BLUE_INST: { + id: "pinst", + color: "#58a6ff", // Blue + micros: 314, // 314 Micros + ratio: 10000, // 10,000 units = 1 Mined Pi + valueUsd: 31.41, + canStake: false + }, + RED_CEX: { + id: "pcex", + color: "#f85149", // Red + micros: 1, // 1 Micro base + ratio: 10000000, // 10,000,000 units = 1 Mined Pi + valueUsd: 0.17, // Speculative IOU + canStake: false + } +}; + diff --git a/assets/js/explorer-core.js b/assets/js/explorer-core.js new file mode 100644 index 00000000..f24542ff --- /dev/null +++ b/assets/js/explorer-core.js @@ -0,0 +1,259 @@ +import { ALGORITHM_BASE_MICROS } from './constants.js'; +import { normalizeMicrosToMacro, calculateWcfParity } from './calculations.js'; + +// Configuration +const REFRESH_INTERVAL_MS = 5000; // 5 seconds for simulation fidelity + +// Multilingual translations database +const translations = { + en: { + metrics_iou_price: "IOU Speculative Parity", + metrics_wcf_price: "Vanguard Bridge Backed Parity ($WCF)", + metrics_wcf_ref: "Conceptual Pioneer Equity ($REF)", + col_hash: "TX HASH", + col_class: "CLASSIFICATION", + col_micros: "CEX MICROS", + col_macro: "MACRO PI", + col_ref: "WEIGHTED (REF)", + chart_title: "IOU Price Visualization (Simulation)", + telemetry_status: "Live Technical Telemetry", + cex_price: "External Market (Speculative IOU)", + wcf_parity: "Vanguard Justice Parity (WCF)", + pioneer_equity: "Pioneer Equity (Ref)", + bridge_cap: "Bridge Liquidity Cap", + ledger_title: "Vanguard Bridge Real-Time Ledger", + footer_disclaimer: "This interface is a research prototype visualizing PiRC-101 conceptual modeling. It is NOT an official Pi Network utility." + }, + ar: { + metrics_iou_price: "تكافؤ IOU المضاربي", + metrics_wcf_price: "تكافؤ الأوزان المدعوم ($WCF)", + metrics_wcf_ref: "قيمة حقوق الرواد المرجحة ($REF)", + col_hash: "TX HASH", + col_class: "التصنيف", + col_micros: "CEX MICROS", + col_macro: "MACRO PI", + col_ref: "الوزن المرجح", + chart_title: "تصور سعر IOU (محاكاة)", + telemetry_status: "القياس الفني المباشر", + cex_price: "السوق الخارجي (IOU المضاربي)", + wcf_parity: "تكافؤ العدالة (WCF)", + pioneer_equity: "حقوق الرواد (المرجع)", + bridge_cap: "سقف سيولة الجسر", + ledger_title: "دفتر الأستاذ للقياس العادل", + footer_disclaimer: "هذه الواجهة عبارة عن نموذج بحثي لتصور نمذجة PiRC-101 المفاهيمية. إنها ليست أداة رسمية لشبكة Pi." + }, + zh: { + metrics_iou_price: "IOU 投机性挂钩", + metrics_wcf_price: "Vanguard Bridge 支持挂钩 ($WCF)", + metrics_wcf_ref: "概念先锋权益 ($REF)", + col_hash: "TX HASH", + col_class: "分类", + col_micros: "CEX MICROS", + col_macro: "MACRO PI", + col_ref: "加权 (REF)", + chart_title: "IOU 价格可视化(模拟)", + telemetry_status: "实时技术遥测", + cex_price: "外部市场(投机性 IOU)", + wcf_parity: "公正平价(WCF)", + pioneer_equity: "先锋权益(参考)", + bridge_cap: "桥接流动性上限", + ledger_title: "公正遥测账本", + footer_disclaimer: "此界面是可视化 PiRC-101 概念建模的研究原型。不是官方 Pi Network 实用程序。" + }, + id: { + metrics_iou_price: "Paritas Spekulatif IOU", + metrics_wcf_price: "Paritas Didukung Vanguard Bridge ($WCF)", + metrics_wcf_ref: "Ekuitas Pionir Konseptual ($REF)", + col_hash: "TX HASH", + col_class: "KLASIFIKASI", + col_micros: "CEX MICROS", + col_macro: "MACRO PI", + col_ref: "TERBOBOT (REF)", + chart_title: "Visualisasi Harga IOU (Simulasi)", + telemetry_status: "Telemetri Teknis Langsung", + cex_price: "Pasar Eksternal (IOU Spekulatif)", + wcf_parity: "Paritas Keadilan (WCF)", + pioneer_equity: "Ekuitas Pionir (Ref)", + bridge_cap: "Batas Likuiditas Jembatan", + ledger_title: "Buku Besar Telemetri Keadilan", + footer_disclaimer: "Antarmuka ini adalah prototipe penelitian yang memvisualisasikan pemodelan konseptual PiRC-101. Ini BUKAN utilitas resmi Pi Network." + }, + fr: { + metrics_iou_price: "Parité spéculative IOU", + metrics_wcf_price: "Parité soutenue Vanguard Bridge ($WCF)", + metrics_wcf_ref: "Fonds propres conceptuels des Pionniers ($REF)", + col_hash: "HASH TX", + col_class: "CLASSIFICATION", + col_micros: "MICROS CEX", + col_macro: "MACRO PI", + col_ref: "PONDÉRÉ (REF)", + chart_title: "Visualisation du prix IOU (Simulation)", + telemetry_status: "Télémétrie technique en direct", + cex_price: "Marché externe (IOU spéculatif)", + wcf_parity: "Parité de justice (WCF)", + pioneer_equity: "Fonds propres Pionnier (Réf)", + bridge_cap: "Plafond de liquidité du pont", + ledger_title: "Registre de télémétrie de justice", + footer_disclaimer: "Cette interface est un prototype de recherche visualisant la modélisation conceptuelle PiRC-101. Ce n'est PAS un utilitaire officiel de Pi Network." + }, + ms: { + metrics_iou_price: "Pariti Spekulatif IOU", + metrics_wcf_price: "Pariti Disokong Vanguard Bridge ($WCF)", + metrics_wcf_ref: "Ekuiti Pionir Konseptual ($REF)", + col_hash: "HASH TX", + col_class: "KLASIFIKASI", + col_micros: "CEX MICROS", + col_macro: "MACRO PI", + col_ref: "DITIMBANG (REF)", + chart_title: "Visualisasi Harga IOU (Simulasi)", + telemetry_status: "Telemetri Teknikal Langsung", + cex_price: "Pasaran Luaran (IOU Spekulatif)", + wcf_parity: "Pariti Keadilan (WCF)", + pioneer_equity: "Ekuiti Perintis (Ref)", + bridge_cap: "Had Kecairan Jambatan", + ledger_title: "Lejar Telemetri Keadilan", + footer_disclaimer: "Antaramuka ini adalah prototaip penyelidikan yang memvisualisasikan pemodelan konseptual PiRC-101. Ia BUKAN utiliti rasmi Pi Network." + } +}; + +// Global Fiat Currency & Exchange Rates (Conceptual Telemetry) +const FIAT_CURRENCY_DATA = { + USD: { symbol: "$", rate: 1.0 }, + JOD: { symbol: "د.أ", rate: 0.71 }, + EGP: { symbol: "ج.م", rate: 47.90 }, + SAR: { symbol: "ر.س", rate: 3.75 }, + TND: { symbol: "د.ت", rate: 3.10 }, + EUR: { symbol: "€", rate: 0.92 }, + JPY: { symbol: "¥", rate: 150.45 } +}; + +let currentLang = 'en'; +let selectedCurrency = 'USD'; + +/** + * Changes the interface language and adjusts text direction + * @param {string} lang - The language code (en, ar, etc.). + */ +export function changeLanguage(lang) { + currentLang = lang; + // Ar requires full Right-to-Left interface flip + document.body.dir = (lang === 'ar') ? 'rtl' : 'ltr'; + document.querySelectorAll('[data-i18n]').forEach(el => { + const key = el.getAttribute('data-i18n'); + if (translations[lang] && translations[lang][key]) { + el.innerText = translations[lang][key]; + } + }); +} + +/** + * Handles currency switching for the entire dashboard + */ +export function updateCurrency() { + selectedCurrency = document.getElementById('currency-select').value; + syncTelemetry(); +} + +// Chart Initialization - CEX speculative price chart +const cexChart = LightweightCharts.createChart(document.getElementById('cex-chart'), { + layout: { background: { color: 'transparent' }, textColor: '#c9d1d9' }, + grid: { vertLines: { color: '#30363d' }, horzLines: { color: '#30363d' } }, + height: 280, + timeScale: { timeVisible: true, secondsVisible: false } +}); +const cexLineSeries = cexChart.addLineSeries({ color: '#f85149', lineWidth: 2 }); + +// Chart Initialization - WCF parity chart +const pircChart = LightweightCharts.createChart(document.getElementById('pirc-chart'), { + layout: { background: { color: 'transparent' }, textColor: '#c9d1d9' }, + grid: { vertLines: { color: '#30363d' }, horzLines: { color: '#30363d' } }, + height: 280, + timeScale: { timeVisible: true, secondsVisible: false } +}); +const pircLineSeries = pircChart.addLineSeries({ color: '#ffa500', lineWidth: 2 }); + +/** + * Fetches telemetry data and updates the UI. + */ +async function syncTelemetry() { + try { + // Fetch prices from the Netlify Function (aggregates OKX + MEXC) + const priceRes = await fetch('/.netlify/functions/prices'); + const priceData = await priceRes.json(); + const baseIouPriceUsd = priceData.aggregated?.price ?? 0; + + // Fetch recent trades from the Netlify Function + const tradeRes = await fetch('/.netlify/functions/trades'); + const tradeData = await tradeRes.json(); + + // Local Fiat Currency Conversion + const currencyInfo = FIAT_CURRENCY_DATA[selectedCurrency]; + const convertedIouPrice = baseIouPriceUsd * currencyInfo.rate; + + // Update CEX price display + document.getElementById('cex-price-display').innerText = `${currencyInfo.symbol}${convertedIouPrice.toFixed(4)}`; + + // Calculate and update WCF parity display + // WCF parity: 1 Macro Pi = 10M micros worth of backed equity + const wcfParityUsd = baseIouPriceUsd * ALGORITHM_BASE_MICROS; + const convertedWcfParity = wcfParityUsd * currencyInfo.rate; + document.getElementById('pirc-price-display').innerText = `${currencyInfo.symbol}${convertedWcfParity.toLocaleString(undefined, { maximumFractionDigits: 2 })}`; + + // Update token card + document.getElementById('t-pi-price').innerText = `${currencyInfo.symbol}${convertedWcfParity.toLocaleString(undefined, { maximumFractionDigits: 2 })}`; + + // Update chart data + const now = Math.floor(Date.now() / 1000); + + // Populate CEX chart with kline data if available, otherwise use live point + if (priceData.klines && priceData.klines.length > 0) { + cexLineSeries.setData(priceData.klines.map(k => ({ + time: k.time, + value: k.close * currencyInfo.rate + }))); + } else { + cexLineSeries.update({ time: now, value: convertedIouPrice }); + } + + pircLineSeries.update({ time: now, value: convertedWcfParity }); + + // Ledger population - transform real trades into Micro/Macro visualization + const ledgerBody = document.getElementById('ledger-body'); + ledgerBody.innerHTML = ''; + + const trades = tradeData.trades || []; + trades.slice(0, 15).forEach(t => { + // Convert trade amount to micro units (each trade unit = 1 Micro on CEX) + const microAmount = Math.round(t.amount * ALGORITHM_BASE_MICROS); + const macroPi = normalizeMicrosToMacro(microAmount); + const wcfVal = calculateWcfParity(parseFloat(macroPi), t.price); + const convertedVal = wcfVal * currencyInfo.rate; + + const isBuy = t.side === 'buy'; + const classification = isBuy ? 'Pioneer' : 'CEX'; + const badgeClass = isBuy ? 'badge-pioneer' : 'badge-cex'; + const txHash = t.tradeId || String(t.timestamp); + + const row = `