@glacislabs/stablegenie-zerodelta 3.4.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -20
- package/dist/{chunk-Q3YSX4D5.js → chunk-DXUESKNC.js} +557 -51
- package/dist/{chunk-TYQF2L5C.js → chunk-YEYFEQWS.js} +566 -26
- package/dist/core/index.cjs +591 -25
- package/dist/core/index.d.cts +42 -4
- package/dist/core/index.d.ts +42 -4
- package/dist/core/index.js +1 -1
- package/dist/index.cjs +1134 -83
- package/dist/index.d.cts +22 -3
- package/dist/index.d.ts +22 -3
- package/dist/index.js +2 -2
- package/dist/{mount-BT2NejVt.d.ts → mount-BFa37j1u.d.ts} +1 -1
- package/dist/{mount-D8NmWtqV.d.cts → mount-DssudKQ7.d.cts} +1 -1
- package/dist/mount.cjs +1113 -83
- package/dist/mount.d.cts +2 -2
- package/dist/mount.d.ts +2 -2
- package/dist/mount.js +2 -2
- package/dist/standalone.global.js +156 -8
- package/dist/{verify-34voZYj1.d.cts → verify-Ce6ZtDhi.d.cts} +290 -1
- package/dist/{verify-34voZYj1.d.ts → verify-Ce6ZtDhi.d.ts} +290 -1
- package/package.json +1 -1
|
@@ -23,6 +23,7 @@ var TRADEABLE_RWA_ASSETS = /* @__PURE__ */ new Set([
|
|
|
23
23
|
]);
|
|
24
24
|
var SUPPORTED_ASSETS = /* @__PURE__ */ new Set([...STABLE_ASSETS, ...TRADEABLE_RWA_ASSETS]);
|
|
25
25
|
var API_CACHE_TTL_MS = 6e4;
|
|
26
|
+
var SCREEN_CACHE_TTL_MS = 5 * 6e4;
|
|
26
27
|
var MAX_QUOTE_CANDIDATES = 8;
|
|
27
28
|
var QUOTE_BUFFER_BPS = 50;
|
|
28
29
|
var LZ_FEE_BUFFER_BPS = 1500n;
|
|
@@ -583,7 +584,7 @@ function buildCatalogue(input) {
|
|
|
583
584
|
);
|
|
584
585
|
const byId = new Map(enabledChains.map((c) => [Number(c.chainId), c]));
|
|
585
586
|
for (const id of chainIds) if (!byId.has(id)) byId.set(id, { chainId: id, isEnabled: true });
|
|
586
|
-
return { ...ctx, product, tokens: catalogue, sources, chainIds, chains: [...byId.values()], ready };
|
|
587
|
+
return { ...ctx, product, tokens: catalogue, sources, chainIds, chains: [...byId.values()], ready, vaultIcons: input.vaultIcons ?? /* @__PURE__ */ new Map() };
|
|
587
588
|
}
|
|
588
589
|
|
|
589
590
|
// src/core/options.ts
|
|
@@ -749,6 +750,366 @@ function brokenLaneReason(lane) {
|
|
|
749
750
|
}
|
|
750
751
|
}
|
|
751
752
|
|
|
753
|
+
// src/core/rwa-icons.ts
|
|
754
|
+
var GATEWAY_ICON_PREFIX = "/api/v1/rwa/icons/";
|
|
755
|
+
var ICON_FILE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}\.(?:png|jpg|jpeg|webp|gif)$/;
|
|
756
|
+
function resolveVaultIcon(apiBase, iconPath) {
|
|
757
|
+
if (typeof iconPath !== "string" || !iconPath.startsWith(GATEWAY_ICON_PREFIX)) return void 0;
|
|
758
|
+
const file = iconPath.slice(GATEWAY_ICON_PREFIX.length);
|
|
759
|
+
if (!ICON_FILE.test(file)) return void 0;
|
|
760
|
+
return `${apiBase.replace(/\/$/, "")}/rwa/icons/${file}`;
|
|
761
|
+
}
|
|
762
|
+
function vaultIconsBySymbol(apiBase, vaults) {
|
|
763
|
+
const out = /* @__PURE__ */ new Map();
|
|
764
|
+
for (const vault of vaults) {
|
|
765
|
+
const key = symbolKey(vault?.symbol);
|
|
766
|
+
if (!key || out.has(key)) continue;
|
|
767
|
+
const url = resolveVaultIcon(apiBase, vault?.iconMiniUrl) ?? resolveVaultIcon(apiBase, vault?.iconUrl);
|
|
768
|
+
if (url) out.set(key, url);
|
|
769
|
+
}
|
|
770
|
+
return out;
|
|
771
|
+
}
|
|
772
|
+
function withVaultArtwork(tokens, icons) {
|
|
773
|
+
if (!icons.size) return tokens;
|
|
774
|
+
return tokens.map((token) => {
|
|
775
|
+
if (token.logoUrl) return token;
|
|
776
|
+
const url = icons.get(symbolKey(token.symbol));
|
|
777
|
+
return url ? { ...token, logoUrl: url } : token;
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
// src/core/compliance.ts
|
|
782
|
+
var COMPLIANCE_DENY_LABEL = "Compliance check failed";
|
|
783
|
+
function complianceView(compliance, hasQuote = true) {
|
|
784
|
+
if (!hasQuote) {
|
|
785
|
+
return {
|
|
786
|
+
tone: "neutral",
|
|
787
|
+
label: "Compliance checks run with your quote",
|
|
788
|
+
headline: "No compliance decision for this payment yet",
|
|
789
|
+
blocked: false,
|
|
790
|
+
needsAction: false,
|
|
791
|
+
screened: false
|
|
792
|
+
};
|
|
793
|
+
}
|
|
794
|
+
const decision = compliance?.decision;
|
|
795
|
+
const screened = compliance?.status === "SCREENED";
|
|
796
|
+
if (decision === "DENY") {
|
|
797
|
+
return {
|
|
798
|
+
tone: "blocked",
|
|
799
|
+
label: COMPLIANCE_DENY_LABEL,
|
|
800
|
+
headline: "Blocked by compliance policy",
|
|
801
|
+
blocked: true,
|
|
802
|
+
needsAction: false,
|
|
803
|
+
screened
|
|
804
|
+
};
|
|
805
|
+
}
|
|
806
|
+
if (decision === "REVIEW" || decision === "REMEDIATE") {
|
|
807
|
+
const word = decision.toLowerCase();
|
|
808
|
+
return {
|
|
809
|
+
tone: "warn",
|
|
810
|
+
label: `Compliance: ${word} required`,
|
|
811
|
+
headline: `Manual ${word} required`,
|
|
812
|
+
blocked: false,
|
|
813
|
+
needsAction: true,
|
|
814
|
+
screened
|
|
815
|
+
};
|
|
816
|
+
}
|
|
817
|
+
if (decision === "ALLOW") {
|
|
818
|
+
return {
|
|
819
|
+
tone: "ok",
|
|
820
|
+
label: screened ? "Compliance checks passed" : "Allowed \u2014 wallets not screened",
|
|
821
|
+
headline: screened ? "Wallets screened and allowed" : "Allowed \u2014 wallets not screened",
|
|
822
|
+
blocked: false,
|
|
823
|
+
needsAction: false,
|
|
824
|
+
screened
|
|
825
|
+
};
|
|
826
|
+
}
|
|
827
|
+
return {
|
|
828
|
+
tone: "neutral",
|
|
829
|
+
label: screened ? "Screened \u2014 no policy decision returned" : "No compliance decision returned",
|
|
830
|
+
headline: screened ? "Screened \u2014 no policy decision returned" : "No compliance decision returned",
|
|
831
|
+
blocked: false,
|
|
832
|
+
needsAction: false,
|
|
833
|
+
screened
|
|
834
|
+
};
|
|
835
|
+
}
|
|
836
|
+
var CATEGORY_PHRASES = {
|
|
837
|
+
SANCTIONS: "sanctions",
|
|
838
|
+
TERRORISM_FINANCING: "terrorism financing",
|
|
839
|
+
STOLEN_FUNDS: "stolen funds",
|
|
840
|
+
RANSOMWARE: "ransomware",
|
|
841
|
+
SCAM: "scam activity",
|
|
842
|
+
DARKNET: "darknet activity",
|
|
843
|
+
MIXER: "mixer usage",
|
|
844
|
+
HIGH_RISK_ENTITY: "a high-risk entity",
|
|
845
|
+
PEP: "a politically-exposed person",
|
|
846
|
+
INDIRECT_EXPOSURE: "indirect exposure",
|
|
847
|
+
UNCLASSIFIED: "an unrecognized risk",
|
|
848
|
+
UNKNOWN: "an unrecognized risk"
|
|
849
|
+
};
|
|
850
|
+
function categoryLabel(code) {
|
|
851
|
+
const key = code.trim().toUpperCase();
|
|
852
|
+
const LABELS = {
|
|
853
|
+
SANCTIONS: "Sanctions",
|
|
854
|
+
TERRORISM_FINANCING: "Terrorist financing",
|
|
855
|
+
STOLEN_FUNDS: "Stolen funds",
|
|
856
|
+
RANSOMWARE: "Ransomware",
|
|
857
|
+
SCAM: "Scam",
|
|
858
|
+
DARKNET: "Darknet services",
|
|
859
|
+
MIXER: "Mixer",
|
|
860
|
+
HIGH_RISK_ENTITY: "High-risk entity",
|
|
861
|
+
PEP: "Politically exposed person (PEP)",
|
|
862
|
+
INDIRECT_EXPOSURE: "Indirect exposure",
|
|
863
|
+
UNCLASSIFIED: "Unclassified risk",
|
|
864
|
+
UNKNOWN: "Unclassified risk"
|
|
865
|
+
};
|
|
866
|
+
return LABELS[key] ?? key.toLowerCase().replace(/_/g, " ");
|
|
867
|
+
}
|
|
868
|
+
function cleanJurisdiction(code) {
|
|
869
|
+
return code.replace(/^(OFAC|TIER\d+|SANCTIONED)_/i, "").trim();
|
|
870
|
+
}
|
|
871
|
+
function stripBundlePrefix(head) {
|
|
872
|
+
if (head.startsWith("policy_")) return { head: head.slice("policy_".length), source: "policy" };
|
|
873
|
+
if (head.startsWith("legislation_")) return { head: head.slice("legislation_".length), source: "legislation" };
|
|
874
|
+
return { head, source: null };
|
|
875
|
+
}
|
|
876
|
+
function complianceReasonHead(raw) {
|
|
877
|
+
return stripBundlePrefix((raw.split(":")[0] ?? "").trim()).head;
|
|
878
|
+
}
|
|
879
|
+
function usd(raw) {
|
|
880
|
+
const n = Number(raw);
|
|
881
|
+
if (!Number.isFinite(n)) return `$${raw}`;
|
|
882
|
+
return `$${n.toLocaleString("en-US", { maximumFractionDigits: 2 })}`;
|
|
883
|
+
}
|
|
884
|
+
function capFromDetail(detail) {
|
|
885
|
+
const m = detail.match(/>([\d.]+)/);
|
|
886
|
+
return m ? ` (${usd(m[1])})` : "";
|
|
887
|
+
}
|
|
888
|
+
function categoryPhrase(detail) {
|
|
889
|
+
const cat = detail.replace(/\s*\(.*\)$/, "").toUpperCase();
|
|
890
|
+
return CATEGORY_PHRASES[cat] ?? cat.toLowerCase().replace(/_/g, " ");
|
|
891
|
+
}
|
|
892
|
+
function humanizeComplianceReason(raw) {
|
|
893
|
+
const [headRaw, ...restParts] = raw.split(":");
|
|
894
|
+
const detail = restParts.join(":").trim();
|
|
895
|
+
const { head, source } = stripBundlePrefix((headRaw ?? "").trim());
|
|
896
|
+
const scope = source === "legislation" ? "applicable regulations" : "the applicable policy";
|
|
897
|
+
switch (head) {
|
|
898
|
+
case "asset_pair_not_allowed": {
|
|
899
|
+
const m = detail.match(/^(\S+)->(\S+)\s+in\s+(\S+)/);
|
|
900
|
+
if (m) return `${m[1]} \u2192 ${m[2]} isn't available in your region (${cleanJurisdiction(m[3])}).`;
|
|
901
|
+
return "This asset pair isn't available in your region.";
|
|
902
|
+
}
|
|
903
|
+
case "asset_not_allowed": {
|
|
904
|
+
const m = detail.match(/^(\S+?)->(\S+?)(?::|$)/);
|
|
905
|
+
if (m) return `${m[1]} \u2192 ${m[2]} isn't permitted under ${scope}.`;
|
|
906
|
+
return `This asset pair isn't permitted under ${scope}.`;
|
|
907
|
+
}
|
|
908
|
+
case "blocked_jurisdiction":
|
|
909
|
+
return `Your region (${cleanJurisdiction(detail)}) isn't supported.`;
|
|
910
|
+
case "blocked_destination_jurisdiction":
|
|
911
|
+
return `The destination region (${cleanJurisdiction(detail)}) isn't supported.`;
|
|
912
|
+
case "jurisdiction_out_of_scope":
|
|
913
|
+
return `Not covered by ${scope}.`;
|
|
914
|
+
case "ui_block":
|
|
915
|
+
return `Payments aren't available in your region (${cleanJurisdiction(detail)}).`;
|
|
916
|
+
case "blocked_corridor_mode":
|
|
917
|
+
return "This route isn't currently open for payments.";
|
|
918
|
+
case "blocked_category":
|
|
919
|
+
return `Flagged for ${categoryPhrase(detail)}.`;
|
|
920
|
+
case "amount_exceeds_max_order_usd":
|
|
921
|
+
case "amount_exceeds_max":
|
|
922
|
+
return `Amount exceeds the maximum order size${capFromDetail(detail)}.`;
|
|
923
|
+
case "amount_exceeds_actor_cap":
|
|
924
|
+
return `Amount exceeds the limit for your account type${capFromDetail(detail)}.`;
|
|
925
|
+
case "amount_exceeds_jurisdiction_max":
|
|
926
|
+
return `Amount exceeds the limit for your region${capFromDetail(detail)}.`;
|
|
927
|
+
case "source_chain_not_allowed":
|
|
928
|
+
return `The source chain isn't permitted under ${scope}.`;
|
|
929
|
+
case "dest_chain_not_allowed":
|
|
930
|
+
return `The destination chain isn't permitted under ${scope}.`;
|
|
931
|
+
default:
|
|
932
|
+
return detail ? `${head.replace(/_/g, " ")} \u2014 ${detail}` : head.replace(/_/g, " ");
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
var COMPLIANCE_CHECK_ORDER = [
|
|
936
|
+
"location",
|
|
937
|
+
"screening",
|
|
938
|
+
"risk",
|
|
939
|
+
"asset",
|
|
940
|
+
"limits"
|
|
941
|
+
];
|
|
942
|
+
var CHECK_LABELS = {
|
|
943
|
+
location: "Location and corridor permitted",
|
|
944
|
+
screening: "Both wallets screened",
|
|
945
|
+
risk: "Risk policy passed",
|
|
946
|
+
asset: "Asset and amount allowed",
|
|
947
|
+
limits: "Transaction limits verified"
|
|
948
|
+
};
|
|
949
|
+
var CHECK_HEADS = {
|
|
950
|
+
location: [
|
|
951
|
+
"blocked_jurisdiction",
|
|
952
|
+
"blocked_destination_jurisdiction",
|
|
953
|
+
"ui_block",
|
|
954
|
+
"blocked_corridor_mode",
|
|
955
|
+
"jurisdiction_out_of_scope"
|
|
956
|
+
],
|
|
957
|
+
screening: [],
|
|
958
|
+
risk: ["blocked_category"],
|
|
959
|
+
asset: ["asset_pair_not_allowed", "asset_not_allowed", "source_chain_not_allowed", "dest_chain_not_allowed"],
|
|
960
|
+
limits: [
|
|
961
|
+
"amount_exceeds_max_order_usd",
|
|
962
|
+
"amount_exceeds_max",
|
|
963
|
+
"amount_exceeds_actor_cap",
|
|
964
|
+
"amount_exceeds_jurisdiction_max"
|
|
965
|
+
]
|
|
966
|
+
};
|
|
967
|
+
function distinctScreenedWallets(compliance) {
|
|
968
|
+
const seen = /* @__PURE__ */ new Set();
|
|
969
|
+
const wallets = [];
|
|
970
|
+
for (const raw of compliance?.screenedWallets ?? []) {
|
|
971
|
+
const address = raw?.trim();
|
|
972
|
+
if (!address) continue;
|
|
973
|
+
const key = /^0x[0-9a-fA-F]+$/.test(address) ? address.toLowerCase() : address;
|
|
974
|
+
if (seen.has(key)) continue;
|
|
975
|
+
seen.add(key);
|
|
976
|
+
wallets.push(address);
|
|
977
|
+
}
|
|
978
|
+
return wallets;
|
|
979
|
+
}
|
|
980
|
+
function shortAddress(a) {
|
|
981
|
+
return a.length > 12 ? `${a.slice(0, 6)}\u2026${a.slice(-4)}` : a;
|
|
982
|
+
}
|
|
983
|
+
function screeningLabel(wallets) {
|
|
984
|
+
if (wallets === 1) return "Wallet screened";
|
|
985
|
+
if (wallets === 2) return CHECK_LABELS.screening;
|
|
986
|
+
return "Wallets screened";
|
|
987
|
+
}
|
|
988
|
+
function complianceChecks(compliance, cv = complianceView(compliance)) {
|
|
989
|
+
if (cv.tone === "neutral") return [];
|
|
990
|
+
const byControl = /* @__PURE__ */ new Map();
|
|
991
|
+
for (const raw of compliance?.reasons ?? []) {
|
|
992
|
+
const head = complianceReasonHead(raw);
|
|
993
|
+
const id = COMPLIANCE_CHECK_ORDER.find((c) => CHECK_HEADS[c].includes(head));
|
|
994
|
+
if (!id) continue;
|
|
995
|
+
byControl.set(id, [...byControl.get(id) ?? [], raw]);
|
|
996
|
+
}
|
|
997
|
+
const screenedWallets = distinctScreenedWallets(compliance);
|
|
998
|
+
const wallets = screenedWallets.length;
|
|
999
|
+
const blocking = compliance?.blockingCategories?.length ?? 0;
|
|
1000
|
+
return COMPLIANCE_CHECK_ORDER.map((id) => {
|
|
1001
|
+
if (id === "screening") {
|
|
1002
|
+
const ok2 = cv.screened || wallets > 0;
|
|
1003
|
+
const note = wallets === 1 ? shortAddress(screenedWallets[0]) : wallets > 1 ? `${wallets} wallets screened` : void 0;
|
|
1004
|
+
return { id, label: ok2 ? screeningLabel(wallets) : "Wallets not screened", ok: ok2, reasons: [], note };
|
|
1005
|
+
}
|
|
1006
|
+
const reasons = byControl.get(id) ?? [];
|
|
1007
|
+
const ok = reasons.length === 0 && !(id === "risk" && blocking > 0);
|
|
1008
|
+
return { id, label: CHECK_LABELS[id], ok, reasons };
|
|
1009
|
+
});
|
|
1010
|
+
}
|
|
1011
|
+
function unattributedComplianceReasons(compliance, cv = complianceView(compliance)) {
|
|
1012
|
+
const claimed = new Set(complianceChecks(compliance, cv).flatMap((c) => c.reasons));
|
|
1013
|
+
return (compliance?.reasons ?? []).filter((r) => !claimed.has(r));
|
|
1014
|
+
}
|
|
1015
|
+
function complianceControlsEvaluated(compliance, cv = complianceView(compliance)) {
|
|
1016
|
+
const checks = complianceChecks(compliance, cv);
|
|
1017
|
+
if (checks.length === 0) return 0;
|
|
1018
|
+
const named = /* @__PURE__ */ new Set();
|
|
1019
|
+
for (const raw of [...compliance?.appliedPolicyNames ?? [], ...compliance?.appliedLegislation ?? []]) {
|
|
1020
|
+
const name = raw?.trim();
|
|
1021
|
+
if (name) named.add(name.toLowerCase());
|
|
1022
|
+
}
|
|
1023
|
+
return checks.length + named.size;
|
|
1024
|
+
}
|
|
1025
|
+
function complianceControlsLine(compliance, cv = complianceView(compliance)) {
|
|
1026
|
+
if (cv.blocked || cv.needsAction) return cv.headline;
|
|
1027
|
+
const n = complianceControlsEvaluated(compliance, cv);
|
|
1028
|
+
if (n === 0) return cv.headline;
|
|
1029
|
+
return `${n} compliance control${n === 1 ? "" : "s"} evaluated for this payment`;
|
|
1030
|
+
}
|
|
1031
|
+
function directComplianceFromScreens(screens) {
|
|
1032
|
+
const blockedAny = screens.some((s) => s.blocked);
|
|
1033
|
+
const cats = (pick) => [
|
|
1034
|
+
...new Set(screens.flatMap((s) => pick(s) ?? []))
|
|
1035
|
+
];
|
|
1036
|
+
return {
|
|
1037
|
+
status: "SCREENED",
|
|
1038
|
+
decision: blockedAny ? "DENY" : "ALLOW",
|
|
1039
|
+
screenedWallets: screens.map((s) => s.address),
|
|
1040
|
+
riskCategories: cats((s) => s.riskCategories),
|
|
1041
|
+
flaggedCategories: cats((s) => s.flaggedCategories),
|
|
1042
|
+
blockingCategories: cats((s) => s.blockingCategories),
|
|
1043
|
+
reasons: blockedAny ? cats((s) => s.blockingCategories).map((c) => `blocked_category:${c}`) : []
|
|
1044
|
+
};
|
|
1045
|
+
}
|
|
1046
|
+
var DIRECT_CHECK_IDS = ["screening", "risk"];
|
|
1047
|
+
var DIRECT_SCOPE_NOTE = "Direct settlement moves your funds straight to the recipient, so wallet screening applies. Jurisdiction, corridor and amount policy are evaluated on routed payments.";
|
|
1048
|
+
var BLOCK_CATEGORY_LABELS = {
|
|
1049
|
+
STOLEN_FUNDS: "flagged as associated with stolen funds",
|
|
1050
|
+
SANCTIONS: "on a sanctions list",
|
|
1051
|
+
SANCTIONED: "on a sanctions list",
|
|
1052
|
+
OFAC: "on a sanctions list",
|
|
1053
|
+
TERRORIST_FINANCING: "flagged for terrorist financing",
|
|
1054
|
+
TERRORISM_FINANCING: "flagged for terrorist financing",
|
|
1055
|
+
FRAUD: "flagged for fraud",
|
|
1056
|
+
SCAM: "flagged as a scam address"
|
|
1057
|
+
};
|
|
1058
|
+
var BLOCK_LABEL_DEFAULT = "flagged by compliance screening";
|
|
1059
|
+
function blockLabelFor(categories) {
|
|
1060
|
+
for (const raw of categories) {
|
|
1061
|
+
const label = BLOCK_CATEGORY_LABELS[String(raw || "").trim().toUpperCase()];
|
|
1062
|
+
if (label) return label;
|
|
1063
|
+
}
|
|
1064
|
+
return BLOCK_LABEL_DEFAULT;
|
|
1065
|
+
}
|
|
1066
|
+
var REASON_TAGS = {
|
|
1067
|
+
blocked_jurisdiction: "Restricted country",
|
|
1068
|
+
ui_block: "Restricted country",
|
|
1069
|
+
blocked_destination_jurisdiction: "Restricted destination",
|
|
1070
|
+
blocked_corridor_mode: "Corridor closed",
|
|
1071
|
+
blocked_category: "Risk flag",
|
|
1072
|
+
amount_exceeds_max_order_usd: "Limit exceeded",
|
|
1073
|
+
amount_exceeds_max: "Limit exceeded",
|
|
1074
|
+
amount_exceeds_actor_cap: "Limit exceeded",
|
|
1075
|
+
amount_exceeds_jurisdiction_max: "Limit exceeded",
|
|
1076
|
+
asset_pair_not_allowed: "Asset not allowed",
|
|
1077
|
+
asset_not_allowed: "Asset not allowed",
|
|
1078
|
+
source_chain_not_allowed: "Chain not allowed",
|
|
1079
|
+
dest_chain_not_allowed: "Chain not allowed",
|
|
1080
|
+
jurisdiction_out_of_scope: "Out of scope"
|
|
1081
|
+
};
|
|
1082
|
+
function complianceReasonTag(raw) {
|
|
1083
|
+
const head = complianceReasonHead(raw);
|
|
1084
|
+
return REASON_TAGS[head] ?? head.replace(/_/g, " ");
|
|
1085
|
+
}
|
|
1086
|
+
function complianceTagOf(compliance) {
|
|
1087
|
+
const first = (compliance?.reasons ?? [])[0];
|
|
1088
|
+
return first ? complianceReasonTag(first) : "";
|
|
1089
|
+
}
|
|
1090
|
+
var FLOOR_CATEGORIES = ["SANCTIONS", "TERRORISM_FINANCING", "STOLEN_FUNDS", "RANSOMWARE"];
|
|
1091
|
+
var TUNABLE_CATEGORIES = ["SCAM", "DARKNET", "MIXER", "HIGH_RISK_ENTITY", "PEP", "INDIRECT_EXPOSURE", "UNCLASSIFIED"];
|
|
1092
|
+
var TUNED_OUTCOMES = {
|
|
1093
|
+
SCAM: "blocked",
|
|
1094
|
+
DARKNET: "blocked",
|
|
1095
|
+
MIXER: "flagged",
|
|
1096
|
+
HIGH_RISK_ENTITY: "flagged",
|
|
1097
|
+
PEP: "flagged",
|
|
1098
|
+
INDIRECT_EXPOSURE: "flagged",
|
|
1099
|
+
UNCLASSIFIED: "flagged"
|
|
1100
|
+
};
|
|
1101
|
+
function screeningOutcomeOf(category) {
|
|
1102
|
+
const key = category.trim().toUpperCase();
|
|
1103
|
+
if (FLOOR_CATEGORIES.includes(key)) return "always-blocked";
|
|
1104
|
+
return TUNED_OUTCOMES[key] ?? null;
|
|
1105
|
+
}
|
|
1106
|
+
var labelsFor = (outcome) => [...FLOOR_CATEGORIES, ...TUNABLE_CATEGORIES].filter((c) => screeningOutcomeOf(c) === outcome).map(categoryLabel);
|
|
1107
|
+
var SCREENING_BUCKETS = [
|
|
1108
|
+
{ outcome: "always-blocked", title: "Always blocked", detail: "Cannot be changed or disabled.", categories: labelsFor("always-blocked") },
|
|
1109
|
+
{ outcome: "blocked", title: "Blocked under this policy", detail: "The current policy stops the order.", categories: labelsFor("blocked") },
|
|
1110
|
+
{ outcome: "flagged", title: "Flagged", detail: "A warning is shown.", categories: labelsFor("flagged") }
|
|
1111
|
+
];
|
|
1112
|
+
|
|
752
1113
|
// src/core/solve.ts
|
|
753
1114
|
async function solveExactOut({ option, destination, destinationToken, payer, fetchQuote }) {
|
|
754
1115
|
const destDecimals = assetDecimals(destinationToken);
|
|
@@ -985,7 +1346,63 @@ function routeLabelFor(option, destinationToken, result) {
|
|
|
985
1346
|
const bridge = result.quote.bridge ? ` via ${result.quote.bridge}` : "";
|
|
986
1347
|
return `Swap ${option.symbol} to ${destinationToken.symbol} and settle on ZeroDelta${bridge}.`;
|
|
987
1348
|
}
|
|
988
|
-
|
|
1349
|
+
function tokenAt(tokens, chainId, address) {
|
|
1350
|
+
const wanted = normalizeAddress(address);
|
|
1351
|
+
if (!wanted || !tokens?.length) return void 0;
|
|
1352
|
+
return tokens.find((t) => Number(t.chainId) === Number(chainId) && normalizeAddress(t.address) === wanted);
|
|
1353
|
+
}
|
|
1354
|
+
function legAmount(raw, decimals) {
|
|
1355
|
+
if (decimals === void 0) return "";
|
|
1356
|
+
try {
|
|
1357
|
+
return formatUnits(raw || "0", decimals);
|
|
1358
|
+
} catch {
|
|
1359
|
+
return "";
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
function buildLegs(orders, ctx) {
|
|
1363
|
+
const legs = [];
|
|
1364
|
+
let fromChainId = ctx.option.chainId;
|
|
1365
|
+
let fromAsset = ctx.option.symbol;
|
|
1366
|
+
let fromDecimals = ctx.option.decimals;
|
|
1367
|
+
for (let index = 0; index < orders.length; index += 1) {
|
|
1368
|
+
const order = orders[index];
|
|
1369
|
+
const isLast = index === orders.length - 1;
|
|
1370
|
+
const toChainId = Number(order.destinationChainId);
|
|
1371
|
+
const askToken = isLast ? ctx.destinationToken : tokenAt(ctx.tokens, toChainId, order.askToken);
|
|
1372
|
+
const toAsset = isLast ? ctx.destinationToken.symbol : askToken?.symbol ?? "";
|
|
1373
|
+
const toDecimals = askToken ? assetDecimals(askToken) : void 0;
|
|
1374
|
+
const executionChainId = Number(order.executionChainId);
|
|
1375
|
+
legs.push({
|
|
1376
|
+
index: index + 1,
|
|
1377
|
+
fromAsset,
|
|
1378
|
+
fromChainId,
|
|
1379
|
+
fromChainName: chainNameOf(fromChainId, ctx.chains),
|
|
1380
|
+
fromAmount: legAmount(order.bidTokenAmount, fromDecimals),
|
|
1381
|
+
toAsset,
|
|
1382
|
+
toChainId,
|
|
1383
|
+
toChainName: chainNameOf(toChainId, ctx.chains),
|
|
1384
|
+
toAmount: legAmount(order.askTokenAmount, toDecimals),
|
|
1385
|
+
executionChainId,
|
|
1386
|
+
executionChainName: chainNameOf(executionChainId, ctx.chains)
|
|
1387
|
+
});
|
|
1388
|
+
fromChainId = toChainId;
|
|
1389
|
+
fromAsset = toAsset;
|
|
1390
|
+
fromDecimals = toDecimals;
|
|
1391
|
+
}
|
|
1392
|
+
return legs;
|
|
1393
|
+
}
|
|
1394
|
+
async function buildRoute({
|
|
1395
|
+
option,
|
|
1396
|
+
destination,
|
|
1397
|
+
destinationToken,
|
|
1398
|
+
chains,
|
|
1399
|
+
tokens,
|
|
1400
|
+
payer,
|
|
1401
|
+
fetchQuote,
|
|
1402
|
+
solve = solveExactOut,
|
|
1403
|
+
amountInRaw,
|
|
1404
|
+
compliance
|
|
1405
|
+
}) {
|
|
989
1406
|
const result = await solve({ option, destination, destinationToken, payer, fetchQuote, amountInRaw });
|
|
990
1407
|
const quote = result.quote;
|
|
991
1408
|
const destDecimals = assetDecimals(destinationToken);
|
|
@@ -1015,6 +1432,23 @@ async function buildRoute({ option, destination, destinationToken, chains, payer
|
|
|
1015
1432
|
},
|
|
1016
1433
|
routeLabel: routeLabelFor(option, destinationToken, result),
|
|
1017
1434
|
deltaLabel: routeDeltaLabel(result, quote),
|
|
1435
|
+
// A direct transfer submits no order at all, but it is still ONE hop and history renders the
|
|
1436
|
+
// same shape for it — an empty `legs` would leave "one order or two?" unanswerable for it alone.
|
|
1437
|
+
legs: [
|
|
1438
|
+
{
|
|
1439
|
+
index: 1,
|
|
1440
|
+
fromAsset: option.symbol,
|
|
1441
|
+
fromChainId: option.chainId,
|
|
1442
|
+
fromChainName: option.chainName,
|
|
1443
|
+
fromAmount: sourceAmount,
|
|
1444
|
+
toAsset: destinationToken.symbol,
|
|
1445
|
+
toChainId: Number(destination.chainId),
|
|
1446
|
+
toChainName: chainNameOf(Number(destination.chainId), chains),
|
|
1447
|
+
toAmount: receiveAmount,
|
|
1448
|
+
executionChainId: option.chainId,
|
|
1449
|
+
executionChainName: option.chainName
|
|
1450
|
+
}
|
|
1451
|
+
],
|
|
1018
1452
|
transactions: [
|
|
1019
1453
|
{
|
|
1020
1454
|
id: "transfer",
|
|
@@ -1032,7 +1466,11 @@ async function buildRoute({ option, destination, destinationToken, chains, payer
|
|
|
1032
1466
|
bridge: quote.bridge,
|
|
1033
1467
|
feeBps: quote.feeBps,
|
|
1034
1468
|
estimatedDuration: quote.estimatedDuration,
|
|
1035
|
-
iterations: result.iterations
|
|
1469
|
+
iterations: result.iterations,
|
|
1470
|
+
// A direct transfer never reaches /quote (solve.ts short-circuits it), so there is no
|
|
1471
|
+
// gateway decision to carry. The caller screens both parties itself and passes the
|
|
1472
|
+
// synthesized verdict in — see plan.ts and compliance.ts::directComplianceFromScreens.
|
|
1473
|
+
compliance
|
|
1036
1474
|
}
|
|
1037
1475
|
};
|
|
1038
1476
|
}
|
|
@@ -1084,6 +1522,7 @@ async function buildRoute({ option, destination, destinationToken, chains, payer
|
|
|
1084
1522
|
},
|
|
1085
1523
|
routeLabel: routeLabelFor(option, destinationToken, result),
|
|
1086
1524
|
deltaLabel: routeDeltaLabel(result, quote),
|
|
1525
|
+
legs: buildLegs(orders, { option, destinationToken, chains, tokens }),
|
|
1087
1526
|
transactions: [
|
|
1088
1527
|
{
|
|
1089
1528
|
id: "approve",
|
|
@@ -1116,7 +1555,11 @@ async function buildRoute({ option, destination, destinationToken, chains, payer
|
|
|
1116
1555
|
gasCostSource: quote.gasCostSource,
|
|
1117
1556
|
msgValue: valueRaw.toString(),
|
|
1118
1557
|
deadline: order.deadline,
|
|
1119
|
-
iterations: result.iterations
|
|
1558
|
+
iterations: result.iterations,
|
|
1559
|
+
// Carried verbatim from the gateway's decision on THIS wallet pair. The projection used to
|
|
1560
|
+
// drop it, which is why the widget could show a price with no evidence of the control that
|
|
1561
|
+
// produced it.
|
|
1562
|
+
compliance: quote.compliance
|
|
1120
1563
|
}
|
|
1121
1564
|
};
|
|
1122
1565
|
}
|
|
@@ -1152,25 +1595,20 @@ function apiMessage(json, fallback) {
|
|
|
1152
1595
|
}
|
|
1153
1596
|
return sanitizeMessage(err?.message, fallback);
|
|
1154
1597
|
}
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
TERRORIST_FINANCING: "flagged for terrorist financing",
|
|
1161
|
-
FRAUD: "flagged for fraud",
|
|
1162
|
-
SCAM: "flagged as a scam address"
|
|
1163
|
-
};
|
|
1164
|
-
var BLOCK_LABEL_DEFAULT = "flagged by compliance screening";
|
|
1598
|
+
function isStructuredComplianceBlock(error) {
|
|
1599
|
+
const code = String(error?.code || "").toUpperCase();
|
|
1600
|
+
if (code === "COMPLIANCE_BLOCKED" || code === "COMPLIANCE_BLOCK") return true;
|
|
1601
|
+
return error?.status === 422 && Array.isArray(error?.reasons) && error.reasons.length > 0;
|
|
1602
|
+
}
|
|
1165
1603
|
function classifyQuoteError(error) {
|
|
1166
1604
|
if (!error) return null;
|
|
1167
1605
|
const reasons = Array.isArray(error.reasons) ? error.reasons : [];
|
|
1168
1606
|
const haystack = `${error.message || ""} ${reasons.join(" ")}`;
|
|
1169
1607
|
const catMatch = /blocked_category:\s*([A-Za-z_]+)/i.exec(haystack);
|
|
1170
|
-
const isBlock = !!catMatch || error.code === "blocked" || error.code === "compliance_block" || /\b(stolen|sanction(?:s|ed|ing)?|block(?:ed|list)|screen(?:ed|ing)?|compliance|ofac|denylist|blacklist)\b/i.test(haystack);
|
|
1608
|
+
const isBlock = isStructuredComplianceBlock(error) || !!catMatch || error.code === "blocked" || error.code === "compliance_block" || /\b(stolen|sanction(?:s|ed|ing)?|block(?:ed|list)|screen(?:ed|ing)?|compliance|ofac|denylist|blacklist)\b/i.test(haystack);
|
|
1171
1609
|
if (!isBlock) return null;
|
|
1172
1610
|
const category = (catMatch?.[1] || "").toUpperCase() || "COMPLIANCE";
|
|
1173
|
-
const label =
|
|
1611
|
+
const label = blockLabelFor([category]);
|
|
1174
1612
|
return {
|
|
1175
1613
|
blocked: true,
|
|
1176
1614
|
category,
|
|
@@ -1192,8 +1630,11 @@ function createApiClient(cfg) {
|
|
|
1192
1630
|
chains: null,
|
|
1193
1631
|
tokens: null,
|
|
1194
1632
|
routes: null,
|
|
1195
|
-
health: null
|
|
1633
|
+
health: null,
|
|
1634
|
+
vaults: null
|
|
1196
1635
|
};
|
|
1636
|
+
const screenCache = /* @__PURE__ */ new Map();
|
|
1637
|
+
const screenInflight = /* @__PURE__ */ new Map();
|
|
1197
1638
|
const apiBase = cfg.apiBase.replace(/\/$/, "");
|
|
1198
1639
|
async function apiRequest(path, init = {}) {
|
|
1199
1640
|
const apiKey = await cfg.getApiKey();
|
|
@@ -1274,6 +1715,19 @@ function createApiClient(cfg) {
|
|
|
1274
1715
|
cache.health = { at: Date.now(), value };
|
|
1275
1716
|
return value;
|
|
1276
1717
|
}
|
|
1718
|
+
async function fetchRwaVaults() {
|
|
1719
|
+
if (nowFresh(cache.vaults)) return cache.vaults.value;
|
|
1720
|
+
let value = [];
|
|
1721
|
+
try {
|
|
1722
|
+
const payload = await apiRequest("/rwa/vaults?status=active,coming_soon", { timeoutMs: 8e3 });
|
|
1723
|
+
const rows = Array.isArray(payload) ? payload : payload?.vaults;
|
|
1724
|
+
value = Array.isArray(rows) ? rows.filter((v) => !!v && typeof v === "object") : [];
|
|
1725
|
+
} catch {
|
|
1726
|
+
value = [];
|
|
1727
|
+
}
|
|
1728
|
+
cache.vaults = { at: Date.now(), value };
|
|
1729
|
+
return value;
|
|
1730
|
+
}
|
|
1277
1731
|
async function fetchQuote(body, retries = 1) {
|
|
1278
1732
|
let lastError;
|
|
1279
1733
|
for (let attempt = 0; attempt <= retries; attempt += 1) {
|
|
@@ -1288,7 +1742,32 @@ function createApiClient(cfg) {
|
|
|
1288
1742
|
}
|
|
1289
1743
|
throw lastError;
|
|
1290
1744
|
}
|
|
1291
|
-
|
|
1745
|
+
async function screenWallet(address, chainId) {
|
|
1746
|
+
const addr = String(address || "").trim();
|
|
1747
|
+
if (!addr) throw apiError("An address is required to screen a wallet.", { code: "bad_request" });
|
|
1748
|
+
const key = `${/^0x[0-9a-fA-F]+$/.test(addr) ? addr.toLowerCase() : addr}|${chainId ?? ""}`;
|
|
1749
|
+
const hit = screenCache.get(key);
|
|
1750
|
+
if (hit && Date.now() - hit.at < SCREEN_CACHE_TTL_MS) return hit.value;
|
|
1751
|
+
const inflight = screenInflight.get(key);
|
|
1752
|
+
if (inflight) return inflight;
|
|
1753
|
+
const request = apiRequest("/screen/wallet", {
|
|
1754
|
+
method: "POST",
|
|
1755
|
+
body: JSON.stringify(chainId == null ? { address: addr } : { address: addr, chainId }),
|
|
1756
|
+
timeoutMs: 12e3
|
|
1757
|
+
}).then((screen) => {
|
|
1758
|
+
if (!screen || typeof screen !== "object" || typeof screen.blocked !== "boolean") {
|
|
1759
|
+
throw apiError("Compliance screening returned an unusable result.", { code: "bad_response" });
|
|
1760
|
+
}
|
|
1761
|
+
const value = { ...screen, address: screen.address || addr };
|
|
1762
|
+
screenCache.set(key, { at: Date.now(), value });
|
|
1763
|
+
return value;
|
|
1764
|
+
}).finally(() => {
|
|
1765
|
+
screenInflight.delete(key);
|
|
1766
|
+
});
|
|
1767
|
+
screenInflight.set(key, request);
|
|
1768
|
+
return request;
|
|
1769
|
+
}
|
|
1770
|
+
return { apiRequest, fetchChains, fetchTokens, fetchRoutes, fetchRouteHealth, fetchRwaVaults, fetchQuote, screenWallet, apiBase };
|
|
1292
1771
|
}
|
|
1293
1772
|
|
|
1294
1773
|
// src/core/plan.ts
|
|
@@ -1356,7 +1835,36 @@ async function fetchPaymentPlan(api, request, payer, wallet = {}, readBalances)
|
|
|
1356
1835
|
balanceTargets.push({ chainId: option.chainId, tokenAddress: option.address, decimals: option.decimals });
|
|
1357
1836
|
}
|
|
1358
1837
|
const walletBalances = readBalances ? await readBalances(payer, balanceTargets).catch(() => ({})) : {};
|
|
1359
|
-
const
|
|
1838
|
+
const directOptions = options.filter((option) => option.direct);
|
|
1839
|
+
let directCompliance = null;
|
|
1840
|
+
if (directOptions.length) {
|
|
1841
|
+
const parties = [];
|
|
1842
|
+
const seenParty = /* @__PURE__ */ new Set();
|
|
1843
|
+
for (const raw of [payer, destination.address]) {
|
|
1844
|
+
const addr = String(raw || "").trim();
|
|
1845
|
+
if (!addr) continue;
|
|
1846
|
+
const key = /^0x[0-9a-fA-F]+$/.test(addr) ? addr.toLowerCase() : addr;
|
|
1847
|
+
if (seenParty.has(key)) continue;
|
|
1848
|
+
seenParty.add(key);
|
|
1849
|
+
parties.push(addr);
|
|
1850
|
+
}
|
|
1851
|
+
try {
|
|
1852
|
+
const screens = await Promise.all(parties.map((address) => api.screenWallet(address, destination.chainId)));
|
|
1853
|
+
const blocked = screens.filter((screen) => screen.blocked);
|
|
1854
|
+
if (blocked.length) {
|
|
1855
|
+
const who = blocked.some((s) => s.address.toLowerCase() === payer.toLowerCase()) ? "your wallet" : "the recipient";
|
|
1856
|
+
const categories = [...new Set(blocked.flatMap((s) => s.blockingCategories ?? []))];
|
|
1857
|
+
throw apiError(
|
|
1858
|
+
`This payment was blocked by compliance screening \u2014 ${who} is ${blockLabelFor(categories)}. Choose a different recipient or connect a different wallet.`,
|
|
1859
|
+
{ blocked: true, blockedCategory: categories[0] || "COMPLIANCE", blockedReason: categories.join(", ") }
|
|
1860
|
+
);
|
|
1861
|
+
}
|
|
1862
|
+
directCompliance = directComplianceFromScreens(screens);
|
|
1863
|
+
} catch (error) {
|
|
1864
|
+
if (error?.blocked) throw error;
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1867
|
+
const candidates = directCompliance ? directOptions : [];
|
|
1360
1868
|
const heldOptions = options.filter((option) => !option.direct && hasPositiveBalance(option, walletBalances));
|
|
1361
1869
|
const heldKeys = new Set(heldOptions.map(optionBalanceKey));
|
|
1362
1870
|
const seenChains = /* @__PURE__ */ new Set();
|
|
@@ -1376,7 +1884,16 @@ async function fetchPaymentPlan(api, request, payer, wallet = {}, readBalances)
|
|
|
1376
1884
|
}
|
|
1377
1885
|
const routeErrors = [];
|
|
1378
1886
|
const routePromises = candidates.map(
|
|
1379
|
-
(option) => buildRoute({
|
|
1887
|
+
(option) => buildRoute({
|
|
1888
|
+
option,
|
|
1889
|
+
destination,
|
|
1890
|
+
destinationToken,
|
|
1891
|
+
chains,
|
|
1892
|
+
tokens,
|
|
1893
|
+
payer,
|
|
1894
|
+
fetchQuote: api.fetchQuote,
|
|
1895
|
+
compliance: option.direct ? directCompliance ?? void 0 : void 0
|
|
1896
|
+
}).catch((error) => {
|
|
1380
1897
|
routeErrors.push(error);
|
|
1381
1898
|
return null;
|
|
1382
1899
|
})
|
|
@@ -1489,7 +2006,7 @@ async function buildSwapPlan(api, swap, payer, wallet = {}) {
|
|
|
1489
2006
|
direct: false
|
|
1490
2007
|
};
|
|
1491
2008
|
const destination = { address: receiver, chainId: v.toChainId, asset: destToken.symbol };
|
|
1492
|
-
const route = await buildRoute({ option, destination, destinationToken: destToken, chains, payer: account, fetchQuote: api.fetchQuote, solve: solveExactIn, amountInRaw });
|
|
2009
|
+
const route = await buildRoute({ option, destination, destinationToken: destToken, chains, tokens, payer: account, fetchQuote: api.fetchQuote, solve: solveExactIn, amountInRaw });
|
|
1493
2010
|
if (route.state === "SHORT") throw new Error("ZeroDelta could not price this swap right now.");
|
|
1494
2011
|
route.recommended = true;
|
|
1495
2012
|
return {
|
|
@@ -1899,6 +2416,24 @@ function resolveConfig(config = {}) {
|
|
|
1899
2416
|
}
|
|
1900
2417
|
|
|
1901
2418
|
// src/core/index.ts
|
|
2419
|
+
function sanitizeLegs(legs) {
|
|
2420
|
+
if (!Array.isArray(legs) || !legs.length) return void 0;
|
|
2421
|
+
const text = (v, max) => String(v ?? "").slice(0, max);
|
|
2422
|
+
const chain = (v) => Number(v) || 0;
|
|
2423
|
+
return legs.slice(0, 8).map((leg, i) => ({
|
|
2424
|
+
index: Number(leg?.index) || i + 1,
|
|
2425
|
+
fromAsset: text(leg?.fromAsset, 12),
|
|
2426
|
+
fromChainId: chain(leg?.fromChainId),
|
|
2427
|
+
fromChainName: text(leg?.fromChainName, 40),
|
|
2428
|
+
fromAmount: text(leg?.fromAmount, 40),
|
|
2429
|
+
toAsset: text(leg?.toAsset, 12),
|
|
2430
|
+
toChainId: chain(leg?.toChainId),
|
|
2431
|
+
toChainName: text(leg?.toChainName, 40),
|
|
2432
|
+
toAmount: text(leg?.toAmount, 40),
|
|
2433
|
+
executionChainId: chain(leg?.executionChainId),
|
|
2434
|
+
executionChainName: text(leg?.executionChainName, 40)
|
|
2435
|
+
}));
|
|
2436
|
+
}
|
|
1902
2437
|
function sanitizeTxEntry(entry) {
|
|
1903
2438
|
return {
|
|
1904
2439
|
kind: entry.kind === "swap" ? "swap" : "payment",
|
|
@@ -1914,7 +2449,8 @@ function sanitizeTxEntry(entry) {
|
|
|
1914
2449
|
recipient: isAddress(entry.recipient) ? normalizeAddress(entry.recipient) : "",
|
|
1915
2450
|
settlement: entry.settlement === "direct" ? "direct" : "escrow",
|
|
1916
2451
|
status: entry.status && ["confirmed", "unconfirmed", "error"].includes(entry.status) ? entry.status : "submitted",
|
|
1917
|
-
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
2452
|
+
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2453
|
+
legs: sanitizeLegs(entry.legs)
|
|
1918
2454
|
};
|
|
1919
2455
|
}
|
|
1920
2456
|
function createEngine(config = {}) {
|
|
@@ -1931,12 +2467,15 @@ function createEngine(config = {}) {
|
|
|
1931
2467
|
fetchRouteHealth: api.fetchRouteHealth,
|
|
1932
2468
|
fetchQuote: api.fetchQuote,
|
|
1933
2469
|
fetchCatalogue: async (allowedAssets, product) => {
|
|
1934
|
-
const [chains,
|
|
2470
|
+
const [chains, registryTokens, routes, health, vaults] = await Promise.all([
|
|
1935
2471
|
api.fetchChains().catch(() => []),
|
|
1936
2472
|
api.fetchTokens().catch(() => []),
|
|
1937
2473
|
api.fetchRoutes().catch(() => []),
|
|
1938
|
-
api.fetchRouteHealth()
|
|
2474
|
+
api.fetchRouteHealth(),
|
|
2475
|
+
api.fetchRwaVaults()
|
|
1939
2476
|
]);
|
|
2477
|
+
const vaultIcons = vaultIconsBySymbol(api.apiBase, vaults);
|
|
2478
|
+
const tokens = withVaultArtwork(registryTokens, vaultIcons);
|
|
1940
2479
|
const allowed = allowedAssets?.length ? new Set([...allowedAssets].map(symbolKey).filter((a) => SUPPORTED_ASSETS.has(a))) : void 0;
|
|
1941
2480
|
return buildCatalogue({
|
|
1942
2481
|
chains,
|
|
@@ -1945,7 +2484,8 @@ function createEngine(config = {}) {
|
|
|
1945
2484
|
product,
|
|
1946
2485
|
...allowed ? { allowedAssets: allowed } : {},
|
|
1947
2486
|
supportedChainIds: SUPPORTED_CHAIN_IDS,
|
|
1948
|
-
brokenLanes: suppressedLanes(health)
|
|
2487
|
+
brokenLanes: suppressedLanes(health),
|
|
2488
|
+
vaultIcons
|
|
1949
2489
|
});
|
|
1950
2490
|
},
|
|
1951
2491
|
fetchPaymentPlan: (request, payer, wallet) => fetchPaymentPlan(api, request, payer, wallet, verifier.readBalances),
|
|
@@ -1966,4 +2506,4 @@ function createEngine(config = {}) {
|
|
|
1966
2506
|
};
|
|
1967
2507
|
}
|
|
1968
2508
|
|
|
1969
|
-
export { API_CACHE_TTL_MS, BUNDLED_NATIVE_SYMBOL, BUNDLED_RPC, CANONICAL_DECIMALS, CANONICAL_ESCROW, CANONICAL_INBOUND_BRIDGE, CHAIN_DISPLAY_NAMES, DEFAULT_WIDGET_API_BASE, ERC20_ALLOWANCE_SELECTOR, ERC20_APPROVE_SELECTOR, ERC20_BALANCEOF_SELECTOR, ERC20_TRANSFER_SELECTOR, EXECUTABLE_STABLE_ASSETS, LZ_FEE_BUFFER_BPS, MAX_LZ_MSG_VALUE_WEI, MAX_LZ_MSG_VALUE_WEI_BY_CHAIN, MAX_QUOTE_CANDIDATES, MAX_SAME_CLASS_PAY_BPS, MAX_UINT64, NO_PARTNER_ID, PREVIEW_OWNER, QUOTE_BUFFER_BPS, SAME_CLASS_STABLE, STABLEGENIE_INTENT_TTL_MS, STABLEGENIE_INTENT_VERSION, STABLEGENIE_SUPPORTED_ASSETS, STABLEGENIE_SUPPORTED_CHAIN_IDS, STABLE_ASSETS, SUBMIT_ORDER_SELECTOR, SUPPORTED_ASSETS, SUPPORTED_CHAIN_IDS, TRADEABLE_RWA_ASSETS, ZERO_ADDRESS, addressWord, allowanceCovers, apiError, applyLayerZeroBuffer, assertAddress, assertQuoteMatchesSelection, assetClassOf, assetDecimals, brokenLaneFor, brokenLaneReason, buildCatalogue, buildPayOptions, buildRoute, buildSwapPlan, bytes32Word, bytesPayload, canAttachApiKey, chainById, chainNameOf, chainSelectable, checkEscrow, checkNativeFee, classifyQuoteError, counterpartTokens, createApiClient, createEngine, createVerifier, decodeSubmitOrderCalldata, destinationAvailability, destinationKeys, encodeAllowance, encodeApprove, encodeBalanceOf, encodeSubmitOrder, encodeTransfer, executableRoutes, executionChainIds, fetchPaymentPlan, finalOf, findToken, formatNative, formatUnits, hasReachableDestination, hubDeliverableSymbols, isAddress, isDeliverable, isExecutableBridge, isHexAddress, isHexData, isHexQuantity, isKnownUnbridgeable, isLayerZeroRoute, isSourceToken, laneKey, laneKeys, maxNativeFeeWei, nativeFeeShortLabel, nativeFeeShortMessage, nativeSymbol, normalizeAddress, normalizeDecimalText, normalizeOrderRequest, normalizeOrderRequests, parseAllowedApiBase, parseUnitsDecimal, planErrorSummary, planMsgValueHex, productAssets, quoteSwapPreview, registryRpc, requiresNativeBridgeFee, resolveApiBase, resolveConfig, resolveSwapReceiver, routeNativeValue, scaleDecimals, solveExactIn, solveExactOut, sourceKeys, stableGenieIntentSchema, strip0x, suppressedLanes, symbolKey, toHexQuantity, tokenEnabled, tokenKey, txMatchesPlan, uint64Word, uintWord, validateDestination, validatePlannedTransaction, validateSwap };
|
|
2509
|
+
export { API_CACHE_TTL_MS, BLOCK_LABEL_DEFAULT, BUNDLED_NATIVE_SYMBOL, BUNDLED_RPC, CANONICAL_DECIMALS, CANONICAL_ESCROW, CANONICAL_INBOUND_BRIDGE, CHAIN_DISPLAY_NAMES, COMPLIANCE_CHECK_ORDER, COMPLIANCE_DENY_LABEL, DEFAULT_WIDGET_API_BASE, DIRECT_CHECK_IDS, DIRECT_SCOPE_NOTE, ERC20_ALLOWANCE_SELECTOR, ERC20_APPROVE_SELECTOR, ERC20_BALANCEOF_SELECTOR, ERC20_TRANSFER_SELECTOR, EXECUTABLE_STABLE_ASSETS, FLOOR_CATEGORIES, LZ_FEE_BUFFER_BPS, MAX_LZ_MSG_VALUE_WEI, MAX_LZ_MSG_VALUE_WEI_BY_CHAIN, MAX_QUOTE_CANDIDATES, MAX_SAME_CLASS_PAY_BPS, MAX_UINT64, NO_PARTNER_ID, PREVIEW_OWNER, QUOTE_BUFFER_BPS, SAME_CLASS_STABLE, SCREENING_BUCKETS, SCREEN_CACHE_TTL_MS, STABLEGENIE_INTENT_TTL_MS, STABLEGENIE_INTENT_VERSION, STABLEGENIE_SUPPORTED_ASSETS, STABLEGENIE_SUPPORTED_CHAIN_IDS, STABLE_ASSETS, SUBMIT_ORDER_SELECTOR, SUPPORTED_ASSETS, SUPPORTED_CHAIN_IDS, TRADEABLE_RWA_ASSETS, TUNABLE_CATEGORIES, ZERO_ADDRESS, addressWord, allowanceCovers, apiError, applyLayerZeroBuffer, assertAddress, assertQuoteMatchesSelection, assetClassOf, assetDecimals, blockLabelFor, brokenLaneFor, brokenLaneReason, buildCatalogue, buildPayOptions, buildRoute, buildSwapPlan, bytes32Word, bytesPayload, canAttachApiKey, categoryLabel, chainById, chainNameOf, chainSelectable, checkEscrow, checkNativeFee, classifyQuoteError, complianceChecks, complianceControlsEvaluated, complianceControlsLine, complianceReasonHead, complianceReasonTag, complianceTagOf, complianceView, counterpartTokens, createApiClient, createEngine, createVerifier, decodeSubmitOrderCalldata, destinationAvailability, destinationKeys, directComplianceFromScreens, distinctScreenedWallets, encodeAllowance, encodeApprove, encodeBalanceOf, encodeSubmitOrder, encodeTransfer, executableRoutes, executionChainIds, fetchPaymentPlan, finalOf, findToken, formatNative, formatUnits, hasReachableDestination, hubDeliverableSymbols, humanizeComplianceReason, isAddress, isDeliverable, isExecutableBridge, isHexAddress, isHexData, isHexQuantity, isKnownUnbridgeable, isLayerZeroRoute, isSourceToken, laneKey, laneKeys, maxNativeFeeWei, nativeFeeShortLabel, nativeFeeShortMessage, nativeSymbol, normalizeAddress, normalizeDecimalText, normalizeOrderRequest, normalizeOrderRequests, parseAllowedApiBase, parseUnitsDecimal, planErrorSummary, planMsgValueHex, productAssets, quoteSwapPreview, registryRpc, requiresNativeBridgeFee, resolveApiBase, resolveConfig, resolveSwapReceiver, resolveVaultIcon, routeNativeValue, scaleDecimals, screeningOutcomeOf, solveExactIn, solveExactOut, sourceKeys, stableGenieIntentSchema, strip0x, suppressedLanes, symbolKey, toHexQuantity, tokenEnabled, tokenKey, txMatchesPlan, uint64Word, uintWord, unattributedComplianceReasons, validateDestination, validatePlannedTransaction, validateSwap, vaultIconsBySymbol, withVaultArtwork };
|