@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
package/dist/core/index.cjs
CHANGED
|
@@ -25,6 +25,7 @@ var TRADEABLE_RWA_ASSETS = /* @__PURE__ */ new Set([
|
|
|
25
25
|
]);
|
|
26
26
|
var SUPPORTED_ASSETS = /* @__PURE__ */ new Set([...STABLE_ASSETS, ...TRADEABLE_RWA_ASSETS]);
|
|
27
27
|
var API_CACHE_TTL_MS = 6e4;
|
|
28
|
+
var SCREEN_CACHE_TTL_MS = 5 * 6e4;
|
|
28
29
|
var MAX_QUOTE_CANDIDATES = 8;
|
|
29
30
|
var QUOTE_BUFFER_BPS = 50;
|
|
30
31
|
var LZ_FEE_BUFFER_BPS = 1500n;
|
|
@@ -585,7 +586,7 @@ function buildCatalogue(input) {
|
|
|
585
586
|
);
|
|
586
587
|
const byId = new Map(enabledChains.map((c) => [Number(c.chainId), c]));
|
|
587
588
|
for (const id of chainIds) if (!byId.has(id)) byId.set(id, { chainId: id, isEnabled: true });
|
|
588
|
-
return { ...ctx, product, tokens: catalogue, sources, chainIds, chains: [...byId.values()], ready };
|
|
589
|
+
return { ...ctx, product, tokens: catalogue, sources, chainIds, chains: [...byId.values()], ready, vaultIcons: input.vaultIcons ?? /* @__PURE__ */ new Map() };
|
|
589
590
|
}
|
|
590
591
|
|
|
591
592
|
// src/core/options.ts
|
|
@@ -751,6 +752,366 @@ function brokenLaneReason(lane) {
|
|
|
751
752
|
}
|
|
752
753
|
}
|
|
753
754
|
|
|
755
|
+
// src/core/rwa-icons.ts
|
|
756
|
+
var GATEWAY_ICON_PREFIX = "/api/v1/rwa/icons/";
|
|
757
|
+
var ICON_FILE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}\.(?:png|jpg|jpeg|webp|gif)$/;
|
|
758
|
+
function resolveVaultIcon(apiBase, iconPath) {
|
|
759
|
+
if (typeof iconPath !== "string" || !iconPath.startsWith(GATEWAY_ICON_PREFIX)) return void 0;
|
|
760
|
+
const file = iconPath.slice(GATEWAY_ICON_PREFIX.length);
|
|
761
|
+
if (!ICON_FILE.test(file)) return void 0;
|
|
762
|
+
return `${apiBase.replace(/\/$/, "")}/rwa/icons/${file}`;
|
|
763
|
+
}
|
|
764
|
+
function vaultIconsBySymbol(apiBase, vaults) {
|
|
765
|
+
const out = /* @__PURE__ */ new Map();
|
|
766
|
+
for (const vault of vaults) {
|
|
767
|
+
const key = symbolKey(vault?.symbol);
|
|
768
|
+
if (!key || out.has(key)) continue;
|
|
769
|
+
const url = resolveVaultIcon(apiBase, vault?.iconMiniUrl) ?? resolveVaultIcon(apiBase, vault?.iconUrl);
|
|
770
|
+
if (url) out.set(key, url);
|
|
771
|
+
}
|
|
772
|
+
return out;
|
|
773
|
+
}
|
|
774
|
+
function withVaultArtwork(tokens, icons) {
|
|
775
|
+
if (!icons.size) return tokens;
|
|
776
|
+
return tokens.map((token) => {
|
|
777
|
+
if (token.logoUrl) return token;
|
|
778
|
+
const url = icons.get(symbolKey(token.symbol));
|
|
779
|
+
return url ? { ...token, logoUrl: url } : token;
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
// src/core/compliance.ts
|
|
784
|
+
var COMPLIANCE_DENY_LABEL = "Compliance check failed";
|
|
785
|
+
function complianceView(compliance, hasQuote = true) {
|
|
786
|
+
if (!hasQuote) {
|
|
787
|
+
return {
|
|
788
|
+
tone: "neutral",
|
|
789
|
+
label: "Compliance checks run with your quote",
|
|
790
|
+
headline: "No compliance decision for this payment yet",
|
|
791
|
+
blocked: false,
|
|
792
|
+
needsAction: false,
|
|
793
|
+
screened: false
|
|
794
|
+
};
|
|
795
|
+
}
|
|
796
|
+
const decision = compliance?.decision;
|
|
797
|
+
const screened = compliance?.status === "SCREENED";
|
|
798
|
+
if (decision === "DENY") {
|
|
799
|
+
return {
|
|
800
|
+
tone: "blocked",
|
|
801
|
+
label: COMPLIANCE_DENY_LABEL,
|
|
802
|
+
headline: "Blocked by compliance policy",
|
|
803
|
+
blocked: true,
|
|
804
|
+
needsAction: false,
|
|
805
|
+
screened
|
|
806
|
+
};
|
|
807
|
+
}
|
|
808
|
+
if (decision === "REVIEW" || decision === "REMEDIATE") {
|
|
809
|
+
const word = decision.toLowerCase();
|
|
810
|
+
return {
|
|
811
|
+
tone: "warn",
|
|
812
|
+
label: `Compliance: ${word} required`,
|
|
813
|
+
headline: `Manual ${word} required`,
|
|
814
|
+
blocked: false,
|
|
815
|
+
needsAction: true,
|
|
816
|
+
screened
|
|
817
|
+
};
|
|
818
|
+
}
|
|
819
|
+
if (decision === "ALLOW") {
|
|
820
|
+
return {
|
|
821
|
+
tone: "ok",
|
|
822
|
+
label: screened ? "Compliance checks passed" : "Allowed \u2014 wallets not screened",
|
|
823
|
+
headline: screened ? "Wallets screened and allowed" : "Allowed \u2014 wallets not screened",
|
|
824
|
+
blocked: false,
|
|
825
|
+
needsAction: false,
|
|
826
|
+
screened
|
|
827
|
+
};
|
|
828
|
+
}
|
|
829
|
+
return {
|
|
830
|
+
tone: "neutral",
|
|
831
|
+
label: screened ? "Screened \u2014 no policy decision returned" : "No compliance decision returned",
|
|
832
|
+
headline: screened ? "Screened \u2014 no policy decision returned" : "No compliance decision returned",
|
|
833
|
+
blocked: false,
|
|
834
|
+
needsAction: false,
|
|
835
|
+
screened
|
|
836
|
+
};
|
|
837
|
+
}
|
|
838
|
+
var CATEGORY_PHRASES = {
|
|
839
|
+
SANCTIONS: "sanctions",
|
|
840
|
+
TERRORISM_FINANCING: "terrorism financing",
|
|
841
|
+
STOLEN_FUNDS: "stolen funds",
|
|
842
|
+
RANSOMWARE: "ransomware",
|
|
843
|
+
SCAM: "scam activity",
|
|
844
|
+
DARKNET: "darknet activity",
|
|
845
|
+
MIXER: "mixer usage",
|
|
846
|
+
HIGH_RISK_ENTITY: "a high-risk entity",
|
|
847
|
+
PEP: "a politically-exposed person",
|
|
848
|
+
INDIRECT_EXPOSURE: "indirect exposure",
|
|
849
|
+
UNCLASSIFIED: "an unrecognized risk",
|
|
850
|
+
UNKNOWN: "an unrecognized risk"
|
|
851
|
+
};
|
|
852
|
+
function categoryLabel(code) {
|
|
853
|
+
const key = code.trim().toUpperCase();
|
|
854
|
+
const LABELS = {
|
|
855
|
+
SANCTIONS: "Sanctions",
|
|
856
|
+
TERRORISM_FINANCING: "Terrorist financing",
|
|
857
|
+
STOLEN_FUNDS: "Stolen funds",
|
|
858
|
+
RANSOMWARE: "Ransomware",
|
|
859
|
+
SCAM: "Scam",
|
|
860
|
+
DARKNET: "Darknet services",
|
|
861
|
+
MIXER: "Mixer",
|
|
862
|
+
HIGH_RISK_ENTITY: "High-risk entity",
|
|
863
|
+
PEP: "Politically exposed person (PEP)",
|
|
864
|
+
INDIRECT_EXPOSURE: "Indirect exposure",
|
|
865
|
+
UNCLASSIFIED: "Unclassified risk",
|
|
866
|
+
UNKNOWN: "Unclassified risk"
|
|
867
|
+
};
|
|
868
|
+
return LABELS[key] ?? key.toLowerCase().replace(/_/g, " ");
|
|
869
|
+
}
|
|
870
|
+
function cleanJurisdiction(code) {
|
|
871
|
+
return code.replace(/^(OFAC|TIER\d+|SANCTIONED)_/i, "").trim();
|
|
872
|
+
}
|
|
873
|
+
function stripBundlePrefix(head) {
|
|
874
|
+
if (head.startsWith("policy_")) return { head: head.slice("policy_".length), source: "policy" };
|
|
875
|
+
if (head.startsWith("legislation_")) return { head: head.slice("legislation_".length), source: "legislation" };
|
|
876
|
+
return { head, source: null };
|
|
877
|
+
}
|
|
878
|
+
function complianceReasonHead(raw) {
|
|
879
|
+
return stripBundlePrefix((raw.split(":")[0] ?? "").trim()).head;
|
|
880
|
+
}
|
|
881
|
+
function usd(raw) {
|
|
882
|
+
const n = Number(raw);
|
|
883
|
+
if (!Number.isFinite(n)) return `$${raw}`;
|
|
884
|
+
return `$${n.toLocaleString("en-US", { maximumFractionDigits: 2 })}`;
|
|
885
|
+
}
|
|
886
|
+
function capFromDetail(detail) {
|
|
887
|
+
const m = detail.match(/>([\d.]+)/);
|
|
888
|
+
return m ? ` (${usd(m[1])})` : "";
|
|
889
|
+
}
|
|
890
|
+
function categoryPhrase(detail) {
|
|
891
|
+
const cat = detail.replace(/\s*\(.*\)$/, "").toUpperCase();
|
|
892
|
+
return CATEGORY_PHRASES[cat] ?? cat.toLowerCase().replace(/_/g, " ");
|
|
893
|
+
}
|
|
894
|
+
function humanizeComplianceReason(raw) {
|
|
895
|
+
const [headRaw, ...restParts] = raw.split(":");
|
|
896
|
+
const detail = restParts.join(":").trim();
|
|
897
|
+
const { head, source } = stripBundlePrefix((headRaw ?? "").trim());
|
|
898
|
+
const scope = source === "legislation" ? "applicable regulations" : "the applicable policy";
|
|
899
|
+
switch (head) {
|
|
900
|
+
case "asset_pair_not_allowed": {
|
|
901
|
+
const m = detail.match(/^(\S+)->(\S+)\s+in\s+(\S+)/);
|
|
902
|
+
if (m) return `${m[1]} \u2192 ${m[2]} isn't available in your region (${cleanJurisdiction(m[3])}).`;
|
|
903
|
+
return "This asset pair isn't available in your region.";
|
|
904
|
+
}
|
|
905
|
+
case "asset_not_allowed": {
|
|
906
|
+
const m = detail.match(/^(\S+?)->(\S+?)(?::|$)/);
|
|
907
|
+
if (m) return `${m[1]} \u2192 ${m[2]} isn't permitted under ${scope}.`;
|
|
908
|
+
return `This asset pair isn't permitted under ${scope}.`;
|
|
909
|
+
}
|
|
910
|
+
case "blocked_jurisdiction":
|
|
911
|
+
return `Your region (${cleanJurisdiction(detail)}) isn't supported.`;
|
|
912
|
+
case "blocked_destination_jurisdiction":
|
|
913
|
+
return `The destination region (${cleanJurisdiction(detail)}) isn't supported.`;
|
|
914
|
+
case "jurisdiction_out_of_scope":
|
|
915
|
+
return `Not covered by ${scope}.`;
|
|
916
|
+
case "ui_block":
|
|
917
|
+
return `Payments aren't available in your region (${cleanJurisdiction(detail)}).`;
|
|
918
|
+
case "blocked_corridor_mode":
|
|
919
|
+
return "This route isn't currently open for payments.";
|
|
920
|
+
case "blocked_category":
|
|
921
|
+
return `Flagged for ${categoryPhrase(detail)}.`;
|
|
922
|
+
case "amount_exceeds_max_order_usd":
|
|
923
|
+
case "amount_exceeds_max":
|
|
924
|
+
return `Amount exceeds the maximum order size${capFromDetail(detail)}.`;
|
|
925
|
+
case "amount_exceeds_actor_cap":
|
|
926
|
+
return `Amount exceeds the limit for your account type${capFromDetail(detail)}.`;
|
|
927
|
+
case "amount_exceeds_jurisdiction_max":
|
|
928
|
+
return `Amount exceeds the limit for your region${capFromDetail(detail)}.`;
|
|
929
|
+
case "source_chain_not_allowed":
|
|
930
|
+
return `The source chain isn't permitted under ${scope}.`;
|
|
931
|
+
case "dest_chain_not_allowed":
|
|
932
|
+
return `The destination chain isn't permitted under ${scope}.`;
|
|
933
|
+
default:
|
|
934
|
+
return detail ? `${head.replace(/_/g, " ")} \u2014 ${detail}` : head.replace(/_/g, " ");
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
var COMPLIANCE_CHECK_ORDER = [
|
|
938
|
+
"location",
|
|
939
|
+
"screening",
|
|
940
|
+
"risk",
|
|
941
|
+
"asset",
|
|
942
|
+
"limits"
|
|
943
|
+
];
|
|
944
|
+
var CHECK_LABELS = {
|
|
945
|
+
location: "Location and corridor permitted",
|
|
946
|
+
screening: "Both wallets screened",
|
|
947
|
+
risk: "Risk policy passed",
|
|
948
|
+
asset: "Asset and amount allowed",
|
|
949
|
+
limits: "Transaction limits verified"
|
|
950
|
+
};
|
|
951
|
+
var CHECK_HEADS = {
|
|
952
|
+
location: [
|
|
953
|
+
"blocked_jurisdiction",
|
|
954
|
+
"blocked_destination_jurisdiction",
|
|
955
|
+
"ui_block",
|
|
956
|
+
"blocked_corridor_mode",
|
|
957
|
+
"jurisdiction_out_of_scope"
|
|
958
|
+
],
|
|
959
|
+
screening: [],
|
|
960
|
+
risk: ["blocked_category"],
|
|
961
|
+
asset: ["asset_pair_not_allowed", "asset_not_allowed", "source_chain_not_allowed", "dest_chain_not_allowed"],
|
|
962
|
+
limits: [
|
|
963
|
+
"amount_exceeds_max_order_usd",
|
|
964
|
+
"amount_exceeds_max",
|
|
965
|
+
"amount_exceeds_actor_cap",
|
|
966
|
+
"amount_exceeds_jurisdiction_max"
|
|
967
|
+
]
|
|
968
|
+
};
|
|
969
|
+
function distinctScreenedWallets(compliance) {
|
|
970
|
+
const seen = /* @__PURE__ */ new Set();
|
|
971
|
+
const wallets = [];
|
|
972
|
+
for (const raw of compliance?.screenedWallets ?? []) {
|
|
973
|
+
const address = raw?.trim();
|
|
974
|
+
if (!address) continue;
|
|
975
|
+
const key = /^0x[0-9a-fA-F]+$/.test(address) ? address.toLowerCase() : address;
|
|
976
|
+
if (seen.has(key)) continue;
|
|
977
|
+
seen.add(key);
|
|
978
|
+
wallets.push(address);
|
|
979
|
+
}
|
|
980
|
+
return wallets;
|
|
981
|
+
}
|
|
982
|
+
function shortAddress(a) {
|
|
983
|
+
return a.length > 12 ? `${a.slice(0, 6)}\u2026${a.slice(-4)}` : a;
|
|
984
|
+
}
|
|
985
|
+
function screeningLabel(wallets) {
|
|
986
|
+
if (wallets === 1) return "Wallet screened";
|
|
987
|
+
if (wallets === 2) return CHECK_LABELS.screening;
|
|
988
|
+
return "Wallets screened";
|
|
989
|
+
}
|
|
990
|
+
function complianceChecks(compliance, cv = complianceView(compliance)) {
|
|
991
|
+
if (cv.tone === "neutral") return [];
|
|
992
|
+
const byControl = /* @__PURE__ */ new Map();
|
|
993
|
+
for (const raw of compliance?.reasons ?? []) {
|
|
994
|
+
const head = complianceReasonHead(raw);
|
|
995
|
+
const id = COMPLIANCE_CHECK_ORDER.find((c) => CHECK_HEADS[c].includes(head));
|
|
996
|
+
if (!id) continue;
|
|
997
|
+
byControl.set(id, [...byControl.get(id) ?? [], raw]);
|
|
998
|
+
}
|
|
999
|
+
const screenedWallets = distinctScreenedWallets(compliance);
|
|
1000
|
+
const wallets = screenedWallets.length;
|
|
1001
|
+
const blocking = compliance?.blockingCategories?.length ?? 0;
|
|
1002
|
+
return COMPLIANCE_CHECK_ORDER.map((id) => {
|
|
1003
|
+
if (id === "screening") {
|
|
1004
|
+
const ok2 = cv.screened || wallets > 0;
|
|
1005
|
+
const note = wallets === 1 ? shortAddress(screenedWallets[0]) : wallets > 1 ? `${wallets} wallets screened` : void 0;
|
|
1006
|
+
return { id, label: ok2 ? screeningLabel(wallets) : "Wallets not screened", ok: ok2, reasons: [], note };
|
|
1007
|
+
}
|
|
1008
|
+
const reasons = byControl.get(id) ?? [];
|
|
1009
|
+
const ok = reasons.length === 0 && !(id === "risk" && blocking > 0);
|
|
1010
|
+
return { id, label: CHECK_LABELS[id], ok, reasons };
|
|
1011
|
+
});
|
|
1012
|
+
}
|
|
1013
|
+
function unattributedComplianceReasons(compliance, cv = complianceView(compliance)) {
|
|
1014
|
+
const claimed = new Set(complianceChecks(compliance, cv).flatMap((c) => c.reasons));
|
|
1015
|
+
return (compliance?.reasons ?? []).filter((r) => !claimed.has(r));
|
|
1016
|
+
}
|
|
1017
|
+
function complianceControlsEvaluated(compliance, cv = complianceView(compliance)) {
|
|
1018
|
+
const checks = complianceChecks(compliance, cv);
|
|
1019
|
+
if (checks.length === 0) return 0;
|
|
1020
|
+
const named = /* @__PURE__ */ new Set();
|
|
1021
|
+
for (const raw of [...compliance?.appliedPolicyNames ?? [], ...compliance?.appliedLegislation ?? []]) {
|
|
1022
|
+
const name = raw?.trim();
|
|
1023
|
+
if (name) named.add(name.toLowerCase());
|
|
1024
|
+
}
|
|
1025
|
+
return checks.length + named.size;
|
|
1026
|
+
}
|
|
1027
|
+
function complianceControlsLine(compliance, cv = complianceView(compliance)) {
|
|
1028
|
+
if (cv.blocked || cv.needsAction) return cv.headline;
|
|
1029
|
+
const n = complianceControlsEvaluated(compliance, cv);
|
|
1030
|
+
if (n === 0) return cv.headline;
|
|
1031
|
+
return `${n} compliance control${n === 1 ? "" : "s"} evaluated for this payment`;
|
|
1032
|
+
}
|
|
1033
|
+
function directComplianceFromScreens(screens) {
|
|
1034
|
+
const blockedAny = screens.some((s) => s.blocked);
|
|
1035
|
+
const cats = (pick) => [
|
|
1036
|
+
...new Set(screens.flatMap((s) => pick(s) ?? []))
|
|
1037
|
+
];
|
|
1038
|
+
return {
|
|
1039
|
+
status: "SCREENED",
|
|
1040
|
+
decision: blockedAny ? "DENY" : "ALLOW",
|
|
1041
|
+
screenedWallets: screens.map((s) => s.address),
|
|
1042
|
+
riskCategories: cats((s) => s.riskCategories),
|
|
1043
|
+
flaggedCategories: cats((s) => s.flaggedCategories),
|
|
1044
|
+
blockingCategories: cats((s) => s.blockingCategories),
|
|
1045
|
+
reasons: blockedAny ? cats((s) => s.blockingCategories).map((c) => `blocked_category:${c}`) : []
|
|
1046
|
+
};
|
|
1047
|
+
}
|
|
1048
|
+
var DIRECT_CHECK_IDS = ["screening", "risk"];
|
|
1049
|
+
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.";
|
|
1050
|
+
var BLOCK_CATEGORY_LABELS = {
|
|
1051
|
+
STOLEN_FUNDS: "flagged as associated with stolen funds",
|
|
1052
|
+
SANCTIONS: "on a sanctions list",
|
|
1053
|
+
SANCTIONED: "on a sanctions list",
|
|
1054
|
+
OFAC: "on a sanctions list",
|
|
1055
|
+
TERRORIST_FINANCING: "flagged for terrorist financing",
|
|
1056
|
+
TERRORISM_FINANCING: "flagged for terrorist financing",
|
|
1057
|
+
FRAUD: "flagged for fraud",
|
|
1058
|
+
SCAM: "flagged as a scam address"
|
|
1059
|
+
};
|
|
1060
|
+
var BLOCK_LABEL_DEFAULT = "flagged by compliance screening";
|
|
1061
|
+
function blockLabelFor(categories) {
|
|
1062
|
+
for (const raw of categories) {
|
|
1063
|
+
const label = BLOCK_CATEGORY_LABELS[String(raw || "").trim().toUpperCase()];
|
|
1064
|
+
if (label) return label;
|
|
1065
|
+
}
|
|
1066
|
+
return BLOCK_LABEL_DEFAULT;
|
|
1067
|
+
}
|
|
1068
|
+
var REASON_TAGS = {
|
|
1069
|
+
blocked_jurisdiction: "Restricted country",
|
|
1070
|
+
ui_block: "Restricted country",
|
|
1071
|
+
blocked_destination_jurisdiction: "Restricted destination",
|
|
1072
|
+
blocked_corridor_mode: "Corridor closed",
|
|
1073
|
+
blocked_category: "Risk flag",
|
|
1074
|
+
amount_exceeds_max_order_usd: "Limit exceeded",
|
|
1075
|
+
amount_exceeds_max: "Limit exceeded",
|
|
1076
|
+
amount_exceeds_actor_cap: "Limit exceeded",
|
|
1077
|
+
amount_exceeds_jurisdiction_max: "Limit exceeded",
|
|
1078
|
+
asset_pair_not_allowed: "Asset not allowed",
|
|
1079
|
+
asset_not_allowed: "Asset not allowed",
|
|
1080
|
+
source_chain_not_allowed: "Chain not allowed",
|
|
1081
|
+
dest_chain_not_allowed: "Chain not allowed",
|
|
1082
|
+
jurisdiction_out_of_scope: "Out of scope"
|
|
1083
|
+
};
|
|
1084
|
+
function complianceReasonTag(raw) {
|
|
1085
|
+
const head = complianceReasonHead(raw);
|
|
1086
|
+
return REASON_TAGS[head] ?? head.replace(/_/g, " ");
|
|
1087
|
+
}
|
|
1088
|
+
function complianceTagOf(compliance) {
|
|
1089
|
+
const first = (compliance?.reasons ?? [])[0];
|
|
1090
|
+
return first ? complianceReasonTag(first) : "";
|
|
1091
|
+
}
|
|
1092
|
+
var FLOOR_CATEGORIES = ["SANCTIONS", "TERRORISM_FINANCING", "STOLEN_FUNDS", "RANSOMWARE"];
|
|
1093
|
+
var TUNABLE_CATEGORIES = ["SCAM", "DARKNET", "MIXER", "HIGH_RISK_ENTITY", "PEP", "INDIRECT_EXPOSURE", "UNCLASSIFIED"];
|
|
1094
|
+
var TUNED_OUTCOMES = {
|
|
1095
|
+
SCAM: "blocked",
|
|
1096
|
+
DARKNET: "blocked",
|
|
1097
|
+
MIXER: "flagged",
|
|
1098
|
+
HIGH_RISK_ENTITY: "flagged",
|
|
1099
|
+
PEP: "flagged",
|
|
1100
|
+
INDIRECT_EXPOSURE: "flagged",
|
|
1101
|
+
UNCLASSIFIED: "flagged"
|
|
1102
|
+
};
|
|
1103
|
+
function screeningOutcomeOf(category) {
|
|
1104
|
+
const key = category.trim().toUpperCase();
|
|
1105
|
+
if (FLOOR_CATEGORIES.includes(key)) return "always-blocked";
|
|
1106
|
+
return TUNED_OUTCOMES[key] ?? null;
|
|
1107
|
+
}
|
|
1108
|
+
var labelsFor = (outcome) => [...FLOOR_CATEGORIES, ...TUNABLE_CATEGORIES].filter((c) => screeningOutcomeOf(c) === outcome).map(categoryLabel);
|
|
1109
|
+
var SCREENING_BUCKETS = [
|
|
1110
|
+
{ outcome: "always-blocked", title: "Always blocked", detail: "Cannot be changed or disabled.", categories: labelsFor("always-blocked") },
|
|
1111
|
+
{ outcome: "blocked", title: "Blocked under this policy", detail: "The current policy stops the order.", categories: labelsFor("blocked") },
|
|
1112
|
+
{ outcome: "flagged", title: "Flagged", detail: "A warning is shown.", categories: labelsFor("flagged") }
|
|
1113
|
+
];
|
|
1114
|
+
|
|
754
1115
|
// src/core/solve.ts
|
|
755
1116
|
async function solveExactOut({ option, destination, destinationToken, payer, fetchQuote }) {
|
|
756
1117
|
const destDecimals = assetDecimals(destinationToken);
|
|
@@ -987,7 +1348,63 @@ function routeLabelFor(option, destinationToken, result) {
|
|
|
987
1348
|
const bridge = result.quote.bridge ? ` via ${result.quote.bridge}` : "";
|
|
988
1349
|
return `Swap ${option.symbol} to ${destinationToken.symbol} and settle on ZeroDelta${bridge}.`;
|
|
989
1350
|
}
|
|
990
|
-
|
|
1351
|
+
function tokenAt(tokens, chainId, address) {
|
|
1352
|
+
const wanted = normalizeAddress(address);
|
|
1353
|
+
if (!wanted || !tokens?.length) return void 0;
|
|
1354
|
+
return tokens.find((t) => Number(t.chainId) === Number(chainId) && normalizeAddress(t.address) === wanted);
|
|
1355
|
+
}
|
|
1356
|
+
function legAmount(raw, decimals) {
|
|
1357
|
+
if (decimals === void 0) return "";
|
|
1358
|
+
try {
|
|
1359
|
+
return formatUnits(raw || "0", decimals);
|
|
1360
|
+
} catch {
|
|
1361
|
+
return "";
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
function buildLegs(orders, ctx) {
|
|
1365
|
+
const legs = [];
|
|
1366
|
+
let fromChainId = ctx.option.chainId;
|
|
1367
|
+
let fromAsset = ctx.option.symbol;
|
|
1368
|
+
let fromDecimals = ctx.option.decimals;
|
|
1369
|
+
for (let index = 0; index < orders.length; index += 1) {
|
|
1370
|
+
const order = orders[index];
|
|
1371
|
+
const isLast = index === orders.length - 1;
|
|
1372
|
+
const toChainId = Number(order.destinationChainId);
|
|
1373
|
+
const askToken = isLast ? ctx.destinationToken : tokenAt(ctx.tokens, toChainId, order.askToken);
|
|
1374
|
+
const toAsset = isLast ? ctx.destinationToken.symbol : askToken?.symbol ?? "";
|
|
1375
|
+
const toDecimals = askToken ? assetDecimals(askToken) : void 0;
|
|
1376
|
+
const executionChainId = Number(order.executionChainId);
|
|
1377
|
+
legs.push({
|
|
1378
|
+
index: index + 1,
|
|
1379
|
+
fromAsset,
|
|
1380
|
+
fromChainId,
|
|
1381
|
+
fromChainName: chainNameOf(fromChainId, ctx.chains),
|
|
1382
|
+
fromAmount: legAmount(order.bidTokenAmount, fromDecimals),
|
|
1383
|
+
toAsset,
|
|
1384
|
+
toChainId,
|
|
1385
|
+
toChainName: chainNameOf(toChainId, ctx.chains),
|
|
1386
|
+
toAmount: legAmount(order.askTokenAmount, toDecimals),
|
|
1387
|
+
executionChainId,
|
|
1388
|
+
executionChainName: chainNameOf(executionChainId, ctx.chains)
|
|
1389
|
+
});
|
|
1390
|
+
fromChainId = toChainId;
|
|
1391
|
+
fromAsset = toAsset;
|
|
1392
|
+
fromDecimals = toDecimals;
|
|
1393
|
+
}
|
|
1394
|
+
return legs;
|
|
1395
|
+
}
|
|
1396
|
+
async function buildRoute({
|
|
1397
|
+
option,
|
|
1398
|
+
destination,
|
|
1399
|
+
destinationToken,
|
|
1400
|
+
chains,
|
|
1401
|
+
tokens,
|
|
1402
|
+
payer,
|
|
1403
|
+
fetchQuote,
|
|
1404
|
+
solve = solveExactOut,
|
|
1405
|
+
amountInRaw,
|
|
1406
|
+
compliance
|
|
1407
|
+
}) {
|
|
991
1408
|
const result = await solve({ option, destination, destinationToken, payer, fetchQuote, amountInRaw });
|
|
992
1409
|
const quote = result.quote;
|
|
993
1410
|
const destDecimals = assetDecimals(destinationToken);
|
|
@@ -1017,6 +1434,23 @@ async function buildRoute({ option, destination, destinationToken, chains, payer
|
|
|
1017
1434
|
},
|
|
1018
1435
|
routeLabel: routeLabelFor(option, destinationToken, result),
|
|
1019
1436
|
deltaLabel: routeDeltaLabel(result, quote),
|
|
1437
|
+
// A direct transfer submits no order at all, but it is still ONE hop and history renders the
|
|
1438
|
+
// same shape for it — an empty `legs` would leave "one order or two?" unanswerable for it alone.
|
|
1439
|
+
legs: [
|
|
1440
|
+
{
|
|
1441
|
+
index: 1,
|
|
1442
|
+
fromAsset: option.symbol,
|
|
1443
|
+
fromChainId: option.chainId,
|
|
1444
|
+
fromChainName: option.chainName,
|
|
1445
|
+
fromAmount: sourceAmount,
|
|
1446
|
+
toAsset: destinationToken.symbol,
|
|
1447
|
+
toChainId: Number(destination.chainId),
|
|
1448
|
+
toChainName: chainNameOf(Number(destination.chainId), chains),
|
|
1449
|
+
toAmount: receiveAmount,
|
|
1450
|
+
executionChainId: option.chainId,
|
|
1451
|
+
executionChainName: option.chainName
|
|
1452
|
+
}
|
|
1453
|
+
],
|
|
1020
1454
|
transactions: [
|
|
1021
1455
|
{
|
|
1022
1456
|
id: "transfer",
|
|
@@ -1034,7 +1468,11 @@ async function buildRoute({ option, destination, destinationToken, chains, payer
|
|
|
1034
1468
|
bridge: quote.bridge,
|
|
1035
1469
|
feeBps: quote.feeBps,
|
|
1036
1470
|
estimatedDuration: quote.estimatedDuration,
|
|
1037
|
-
iterations: result.iterations
|
|
1471
|
+
iterations: result.iterations,
|
|
1472
|
+
// A direct transfer never reaches /quote (solve.ts short-circuits it), so there is no
|
|
1473
|
+
// gateway decision to carry. The caller screens both parties itself and passes the
|
|
1474
|
+
// synthesized verdict in — see plan.ts and compliance.ts::directComplianceFromScreens.
|
|
1475
|
+
compliance
|
|
1038
1476
|
}
|
|
1039
1477
|
};
|
|
1040
1478
|
}
|
|
@@ -1086,6 +1524,7 @@ async function buildRoute({ option, destination, destinationToken, chains, payer
|
|
|
1086
1524
|
},
|
|
1087
1525
|
routeLabel: routeLabelFor(option, destinationToken, result),
|
|
1088
1526
|
deltaLabel: routeDeltaLabel(result, quote),
|
|
1527
|
+
legs: buildLegs(orders, { option, destinationToken, chains, tokens }),
|
|
1089
1528
|
transactions: [
|
|
1090
1529
|
{
|
|
1091
1530
|
id: "approve",
|
|
@@ -1118,7 +1557,11 @@ async function buildRoute({ option, destination, destinationToken, chains, payer
|
|
|
1118
1557
|
gasCostSource: quote.gasCostSource,
|
|
1119
1558
|
msgValue: valueRaw.toString(),
|
|
1120
1559
|
deadline: order.deadline,
|
|
1121
|
-
iterations: result.iterations
|
|
1560
|
+
iterations: result.iterations,
|
|
1561
|
+
// Carried verbatim from the gateway's decision on THIS wallet pair. The projection used to
|
|
1562
|
+
// drop it, which is why the widget could show a price with no evidence of the control that
|
|
1563
|
+
// produced it.
|
|
1564
|
+
compliance: quote.compliance
|
|
1122
1565
|
}
|
|
1123
1566
|
};
|
|
1124
1567
|
}
|
|
@@ -1154,25 +1597,20 @@ function apiMessage(json, fallback) {
|
|
|
1154
1597
|
}
|
|
1155
1598
|
return sanitizeMessage(err?.message, fallback);
|
|
1156
1599
|
}
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
TERRORIST_FINANCING: "flagged for terrorist financing",
|
|
1163
|
-
FRAUD: "flagged for fraud",
|
|
1164
|
-
SCAM: "flagged as a scam address"
|
|
1165
|
-
};
|
|
1166
|
-
var BLOCK_LABEL_DEFAULT = "flagged by compliance screening";
|
|
1600
|
+
function isStructuredComplianceBlock(error) {
|
|
1601
|
+
const code = String(error?.code || "").toUpperCase();
|
|
1602
|
+
if (code === "COMPLIANCE_BLOCKED" || code === "COMPLIANCE_BLOCK") return true;
|
|
1603
|
+
return error?.status === 422 && Array.isArray(error?.reasons) && error.reasons.length > 0;
|
|
1604
|
+
}
|
|
1167
1605
|
function classifyQuoteError(error) {
|
|
1168
1606
|
if (!error) return null;
|
|
1169
1607
|
const reasons = Array.isArray(error.reasons) ? error.reasons : [];
|
|
1170
1608
|
const haystack = `${error.message || ""} ${reasons.join(" ")}`;
|
|
1171
1609
|
const catMatch = /blocked_category:\s*([A-Za-z_]+)/i.exec(haystack);
|
|
1172
|
-
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);
|
|
1610
|
+
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);
|
|
1173
1611
|
if (!isBlock) return null;
|
|
1174
1612
|
const category = (catMatch?.[1] || "").toUpperCase() || "COMPLIANCE";
|
|
1175
|
-
const label =
|
|
1613
|
+
const label = blockLabelFor([category]);
|
|
1176
1614
|
return {
|
|
1177
1615
|
blocked: true,
|
|
1178
1616
|
category,
|
|
@@ -1194,8 +1632,11 @@ function createApiClient(cfg) {
|
|
|
1194
1632
|
chains: null,
|
|
1195
1633
|
tokens: null,
|
|
1196
1634
|
routes: null,
|
|
1197
|
-
health: null
|
|
1635
|
+
health: null,
|
|
1636
|
+
vaults: null
|
|
1198
1637
|
};
|
|
1638
|
+
const screenCache = /* @__PURE__ */ new Map();
|
|
1639
|
+
const screenInflight = /* @__PURE__ */ new Map();
|
|
1199
1640
|
const apiBase = cfg.apiBase.replace(/\/$/, "");
|
|
1200
1641
|
async function apiRequest(path, init = {}) {
|
|
1201
1642
|
const apiKey = await cfg.getApiKey();
|
|
@@ -1276,6 +1717,19 @@ function createApiClient(cfg) {
|
|
|
1276
1717
|
cache.health = { at: Date.now(), value };
|
|
1277
1718
|
return value;
|
|
1278
1719
|
}
|
|
1720
|
+
async function fetchRwaVaults() {
|
|
1721
|
+
if (nowFresh(cache.vaults)) return cache.vaults.value;
|
|
1722
|
+
let value = [];
|
|
1723
|
+
try {
|
|
1724
|
+
const payload = await apiRequest("/rwa/vaults?status=active,coming_soon", { timeoutMs: 8e3 });
|
|
1725
|
+
const rows = Array.isArray(payload) ? payload : payload?.vaults;
|
|
1726
|
+
value = Array.isArray(rows) ? rows.filter((v) => !!v && typeof v === "object") : [];
|
|
1727
|
+
} catch {
|
|
1728
|
+
value = [];
|
|
1729
|
+
}
|
|
1730
|
+
cache.vaults = { at: Date.now(), value };
|
|
1731
|
+
return value;
|
|
1732
|
+
}
|
|
1279
1733
|
async function fetchQuote(body, retries = 1) {
|
|
1280
1734
|
let lastError;
|
|
1281
1735
|
for (let attempt = 0; attempt <= retries; attempt += 1) {
|
|
@@ -1290,7 +1744,32 @@ function createApiClient(cfg) {
|
|
|
1290
1744
|
}
|
|
1291
1745
|
throw lastError;
|
|
1292
1746
|
}
|
|
1293
|
-
|
|
1747
|
+
async function screenWallet(address, chainId) {
|
|
1748
|
+
const addr = String(address || "").trim();
|
|
1749
|
+
if (!addr) throw apiError("An address is required to screen a wallet.", { code: "bad_request" });
|
|
1750
|
+
const key = `${/^0x[0-9a-fA-F]+$/.test(addr) ? addr.toLowerCase() : addr}|${chainId ?? ""}`;
|
|
1751
|
+
const hit = screenCache.get(key);
|
|
1752
|
+
if (hit && Date.now() - hit.at < SCREEN_CACHE_TTL_MS) return hit.value;
|
|
1753
|
+
const inflight = screenInflight.get(key);
|
|
1754
|
+
if (inflight) return inflight;
|
|
1755
|
+
const request = apiRequest("/screen/wallet", {
|
|
1756
|
+
method: "POST",
|
|
1757
|
+
body: JSON.stringify(chainId == null ? { address: addr } : { address: addr, chainId }),
|
|
1758
|
+
timeoutMs: 12e3
|
|
1759
|
+
}).then((screen) => {
|
|
1760
|
+
if (!screen || typeof screen !== "object" || typeof screen.blocked !== "boolean") {
|
|
1761
|
+
throw apiError("Compliance screening returned an unusable result.", { code: "bad_response" });
|
|
1762
|
+
}
|
|
1763
|
+
const value = { ...screen, address: screen.address || addr };
|
|
1764
|
+
screenCache.set(key, { at: Date.now(), value });
|
|
1765
|
+
return value;
|
|
1766
|
+
}).finally(() => {
|
|
1767
|
+
screenInflight.delete(key);
|
|
1768
|
+
});
|
|
1769
|
+
screenInflight.set(key, request);
|
|
1770
|
+
return request;
|
|
1771
|
+
}
|
|
1772
|
+
return { apiRequest, fetchChains, fetchTokens, fetchRoutes, fetchRouteHealth, fetchRwaVaults, fetchQuote, screenWallet, apiBase };
|
|
1294
1773
|
}
|
|
1295
1774
|
|
|
1296
1775
|
// src/core/plan.ts
|
|
@@ -1358,7 +1837,36 @@ async function fetchPaymentPlan(api, request, payer, wallet = {}, readBalances)
|
|
|
1358
1837
|
balanceTargets.push({ chainId: option.chainId, tokenAddress: option.address, decimals: option.decimals });
|
|
1359
1838
|
}
|
|
1360
1839
|
const walletBalances = readBalances ? await readBalances(payer, balanceTargets).catch(() => ({})) : {};
|
|
1361
|
-
const
|
|
1840
|
+
const directOptions = options.filter((option) => option.direct);
|
|
1841
|
+
let directCompliance = null;
|
|
1842
|
+
if (directOptions.length) {
|
|
1843
|
+
const parties = [];
|
|
1844
|
+
const seenParty = /* @__PURE__ */ new Set();
|
|
1845
|
+
for (const raw of [payer, destination.address]) {
|
|
1846
|
+
const addr = String(raw || "").trim();
|
|
1847
|
+
if (!addr) continue;
|
|
1848
|
+
const key = /^0x[0-9a-fA-F]+$/.test(addr) ? addr.toLowerCase() : addr;
|
|
1849
|
+
if (seenParty.has(key)) continue;
|
|
1850
|
+
seenParty.add(key);
|
|
1851
|
+
parties.push(addr);
|
|
1852
|
+
}
|
|
1853
|
+
try {
|
|
1854
|
+
const screens = await Promise.all(parties.map((address) => api.screenWallet(address, destination.chainId)));
|
|
1855
|
+
const blocked = screens.filter((screen) => screen.blocked);
|
|
1856
|
+
if (blocked.length) {
|
|
1857
|
+
const who = blocked.some((s) => s.address.toLowerCase() === payer.toLowerCase()) ? "your wallet" : "the recipient";
|
|
1858
|
+
const categories = [...new Set(blocked.flatMap((s) => s.blockingCategories ?? []))];
|
|
1859
|
+
throw apiError(
|
|
1860
|
+
`This payment was blocked by compliance screening \u2014 ${who} is ${blockLabelFor(categories)}. Choose a different recipient or connect a different wallet.`,
|
|
1861
|
+
{ blocked: true, blockedCategory: categories[0] || "COMPLIANCE", blockedReason: categories.join(", ") }
|
|
1862
|
+
);
|
|
1863
|
+
}
|
|
1864
|
+
directCompliance = directComplianceFromScreens(screens);
|
|
1865
|
+
} catch (error) {
|
|
1866
|
+
if (error?.blocked) throw error;
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1869
|
+
const candidates = directCompliance ? directOptions : [];
|
|
1362
1870
|
const heldOptions = options.filter((option) => !option.direct && hasPositiveBalance(option, walletBalances));
|
|
1363
1871
|
const heldKeys = new Set(heldOptions.map(optionBalanceKey));
|
|
1364
1872
|
const seenChains = /* @__PURE__ */ new Set();
|
|
@@ -1378,7 +1886,16 @@ async function fetchPaymentPlan(api, request, payer, wallet = {}, readBalances)
|
|
|
1378
1886
|
}
|
|
1379
1887
|
const routeErrors = [];
|
|
1380
1888
|
const routePromises = candidates.map(
|
|
1381
|
-
(option) => buildRoute({
|
|
1889
|
+
(option) => buildRoute({
|
|
1890
|
+
option,
|
|
1891
|
+
destination,
|
|
1892
|
+
destinationToken,
|
|
1893
|
+
chains,
|
|
1894
|
+
tokens,
|
|
1895
|
+
payer,
|
|
1896
|
+
fetchQuote: api.fetchQuote,
|
|
1897
|
+
compliance: option.direct ? directCompliance ?? void 0 : void 0
|
|
1898
|
+
}).catch((error) => {
|
|
1382
1899
|
routeErrors.push(error);
|
|
1383
1900
|
return null;
|
|
1384
1901
|
})
|
|
@@ -1491,7 +2008,7 @@ async function buildSwapPlan(api, swap, payer, wallet = {}) {
|
|
|
1491
2008
|
direct: false
|
|
1492
2009
|
};
|
|
1493
2010
|
const destination = { address: receiver, chainId: v.toChainId, asset: destToken.symbol };
|
|
1494
|
-
const route = await buildRoute({ option, destination, destinationToken: destToken, chains, payer: account, fetchQuote: api.fetchQuote, solve: solveExactIn, amountInRaw });
|
|
2011
|
+
const route = await buildRoute({ option, destination, destinationToken: destToken, chains, tokens, payer: account, fetchQuote: api.fetchQuote, solve: solveExactIn, amountInRaw });
|
|
1495
2012
|
if (route.state === "SHORT") throw new Error("ZeroDelta could not price this swap right now.");
|
|
1496
2013
|
route.recommended = true;
|
|
1497
2014
|
return {
|
|
@@ -1901,6 +2418,24 @@ function resolveConfig(config = {}) {
|
|
|
1901
2418
|
}
|
|
1902
2419
|
|
|
1903
2420
|
// src/core/index.ts
|
|
2421
|
+
function sanitizeLegs(legs) {
|
|
2422
|
+
if (!Array.isArray(legs) || !legs.length) return void 0;
|
|
2423
|
+
const text = (v, max) => String(v ?? "").slice(0, max);
|
|
2424
|
+
const chain = (v) => Number(v) || 0;
|
|
2425
|
+
return legs.slice(0, 8).map((leg, i) => ({
|
|
2426
|
+
index: Number(leg?.index) || i + 1,
|
|
2427
|
+
fromAsset: text(leg?.fromAsset, 12),
|
|
2428
|
+
fromChainId: chain(leg?.fromChainId),
|
|
2429
|
+
fromChainName: text(leg?.fromChainName, 40),
|
|
2430
|
+
fromAmount: text(leg?.fromAmount, 40),
|
|
2431
|
+
toAsset: text(leg?.toAsset, 12),
|
|
2432
|
+
toChainId: chain(leg?.toChainId),
|
|
2433
|
+
toChainName: text(leg?.toChainName, 40),
|
|
2434
|
+
toAmount: text(leg?.toAmount, 40),
|
|
2435
|
+
executionChainId: chain(leg?.executionChainId),
|
|
2436
|
+
executionChainName: text(leg?.executionChainName, 40)
|
|
2437
|
+
}));
|
|
2438
|
+
}
|
|
1904
2439
|
function sanitizeTxEntry(entry) {
|
|
1905
2440
|
return {
|
|
1906
2441
|
kind: entry.kind === "swap" ? "swap" : "payment",
|
|
@@ -1916,7 +2451,8 @@ function sanitizeTxEntry(entry) {
|
|
|
1916
2451
|
recipient: isAddress(entry.recipient) ? normalizeAddress(entry.recipient) : "",
|
|
1917
2452
|
settlement: entry.settlement === "direct" ? "direct" : "escrow",
|
|
1918
2453
|
status: entry.status && ["confirmed", "unconfirmed", "error"].includes(entry.status) ? entry.status : "submitted",
|
|
1919
|
-
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
2454
|
+
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2455
|
+
legs: sanitizeLegs(entry.legs)
|
|
1920
2456
|
};
|
|
1921
2457
|
}
|
|
1922
2458
|
function createEngine(config = {}) {
|
|
@@ -1933,12 +2469,15 @@ function createEngine(config = {}) {
|
|
|
1933
2469
|
fetchRouteHealth: api.fetchRouteHealth,
|
|
1934
2470
|
fetchQuote: api.fetchQuote,
|
|
1935
2471
|
fetchCatalogue: async (allowedAssets, product) => {
|
|
1936
|
-
const [chains,
|
|
2472
|
+
const [chains, registryTokens, routes, health, vaults] = await Promise.all([
|
|
1937
2473
|
api.fetchChains().catch(() => []),
|
|
1938
2474
|
api.fetchTokens().catch(() => []),
|
|
1939
2475
|
api.fetchRoutes().catch(() => []),
|
|
1940
|
-
api.fetchRouteHealth()
|
|
2476
|
+
api.fetchRouteHealth(),
|
|
2477
|
+
api.fetchRwaVaults()
|
|
1941
2478
|
]);
|
|
2479
|
+
const vaultIcons = vaultIconsBySymbol(api.apiBase, vaults);
|
|
2480
|
+
const tokens = withVaultArtwork(registryTokens, vaultIcons);
|
|
1942
2481
|
const allowed = allowedAssets?.length ? new Set([...allowedAssets].map(symbolKey).filter((a) => SUPPORTED_ASSETS.has(a))) : void 0;
|
|
1943
2482
|
return buildCatalogue({
|
|
1944
2483
|
chains,
|
|
@@ -1947,7 +2486,8 @@ function createEngine(config = {}) {
|
|
|
1947
2486
|
product,
|
|
1948
2487
|
...allowed ? { allowedAssets: allowed } : {},
|
|
1949
2488
|
supportedChainIds: SUPPORTED_CHAIN_IDS,
|
|
1950
|
-
brokenLanes: suppressedLanes(health)
|
|
2489
|
+
brokenLanes: suppressedLanes(health),
|
|
2490
|
+
vaultIcons
|
|
1951
2491
|
});
|
|
1952
2492
|
},
|
|
1953
2493
|
fetchPaymentPlan: (request, payer, wallet) => fetchPaymentPlan(api, request, payer, wallet, verifier.readBalances),
|
|
@@ -1969,18 +2509,24 @@ function createEngine(config = {}) {
|
|
|
1969
2509
|
}
|
|
1970
2510
|
|
|
1971
2511
|
exports.API_CACHE_TTL_MS = API_CACHE_TTL_MS;
|
|
2512
|
+
exports.BLOCK_LABEL_DEFAULT = BLOCK_LABEL_DEFAULT;
|
|
1972
2513
|
exports.BUNDLED_NATIVE_SYMBOL = BUNDLED_NATIVE_SYMBOL;
|
|
1973
2514
|
exports.BUNDLED_RPC = BUNDLED_RPC;
|
|
1974
2515
|
exports.CANONICAL_DECIMALS = CANONICAL_DECIMALS;
|
|
1975
2516
|
exports.CANONICAL_ESCROW = CANONICAL_ESCROW;
|
|
1976
2517
|
exports.CANONICAL_INBOUND_BRIDGE = CANONICAL_INBOUND_BRIDGE;
|
|
1977
2518
|
exports.CHAIN_DISPLAY_NAMES = CHAIN_DISPLAY_NAMES;
|
|
2519
|
+
exports.COMPLIANCE_CHECK_ORDER = COMPLIANCE_CHECK_ORDER;
|
|
2520
|
+
exports.COMPLIANCE_DENY_LABEL = COMPLIANCE_DENY_LABEL;
|
|
1978
2521
|
exports.DEFAULT_WIDGET_API_BASE = DEFAULT_WIDGET_API_BASE;
|
|
2522
|
+
exports.DIRECT_CHECK_IDS = DIRECT_CHECK_IDS;
|
|
2523
|
+
exports.DIRECT_SCOPE_NOTE = DIRECT_SCOPE_NOTE;
|
|
1979
2524
|
exports.ERC20_ALLOWANCE_SELECTOR = ERC20_ALLOWANCE_SELECTOR;
|
|
1980
2525
|
exports.ERC20_APPROVE_SELECTOR = ERC20_APPROVE_SELECTOR;
|
|
1981
2526
|
exports.ERC20_BALANCEOF_SELECTOR = ERC20_BALANCEOF_SELECTOR;
|
|
1982
2527
|
exports.ERC20_TRANSFER_SELECTOR = ERC20_TRANSFER_SELECTOR;
|
|
1983
2528
|
exports.EXECUTABLE_STABLE_ASSETS = EXECUTABLE_STABLE_ASSETS;
|
|
2529
|
+
exports.FLOOR_CATEGORIES = FLOOR_CATEGORIES;
|
|
1984
2530
|
exports.LZ_FEE_BUFFER_BPS = LZ_FEE_BUFFER_BPS;
|
|
1985
2531
|
exports.MAX_LZ_MSG_VALUE_WEI = MAX_LZ_MSG_VALUE_WEI;
|
|
1986
2532
|
exports.MAX_LZ_MSG_VALUE_WEI_BY_CHAIN = MAX_LZ_MSG_VALUE_WEI_BY_CHAIN;
|
|
@@ -1991,6 +2537,8 @@ exports.NO_PARTNER_ID = NO_PARTNER_ID;
|
|
|
1991
2537
|
exports.PREVIEW_OWNER = PREVIEW_OWNER;
|
|
1992
2538
|
exports.QUOTE_BUFFER_BPS = QUOTE_BUFFER_BPS;
|
|
1993
2539
|
exports.SAME_CLASS_STABLE = SAME_CLASS_STABLE;
|
|
2540
|
+
exports.SCREENING_BUCKETS = SCREENING_BUCKETS;
|
|
2541
|
+
exports.SCREEN_CACHE_TTL_MS = SCREEN_CACHE_TTL_MS;
|
|
1994
2542
|
exports.STABLEGENIE_INTENT_TTL_MS = STABLEGENIE_INTENT_TTL_MS;
|
|
1995
2543
|
exports.STABLEGENIE_INTENT_VERSION = STABLEGENIE_INTENT_VERSION;
|
|
1996
2544
|
exports.STABLEGENIE_SUPPORTED_ASSETS = STABLEGENIE_SUPPORTED_ASSETS;
|
|
@@ -2000,6 +2548,7 @@ exports.SUBMIT_ORDER_SELECTOR = SUBMIT_ORDER_SELECTOR;
|
|
|
2000
2548
|
exports.SUPPORTED_ASSETS = SUPPORTED_ASSETS;
|
|
2001
2549
|
exports.SUPPORTED_CHAIN_IDS = SUPPORTED_CHAIN_IDS;
|
|
2002
2550
|
exports.TRADEABLE_RWA_ASSETS = TRADEABLE_RWA_ASSETS;
|
|
2551
|
+
exports.TUNABLE_CATEGORIES = TUNABLE_CATEGORIES;
|
|
2003
2552
|
exports.ZERO_ADDRESS = ZERO_ADDRESS;
|
|
2004
2553
|
exports.addressWord = addressWord;
|
|
2005
2554
|
exports.allowanceCovers = allowanceCovers;
|
|
@@ -2009,6 +2558,7 @@ exports.assertAddress = assertAddress;
|
|
|
2009
2558
|
exports.assertQuoteMatchesSelection = assertQuoteMatchesSelection;
|
|
2010
2559
|
exports.assetClassOf = assetClassOf;
|
|
2011
2560
|
exports.assetDecimals = assetDecimals;
|
|
2561
|
+
exports.blockLabelFor = blockLabelFor;
|
|
2012
2562
|
exports.brokenLaneFor = brokenLaneFor;
|
|
2013
2563
|
exports.brokenLaneReason = brokenLaneReason;
|
|
2014
2564
|
exports.buildCatalogue = buildCatalogue;
|
|
@@ -2018,12 +2568,20 @@ exports.buildSwapPlan = buildSwapPlan;
|
|
|
2018
2568
|
exports.bytes32Word = bytes32Word;
|
|
2019
2569
|
exports.bytesPayload = bytesPayload;
|
|
2020
2570
|
exports.canAttachApiKey = canAttachApiKey;
|
|
2571
|
+
exports.categoryLabel = categoryLabel;
|
|
2021
2572
|
exports.chainById = chainById;
|
|
2022
2573
|
exports.chainNameOf = chainNameOf;
|
|
2023
2574
|
exports.chainSelectable = chainSelectable;
|
|
2024
2575
|
exports.checkEscrow = checkEscrow;
|
|
2025
2576
|
exports.checkNativeFee = checkNativeFee;
|
|
2026
2577
|
exports.classifyQuoteError = classifyQuoteError;
|
|
2578
|
+
exports.complianceChecks = complianceChecks;
|
|
2579
|
+
exports.complianceControlsEvaluated = complianceControlsEvaluated;
|
|
2580
|
+
exports.complianceControlsLine = complianceControlsLine;
|
|
2581
|
+
exports.complianceReasonHead = complianceReasonHead;
|
|
2582
|
+
exports.complianceReasonTag = complianceReasonTag;
|
|
2583
|
+
exports.complianceTagOf = complianceTagOf;
|
|
2584
|
+
exports.complianceView = complianceView;
|
|
2027
2585
|
exports.counterpartTokens = counterpartTokens;
|
|
2028
2586
|
exports.createApiClient = createApiClient;
|
|
2029
2587
|
exports.createEngine = createEngine;
|
|
@@ -2031,6 +2589,8 @@ exports.createVerifier = createVerifier;
|
|
|
2031
2589
|
exports.decodeSubmitOrderCalldata = decodeSubmitOrderCalldata;
|
|
2032
2590
|
exports.destinationAvailability = destinationAvailability;
|
|
2033
2591
|
exports.destinationKeys = destinationKeys;
|
|
2592
|
+
exports.directComplianceFromScreens = directComplianceFromScreens;
|
|
2593
|
+
exports.distinctScreenedWallets = distinctScreenedWallets;
|
|
2034
2594
|
exports.encodeAllowance = encodeAllowance;
|
|
2035
2595
|
exports.encodeApprove = encodeApprove;
|
|
2036
2596
|
exports.encodeBalanceOf = encodeBalanceOf;
|
|
@@ -2045,6 +2605,7 @@ exports.formatNative = formatNative;
|
|
|
2045
2605
|
exports.formatUnits = formatUnits;
|
|
2046
2606
|
exports.hasReachableDestination = hasReachableDestination;
|
|
2047
2607
|
exports.hubDeliverableSymbols = hubDeliverableSymbols;
|
|
2608
|
+
exports.humanizeComplianceReason = humanizeComplianceReason;
|
|
2048
2609
|
exports.isAddress = isAddress;
|
|
2049
2610
|
exports.isDeliverable = isDeliverable;
|
|
2050
2611
|
exports.isExecutableBridge = isExecutableBridge;
|
|
@@ -2075,8 +2636,10 @@ exports.requiresNativeBridgeFee = requiresNativeBridgeFee;
|
|
|
2075
2636
|
exports.resolveApiBase = resolveApiBase;
|
|
2076
2637
|
exports.resolveConfig = resolveConfig;
|
|
2077
2638
|
exports.resolveSwapReceiver = resolveSwapReceiver;
|
|
2639
|
+
exports.resolveVaultIcon = resolveVaultIcon;
|
|
2078
2640
|
exports.routeNativeValue = routeNativeValue;
|
|
2079
2641
|
exports.scaleDecimals = scaleDecimals;
|
|
2642
|
+
exports.screeningOutcomeOf = screeningOutcomeOf;
|
|
2080
2643
|
exports.solveExactIn = solveExactIn;
|
|
2081
2644
|
exports.solveExactOut = solveExactOut;
|
|
2082
2645
|
exports.sourceKeys = sourceKeys;
|
|
@@ -2090,6 +2653,9 @@ exports.tokenKey = tokenKey;
|
|
|
2090
2653
|
exports.txMatchesPlan = txMatchesPlan;
|
|
2091
2654
|
exports.uint64Word = uint64Word;
|
|
2092
2655
|
exports.uintWord = uintWord;
|
|
2656
|
+
exports.unattributedComplianceReasons = unattributedComplianceReasons;
|
|
2093
2657
|
exports.validateDestination = validateDestination;
|
|
2094
2658
|
exports.validatePlannedTransaction = validatePlannedTransaction;
|
|
2095
2659
|
exports.validateSwap = validateSwap;
|
|
2660
|
+
exports.vaultIconsBySymbol = vaultIconsBySymbol;
|
|
2661
|
+
exports.withVaultArtwork = withVaultArtwork;
|