Terminal: stablecoin price/status table in Web3; AML preview (window total, taint share, review chance) in the bank withdrawal

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ZHU MINCHAOandClaude Sonnet 5.5 committed 2026-11-03 15:44:49 +08:00
1 parent 00f7811e7c
commit e95588a76f
3 files changed
+62

No files matched your search

+44
View File
@@ -139,11 +139,54 @@ namespace Decentralized
r.AddHeader(L.T("bank.ops"));
foreach (var line in L.T("bank.hint").Split('|')) r.AddLabel(line);
AmountRow(r);
AmlPreview(r);
r.AddButton(L.T("trade.deposit"), Deposit);
r.AddButton(L.T("trade.withdraw"), Withdraw);
});
}
/// <summary>提取前的合规审查提示:本周已提取的累计、污点比例,以及按当前数量估算的审查概率。</summary>
private static void AmlPreview(CustomUIBuilder b)
{
var d = Session.Data;
int day = StoreStation.GetDayCounter();
double rent = Session.Rent();
double recent = d.Exchange.History.Where(h => h.Key > day - Tuning.AmlWindowDays).Sum(h => h.Value);
b.AddSeparator();
b.AddLabel(L.T("aml.window", Tuning.AmlWindowDays, Fmt.Credits(recent), Fmt.Credits(Tuning.AmlCumRents * rent)));
double total = d.Hot.Value(Session.Price);
double taintRatio = total > 0 ? d.Hot.Taint / total : 0;
b.AddLabel(L.T("aml.taint", (int)Math.Round(taintRatio * 100)));
if (double.TryParse((_amount ?? "").Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out double v) && v > 0)
{
double value = Math.Min(v, d.Hot.Get(Assets.CRC)) * Session.Price(Assets.CRC);
double taint = total > 0 ? d.Hot.Taint * Math.Min(1, value / total) : 0;
double chance = Exchange.HitChance(value, taint, recent, rent, d.Hot.Flagged);
b.AddLabel(L.T("aml.chance", (int)Math.Round(chance * 100)));
}
}
private static readonly float[] StableW = { 80f, 100f, 220f };
private static string StableStatus(Stablecoins st, string asset, int day)
{
double p = st.Price(asset);
if (asset == Assets.CRA && st.CraWarning(day)) return L.T("stable.warn");
if (asset == Assets.CRA && p < 0.97) return L.T("stable.spiral");
return p < 0.99 ? L.T("stable.depeg") : L.T("stable.ok");
}
/// <summary>稳定币行情:价格与状态(脱锚、预兆)。</summary>
private static void StableTable(CustomUIBuilder b)
{
var st = Session.Data.Stable;
int day = StoreStation.GetDayCounter();
b.AddSeparator();
TableHeader(b, StableW, L.T("col.asset"), L.T("col.peg"), L.T("col.status"));
foreach (var a in new[] { Assets.CRC, Assets.CRT, Assets.CRA })
TableRow(b, StableW, a, Fmt.Num(st.Price(a)), StableStatus(st, a, day));
}
private static void TradeRows(CustomUIBuilder b, Venue venue)
{
foreach (var pool in Session.Data.Market.Pools.Where(x => x.Venue == venue))
@@ -199,6 +242,7 @@ namespace Decentralized
l.AddSeparator();
l.AddLabel(L.T("wallet.total", Fmt.Credits(w.Value(Session.Price))));
if (w.Taint > 0.5) l.AddLabel(L.T("wallet.taint", Fmt.Credits(w.Taint)));
StableTable(l);
}, r =>
{
r.AddHeader(L.T("trade.h"));