UntitledFinancial commited on
Commit
587d47d
Β·
0 Parent(s):

Initial commit: DPX Protocol Gradio demo

Browse files
Files changed (3) hide show
  1. README.md +33 -0
  2. app.py +227 -0
  3. requirements.txt +2 -0
README.md ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: DPX Protocol
3
+ emoji: 🌐
4
+ colorFrom: gray
5
+ colorTo: slate
6
+ sdk: gradio
7
+ sdk_version: 4.44.0
8
+ app_file: app.py
9
+ pinned: false
10
+ license: other
11
+ short_description: Live demo of DPX β€” compliance-grade stablecoin settlement rail
12
+ ---
13
+
14
+ # DPX Protocol β€” Live Settlement Infrastructure
15
+
16
+ Compliance-grade stablecoin settlement rail for cross-border payments. Any agent can discover, price, and execute settlements autonomously via the MCP server or REST API.
17
+
18
+ **Live infrastructure:**
19
+ - Settlement quotes backed by the Stability Oracle (9-layer signal architecture, 25+ institutional sources)
20
+ - ESG counterparty scoring updated hourly (6 institutional sources: World Bank, IMF, OECD, UN, SEC, ClimateMonitor)
21
+ - FX corridor risk assessment across 10 major currency pairs
22
+ - FATF Travel Rule compliant Β· MiCA Β· GENIUS Act Β· SFDR/CSRD Β· Basel III Group 1b
23
+
24
+ **MCP integration:**
25
+ ```bash
26
+ npx @untitledfinancial/dpx-mcp
27
+ ```
28
+
29
+ **Links:**
30
+ - [Documentation](https://docs.untitledfinancial.com)
31
+ - [MCP on Smithery](https://smithery.ai/server/@untitledfinancial/dpx-mcp)
32
+ - [npm](https://www.npmjs.com/package/@untitledfinancial/dpx-mcp)
33
+ - [Contracts on Base mainnet](https://base.blockscout.com/address/0xe333551E18ef0471A71d7e8e761212766aa5AD4f)
app.py ADDED
@@ -0,0 +1,227 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ DPX Protocol β€” Hugging Face Space
3
+ Live demo of the DPX settlement infrastructure via MCP-callable endpoints.
4
+ github.com/untitledfinancial/dpx-mcp Β· docs.untitledfinancial.com
5
+ """
6
+
7
+ import gradio as gr
8
+ import httpx
9
+ import json
10
+ from datetime import datetime
11
+
12
+ STABILITY_URL = "https://stability.untitledfinancial.com"
13
+ ESG_URL = "https://esg.untitledfinancial.com"
14
+ AGENT_URL = "https://agent.untitledfinancial.com"
15
+ TIMEOUT = 12.0
16
+
17
+
18
+ def _get(url: str) -> dict:
19
+ with httpx.Client(timeout=TIMEOUT) as client:
20
+ r = client.get(url, headers={"User-Agent": "DPX-HF-Space/1.0"})
21
+ r.raise_for_status()
22
+ return r.json()
23
+
24
+
25
+ # ── Tab 1: Settlement Quote ────────────────────────────────────────────────────
26
+
27
+ def get_quote(amount_usd: float, has_fx: bool, esg_score: float) -> str:
28
+ try:
29
+ params = f"amountUsd={amount_usd}&hasFx={'true' if has_fx else 'false'}&esgScore={int(esg_score)}"
30
+ data = _get(f"{AGENT_URL}/quote?{params}")
31
+ lines = [
32
+ f"**Quote ID:** `{data.get('quoteId', 'N/A')}`",
33
+ f"**Amount:** ${amount_usd:,.2f} USD",
34
+ f"**Net amount (after fees):** ${data.get('netAmountUsd', 0):,.2f} USD",
35
+ "",
36
+ "**Fee breakdown:**",
37
+ ]
38
+ fees = data.get("fees", {})
39
+ for key in ["core", "fx", "esg", "license", "total"]:
40
+ f = fees.get(key, {})
41
+ if f:
42
+ lines.append(f"- {key.capitalize()}: {f.get('pct', 0):.3f}% (${f.get('usd', 0):,.2f})")
43
+ lines += [
44
+ "",
45
+ f"**Oracle status:** {data.get('oracleStatus', 'N/A')} (score: {data.get('oracleScore', 'N/A')})",
46
+ f"**Volume tier:** {data.get('tier', 'N/A')}",
47
+ f"**Quote expires:** {data.get('expiresAt', 'N/A')}",
48
+ "",
49
+ f"**AI reasoning:** {data.get('reasoning', 'N/A')}",
50
+ ]
51
+ return "\n".join(lines)
52
+ except Exception as e:
53
+ return f"Error: {e}"
54
+
55
+
56
+ # ── Tab 2: Oracle Status ───────────────────────────────────────────────────────
57
+
58
+ def get_oracle_status() -> str:
59
+ try:
60
+ data = _get(f"{STABILITY_URL}/reliability")
61
+ lines = [
62
+ f"**Status:** {data.get('status', 'N/A')}",
63
+ f"**Stability score:** {data.get('stabilityScore', data.get('score', 'N/A'))} / 100",
64
+ f"**Recommendation:** {data.get('recommendation', 'N/A')}",
65
+ f"**Peg deviation:** {data.get('pegDeviation', 'N/A')} bps",
66
+ f"**Outlook:** {data.get('outlook', 'N/A')}",
67
+ "",
68
+ f"**AI reasoning:** {data.get('reasoning', data.get('briefing', 'N/A'))}",
69
+ "",
70
+ f"*Last updated: {data.get('timestamp', datetime.utcnow().isoformat())}*",
71
+ ]
72
+ return "\n".join(lines)
73
+ except Exception as e:
74
+ return f"Error: {e}"
75
+
76
+
77
+ def get_oracle_signals() -> str:
78
+ try:
79
+ data = _get(f"{STABILITY_URL}/oracle-status")
80
+ signals = data.get("signals", {})
81
+ if not signals:
82
+ return json.dumps(data, indent=2)
83
+ lines = [
84
+ f"**Composite score:** {data.get('score', 'N/A')} Β· **Status:** {data.get('status', 'N/A')}",
85
+ f"**Chaos regime:** {'⚠️ YES' if data.get('chaosRegime') else 'No'}",
86
+ "",
87
+ "**Signal layers (0–100, higher = more stable):**",
88
+ ]
89
+ for sig, val in signals.items():
90
+ bar = "β–ˆ" * int(val / 10) + "β–‘" * (10 - int(val / 10))
91
+ lines.append(f"- {sig:<16} {bar} {val:.0f}")
92
+ alerts = data.get("alerts", [])
93
+ if alerts:
94
+ lines += ["", "**Active alerts:**"] + [f"- {a}" for a in alerts]
95
+ briefing = data.get("briefing", "")
96
+ if briefing:
97
+ lines += ["", f"**Intelligence briefing:** {briefing}"]
98
+ return "\n".join(lines)
99
+ except Exception as e:
100
+ return f"Error: {e}"
101
+
102
+
103
+ # ── Tab 3: ESG Score ───────────────────────────────────────────────────────────
104
+
105
+ def get_esg_score(address: str) -> str:
106
+ try:
107
+ addr = address.strip() or "default"
108
+ path = f"/esg-score/{addr}" if addr != "default" else "/esg-score"
109
+ data = _get(f"{ESG_URL}{path}")
110
+ lines = [
111
+ f"**Address:** `{data.get('address', addr)}`",
112
+ f"**Composite ESG score:** {data.get('esgScore', data.get('score', 'N/A'))} / 100",
113
+ "",
114
+ "**Sub-scores:**",
115
+ f"- Environmental: {data.get('environmental', 'N/A')}",
116
+ f"- Social: {data.get('social', 'N/A')}",
117
+ f"- Governance: {data.get('governance', 'N/A')}",
118
+ "",
119
+ f"**ESG fee at settlement:** {data.get('feePct', 'N/A')}%",
120
+ f"**Tier:** {data.get('tier', 'N/A')}",
121
+ f"**Last updated:** {data.get('updatedAt', 'N/A')}",
122
+ ]
123
+ sources = data.get("sources", [])
124
+ if sources:
125
+ lines += ["", f"**Data sources:** {', '.join(sources)}"]
126
+ return "\n".join(lines)
127
+ except Exception as e:
128
+ return f"Error: {e}"
129
+
130
+
131
+ # ── Tab 4: FX Corridor ─────────────────────────────────────────────────────────
132
+
133
+ def get_fx_corridors() -> str:
134
+ try:
135
+ data = _get(f"{STABILITY_URL}/fx-settlement")
136
+ lines = [
137
+ f"**Overall risk:** {data.get('overallRisk', 'N/A')}",
138
+ ]
139
+ dxy = data.get("dxy", {})
140
+ if dxy:
141
+ lines += [
142
+ f"**DXY:** {dxy.get('value', 'N/A')} Β· Regime: {dxy.get('regime', 'N/A')}",
143
+ "",
144
+ ]
145
+ corridors = data.get("corridors", [])
146
+ if corridors:
147
+ lines.append("**Per-corridor risk:**")
148
+ for c in corridors:
149
+ pair = c.get("pair", "?")
150
+ advice = c.get("advice", "?")
151
+ risk = c.get("risk", "?")
152
+ spot = c.get("spotRate", "")
153
+ spot_s = f" ({spot})" if spot else ""
154
+ lines.append(f"- **{pair}**{spot_s}: {risk} β†’ {advice}")
155
+ summary = data.get("executiveSummary", "")
156
+ if summary:
157
+ lines += ["", f"**Summary:** {summary}"]
158
+ actions = data.get("recommendedActions", [])
159
+ if actions:
160
+ lines += ["", "**Recommended actions:**"] + [f"- {a}" for a in actions]
161
+ return "\n".join(lines)
162
+ except Exception as e:
163
+ return f"Error: {e}"
164
+
165
+
166
+ # ── Layout ─────────────────────────────────────────────────────────────────────
167
+
168
+ with gr.Blocks(
169
+ title="DPX Protocol β€” Live Demo",
170
+ theme=gr.themes.Base(primary_hue="slate"),
171
+ css=".gr-button-primary { background: #18181b !important; }",
172
+ ) as demo:
173
+ gr.Markdown(
174
+ """
175
+ # DPX Protocol β€” Live Settlement Infrastructure
176
+
177
+ Compliance-grade stablecoin settlement rail. Any agent can discover, price, and execute cross-border payments autonomously β€” no onboarding, no API key, no human step.
178
+
179
+ **Contracts live on Base mainnet Β· [docs.untitledfinancial.com](https://docs.untitledfinancial.com) Β· [MCP server](https://smithery.ai/server/@untitledfinancial/dpx-mcp)**
180
+ """
181
+ )
182
+
183
+ with gr.Tabs():
184
+
185
+ with gr.TabItem("Settlement Quote"):
186
+ gr.Markdown("Get a binding fee quote. All calculations run against the live Stability Oracle.")
187
+ with gr.Row():
188
+ amount = gr.Number(label="Amount (USD)", value=500000, minimum=1)
189
+ has_fx = gr.Checkbox(label="Cross-currency (FX)", value=True)
190
+ esg_sl = gr.Slider(label="ESG score (0–100)", minimum=0, maximum=100, value=75, step=1)
191
+ quote_btn = gr.Button("Get quote", variant="primary")
192
+ quote_out = gr.Markdown()
193
+ quote_btn.click(get_quote, inputs=[amount, has_fx, esg_sl], outputs=quote_out)
194
+
195
+ with gr.TabItem("Oracle Status"):
196
+ gr.Markdown("Live macro stability assessment. Gates every settlement β€” UNSTABLE halts execution automatically.")
197
+ with gr.Row():
198
+ oracle_btn = gr.Button("Check stability", variant="primary")
199
+ oracle_sig_btn = gr.Button("Full signal layers")
200
+ oracle_out = gr.Markdown()
201
+ oracle_btn.click(get_oracle_status, outputs=oracle_out)
202
+ oracle_sig_btn.click(get_oracle_signals, outputs=oracle_out)
203
+
204
+ with gr.TabItem("ESG Score"):
205
+ gr.Markdown("Score a counterparty wallet for ESG risk. Required for EU SFDR/CSRD compliance. Updated hourly from 6 institutional sources.")
206
+ addr_in = gr.Textbox(label="Wallet address (0x...) β€” leave blank for protocol default", placeholder="0x...")
207
+ esg_btn = gr.Button("Get ESG score", variant="primary")
208
+ esg_out = gr.Markdown()
209
+ esg_btn.click(get_esg_score, inputs=addr_in, outputs=esg_out)
210
+
211
+ with gr.TabItem("FX Corridors"):
212
+ gr.Markdown("Per-pair execution risk for 10 major currency corridors. SETTLE_NOW / DELAY / AVOID recommendations updated hourly.")
213
+ fx_btn = gr.Button("Get FX corridor status", variant="primary")
214
+ fx_out = gr.Markdown()
215
+ fx_btn.click(get_fx_corridors, outputs=fx_out)
216
+
217
+ gr.Markdown(
218
+ """
219
+ ---
220
+ **Integration:** `npx @untitledfinancial/dpx-mcp` Β· Listed on Anthropic MCP registry, Smithery, mcp.so, npm
221
+ **Agentic payments:** x402 micropayment standard on Base mainnet β€” agents pay per call in USDC, no API key required
222
+ **Compliance:** FATF R16 Β· MiCA Β· GENIUS Act Β· SFDR/CSRD Β· Basel III Group 1b
223
+ """
224
+ )
225
+
226
+ if __name__ == "__main__":
227
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio>=4.0.0
2
+ httpx>=0.27.0