@glacislabs/stablegenie-zerodelta 4.0.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-ABI6ZH7O.js → chunk-DXUESKNC.js} +214 -49
- package/dist/{chunk-FJQQLB2K.js → chunk-YEYFEQWS.js} +159 -11
- package/dist/core/index.cjs +161 -10
- package/dist/core/index.d.cts +25 -4
- package/dist/core/index.d.ts +25 -4
- package/dist/core/index.js +1 -1
- package/dist/index.cjs +373 -60
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/{mount-D5k_u92L.d.ts → mount-BFa37j1u.d.ts} +1 -1
- package/dist/{mount-mcyZAzZc.d.cts → mount-DssudKQ7.d.cts} +1 -1
- package/dist/mount.cjs +373 -60
- 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 +63 -7
- package/dist/{verify-C9vzpm4T.d.cts → verify-Ce6ZtDhi.d.cts} +66 -1
- package/dist/{verify-C9vzpm4T.d.ts → verify-Ce6ZtDhi.d.ts} +66 -1
- package/package.json +1 -1
|
@@ -584,7 +584,7 @@ function buildCatalogue(input) {
|
|
|
584
584
|
);
|
|
585
585
|
const byId = new Map(enabledChains.map((c) => [Number(c.chainId), c]));
|
|
586
586
|
for (const id of chainIds) if (!byId.has(id)) byId.set(id, { chainId: id, isEnabled: true });
|
|
587
|
-
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() };
|
|
588
588
|
}
|
|
589
589
|
|
|
590
590
|
// src/core/options.ts
|
|
@@ -750,6 +750,34 @@ function brokenLaneReason(lane) {
|
|
|
750
750
|
}
|
|
751
751
|
}
|
|
752
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
|
+
|
|
753
781
|
// src/core/compliance.ts
|
|
754
782
|
var COMPLIANCE_DENY_LABEL = "Compliance check failed";
|
|
755
783
|
function complianceView(compliance, hasQuote = true) {
|
|
@@ -1318,7 +1346,63 @@ function routeLabelFor(option, destinationToken, result) {
|
|
|
1318
1346
|
const bridge = result.quote.bridge ? ` via ${result.quote.bridge}` : "";
|
|
1319
1347
|
return `Swap ${option.symbol} to ${destinationToken.symbol} and settle on ZeroDelta${bridge}.`;
|
|
1320
1348
|
}
|
|
1321
|
-
|
|
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
|
+
}) {
|
|
1322
1406
|
const result = await solve({ option, destination, destinationToken, payer, fetchQuote, amountInRaw });
|
|
1323
1407
|
const quote = result.quote;
|
|
1324
1408
|
const destDecimals = assetDecimals(destinationToken);
|
|
@@ -1348,6 +1432,23 @@ async function buildRoute({ option, destination, destinationToken, chains, payer
|
|
|
1348
1432
|
},
|
|
1349
1433
|
routeLabel: routeLabelFor(option, destinationToken, result),
|
|
1350
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
|
+
],
|
|
1351
1452
|
transactions: [
|
|
1352
1453
|
{
|
|
1353
1454
|
id: "transfer",
|
|
@@ -1421,6 +1522,7 @@ async function buildRoute({ option, destination, destinationToken, chains, payer
|
|
|
1421
1522
|
},
|
|
1422
1523
|
routeLabel: routeLabelFor(option, destinationToken, result),
|
|
1423
1524
|
deltaLabel: routeDeltaLabel(result, quote),
|
|
1525
|
+
legs: buildLegs(orders, { option, destinationToken, chains, tokens }),
|
|
1424
1526
|
transactions: [
|
|
1425
1527
|
{
|
|
1426
1528
|
id: "approve",
|
|
@@ -1528,7 +1630,8 @@ function createApiClient(cfg) {
|
|
|
1528
1630
|
chains: null,
|
|
1529
1631
|
tokens: null,
|
|
1530
1632
|
routes: null,
|
|
1531
|
-
health: null
|
|
1633
|
+
health: null,
|
|
1634
|
+
vaults: null
|
|
1532
1635
|
};
|
|
1533
1636
|
const screenCache = /* @__PURE__ */ new Map();
|
|
1534
1637
|
const screenInflight = /* @__PURE__ */ new Map();
|
|
@@ -1612,6 +1715,19 @@ function createApiClient(cfg) {
|
|
|
1612
1715
|
cache.health = { at: Date.now(), value };
|
|
1613
1716
|
return value;
|
|
1614
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
|
+
}
|
|
1615
1731
|
async function fetchQuote(body, retries = 1) {
|
|
1616
1732
|
let lastError;
|
|
1617
1733
|
for (let attempt = 0; attempt <= retries; attempt += 1) {
|
|
@@ -1651,7 +1767,7 @@ function createApiClient(cfg) {
|
|
|
1651
1767
|
screenInflight.set(key, request);
|
|
1652
1768
|
return request;
|
|
1653
1769
|
}
|
|
1654
|
-
return { apiRequest, fetchChains, fetchTokens, fetchRoutes, fetchRouteHealth, fetchQuote, screenWallet, apiBase };
|
|
1770
|
+
return { apiRequest, fetchChains, fetchTokens, fetchRoutes, fetchRouteHealth, fetchRwaVaults, fetchQuote, screenWallet, apiBase };
|
|
1655
1771
|
}
|
|
1656
1772
|
|
|
1657
1773
|
// src/core/plan.ts
|
|
@@ -1768,7 +1884,16 @@ async function fetchPaymentPlan(api, request, payer, wallet = {}, readBalances)
|
|
|
1768
1884
|
}
|
|
1769
1885
|
const routeErrors = [];
|
|
1770
1886
|
const routePromises = candidates.map(
|
|
1771
|
-
(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) => {
|
|
1772
1897
|
routeErrors.push(error);
|
|
1773
1898
|
return null;
|
|
1774
1899
|
})
|
|
@@ -1881,7 +2006,7 @@ async function buildSwapPlan(api, swap, payer, wallet = {}) {
|
|
|
1881
2006
|
direct: false
|
|
1882
2007
|
};
|
|
1883
2008
|
const destination = { address: receiver, chainId: v.toChainId, asset: destToken.symbol };
|
|
1884
|
-
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 });
|
|
1885
2010
|
if (route.state === "SHORT") throw new Error("ZeroDelta could not price this swap right now.");
|
|
1886
2011
|
route.recommended = true;
|
|
1887
2012
|
return {
|
|
@@ -2291,6 +2416,24 @@ function resolveConfig(config = {}) {
|
|
|
2291
2416
|
}
|
|
2292
2417
|
|
|
2293
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
|
+
}
|
|
2294
2437
|
function sanitizeTxEntry(entry) {
|
|
2295
2438
|
return {
|
|
2296
2439
|
kind: entry.kind === "swap" ? "swap" : "payment",
|
|
@@ -2306,7 +2449,8 @@ function sanitizeTxEntry(entry) {
|
|
|
2306
2449
|
recipient: isAddress(entry.recipient) ? normalizeAddress(entry.recipient) : "",
|
|
2307
2450
|
settlement: entry.settlement === "direct" ? "direct" : "escrow",
|
|
2308
2451
|
status: entry.status && ["confirmed", "unconfirmed", "error"].includes(entry.status) ? entry.status : "submitted",
|
|
2309
|
-
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
2452
|
+
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2453
|
+
legs: sanitizeLegs(entry.legs)
|
|
2310
2454
|
};
|
|
2311
2455
|
}
|
|
2312
2456
|
function createEngine(config = {}) {
|
|
@@ -2323,12 +2467,15 @@ function createEngine(config = {}) {
|
|
|
2323
2467
|
fetchRouteHealth: api.fetchRouteHealth,
|
|
2324
2468
|
fetchQuote: api.fetchQuote,
|
|
2325
2469
|
fetchCatalogue: async (allowedAssets, product) => {
|
|
2326
|
-
const [chains,
|
|
2470
|
+
const [chains, registryTokens, routes, health, vaults] = await Promise.all([
|
|
2327
2471
|
api.fetchChains().catch(() => []),
|
|
2328
2472
|
api.fetchTokens().catch(() => []),
|
|
2329
2473
|
api.fetchRoutes().catch(() => []),
|
|
2330
|
-
api.fetchRouteHealth()
|
|
2474
|
+
api.fetchRouteHealth(),
|
|
2475
|
+
api.fetchRwaVaults()
|
|
2331
2476
|
]);
|
|
2477
|
+
const vaultIcons = vaultIconsBySymbol(api.apiBase, vaults);
|
|
2478
|
+
const tokens = withVaultArtwork(registryTokens, vaultIcons);
|
|
2332
2479
|
const allowed = allowedAssets?.length ? new Set([...allowedAssets].map(symbolKey).filter((a) => SUPPORTED_ASSETS.has(a))) : void 0;
|
|
2333
2480
|
return buildCatalogue({
|
|
2334
2481
|
chains,
|
|
@@ -2337,7 +2484,8 @@ function createEngine(config = {}) {
|
|
|
2337
2484
|
product,
|
|
2338
2485
|
...allowed ? { allowedAssets: allowed } : {},
|
|
2339
2486
|
supportedChainIds: SUPPORTED_CHAIN_IDS,
|
|
2340
|
-
brokenLanes: suppressedLanes(health)
|
|
2487
|
+
brokenLanes: suppressedLanes(health),
|
|
2488
|
+
vaultIcons
|
|
2341
2489
|
});
|
|
2342
2490
|
},
|
|
2343
2491
|
fetchPaymentPlan: (request, payer, wallet) => fetchPaymentPlan(api, request, payer, wallet, verifier.readBalances),
|
|
@@ -2358,4 +2506,4 @@ function createEngine(config = {}) {
|
|
|
2358
2506
|
};
|
|
2359
2507
|
}
|
|
2360
2508
|
|
|
2361
|
-
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, routeNativeValue, scaleDecimals, screeningOutcomeOf, solveExactIn, solveExactOut, sourceKeys, stableGenieIntentSchema, strip0x, suppressedLanes, symbolKey, toHexQuantity, tokenEnabled, tokenKey, txMatchesPlan, uint64Word, uintWord, unattributedComplianceReasons, 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 };
|
package/dist/core/index.cjs
CHANGED
|
@@ -586,7 +586,7 @@ function buildCatalogue(input) {
|
|
|
586
586
|
);
|
|
587
587
|
const byId = new Map(enabledChains.map((c) => [Number(c.chainId), c]));
|
|
588
588
|
for (const id of chainIds) if (!byId.has(id)) byId.set(id, { chainId: id, isEnabled: true });
|
|
589
|
-
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() };
|
|
590
590
|
}
|
|
591
591
|
|
|
592
592
|
// src/core/options.ts
|
|
@@ -752,6 +752,34 @@ function brokenLaneReason(lane) {
|
|
|
752
752
|
}
|
|
753
753
|
}
|
|
754
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
|
+
|
|
755
783
|
// src/core/compliance.ts
|
|
756
784
|
var COMPLIANCE_DENY_LABEL = "Compliance check failed";
|
|
757
785
|
function complianceView(compliance, hasQuote = true) {
|
|
@@ -1320,7 +1348,63 @@ function routeLabelFor(option, destinationToken, result) {
|
|
|
1320
1348
|
const bridge = result.quote.bridge ? ` via ${result.quote.bridge}` : "";
|
|
1321
1349
|
return `Swap ${option.symbol} to ${destinationToken.symbol} and settle on ZeroDelta${bridge}.`;
|
|
1322
1350
|
}
|
|
1323
|
-
|
|
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
|
+
}) {
|
|
1324
1408
|
const result = await solve({ option, destination, destinationToken, payer, fetchQuote, amountInRaw });
|
|
1325
1409
|
const quote = result.quote;
|
|
1326
1410
|
const destDecimals = assetDecimals(destinationToken);
|
|
@@ -1350,6 +1434,23 @@ async function buildRoute({ option, destination, destinationToken, chains, payer
|
|
|
1350
1434
|
},
|
|
1351
1435
|
routeLabel: routeLabelFor(option, destinationToken, result),
|
|
1352
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
|
+
],
|
|
1353
1454
|
transactions: [
|
|
1354
1455
|
{
|
|
1355
1456
|
id: "transfer",
|
|
@@ -1423,6 +1524,7 @@ async function buildRoute({ option, destination, destinationToken, chains, payer
|
|
|
1423
1524
|
},
|
|
1424
1525
|
routeLabel: routeLabelFor(option, destinationToken, result),
|
|
1425
1526
|
deltaLabel: routeDeltaLabel(result, quote),
|
|
1527
|
+
legs: buildLegs(orders, { option, destinationToken, chains, tokens }),
|
|
1426
1528
|
transactions: [
|
|
1427
1529
|
{
|
|
1428
1530
|
id: "approve",
|
|
@@ -1530,7 +1632,8 @@ function createApiClient(cfg) {
|
|
|
1530
1632
|
chains: null,
|
|
1531
1633
|
tokens: null,
|
|
1532
1634
|
routes: null,
|
|
1533
|
-
health: null
|
|
1635
|
+
health: null,
|
|
1636
|
+
vaults: null
|
|
1534
1637
|
};
|
|
1535
1638
|
const screenCache = /* @__PURE__ */ new Map();
|
|
1536
1639
|
const screenInflight = /* @__PURE__ */ new Map();
|
|
@@ -1614,6 +1717,19 @@ function createApiClient(cfg) {
|
|
|
1614
1717
|
cache.health = { at: Date.now(), value };
|
|
1615
1718
|
return value;
|
|
1616
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
|
+
}
|
|
1617
1733
|
async function fetchQuote(body, retries = 1) {
|
|
1618
1734
|
let lastError;
|
|
1619
1735
|
for (let attempt = 0; attempt <= retries; attempt += 1) {
|
|
@@ -1653,7 +1769,7 @@ function createApiClient(cfg) {
|
|
|
1653
1769
|
screenInflight.set(key, request);
|
|
1654
1770
|
return request;
|
|
1655
1771
|
}
|
|
1656
|
-
return { apiRequest, fetchChains, fetchTokens, fetchRoutes, fetchRouteHealth, fetchQuote, screenWallet, apiBase };
|
|
1772
|
+
return { apiRequest, fetchChains, fetchTokens, fetchRoutes, fetchRouteHealth, fetchRwaVaults, fetchQuote, screenWallet, apiBase };
|
|
1657
1773
|
}
|
|
1658
1774
|
|
|
1659
1775
|
// src/core/plan.ts
|
|
@@ -1770,7 +1886,16 @@ async function fetchPaymentPlan(api, request, payer, wallet = {}, readBalances)
|
|
|
1770
1886
|
}
|
|
1771
1887
|
const routeErrors = [];
|
|
1772
1888
|
const routePromises = candidates.map(
|
|
1773
|
-
(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) => {
|
|
1774
1899
|
routeErrors.push(error);
|
|
1775
1900
|
return null;
|
|
1776
1901
|
})
|
|
@@ -1883,7 +2008,7 @@ async function buildSwapPlan(api, swap, payer, wallet = {}) {
|
|
|
1883
2008
|
direct: false
|
|
1884
2009
|
};
|
|
1885
2010
|
const destination = { address: receiver, chainId: v.toChainId, asset: destToken.symbol };
|
|
1886
|
-
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 });
|
|
1887
2012
|
if (route.state === "SHORT") throw new Error("ZeroDelta could not price this swap right now.");
|
|
1888
2013
|
route.recommended = true;
|
|
1889
2014
|
return {
|
|
@@ -2293,6 +2418,24 @@ function resolveConfig(config = {}) {
|
|
|
2293
2418
|
}
|
|
2294
2419
|
|
|
2295
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
|
+
}
|
|
2296
2439
|
function sanitizeTxEntry(entry) {
|
|
2297
2440
|
return {
|
|
2298
2441
|
kind: entry.kind === "swap" ? "swap" : "payment",
|
|
@@ -2308,7 +2451,8 @@ function sanitizeTxEntry(entry) {
|
|
|
2308
2451
|
recipient: isAddress(entry.recipient) ? normalizeAddress(entry.recipient) : "",
|
|
2309
2452
|
settlement: entry.settlement === "direct" ? "direct" : "escrow",
|
|
2310
2453
|
status: entry.status && ["confirmed", "unconfirmed", "error"].includes(entry.status) ? entry.status : "submitted",
|
|
2311
|
-
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
2454
|
+
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2455
|
+
legs: sanitizeLegs(entry.legs)
|
|
2312
2456
|
};
|
|
2313
2457
|
}
|
|
2314
2458
|
function createEngine(config = {}) {
|
|
@@ -2325,12 +2469,15 @@ function createEngine(config = {}) {
|
|
|
2325
2469
|
fetchRouteHealth: api.fetchRouteHealth,
|
|
2326
2470
|
fetchQuote: api.fetchQuote,
|
|
2327
2471
|
fetchCatalogue: async (allowedAssets, product) => {
|
|
2328
|
-
const [chains,
|
|
2472
|
+
const [chains, registryTokens, routes, health, vaults] = await Promise.all([
|
|
2329
2473
|
api.fetchChains().catch(() => []),
|
|
2330
2474
|
api.fetchTokens().catch(() => []),
|
|
2331
2475
|
api.fetchRoutes().catch(() => []),
|
|
2332
|
-
api.fetchRouteHealth()
|
|
2476
|
+
api.fetchRouteHealth(),
|
|
2477
|
+
api.fetchRwaVaults()
|
|
2333
2478
|
]);
|
|
2479
|
+
const vaultIcons = vaultIconsBySymbol(api.apiBase, vaults);
|
|
2480
|
+
const tokens = withVaultArtwork(registryTokens, vaultIcons);
|
|
2334
2481
|
const allowed = allowedAssets?.length ? new Set([...allowedAssets].map(symbolKey).filter((a) => SUPPORTED_ASSETS.has(a))) : void 0;
|
|
2335
2482
|
return buildCatalogue({
|
|
2336
2483
|
chains,
|
|
@@ -2339,7 +2486,8 @@ function createEngine(config = {}) {
|
|
|
2339
2486
|
product,
|
|
2340
2487
|
...allowed ? { allowedAssets: allowed } : {},
|
|
2341
2488
|
supportedChainIds: SUPPORTED_CHAIN_IDS,
|
|
2342
|
-
brokenLanes: suppressedLanes(health)
|
|
2489
|
+
brokenLanes: suppressedLanes(health),
|
|
2490
|
+
vaultIcons
|
|
2343
2491
|
});
|
|
2344
2492
|
},
|
|
2345
2493
|
fetchPaymentPlan: (request, payer, wallet) => fetchPaymentPlan(api, request, payer, wallet, verifier.readBalances),
|
|
@@ -2488,6 +2636,7 @@ exports.requiresNativeBridgeFee = requiresNativeBridgeFee;
|
|
|
2488
2636
|
exports.resolveApiBase = resolveApiBase;
|
|
2489
2637
|
exports.resolveConfig = resolveConfig;
|
|
2490
2638
|
exports.resolveSwapReceiver = resolveSwapReceiver;
|
|
2639
|
+
exports.resolveVaultIcon = resolveVaultIcon;
|
|
2491
2640
|
exports.routeNativeValue = routeNativeValue;
|
|
2492
2641
|
exports.scaleDecimals = scaleDecimals;
|
|
2493
2642
|
exports.screeningOutcomeOf = screeningOutcomeOf;
|
|
@@ -2508,3 +2657,5 @@ exports.unattributedComplianceReasons = unattributedComplianceReasons;
|
|
|
2508
2657
|
exports.validateDestination = validateDestination;
|
|
2509
2658
|
exports.validatePlannedTransaction = validatePlannedTransaction;
|
|
2510
2659
|
exports.validateSwap = validateSwap;
|
|
2660
|
+
exports.vaultIconsBySymbol = vaultIconsBySymbol;
|
|
2661
|
+
exports.withVaultArtwork = withVaultArtwork;
|
package/dist/core/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as Token, Q as Quote, N as NormalizedOrder,
|
|
2
|
-
export {
|
|
1
|
+
import { T as Token, Q as Quote, N as NormalizedOrder, r as PayOption, h as RouteResult, b as Chain, R as Route, a as Catalogue, s as RwaVault, F as FetchQuoteFn, t as SolveResult, O as OrderRequest, C as Compliance, u as BalanceTarget, v as BalanceEntry, w as ApiClient, P as Plan, x as SwapInput, y as PlannedTx, z as Verifier, f as ExchangeProduct, i as TxHistoryEntry, S as SanitizedTxEntry, E as EngineConfig } from '../verify-Ce6ZtDhi.cjs';
|
|
2
|
+
export { D as Address, G as ApiError, A as Availability, H as BLOCK_LABEL_DEFAULT, B as BrokenLane, I as COMPLIANCE_CHECK_ORDER, J as COMPLIANCE_DENY_LABEL, K as CatalogueContext, L as CatalogueInput, c as ComplianceCheck, M as ComplianceCheckId, U as ComplianceDecision, d as ComplianceTone, e as ComplianceView, X as DIRECT_CHECK_IDS, Y as DIRECT_SCOPE_NOTE, Z as Destination, _ as FLOOR_CATEGORIES, $ as Hex, a0 as PlannedTxKind, a1 as QuoteBlock, a2 as ResolvedConfig, a3 as RouteHealth, a4 as RouteHealthLane, g as RouteLeg, a5 as SCREENING_BUCKETS, a6 as ScreenProvider, a7 as ScreeningBucket, a8 as ScreeningOutcome, a9 as TUNABLE_CATEGORIES, aa as TxPlan, V as VerifyResult, W as WalletScreen, ab as apiError, j as assetClassOf, ac as blockLabelFor, ad as brokenLaneFor, k as brokenLaneReason, ae as buildCatalogue, af as canAttachApiKey, ag as categoryLabel, ah as classifyQuoteError, l as complianceChecks, ai as complianceControlsEvaluated, m as complianceControlsLine, aj as complianceReasonHead, ak as complianceReasonTag, al as complianceTagOf, n as complianceView, o as counterpartTokens, am as createApiClient, an as createVerifier, p as destinationAvailability, ao as destinationKeys, ap as directComplianceFromScreens, aq as distinctScreenedWallets, ar as executableRoutes, as as executionChainIds, at as hasReachableDestination, au as hubDeliverableSymbols, q as humanizeComplianceReason, av as isExecutableBridge, aw as isKnownUnbridgeable, ax as isSourceToken, ay as laneKey, az as laneKeys, aA as parseAllowedApiBase, aB as productAssets, aC as registryRpc, aD as resolveApiBase, aE as resolveConfig, aF as screeningOutcomeOf, aG as sourceKeys, aH as suppressedLanes, aI as tokenKey, aJ as txMatchesPlan, aK as unattributedComplianceReasons } from '../verify-Ce6ZtDhi.cjs';
|
|
3
3
|
|
|
4
4
|
/** Default request base for the widget: the same-origin keyless custody proxy (server injects the
|
|
5
5
|
* ZeroDelta key). A host may override to `/api/v1` + an apiKey for the demo-first fallback path. */
|
|
@@ -235,6 +235,24 @@ interface BuildPayOptionsArgs {
|
|
|
235
235
|
*/
|
|
236
236
|
declare function buildPayOptions({ invoiceAsset, invoiceChainId, tokens, routes, chains, walletChainId, catalogue }: BuildPayOptionsArgs): PayOption[];
|
|
237
237
|
|
|
238
|
+
/**
|
|
239
|
+
* Turn the gateway's root-relative icon path into one the WIDGET can load.
|
|
240
|
+
*
|
|
241
|
+
* The dapp can use `/api/v1/rwa/icons/x.png` verbatim because it is served from the gateway's own
|
|
242
|
+
* origin. The widget is embedded in someone else's page, so the same string would resolve against
|
|
243
|
+
* the HOST and 404 — it has to go through the widget's `apiBase` (the keyless proxy), which relays
|
|
244
|
+
* the bytes same-origin. Returns undefined for anything that is not the gateway's icon route, so an
|
|
245
|
+
* `iconUrl` repointed at a third party by a hostile response never reaches an `<img>`.
|
|
246
|
+
*/
|
|
247
|
+
declare function resolveVaultIcon(apiBase: string, iconPath: unknown): string | undefined;
|
|
248
|
+
/** Symbol key → widget-loadable icon URL. The MINI mark wins: it is the round badge the pickers want,
|
|
249
|
+
* and the full-size one is a card image. */
|
|
250
|
+
declare function vaultIconsBySymbol(apiBase: string, vaults: readonly RwaVault[]): Map<string, string>;
|
|
251
|
+
/** Fill in `logoUrl` on the deployments that have none. Registry artwork always wins — deJAAA and
|
|
252
|
+
* deSPXA already ship one — and a token whose vault publishes nothing is returned untouched, so it
|
|
253
|
+
* falls through to the letters disc exactly as before. */
|
|
254
|
+
declare function withVaultArtwork(tokens: readonly Token[], icons: ReadonlyMap<string, string>): Token[];
|
|
255
|
+
|
|
238
256
|
interface SolveArgs {
|
|
239
257
|
option: PayOption;
|
|
240
258
|
destination: {
|
|
@@ -290,6 +308,9 @@ interface BuildRouteArgs {
|
|
|
290
308
|
};
|
|
291
309
|
destinationToken: Token;
|
|
292
310
|
chains: Chain[];
|
|
311
|
+
/** The registry, used ONLY to name the intermediate hop of a chained order. Omit and a two-leg
|
|
312
|
+
* route still reports both legs — the middle asset simply goes unnamed. */
|
|
313
|
+
tokens?: Token[];
|
|
293
314
|
payer: string;
|
|
294
315
|
fetchQuote: FetchQuoteFn;
|
|
295
316
|
solve?: typeof solveExactOut;
|
|
@@ -303,7 +324,7 @@ interface BuildRouteArgs {
|
|
|
303
324
|
*/
|
|
304
325
|
compliance?: Compliance;
|
|
305
326
|
}
|
|
306
|
-
declare function buildRoute({ option, destination, destinationToken, chains, payer, fetchQuote, solve, amountInRaw, compliance }: BuildRouteArgs): Promise<RouteResult>;
|
|
327
|
+
declare function buildRoute({ option, destination, destinationToken, chains, tokens, payer, fetchQuote, solve, amountInRaw, compliance, }: BuildRouteArgs): Promise<RouteResult>;
|
|
307
328
|
|
|
308
329
|
interface PayRequest {
|
|
309
330
|
address: string;
|
|
@@ -501,4 +522,4 @@ interface Engine {
|
|
|
501
522
|
/** Create an engine bound to a config. The 60s resource cache is per-engine. */
|
|
502
523
|
declare function createEngine(config?: EngineConfig): Engine;
|
|
503
524
|
|
|
504
|
-
export { API_CACHE_TTL_MS, ApiClient, type AssertQuoteArgs, BUNDLED_NATIVE_SYMBOL, BUNDLED_RPC, BalanceEntry, type BalanceReader, BalanceTarget, type BuildPayOptionsArgs, type BuildRouteArgs, CANONICAL_DECIMALS, CANONICAL_ESCROW, CANONICAL_INBOUND_BRIDGE, CHAIN_DISPLAY_NAMES, Catalogue, Chain, Compliance, DEFAULT_WIDGET_API_BASE, type DecodedOrderRequest, type DecodedSubmitOrder, ERC20_ALLOWANCE_SELECTOR, ERC20_APPROVE_SELECTOR, ERC20_BALANCEOF_SELECTOR, ERC20_TRANSFER_SELECTOR, EXECUTABLE_STABLE_ASSETS, type Engine, EngineConfig, ExchangeProduct, FetchQuoteFn, 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, type NativeFeeCheck, NormalizedOrder, OrderRequest, PREVIEW_OWNER, PayOption, type PayRequest, type PaymentWalletContext, Plan, PlannedTx, QUOTE_BUFFER_BPS, Quote, Route, RouteResult, SAME_CLASS_STABLE, 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, SanitizedTxEntry, type SolveArgs, SolveResult, SwapInput, type SwapPreview, TRADEABLE_RWA_ASSETS, Token, TxHistoryEntry, type ValidatedSwap, Verifier, ZERO_ADDRESS, addressWord, allowanceCovers, applyLayerZeroBuffer, assertAddress, assertQuoteMatchesSelection, assetDecimals, buildPayOptions, buildRoute, buildSwapPlan, bytes32Word, bytesPayload, chainById, chainNameOf, chainSelectable, checkEscrow, checkNativeFee, createEngine, decodeSubmitOrderCalldata, encodeAllowance, encodeApprove, encodeBalanceOf, encodeSubmitOrder, encodeTransfer, fetchPaymentPlan, finalOf, findToken, formatNative, formatUnits, isAddress, isDeliverable, isHexAddress, isHexData, isHexQuantity, isLayerZeroRoute, maxNativeFeeWei, nativeFeeShortLabel, nativeFeeShortMessage, nativeSymbol, normalizeAddress, normalizeDecimalText, normalizeOrderRequest, normalizeOrderRequests, parseUnitsDecimal, planErrorSummary, planMsgValueHex, quoteSwapPreview, requiresNativeBridgeFee, resolveSwapReceiver, routeNativeValue, scaleDecimals, solveExactIn, solveExactOut, stableGenieIntentSchema, strip0x, symbolKey, toHexQuantity, tokenEnabled, uint64Word, uintWord, validateDestination, validatePlannedTransaction, validateSwap };
|
|
525
|
+
export { API_CACHE_TTL_MS, ApiClient, type AssertQuoteArgs, BUNDLED_NATIVE_SYMBOL, BUNDLED_RPC, BalanceEntry, type BalanceReader, BalanceTarget, type BuildPayOptionsArgs, type BuildRouteArgs, CANONICAL_DECIMALS, CANONICAL_ESCROW, CANONICAL_INBOUND_BRIDGE, CHAIN_DISPLAY_NAMES, Catalogue, Chain, Compliance, DEFAULT_WIDGET_API_BASE, type DecodedOrderRequest, type DecodedSubmitOrder, ERC20_ALLOWANCE_SELECTOR, ERC20_APPROVE_SELECTOR, ERC20_BALANCEOF_SELECTOR, ERC20_TRANSFER_SELECTOR, EXECUTABLE_STABLE_ASSETS, type Engine, EngineConfig, ExchangeProduct, FetchQuoteFn, 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, type NativeFeeCheck, NormalizedOrder, OrderRequest, PREVIEW_OWNER, PayOption, type PayRequest, type PaymentWalletContext, Plan, PlannedTx, QUOTE_BUFFER_BPS, Quote, Route, RouteResult, RwaVault, SAME_CLASS_STABLE, 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, SanitizedTxEntry, type SolveArgs, SolveResult, SwapInput, type SwapPreview, TRADEABLE_RWA_ASSETS, Token, TxHistoryEntry, type ValidatedSwap, Verifier, ZERO_ADDRESS, addressWord, allowanceCovers, applyLayerZeroBuffer, assertAddress, assertQuoteMatchesSelection, assetDecimals, buildPayOptions, buildRoute, buildSwapPlan, bytes32Word, bytesPayload, chainById, chainNameOf, chainSelectable, checkEscrow, checkNativeFee, createEngine, decodeSubmitOrderCalldata, encodeAllowance, encodeApprove, encodeBalanceOf, encodeSubmitOrder, encodeTransfer, fetchPaymentPlan, finalOf, findToken, formatNative, formatUnits, isAddress, isDeliverable, isHexAddress, isHexData, isHexQuantity, isLayerZeroRoute, maxNativeFeeWei, nativeFeeShortLabel, nativeFeeShortMessage, nativeSymbol, normalizeAddress, normalizeDecimalText, normalizeOrderRequest, normalizeOrderRequests, parseUnitsDecimal, planErrorSummary, planMsgValueHex, quoteSwapPreview, requiresNativeBridgeFee, resolveSwapReceiver, resolveVaultIcon, routeNativeValue, scaleDecimals, solveExactIn, solveExactOut, stableGenieIntentSchema, strip0x, symbolKey, toHexQuantity, tokenEnabled, uint64Word, uintWord, validateDestination, validatePlannedTransaction, validateSwap, vaultIconsBySymbol, withVaultArtwork };
|