@anywalletkit/protocol-swap2-across 0.0.0-stage → 0.1.1
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/LICENSE +202 -0
- package/README.md +177 -2
- package/dist/activity.cjs +142 -0
- package/dist/activity.cjs.map +1 -0
- package/dist/activity.d.cts +16 -0
- package/dist/activity.d.ts +16 -0
- package/dist/activity.js +10 -0
- package/dist/activity.js.map +1 -0
- package/dist/api.cjs +441 -0
- package/dist/api.cjs.map +1 -0
- package/dist/api.d.cts +207 -0
- package/dist/api.d.ts +207 -0
- package/dist/api.js +35 -0
- package/dist/api.js.map +1 -0
- package/dist/build.cjs +776 -0
- package/dist/build.cjs.map +1 -0
- package/dist/build.d.cts +93 -0
- package/dist/build.d.ts +93 -0
- package/dist/build.js +14 -0
- package/dist/build.js.map +1 -0
- package/dist/chunk-32YJEBZX.js +125 -0
- package/dist/chunk-32YJEBZX.js.map +1 -0
- package/dist/chunk-3UBRQ3ZE.js +255 -0
- package/dist/chunk-3UBRQ3ZE.js.map +1 -0
- package/dist/chunk-5BDZXOOP.js +21 -0
- package/dist/chunk-5BDZXOOP.js.map +1 -0
- package/dist/chunk-6Z4GXNLE.js +102 -0
- package/dist/chunk-6Z4GXNLE.js.map +1 -0
- package/dist/chunk-AWQT5S4V.js +101 -0
- package/dist/chunk-AWQT5S4V.js.map +1 -0
- package/dist/chunk-E5WFOPN2.js +16 -0
- package/dist/chunk-E5WFOPN2.js.map +1 -0
- package/dist/chunk-GX67FRPG.js +194 -0
- package/dist/chunk-GX67FRPG.js.map +1 -0
- package/dist/chunk-KATEONJQ.js +396 -0
- package/dist/chunk-KATEONJQ.js.map +1 -0
- package/dist/chunk-P32AW6XS.js +27 -0
- package/dist/chunk-P32AW6XS.js.map +1 -0
- package/dist/chunk-PPPZIG7S.js +265 -0
- package/dist/chunk-PPPZIG7S.js.map +1 -0
- package/dist/chunk-SJOFLM27.js +138 -0
- package/dist/chunk-SJOFLM27.js.map +1 -0
- package/dist/chunk-YGNP7KPL.js +311 -0
- package/dist/chunk-YGNP7KPL.js.map +1 -0
- package/dist/config.cjs +214 -0
- package/dist/config.cjs.map +1 -0
- package/dist/config.d.cts +119 -0
- package/dist/config.d.ts +119 -0
- package/dist/config.js +47 -0
- package/dist/config.js.map +1 -0
- package/dist/deposit.cjs +252 -0
- package/dist/deposit.cjs.map +1 -0
- package/dist/deposit.d.cts +95 -0
- package/dist/deposit.d.ts +95 -0
- package/dist/deposit.js +19 -0
- package/dist/deposit.js.map +1 -0
- package/dist/index.cjs +1789 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +34 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +242 -0
- package/dist/index.js.map +1 -0
- package/dist/pricing.cjs +132 -0
- package/dist/pricing.cjs.map +1 -0
- package/dist/pricing.d.cts +123 -0
- package/dist/pricing.d.ts +123 -0
- package/dist/pricing.js +42 -0
- package/dist/pricing.js.map +1 -0
- package/dist/protocol.cjs +1596 -0
- package/dist/protocol.cjs.map +1 -0
- package/dist/protocol.d.cts +20 -0
- package/dist/protocol.d.ts +20 -0
- package/dist/protocol.js +17 -0
- package/dist/protocol.js.map +1 -0
- package/dist/provider.cjs +1581 -0
- package/dist/provider.cjs.map +1 -0
- package/dist/provider.d.cts +45 -0
- package/dist/provider.d.ts +45 -0
- package/dist/provider.js +18 -0
- package/dist/provider.js.map +1 -0
- package/dist/remote.cjs +1659 -0
- package/dist/remote.cjs.map +1 -0
- package/dist/remote.d.cts +55 -0
- package/dist/remote.d.ts +55 -0
- package/dist/remote.js +17 -0
- package/dist/remote.js.map +1 -0
- package/dist/status.cjs +443 -0
- package/dist/status.cjs.map +1 -0
- package/dist/status.d.cts +109 -0
- package/dist/status.d.ts +109 -0
- package/dist/status.js +26 -0
- package/dist/status.js.map +1 -0
- package/dist/verify.cjs +690 -0
- package/dist/verify.cjs.map +1 -0
- package/dist/verify.d.cts +245 -0
- package/dist/verify.d.ts +245 -0
- package/dist/verify.js +69 -0
- package/dist/verify.js.map +1 -0
- package/module.json +32 -0
- package/package.json +124 -3
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ACROSS_API,
|
|
3
|
+
acrossChain
|
|
4
|
+
} from "./chunk-GX67FRPG.js";
|
|
5
|
+
import {
|
|
6
|
+
AcrossRefusal
|
|
7
|
+
} from "./chunk-E5WFOPN2.js";
|
|
8
|
+
|
|
9
|
+
// src/api.ts
|
|
10
|
+
import { httpRefusal } from "@anywalletkit/protocol-swap2-core/errors";
|
|
11
|
+
import { anySignal, timeoutSignal } from "@anywalletkit/protocol-swap2-core/util";
|
|
12
|
+
var ACROSS_API_V1 = `${ACROSS_API}/v1`;
|
|
13
|
+
var ACROSS_SUGGESTED_FEES_URL = "https://app.across.to/api/suggested-fees";
|
|
14
|
+
var ACROSS_V5_PRICING_MAX_FEE_BPS = 5e3;
|
|
15
|
+
var MAX_ANSWER_CHARS = 512 * 1024;
|
|
16
|
+
function acrossV5QuoteRequest(request) {
|
|
17
|
+
const src = acrossChain(request.sourceChain);
|
|
18
|
+
const dst = acrossChain(request.destChain);
|
|
19
|
+
if (!src || !dst) throw new Error("across: the request's chains are not pinned");
|
|
20
|
+
return {
|
|
21
|
+
origin: { token: { chainId: src.chainId, address: request.sourceToken.toLowerCase() }, depositor: request.depositor.toLowerCase(), amount: request.amount.toString(10) },
|
|
22
|
+
destination: { token: { chainId: dst.chainId, address: request.destToken.toLowerCase() }, recipient: request.recipient.toLowerCase() },
|
|
23
|
+
amountType: "exact_input",
|
|
24
|
+
capabilities: { operations: [{ kind: "approve_token", ecosystem: "evm" }, { kind: "send_transaction", ecosystem: "evm" }] },
|
|
25
|
+
authorizationPolicy: { allowedTypes: ["approval"], approvalAmount: "exact" },
|
|
26
|
+
maxFee: { bps: ACROSS_V5_PRICING_MAX_FEE_BPS }
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
var ADDRESS = /^0x[0-9a-fA-F]{40}$/;
|
|
30
|
+
var ZERO = /^0x0{40}$/;
|
|
31
|
+
var UINT = /^(?:0|[1-9]\d{0,77})$/;
|
|
32
|
+
var DECIMAL = /^(?:0|[1-9]\d{0,15})(?:\.\d{1,30})?$/;
|
|
33
|
+
var plain = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
|
|
34
|
+
var own = (o, key) => Object.prototype.hasOwnProperty.call(o, key) ? o[key] : void 0;
|
|
35
|
+
var uint = (v) => typeof v === "string" && UINT.test(v) ? BigInt(v) : null;
|
|
36
|
+
var sameAddress = (a, b) => typeof a === "string" && ADDRESS.test(a) && a.toLowerCase() === b.toLowerCase();
|
|
37
|
+
function scaled(text2, scale) {
|
|
38
|
+
if (!DECIMAL.test(text2)) return null;
|
|
39
|
+
const [whole, frac = ""] = text2.split(".");
|
|
40
|
+
return BigInt(whole + frac.slice(0, scale).padEnd(scale, "0"));
|
|
41
|
+
}
|
|
42
|
+
var USD_SCALE = 18;
|
|
43
|
+
var PRICE_SCALE = 12;
|
|
44
|
+
function acrossUsdToUnits(amountUsd, priceUsd, decimals) {
|
|
45
|
+
if (typeof amountUsd !== "string" || typeof priceUsd !== "number" || !Number.isFinite(priceUsd) || priceUsd <= 0 || priceUsd >= 1e12) return null;
|
|
46
|
+
if (!Number.isInteger(decimals) || decimals < 0 || decimals > 36) return null;
|
|
47
|
+
const usd = scaled(amountUsd, USD_SCALE);
|
|
48
|
+
const price = scaled(priceUsd.toFixed(PRICE_SCALE), PRICE_SCALE);
|
|
49
|
+
if (usd === null || price === null || price === 0n) return null;
|
|
50
|
+
return usd * 10n ** BigInt(decimals) * 10n ** BigInt(PRICE_SCALE) / (price * 10n ** BigInt(USD_SCALE));
|
|
51
|
+
}
|
|
52
|
+
function readAcrossV5Quote(request, route, body) {
|
|
53
|
+
const malformed = (what) => {
|
|
54
|
+
throw new AcrossRefusal("api-answer", `the V5 quote ${what}`, "upstream_unavailable");
|
|
55
|
+
};
|
|
56
|
+
const other = (what) => {
|
|
57
|
+
throw new AcrossRefusal("api-answer", `the V5 quote ${what}`, "policy_refused");
|
|
58
|
+
};
|
|
59
|
+
if (!plain(body)) return malformed("is not a JSON object");
|
|
60
|
+
const amountType = own(body, "amountType");
|
|
61
|
+
if (amountType !== void 0 && amountType !== "exact_input") other(`is ${String(amountType).slice(0, 20)}, not exact input`);
|
|
62
|
+
const src = route.input.chain;
|
|
63
|
+
const dst = route.output.chain;
|
|
64
|
+
const origin = own(body, "origin");
|
|
65
|
+
const destination = own(body, "destination");
|
|
66
|
+
if (!plain(origin) || !plain(destination)) return malformed("has no origin or destination");
|
|
67
|
+
const oToken = own(origin, "token");
|
|
68
|
+
const dToken = own(destination, "token");
|
|
69
|
+
if (!plain(oToken) || !plain(dToken)) return malformed("names no tokens");
|
|
70
|
+
if (own(oToken, "chainId") !== src.chainId || !sameAddress(own(oToken, "address"), request.sourceToken)) other("is for another input token or chain");
|
|
71
|
+
if (own(dToken, "chainId") !== dst.chainId || !sameAddress(own(dToken, "address"), request.destToken)) other("is for another output token or chain");
|
|
72
|
+
const amountIn = uint(own(origin, "amount"));
|
|
73
|
+
if (amountIn === null) return malformed("states no input amount");
|
|
74
|
+
if (amountIn !== request.amount) other(`sends ${amountIn}, the request ${request.amount}`);
|
|
75
|
+
const destinationAmount = uint(own(destination, "amount"));
|
|
76
|
+
if (destinationAmount === null) return malformed("states no output estimate");
|
|
77
|
+
if (destinationAmount > request.amount) other("expects more to arrive than goes in");
|
|
78
|
+
const fee = own(body, "fee");
|
|
79
|
+
if (!plain(fee)) return malformed("has no fee");
|
|
80
|
+
const total = own(fee, "totalFee");
|
|
81
|
+
if (!plain(total)) return malformed("has no total fee");
|
|
82
|
+
const totalFee = uint(own(total, "amount"));
|
|
83
|
+
if (totalFee === null) return malformed("states a total fee that is not a base-unit integer");
|
|
84
|
+
const feeToken = own(total, "token");
|
|
85
|
+
if (!plain(feeToken) || own(feeToken, "chainId") !== dst.chainId || !sameAddress(own(feeToken, "address"), request.destToken) || own(feeToken, "decimals") !== route.output.decimals) {
|
|
86
|
+
malformed("states its fee in another token");
|
|
87
|
+
}
|
|
88
|
+
if (totalFee !== request.amount - destinationAmount) malformed(`fee ${totalFee} is not its input minus its estimate (${request.amount - destinationAmount})`);
|
|
89
|
+
const appFee = own(fee, "appFee");
|
|
90
|
+
if (appFee !== void 0 && appFee !== null) {
|
|
91
|
+
const app = plain(appFee) ? uint(own(appFee, "amount")) : null;
|
|
92
|
+
if (app === null) return malformed("states an app fee that does not read");
|
|
93
|
+
if (app > 0n) other("carries an app fee this module never asks for");
|
|
94
|
+
}
|
|
95
|
+
const fill = own(body, "expectedFillTimeMs");
|
|
96
|
+
if (typeof fill !== "number" || !Number.isFinite(fill) || fill < 0) return malformed("states no fill time");
|
|
97
|
+
const priceUsd = own(dToken, "priceUsd");
|
|
98
|
+
const legs = own(body, "gasEstimates");
|
|
99
|
+
if (!Array.isArray(legs) || legs.length > 16) return malformed("has no gas estimates");
|
|
100
|
+
let originGas = 0n;
|
|
101
|
+
let destinationGas = 0n;
|
|
102
|
+
for (const leg of legs) {
|
|
103
|
+
if (!plain(leg)) return malformed("has a gas estimate that is not an object");
|
|
104
|
+
if (own(leg, "effect") !== "included_in_transfer_fee") continue;
|
|
105
|
+
const side = own(leg, "leg");
|
|
106
|
+
if (side !== "origin" && side !== "destination") continue;
|
|
107
|
+
const units = legUnits(leg, route, priceUsd);
|
|
108
|
+
if (side === "origin") originGas += units ?? 0n;
|
|
109
|
+
else destinationGas = units === null || destinationGas === null ? null : destinationGas + units;
|
|
110
|
+
}
|
|
111
|
+
if (originGas > totalFee) originGas = totalFee;
|
|
112
|
+
const usdText = own(origin, "amountUsd");
|
|
113
|
+
const amountUsd = typeof usdText === "string" && DECIMAL.test(usdText) ? Number(usdText) : void 0;
|
|
114
|
+
return { totalFee, destinationAmount, originGas, destinationGas, expectedFillTimeMs: fill, ...amountUsd !== void 0 && Number.isFinite(amountUsd) ? { amountUsd } : {} };
|
|
115
|
+
}
|
|
116
|
+
function legUnits(leg, route, priceUsd) {
|
|
117
|
+
const token = own(leg, "token");
|
|
118
|
+
const amount = uint(own(leg, "amount"));
|
|
119
|
+
if (route.asset === "ETH" && plain(token) && amount !== null && ZERO.test(String(own(token, "address"))) && own(token, "decimals") === 18) {
|
|
120
|
+
const chainId = own(token, "chainId");
|
|
121
|
+
const side = chainId === route.input.chain.chainId ? route.input.chain : chainId === route.output.chain.chainId ? route.output.chain : void 0;
|
|
122
|
+
if (side?.nativeIsEth) return amount;
|
|
123
|
+
}
|
|
124
|
+
return acrossUsdToUnits(own(leg, "amountUsd"), priceUsd, route.input.decimals);
|
|
125
|
+
}
|
|
126
|
+
function acrossSuggestedFeesQuery(request, route) {
|
|
127
|
+
const q = [
|
|
128
|
+
["inputToken", route.input.token],
|
|
129
|
+
["outputToken", route.output.token],
|
|
130
|
+
["originChainId", String(route.input.chain.chainId)],
|
|
131
|
+
["destinationChainId", String(route.output.chain.chainId)],
|
|
132
|
+
["amount", request.amount.toString(10)],
|
|
133
|
+
["recipient", request.recipient.toLowerCase()]
|
|
134
|
+
];
|
|
135
|
+
return q.map(([k, v]) => `${k}=${encodeURIComponent(v)}`).join("&");
|
|
136
|
+
}
|
|
137
|
+
var ACROSS_SUGGESTED_FEES_MAX_AGE_S = 600;
|
|
138
|
+
var ACROSS_SUGGESTED_FEES_MAX_AHEAD_S = 0;
|
|
139
|
+
function readAcrossSuggestedFees(request, route, status, body, nowS) {
|
|
140
|
+
const unavailable = (detail) => ({ kind: "unavailable", detail });
|
|
141
|
+
const refused = (detail, reason) => ({ kind: "refused", detail, reason });
|
|
142
|
+
if (status !== 200) {
|
|
143
|
+
const code = plain(body) ? own(body, "code") : void 0;
|
|
144
|
+
const label = typeof code === "string" ? ` ${code.slice(0, 40)}` : "";
|
|
145
|
+
if (status === 400) {
|
|
146
|
+
if (code === "AMOUNT_TOO_LOW") return refused("Across's relayer fee quote says the amount is too low relative to fees", "amount_too_small");
|
|
147
|
+
if (code === "AMOUNT_TOO_HIGH") return refused("Across's relayer fee quote says the amount is higher than relayer liquidity", "amount_too_large");
|
|
148
|
+
if (code === "ROUTE_NOT_ENABLED") return refused("Across's relayer fee quote says this route is not enabled for relayers", "unsupported_pair");
|
|
149
|
+
const param = plain(body) ? own(body, "param") : void 0;
|
|
150
|
+
const message = plain(body) ? own(body, "message") : void 0;
|
|
151
|
+
if (code === "INVALID_PARAM" && /token|chain/i.test(`${typeof param === "string" ? param : ""} ${typeof message === "string" ? message : ""}`)) {
|
|
152
|
+
return refused(`Across's relayer fee quote does not serve this token or chain (INVALID_PARAM${typeof param === "string" ? ` ${param.slice(0, 40)}` : ""})`, "unsupported_pair");
|
|
153
|
+
}
|
|
154
|
+
return refused(`Across's relayer fee quote refused the deposit (HTTP 400${label})`, "upstream_unavailable");
|
|
155
|
+
}
|
|
156
|
+
return unavailable(`it answered HTTP ${status}${label}`);
|
|
157
|
+
}
|
|
158
|
+
if (!plain(body)) return unavailable("its answer is not a JSON object");
|
|
159
|
+
const inputToken = own(body, "inputToken");
|
|
160
|
+
const outputToken = own(body, "outputToken");
|
|
161
|
+
if (!plain(inputToken) || !plain(outputToken)) return unavailable("its answer names no tokens");
|
|
162
|
+
if (!sameAddress(own(inputToken, "address"), route.input.token) || own(inputToken, "chainId") !== route.input.chain.chainId || !sameAddress(own(outputToken, "address"), route.output.token) || own(outputToken, "chainId") !== route.output.chain.chainId) {
|
|
163
|
+
return unavailable("its answer is for another route");
|
|
164
|
+
}
|
|
165
|
+
const spoke = own(body, "spokePoolAddress");
|
|
166
|
+
const destSpoke = own(body, "destinationSpokePoolAddress");
|
|
167
|
+
const spokeMoved = spoke !== void 0 && !sameAddress(spoke, route.input.chain.spokePool);
|
|
168
|
+
if (spokeMoved || destSpoke !== void 0 && !sameAddress(destSpoke, route.output.chain.spokePool)) {
|
|
169
|
+
return refused(`Across quotes this route on another SpokePool than the one pinned for ${spokeMoved ? route.input.chain.name : route.output.chain.name} \u2014 the pins need a review`, "vault_mismatch");
|
|
170
|
+
}
|
|
171
|
+
const totalRelay = own(body, "totalRelayFee");
|
|
172
|
+
const total = plain(totalRelay) ? uint(own(totalRelay, "total")) : null;
|
|
173
|
+
const outputAmount = uint(own(body, "outputAmount"));
|
|
174
|
+
if (total === null || outputAmount === null) return unavailable("its answer states no relayer fee");
|
|
175
|
+
if (outputAmount + total !== request.amount) return unavailable("its fee is not the amount minus its output");
|
|
176
|
+
if (own(body, "isAmountTooLow") === true || total >= request.amount) return refused("Across's relayer fee quote says the amount is too low relative to fees", "amount_too_small");
|
|
177
|
+
const limits = own(body, "limits");
|
|
178
|
+
if (plain(limits)) {
|
|
179
|
+
const min = uint(own(limits, "minDeposit"));
|
|
180
|
+
const max = uint(own(limits, "maxDeposit"));
|
|
181
|
+
if (min !== null && request.amount < min) return refused(`Across's relayers take at least ${min} base units on this route`, "amount_too_small");
|
|
182
|
+
if (max !== null && request.amount > max) return refused(`Across's relayers take at most ${max} base units on this route`, "amount_too_large");
|
|
183
|
+
}
|
|
184
|
+
const ts = own(body, "timestamp");
|
|
185
|
+
const timestamp = typeof ts === "string" && /^[1-9]\d{8,9}$/.test(ts) ? Number(ts) : NaN;
|
|
186
|
+
if (!Number.isInteger(timestamp)) return unavailable("its answer states no quote time");
|
|
187
|
+
if (timestamp - nowS > ACROSS_SUGGESTED_FEES_MAX_AHEAD_S) return unavailable(`its quote time is ${timestamp - nowS} s ahead of this clock`);
|
|
188
|
+
if (nowS - timestamp > ACROSS_SUGGESTED_FEES_MAX_AGE_S) return unavailable(`its quote time is ${nowS - timestamp} s old`);
|
|
189
|
+
const eta = own(body, "estimatedFillTimeSec");
|
|
190
|
+
return { kind: "fees", totalRelayFee: total, timestamp, estimatedFillTimeSec: typeof eta === "number" && Number.isFinite(eta) && eta >= 0 ? eta : 2 };
|
|
191
|
+
}
|
|
192
|
+
var text = (v, max) => typeof v === "string" && v.length > 0 ? v.slice(0, max) : void 0;
|
|
193
|
+
var FEE_CAP = /\bmax[ _-]?fee\b|\bmaximum (?:total |transfer )?fee\b|\bfee (?:cap|limit)\b|\bfees? (?:is |are )?(?:above|exceeds?|over|greater than|more than)\b/;
|
|
194
|
+
function reasonOfCode(code, message, param, side, status) {
|
|
195
|
+
switch (code) {
|
|
196
|
+
case "unauthenticated":
|
|
197
|
+
case "auth.missing_credentials":
|
|
198
|
+
case "auth.invalid_credentials":
|
|
199
|
+
// A feature the key is not entitled to (a permission Across grants per integration).
|
|
200
|
+
case "permission.not_entitled":
|
|
201
|
+
return { reason: "key_rejected", httpStatus: status };
|
|
202
|
+
case "policy.amount_out_of_range": {
|
|
203
|
+
if (side === "min") return { reason: "amount_too_small" };
|
|
204
|
+
if (side === "max") return { reason: "amount_too_large" };
|
|
205
|
+
const m = (message ?? "").toLowerCase();
|
|
206
|
+
if (/\b(?:raise|increase) the amount\b/.test(m)) return { reason: "amount_too_small" };
|
|
207
|
+
if (/\b(?:lower|reduce|decrease) the amount\b/.test(m)) return { reason: "amount_too_large" };
|
|
208
|
+
if (FEE_CAP.test(m)) return { reason: "price_check_failed" };
|
|
209
|
+
if (/\b(?:too low|too small|below|minimum|min)\b/.test(m)) return { reason: "amount_too_small" };
|
|
210
|
+
if (/\b(?:too high|too large|above|maximum|max|liquidity)\b/.test(m)) return { reason: "amount_too_large" };
|
|
211
|
+
return { reason: "price_check_failed" };
|
|
212
|
+
}
|
|
213
|
+
// The API no longer takes what this module sends (a field it does not know, or one it now requires): an API of
|
|
214
|
+
// another shape than the one this module was built against.
|
|
215
|
+
case "request.unsupported_param":
|
|
216
|
+
case "request.missing_field":
|
|
217
|
+
return { reason: "upstream_unavailable", httpStatus: status };
|
|
218
|
+
// Only pinned tokens and chains are sent: one V5 calls invalid ("unknown token … is not a known token") is one it
|
|
219
|
+
// does not serve. Any other value it no longer takes is, like the codes above, an API of another shape.
|
|
220
|
+
case "request.invalid_field":
|
|
221
|
+
return /token|chain/i.test(`${param ?? ""} ${message ?? ""}`) ? { reason: "unsupported_pair" } : { reason: "upstream_unavailable", httpStatus: status };
|
|
222
|
+
case "system.unavailable":
|
|
223
|
+
case "conflict.submission_state_unknown":
|
|
224
|
+
return { reason: "upstream_unavailable", httpStatus: status };
|
|
225
|
+
default:
|
|
226
|
+
return void 0;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
function parseAcrossV5Error(status, body, retryAfter, nowMs = Date.now()) {
|
|
230
|
+
const o = plain(body) ? body : void 0;
|
|
231
|
+
const nested = o !== void 0 && plain(o["error"]) ? o["error"] : void 0;
|
|
232
|
+
const code = text(nested?.["code"], 80) ?? text(o?.["code"], 80);
|
|
233
|
+
const type = text(nested?.["type"], 80);
|
|
234
|
+
const message = text(nested?.["message"], 240) ?? text(o?.["message"], 240);
|
|
235
|
+
const param = text(nested?.["param"], 80);
|
|
236
|
+
const requestId = text(nested?.["requestId"], 120);
|
|
237
|
+
const details = nested !== void 0 && plain(nested["details"]) ? nested["details"] : o !== void 0 && plain(o["details"]) ? o["details"] : void 0;
|
|
238
|
+
const limits = details !== void 0 && plain(details["amountLimits"]) ? details["amountLimits"] : void 0;
|
|
239
|
+
const rawSide = limits?.["side"];
|
|
240
|
+
const side = rawSide === "min" || rawSide === "max" ? rawSide : void 0;
|
|
241
|
+
const rawBound = limits?.["amount"];
|
|
242
|
+
const bound = typeof rawBound === "string" && UINT.test(rawBound) ? rawBound : void 0;
|
|
243
|
+
const byStatus = httpRefusal(status, retryAfter, nowMs);
|
|
244
|
+
let info;
|
|
245
|
+
if (byStatus?.reason === "rate_limited") info = byStatus;
|
|
246
|
+
else info = (code !== void 0 ? reasonOfCode(code, message, param, side, status) : void 0) ?? byStatus ?? (o !== void 0 && status >= 400 && status < 500 && status !== 404 ? { reason: "no_route" } : void 0);
|
|
247
|
+
return {
|
|
248
|
+
status,
|
|
249
|
+
...code !== void 0 ? { code } : {},
|
|
250
|
+
...type !== void 0 ? { type } : {},
|
|
251
|
+
...message !== void 0 ? { message } : {},
|
|
252
|
+
...param !== void 0 ? { param } : {},
|
|
253
|
+
...requestId !== void 0 ? { requestId } : {},
|
|
254
|
+
...side !== void 0 ? { amountLimit: { side, ...bound !== void 0 ? { amount: bound } : {} } } : {},
|
|
255
|
+
...info !== void 0 ? { info } : {},
|
|
256
|
+
retrySameRequest: status === 409 && code === "conflict.submission_state_unknown"
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
function acrossApiUrl(url, what) {
|
|
260
|
+
const u = String(url).trim().replace(/\/+$/, "");
|
|
261
|
+
if (/^https:\/\/[^\s/?#@]+(?:\/[^\s?#]*)?$/i.test(u)) return u;
|
|
262
|
+
if (/^http:\/\/(?:localhost|127\.0\.0\.1)(?::[0-9]{1,5})?(?:\/[^\s?#]*)?$/i.test(u)) return u;
|
|
263
|
+
throw new Error(`across: ${what} must be an https:// URL (http only for localhost)`);
|
|
264
|
+
}
|
|
265
|
+
var acrossOriginOf = (url) => (/^[a-z][a-z0-9+.-]*:\/\/[^/?#]*/i.exec(url)?.[0] ?? "").toLowerCase();
|
|
266
|
+
async function acrossHttp(url, init, opts) {
|
|
267
|
+
const expected = acrossOriginOf(url);
|
|
268
|
+
let status;
|
|
269
|
+
let raw;
|
|
270
|
+
let retryAfter = null;
|
|
271
|
+
try {
|
|
272
|
+
const timeout = timeoutSignal(opts.timeoutMs);
|
|
273
|
+
const res = await (opts.fetchImpl ?? fetch)(url, { ...init, redirect: "error", signal: opts.signal ? anySignal([opts.signal, timeout]) : timeout });
|
|
274
|
+
if (res.redirected === true || typeof res.url === "string" && res.url !== "" && acrossOriginOf(res.url) !== expected) {
|
|
275
|
+
throw new AcrossRefusal("api-answer", `${opts.what} answered through a redirect or from another origin \u2014 refused (a key must not follow one)`, "policy_refused");
|
|
276
|
+
}
|
|
277
|
+
status = res.status;
|
|
278
|
+
retryAfter = res.headers?.get?.("retry-after") ?? null;
|
|
279
|
+
raw = await res.text();
|
|
280
|
+
} catch (err) {
|
|
281
|
+
if (err instanceof AcrossRefusal) throw err;
|
|
282
|
+
const name = err instanceof Error ? err.name.slice(0, 40) : "error";
|
|
283
|
+
throw new AcrossRefusal("api-answer", `${opts.what} did not answer (${name})`, opts.signal?.aborted ? void 0 : "upstream_unavailable");
|
|
284
|
+
}
|
|
285
|
+
if (raw.length > MAX_ANSWER_CHARS) throw new AcrossRefusal("api-answer", `${opts.what} answered more than any quote`, "upstream_unavailable");
|
|
286
|
+
let body;
|
|
287
|
+
try {
|
|
288
|
+
body = JSON.parse(raw);
|
|
289
|
+
} catch {
|
|
290
|
+
body = void 0;
|
|
291
|
+
}
|
|
292
|
+
return { status, body, retryAfter };
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export {
|
|
296
|
+
ACROSS_API_V1,
|
|
297
|
+
ACROSS_SUGGESTED_FEES_URL,
|
|
298
|
+
ACROSS_V5_PRICING_MAX_FEE_BPS,
|
|
299
|
+
acrossV5QuoteRequest,
|
|
300
|
+
acrossUsdToUnits,
|
|
301
|
+
readAcrossV5Quote,
|
|
302
|
+
acrossSuggestedFeesQuery,
|
|
303
|
+
ACROSS_SUGGESTED_FEES_MAX_AGE_S,
|
|
304
|
+
ACROSS_SUGGESTED_FEES_MAX_AHEAD_S,
|
|
305
|
+
readAcrossSuggestedFees,
|
|
306
|
+
parseAcrossV5Error,
|
|
307
|
+
acrossApiUrl,
|
|
308
|
+
acrossOriginOf,
|
|
309
|
+
acrossHttp
|
|
310
|
+
};
|
|
311
|
+
//# sourceMappingURL=chunk-YGNP7KPL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/api.ts"],"sourcesContent":["/**\n * The two Across APIs this module reads — for NUMBERS only. Nothing either one answers is signed or executed: the\n * deposit is encoded on the device from the pins and the user's request (`build.ts`) and verified (`verify.ts`).\n *\n * - **Across API V5** (`POST https://api.across.to/v1/quotes`, a key from dashboard.across.to, server-side only) is\n * the price source. A V5 quote prices V5's own route — an execution step on the origin chain (Across's Gateway),\n * sometimes another rail (CCTP, an OFT) — and funds it through `nextActions` that pay an escrow keyed by an order\n * id the device cannot open (the recipient, the destination and the floor are not in anything it would sign). So\n * `nextActions`, `orderId`, `minAmount` and the attestation are never read: only the fee, its gas legs, the fill\n * estimate and the USD prices, each read strictly ({@link readAcrossV5Quote}).\n * - **`/suggested-fees`** (`GET https://app.across.to/api/suggested-fees`, keyless, the Across app's own relayer-fee\n * quote — Across calls it legacy) is the independent statement of what an Across relayer needs to fill a plain\n * SpokePool deposit, and the `timestamp` its LP fee was priced at ({@link readAcrossSuggestedFees}).\n *\n * `pricing.ts` turns the two into the deposit's numbers. Sources: Across's V5 integration skills\n * (github.com/across-protocol/skills @ f4d425e6, `quote-and-execute`, `security`) and real answers of both APIs\n * recorded 2026-11-15 (fixtures/api).\n */\nimport {httpRefusal, type Swap2RefusalInfo, type Swap2RefusalReason} from \"@anywalletkit/protocol-swap2-core/errors\";\nimport {anySignal, timeoutSignal} from \"@anywalletkit/protocol-swap2-core/util\";\nimport {ACROSS_API, acrossChain, type AcrossRoute} from \"./config.js\";\nimport {AcrossRefusal} from \"./refusal.js\";\nimport type {AcrossRequest} from \"./verify.js\";\n\n/** The V5 base (`ACROSS_API` + `/v1`). */\nexport const ACROSS_API_V1 = `${ACROSS_API}/v1`;\n/** Across's keyless relayer-fee quote (the Across app's own `/suggested-fees`). */\nexport const ACROSS_SUGGESTED_FEES_URL = \"https://app.across.to/api/suggested-fees\";\n/**\n * `maxFee.bps` sent with every V5 quote request: the widest V5 takes. It only bounds V5's own guaranteed minimum,\n * which is never used here (V5's estimate does not move with it: 24 962 036 / 24 962 140 / 24 963 399 base units for\n * the same 25 USDC at three caps, 2026-11-14); at 1000 V5 refused Ethereum-origin transfers under ~$16.5–19 because\n * its own origin gas alone was over the cap. The user's own cap is held on the deposit, by the verifier.\n */\nexport const ACROSS_V5_PRICING_MAX_FEE_BPS = 5_000;\n/** Longest answer read from either API, in characters (a V5 quote is ~12 kB). */\nconst MAX_ANSWER_CHARS = 512 * 1024;\n\nexport interface AcrossV5Token {\n chainId: number;\n address: string;\n}\n\n/** `POST /v1/quotes` body, exactly the fields this module sends (the API refuses any field it does not know). */\nexport interface AcrossV5QuoteRequest {\n origin: {token: AcrossV5Token; depositor: string; amount: string};\n destination: {token: AcrossV5Token; recipient: string};\n amountType: \"exact_input\";\n /** What the client can do: approve a token and send a transaction on an EVM chain. No typed data, no submissions. */\n capabilities: {operations: readonly {kind: \"approve_token\" | \"send_transaction\"; ecosystem: \"evm\"}[]};\n /** An approval of exactly the funded amount — never `infinite`. */\n authorizationPolicy: {allowedTypes: readonly [\"approval\"]; approvalAmount: \"exact\"};\n /** {@link ACROSS_V5_PRICING_MAX_FEE_BPS}. */\n maxFee: {bps: number};\n}\n\n/**\n * The `POST /v1/quotes` body for a request. Pure. Native ETH is the zero address on both sides, as V5 names it; the\n * funding is the plain approval flow (`approve_token` + `send_transaction`, exact amount) — the one whose price was\n * studied; nothing it returns is executed.\n */\nexport function acrossV5QuoteRequest(request: AcrossRequest): AcrossV5QuoteRequest {\n const src = acrossChain(request.sourceChain);\n const dst = acrossChain(request.destChain);\n if (!src || !dst) throw new Error(\"across: the request's chains are not pinned\");\n return {\n origin: {token: {chainId: src.chainId, address: request.sourceToken.toLowerCase()}, depositor: request.depositor.toLowerCase(), amount: request.amount.toString(10)},\n destination: {token: {chainId: dst.chainId, address: request.destToken.toLowerCase()}, recipient: request.recipient.toLowerCase()},\n amountType: \"exact_input\",\n capabilities: {operations: [{kind: \"approve_token\", ecosystem: \"evm\"}, {kind: \"send_transaction\", ecosystem: \"evm\"}]},\n authorizationPolicy: {allowedTypes: [\"approval\"], approvalAmount: \"exact\"},\n maxFee: {bps: ACROSS_V5_PRICING_MAX_FEE_BPS},\n };\n}\n\n// ── reading answers ────────────────────────────────────────────────────────────\n\nconst ADDRESS = /^0x[0-9a-fA-F]{40}$/;\nconst ZERO = /^0x0{40}$/;\nconst UINT = /^(?:0|[1-9]\\d{0,77})$/;\n/** A non-negative decimal as V5 writes USD amounts (\"0.012048778559999999\"). */\nconst DECIMAL = /^(?:0|[1-9]\\d{0,15})(?:\\.\\d{1,30})?$/;\nconst plain = (v: unknown): v is Record<string, unknown> => v !== null && typeof v === \"object\" && !Array.isArray(v);\nconst own = (o: Record<string, unknown>, key: string): unknown => (Object.prototype.hasOwnProperty.call(o, key) ? o[key] : undefined);\nconst uint = (v: unknown): bigint | null => (typeof v === \"string\" && UINT.test(v) ? BigInt(v) : null);\nconst sameAddress = (a: unknown, b: string): boolean => typeof a === \"string\" && ADDRESS.test(a) && a.toLowerCase() === b.toLowerCase();\n\n/** A decimal string as an integer scaled by 10^`scale`, rounded down; null when it is not one. */\nfunction scaled(text: string, scale: number): bigint | null {\n if (!DECIMAL.test(text)) return null;\n const [whole, frac = \"\"] = text.split(\".\");\n return BigInt(whole! + frac.slice(0, scale).padEnd(scale, \"0\"));\n}\n\nconst USD_SCALE = 18;\nconst PRICE_SCALE = 12;\n\n/**\n * A USD amount as base units of a token priced at `priceUsd`, rounded down — integer math only (no `Number` of a big\n * value): `amountUsd × 10^decimals / priceUsd`. Null when either is not a usable number.\n */\nexport function acrossUsdToUnits(amountUsd: unknown, priceUsd: unknown, decimals: number): bigint | null {\n if (typeof amountUsd !== \"string\" || typeof priceUsd !== \"number\" || !Number.isFinite(priceUsd) || priceUsd <= 0 || priceUsd >= 1e12) return null;\n if (!Number.isInteger(decimals) || decimals < 0 || decimals > 36) return null;\n const usd = scaled(amountUsd, USD_SCALE);\n const price = scaled(priceUsd.toFixed(PRICE_SCALE), PRICE_SCALE);\n if (usd === null || price === null || price === 0n) return null;\n return (usd * 10n ** BigInt(decimals) * 10n ** BigInt(PRICE_SCALE)) / (price * 10n ** BigInt(USD_SCALE));\n}\n\n/** What a V5 quote says that the pricing rule reads — every amount in base units of the input token. */\nexport interface AcrossV5Price {\n /** `fee.totalFee.amount`: input − `destination.amount` (checked to add up). */\n totalFee: bigint;\n /** V5's estimate of what arrives (`destination.amount`). */\n destinationAmount: bigint;\n /**\n * Σ `gasEstimates[leg = \"origin\", effect = \"included_in_transfer_fee\"]`: V5's own execution step on the origin\n * chain, charged inside its fee. Exact wei on an ETH route; a token route converts its USD figure at the\n * destination token's price, rounded down. A leg that cannot be read adds nothing (the fee stays higher).\n */\n originGas: bigint;\n /** Σ `gasEstimates[leg = \"destination\", effect = \"included_in_transfer_fee\"]`, converted alike; null when a leg cannot be. */\n destinationGas: bigint | null;\n /** `expectedFillTimeMs`. Over a minute it is not an Across relayer fill: V5 prices another rail (`acrossV5OtherRail`). */\n expectedFillTimeMs: number;\n /** `origin.amountUsd`, when given: the transfer's size in dollars (the floor curve for ETH from an L2 is by size). */\n amountUsd?: number;\n}\n\n/**\n * A V5 quote answer, read strictly against the request it was asked for. Throws {@link AcrossRefusal} `api-answer`:\n * `policy_refused` for an answer about another transfer (tokens, chains, amount, an app fee nobody asked for),\n * `upstream_unavailable` for one that does not read or does not add up. `nextActions`, `orderId`, `minAmount` and any\n * attestation are not read.\n */\nexport function readAcrossV5Quote(request: AcrossRequest, route: AcrossRoute, body: unknown): AcrossV5Price {\n const malformed = (what: string): never => { throw new AcrossRefusal(\"api-answer\", `the V5 quote ${what}`, \"upstream_unavailable\"); };\n const other = (what: string): never => { throw new AcrossRefusal(\"api-answer\", `the V5 quote ${what}`, \"policy_refused\"); };\n if (!plain(body)) return malformed(\"is not a JSON object\");\n const amountType = own(body, \"amountType\");\n if (amountType !== undefined && amountType !== \"exact_input\") other(`is ${String(amountType).slice(0, 20)}, not exact input`);\n const src = route.input.chain;\n const dst = route.output.chain;\n\n const origin = own(body, \"origin\");\n const destination = own(body, \"destination\");\n if (!plain(origin) || !plain(destination)) return malformed(\"has no origin or destination\");\n const oToken = own(origin, \"token\");\n const dToken = own(destination, \"token\");\n if (!plain(oToken) || !plain(dToken)) return malformed(\"names no tokens\");\n if (own(oToken, \"chainId\") !== src.chainId || !sameAddress(own(oToken, \"address\"), request.sourceToken)) other(\"is for another input token or chain\");\n if (own(dToken, \"chainId\") !== dst.chainId || !sameAddress(own(dToken, \"address\"), request.destToken)) other(\"is for another output token or chain\");\n const amountIn = uint(own(origin, \"amount\"));\n if (amountIn === null) return malformed(\"states no input amount\");\n if (amountIn !== request.amount) other(`sends ${amountIn}, the request ${request.amount}`);\n const destinationAmount = uint(own(destination, \"amount\"));\n if (destinationAmount === null) return malformed(\"states no output estimate\");\n if (destinationAmount > request.amount) other(\"expects more to arrive than goes in\");\n\n const fee = own(body, \"fee\");\n if (!plain(fee)) return malformed(\"has no fee\");\n const total = own(fee, \"totalFee\");\n if (!plain(total)) return malformed(\"has no total fee\");\n const totalFee = uint(own(total, \"amount\"));\n if (totalFee === null) return malformed(\"states a total fee that is not a base-unit integer\");\n const feeToken = own(total, \"token\");\n if (!plain(feeToken) || own(feeToken, \"chainId\") !== dst.chainId || !sameAddress(own(feeToken, \"address\"), request.destToken) || own(feeToken, \"decimals\") !== route.output.decimals) {\n malformed(\"states its fee in another token\");\n }\n if (totalFee !== request.amount - destinationAmount) malformed(`fee ${totalFee} is not its input minus its estimate (${request.amount - destinationAmount})`);\n const appFee = own(fee, \"appFee\");\n if (appFee !== undefined && appFee !== null) {\n const app = plain(appFee) ? uint(own(appFee, \"amount\")) : null;\n if (app === null) return malformed(\"states an app fee that does not read\");\n if (app > 0n) other(\"carries an app fee this module never asks for\");\n }\n\n const fill = own(body, \"expectedFillTimeMs\");\n if (typeof fill !== \"number\" || !Number.isFinite(fill) || fill < 0) return malformed(\"states no fill time\");\n const priceUsd = own(dToken, \"priceUsd\");\n const legs = own(body, \"gasEstimates\");\n if (!Array.isArray(legs) || legs.length > 16) return malformed(\"has no gas estimates\");\n let originGas = 0n;\n let destinationGas: bigint | null = 0n;\n for (const leg of legs as unknown[]) {\n if (!plain(leg)) return malformed(\"has a gas estimate that is not an object\");\n if (own(leg, \"effect\") !== \"included_in_transfer_fee\") continue;\n const side = own(leg, \"leg\");\n if (side !== \"origin\" && side !== \"destination\") continue;\n const units = legUnits(leg, route, priceUsd);\n if (side === \"origin\") originGas += units ?? 0n;\n else destinationGas = units === null || destinationGas === null ? null : destinationGas + units;\n }\n // An add-back is never more than the fee it is taken from.\n if (originGas > totalFee) originGas = totalFee;\n\n const usdText = own(origin, \"amountUsd\");\n const amountUsd = typeof usdText === \"string\" && DECIMAL.test(usdText) ? Number(usdText) : undefined;\n return {totalFee, destinationAmount, originGas, destinationGas, expectedFillTimeMs: fill, ...(amountUsd !== undefined && Number.isFinite(amountUsd) ? {amountUsd} : {})};\n}\n\n/**\n * One gas leg in base units of the input token. On an ETH route a leg paid in the native ether of either chain is\n * exact (wei is the bridged asset's own unit); anything else is its `amountUsd` at the destination token's price.\n */\nfunction legUnits(leg: Record<string, unknown>, route: AcrossRoute, priceUsd: unknown): bigint | null {\n const token = own(leg, \"token\");\n const amount = uint(own(leg, \"amount\"));\n if (route.asset === \"ETH\" && plain(token) && amount !== null && ZERO.test(String(own(token, \"address\"))) && own(token, \"decimals\") === 18) {\n const chainId = own(token, \"chainId\");\n const side = chainId === route.input.chain.chainId ? route.input.chain : chainId === route.output.chain.chainId ? route.output.chain : undefined;\n if (side?.nativeIsEth) return amount;\n }\n return acrossUsdToUnits(own(leg, \"amountUsd\"), priceUsd, route.input.decimals);\n}\n\n/** What `/suggested-fees` answered, as the pricing rule reads it. */\nexport type AcrossSuggestedFees =\n /** A relayer fee for this exact deposit. */\n | {kind: \"fees\"; totalRelayFee: bigint; timestamp: number; estimatedFillTimeSec: number}\n /** Across says relayers will not take this deposit (too small, too large, the route not enabled): refuse. */\n | {kind: \"refused\"; detail: string; reason: Swap2RefusalReason}\n /** No usable answer (unreachable, another shape, stale): the pinned floor stands in. */\n | {kind: \"unavailable\"; detail: string};\n\n/** The `/suggested-fees` query for a request: the deposit's own tokens (the wrapped native token for ETH) and recipient. */\nexport function acrossSuggestedFeesQuery(request: AcrossRequest, route: AcrossRoute): string {\n const q: [string, string][] = [\n [\"inputToken\", route.input.token],\n [\"outputToken\", route.output.token],\n [\"originChainId\", String(route.input.chain.chainId)],\n [\"destinationChainId\", String(route.output.chain.chainId)],\n [\"amount\", request.amount.toString(10)],\n [\"recipient\", request.recipient.toLowerCase()],\n ];\n return q.map(([k, v]) => `${k}=${encodeURIComponent(v)}`).join(\"&\");\n}\n\n/**\n * How old a `/suggested-fees` timestamp may be (s). It becomes the deposit's quote time, so it is never taken from\n * ahead of the reader's clock: the SpokePool reverts a quote time ahead of its block, and Across's are HubPool block\n * times minutes in the past (217–245 s on every recorded answer).\n */\nexport const ACROSS_SUGGESTED_FEES_MAX_AGE_S = 600;\nexport const ACROSS_SUGGESTED_FEES_MAX_AHEAD_S = 0;\n\n/**\n * A `/suggested-fees` answer for a request, at `nowS`. Across's own refusals of the deposit — any 400 it answers\n * (`AMOUNT_TOO_LOW`, `AMOUNT_TOO_HIGH`, `ROUTE_NOT_ENABLED`, `INVALID_PARAM` for a token or a chain it does not serve,\n * or a code this module does not know), `isAmountTooLow`, an amount outside `limits` — and a SpokePool other than the\n * pinned one are `refused`; no answer, another status, or one that is not a clean, consistent, fresh answer is\n * `unavailable` (the pinned floor may then stand in).\n */\nexport function readAcrossSuggestedFees(request: AcrossRequest, route: AcrossRoute, status: number, body: unknown, nowS: number): AcrossSuggestedFees {\n const unavailable = (detail: string): AcrossSuggestedFees => ({kind: \"unavailable\", detail});\n const refused = (detail: string, reason: Swap2RefusalReason): AcrossSuggestedFees => ({kind: \"refused\", detail, reason});\n if (status !== 200) {\n const code = plain(body) ? own(body, \"code\") : undefined;\n const label = typeof code === \"string\" ? ` ${code.slice(0, 40)}` : \"\";\n if (status === 400) {\n if (code === \"AMOUNT_TOO_LOW\") return refused(\"Across's relayer fee quote says the amount is too low relative to fees\", \"amount_too_small\");\n if (code === \"AMOUNT_TOO_HIGH\") return refused(\"Across's relayer fee quote says the amount is higher than relayer liquidity\", \"amount_too_large\");\n if (code === \"ROUTE_NOT_ENABLED\") return refused(\"Across's relayer fee quote says this route is not enabled for relayers\", \"unsupported_pair\");\n // Only pinned tokens and chains are asked for: one Across calls invalid (\"Unsupported token on given origin\n // chain\") is one its relayers do not serve — a deposit priced on the floor for it would never be filled.\n const param = plain(body) ? own(body, \"param\") : undefined;\n const message = plain(body) ? own(body, \"message\") : undefined;\n if (code === \"INVALID_PARAM\" && /token|chain/i.test(`${typeof param === \"string\" ? param : \"\"} ${typeof message === \"string\" ? message : \"\"}`)) {\n return refused(`Across's relayer fee quote does not serve this token or chain (INVALID_PARAM${typeof param === \"string\" ? ` ${param.slice(0, 40)}` : \"\"})`, \"unsupported_pair\");\n }\n // Any other refusal of this exact deposit: Across said no, so nothing stands in for its price.\n return refused(`Across's relayer fee quote refused the deposit (HTTP 400${label})`, \"upstream_unavailable\");\n }\n return unavailable(`it answered HTTP ${status}${label}`);\n }\n if (!plain(body)) return unavailable(\"its answer is not a JSON object\");\n const inputToken = own(body, \"inputToken\");\n const outputToken = own(body, \"outputToken\");\n if (!plain(inputToken) || !plain(outputToken)) return unavailable(\"its answer names no tokens\");\n if (!sameAddress(own(inputToken, \"address\"), route.input.token) || own(inputToken, \"chainId\") !== route.input.chain.chainId\n || !sameAddress(own(outputToken, \"address\"), route.output.token) || own(outputToken, \"chainId\") !== route.output.chain.chainId) {\n return unavailable(\"its answer is for another route\");\n }\n // The SpokePools relayers watch for this route: the pinned ones, or the pins are out of date.\n const spoke = own(body, \"spokePoolAddress\");\n const destSpoke = own(body, \"destinationSpokePoolAddress\");\n const spokeMoved = spoke !== undefined && !sameAddress(spoke, route.input.chain.spokePool);\n if (spokeMoved || (destSpoke !== undefined && !sameAddress(destSpoke, route.output.chain.spokePool))) {\n return refused(`Across quotes this route on another SpokePool than the one pinned for ${spokeMoved ? route.input.chain.name : route.output.chain.name} — the pins need a review`, \"vault_mismatch\");\n }\n const totalRelay = own(body, \"totalRelayFee\");\n const total = plain(totalRelay) ? uint(own(totalRelay, \"total\")) : null;\n const outputAmount = uint(own(body, \"outputAmount\"));\n if (total === null || outputAmount === null) return unavailable(\"its answer states no relayer fee\");\n if (outputAmount + total !== request.amount) return unavailable(\"its fee is not the amount minus its output\");\n if (own(body, \"isAmountTooLow\") === true || total >= request.amount) return refused(\"Across's relayer fee quote says the amount is too low relative to fees\", \"amount_too_small\");\n const limits = own(body, \"limits\");\n if (plain(limits)) {\n const min = uint(own(limits, \"minDeposit\"));\n const max = uint(own(limits, \"maxDeposit\"));\n if (min !== null && request.amount < min) return refused(`Across's relayers take at least ${min} base units on this route`, \"amount_too_small\");\n if (max !== null && request.amount > max) return refused(`Across's relayers take at most ${max} base units on this route`, \"amount_too_large\");\n }\n const ts = own(body, \"timestamp\");\n const timestamp = typeof ts === \"string\" && /^[1-9]\\d{8,9}$/.test(ts) ? Number(ts) : NaN;\n if (!Number.isInteger(timestamp)) return unavailable(\"its answer states no quote time\");\n if (timestamp - nowS > ACROSS_SUGGESTED_FEES_MAX_AHEAD_S) return unavailable(`its quote time is ${timestamp - nowS} s ahead of this clock`);\n if (nowS - timestamp > ACROSS_SUGGESTED_FEES_MAX_AGE_S) return unavailable(`its quote time is ${nowS - timestamp} s old`);\n const eta = own(body, \"estimatedFillTimeSec\");\n return {kind: \"fees\", totalRelayFee: total, timestamp, estimatedFillTimeSec: typeof eta === \"number\" && Number.isFinite(eta) && eta >= 0 ? eta : 2};\n}\n\n// ── V5 errors ──────────────────────────────────────────────────────────────────\n\n/** A V5 error answer, read from either envelope, with its classification. */\nexport interface AcrossV5Error {\n /** HTTP status of the answer. */\n status: number;\n /** `error.code`, else the top-level `code` (`unauthenticated`, `policy.amount_out_of_range`, …). */\n code?: string;\n /** `error.type` (nested envelope only). */\n type?: string;\n message?: string;\n /** The field the error names (`error.param`). */\n param?: string;\n /** Across's id for the request, for support (`error.requestId`). */\n requestId?: string;\n /** `error.details.amountLimits`: which bound the amount crossed and where it lies, base units of the input token. */\n amountLimit?: {side: \"min\" | \"max\"; amount?: string};\n /** The CS-13 classification; undefined when neither the code nor the status says what it is. */\n info?: Swap2RefusalInfo;\n /**\n * `409 conflict.submission_state_unknown`: the execution's outcome is unknown — retry the SAME request with backoff,\n * never quote again (a new quote could fund the transfer twice). Quoting never meets it; kept for completeness.\n */\n retrySameRequest: boolean;\n}\n\nconst text = (v: unknown, max: number): string | undefined => (typeof v === \"string\" && v.length > 0 ? v.slice(0, max) : undefined);\n\n/**\n * A refusal over the `maxFee` cap, in Across's wording or near it: the cap named (`maxFee`, \"maximum fee\", \"fee cap\"),\n * or a fee said to be above something. \"Amount too low to cover fees\" is not one — that is the amount's own direction.\n */\nconst FEE_CAP = /\\bmax[ _-]?fee\\b|\\bmaximum (?:total |transfer )?fee\\b|\\bfee (?:cap|limit)\\b|\\bfees? (?:is |are )?(?:above|exceeds?|over|greater than|more than)\\b/;\n\n/** What an error code says on its own (Across's documented codes), before the HTTP status is consulted. */\nfunction reasonOfCode(code: string, message: string | undefined, param: string | undefined, side: \"min\" | \"max\" | undefined, status: number): Swap2RefusalInfo | undefined {\n switch (code) {\n case \"unauthenticated\":\n case \"auth.missing_credentials\":\n case \"auth.invalid_credentials\":\n // A feature the key is not entitled to (a permission Across grants per integration).\n case \"permission.not_entitled\":\n return {reason: \"key_rejected\", httpStatus: status};\n case \"policy.amount_out_of_range\": {\n // The bound V5 names is the answer: the real fee-cap refusal reads \"quote value loss exceeds the allowance of\n // 1000 bps plus $0; raise the amount above N base units\" with `amountLimits.side = \"min\"` — its \"above\" names\n // the amount the user must reach, not an amount that is too large.\n if (side === \"min\") return {reason: \"amount_too_small\"};\n if (side === \"max\") return {reason: \"amount_too_large\"};\n const m = (message ?? \"\").toLowerCase();\n if (/\\b(?:raise|increase) the amount\\b/.test(m)) return {reason: \"amount_too_small\"};\n if (/\\b(?:lower|reduce|decrease) the amount\\b/.test(m)) return {reason: \"amount_too_large\"};\n if (FEE_CAP.test(m)) return {reason: \"price_check_failed\"};\n if (/\\b(?:too low|too small|below|minimum|min)\\b/.test(m)) return {reason: \"amount_too_small\"};\n if (/\\b(?:too high|too large|above|maximum|max|liquidity)\\b/.test(m)) return {reason: \"amount_too_large\"};\n return {reason: \"price_check_failed\"};\n }\n // The API no longer takes what this module sends (a field it does not know, or one it now requires): an API of\n // another shape than the one this module was built against.\n case \"request.unsupported_param\":\n case \"request.missing_field\":\n return {reason: \"upstream_unavailable\", httpStatus: status};\n // Only pinned tokens and chains are sent: one V5 calls invalid (\"unknown token … is not a known token\") is one it\n // does not serve. Any other value it no longer takes is, like the codes above, an API of another shape.\n case \"request.invalid_field\":\n return /token|chain/i.test(`${param ?? \"\"} ${message ?? \"\"}`) ? {reason: \"unsupported_pair\"} : {reason: \"upstream_unavailable\", httpStatus: status};\n case \"system.unavailable\":\n case \"conflict.submission_state_unknown\":\n return {reason: \"upstream_unavailable\", httpStatus: status};\n default:\n return undefined;\n }\n}\n\n/**\n * Read a non-2xx V5 answer: the two envelopes Across uses — flat `{code, message, details}` (the gateway's 401) and\n * nested `{error: {type, code, message, param, requestId, details}}` — and its CS-13 classification. A 429 is\n * `rate_limited` with its Retry-After first; then the code (with `details.amountLimits.side` for\n * `policy.amount_out_of_range`); then the status (401 / 403 → `key_rejected`, 408 / 425 / 5xx →\n * `upstream_unavailable`); a JSON refusal neither names is a quote the API does not have (`no_route`).\n */\nexport function parseAcrossV5Error(status: number, body: unknown, retryAfter?: string | null, nowMs: number = Date.now()): AcrossV5Error {\n const o = plain(body) ? body : undefined;\n const nested = o !== undefined && plain(o[\"error\"]) ? o[\"error\"] : undefined;\n const code = text(nested?.[\"code\"], 80) ?? text(o?.[\"code\"], 80);\n const type = text(nested?.[\"type\"], 80);\n const message = text(nested?.[\"message\"], 240) ?? text(o?.[\"message\"], 240);\n const param = text(nested?.[\"param\"], 80);\n const requestId = text(nested?.[\"requestId\"], 120);\n const details = nested !== undefined && plain(nested[\"details\"]) ? nested[\"details\"] : o !== undefined && plain(o[\"details\"]) ? o[\"details\"] : undefined;\n const limits = details !== undefined && plain(details[\"amountLimits\"]) ? details[\"amountLimits\"] : undefined;\n const rawSide = limits?.[\"side\"];\n const side = rawSide === \"min\" || rawSide === \"max\" ? rawSide : undefined;\n const rawBound = limits?.[\"amount\"];\n const bound = typeof rawBound === \"string\" && UINT.test(rawBound) ? rawBound : undefined;\n const byStatus = httpRefusal(status, retryAfter, nowMs);\n let info: Swap2RefusalInfo | undefined;\n if (byStatus?.reason === \"rate_limited\") info = byStatus;\n else info = (code !== undefined ? reasonOfCode(code, message, param, side, status) : undefined) ?? byStatus ?? (o !== undefined && status >= 400 && status < 500 && status !== 404 ? {reason: \"no_route\"} : undefined);\n return {\n status,\n ...(code !== undefined ? {code} : {}),\n ...(type !== undefined ? {type} : {}),\n ...(message !== undefined ? {message} : {}),\n ...(param !== undefined ? {param} : {}),\n ...(requestId !== undefined ? {requestId} : {}),\n ...(side !== undefined ? {amountLimit: {side, ...(bound !== undefined ? {amount: bound} : {})}} : {}),\n ...(info !== undefined ? {info} : {}),\n retrySameRequest: status === 409 && code === \"conflict.submission_state_unknown\",\n };\n}\n\n// ── HTTP ───────────────────────────────────────────────────────────────────────\n\n/** An API URL, trailing slashes trimmed; throws a plain `Error` unless https (or http on this machine). */\nexport function acrossApiUrl(url: string, what: string): string {\n const u = String(url).trim().replace(/\\/+$/, \"\");\n if (/^https:\\/\\/[^\\s/?#@]+(?:\\/[^\\s?#]*)?$/i.test(u)) return u;\n if (/^http:\\/\\/(?:localhost|127\\.0\\.0\\.1)(?::[0-9]{1,5})?(?:\\/[^\\s?#]*)?$/i.test(u)) return u;\n throw new Error(`across: ${what} must be an https:// URL (http only for localhost)`);\n}\n\n/** `scheme://host[:port]` of a URL, lowercase; \"\" when it has none. No URL class: React Native's lacks `origin`. */\nexport const acrossOriginOf = (url: string): string => (/^[a-z][a-z0-9+.-]*:\\/\\/[^/?#]*/i.exec(url)?.[0] ?? \"\").toLowerCase();\n\n/** An answer as read: status, parsed body (undefined when not JSON), Retry-After. */\nexport interface AcrossHttpAnswer {\n status: number;\n body: unknown;\n retryAfter: string | null;\n}\n\n/**\n * One request to an Across API, bounded by `timeoutMs` (and the caller's signal). An answer that came through a\n * redirect, or from another origin than the URL's, is refused (`policy_refused`) — a key header must not follow one,\n * and React Native's fetch follows redirects whatever `redirect` says. Throws {@link AcrossRefusal} `api-answer` for a\n * redirect, an answer larger than any quote, or no answer (`upstream_unavailable`; unclassified when the caller's own\n * signal fired).\n */\nexport async function acrossHttp(\n url: string,\n init: {method: \"GET\" | \"POST\"; headers: Record<string, string>; body?: string},\n opts: {fetchImpl?: typeof fetch | undefined; timeoutMs: number; signal?: AbortSignal | undefined; what: string},\n): Promise<AcrossHttpAnswer> {\n const expected = acrossOriginOf(url);\n let status: number;\n let raw: string;\n let retryAfter: string | null = null;\n try {\n const timeout = timeoutSignal(opts.timeoutMs);\n const res = await (opts.fetchImpl ?? fetch)(url, {...init, redirect: \"error\", signal: opts.signal ? anySignal([opts.signal, timeout]) : timeout});\n if (res.redirected === true || (typeof res.url === \"string\" && res.url !== \"\" && acrossOriginOf(res.url) !== expected)) {\n throw new AcrossRefusal(\"api-answer\", `${opts.what} answered through a redirect or from another origin — refused (a key must not follow one)`, \"policy_refused\");\n }\n status = res.status;\n retryAfter = res.headers?.get?.(\"retry-after\") ?? null;\n raw = await res.text();\n } catch (err) {\n if (err instanceof AcrossRefusal) throw err;\n const name = err instanceof Error ? err.name.slice(0, 40) : \"error\";\n throw new AcrossRefusal(\"api-answer\", `${opts.what} did not answer (${name})`, opts.signal?.aborted ? undefined : \"upstream_unavailable\");\n }\n if (raw.length > MAX_ANSWER_CHARS) throw new AcrossRefusal(\"api-answer\", `${opts.what} answered more than any quote`, \"upstream_unavailable\");\n let body: unknown;\n try {\n body = JSON.parse(raw);\n } catch {\n body = undefined;\n }\n return {status, body, retryAfter};\n}\n"],"mappings":";;;;;;;;;AAkBA,SAAQ,mBAAkE;AAC1E,SAAQ,WAAW,qBAAoB;AAMhC,IAAM,gBAAgB,GAAG,UAAU;AAEnC,IAAM,4BAA4B;AAOlC,IAAM,gCAAgC;AAE7C,IAAM,mBAAmB,MAAM;AAyBxB,SAAS,qBAAqB,SAA8C;AACjF,QAAM,MAAM,YAAY,QAAQ,WAAW;AAC3C,QAAM,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AM,WAAU;AAClC;","names":["text"]}
|
package/dist/config.cjs
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/config.ts
|
|
21
|
+
var config_exports = {};
|
|
22
|
+
__export(config_exports, {
|
|
23
|
+
ACROSS_API: () => ACROSS_API,
|
|
24
|
+
ACROSS_CHAINS: () => ACROSS_CHAINS,
|
|
25
|
+
ACROSS_DEPOSIT: () => ACROSS_DEPOSIT,
|
|
26
|
+
ACROSS_DEPOSIT_QUOTE_TIME_BUFFER_S: () => ACROSS_DEPOSIT_QUOTE_TIME_BUFFER_S,
|
|
27
|
+
ACROSS_DEPOSIT_V3: () => ACROSS_DEPOSIT_V3,
|
|
28
|
+
ACROSS_FILL_DEADLINE_BUFFER_S: () => ACROSS_FILL_DEADLINE_BUFFER_S,
|
|
29
|
+
ACROSS_FILL_STATUSES: () => ACROSS_FILL_STATUSES,
|
|
30
|
+
ACROSS_FUNDS_DEPOSITED: () => ACROSS_FUNDS_DEPOSITED,
|
|
31
|
+
ACROSS_HUB_CROSS_CHAIN_CONTRACTS: () => ACROSS_HUB_CROSS_CHAIN_CONTRACTS,
|
|
32
|
+
ACROSS_HUB_POOL: () => ACROSS_HUB_POOL,
|
|
33
|
+
ACROSS_MAX_EXCLUSIVITY_PERIOD_S: () => ACROSS_MAX_EXCLUSIVITY_PERIOD_S,
|
|
34
|
+
ACROSS_NATIVE: () => ACROSS_NATIVE,
|
|
35
|
+
ACROSS_REFUSED_SELECTORS: () => ACROSS_REFUSED_SELECTORS,
|
|
36
|
+
ACROSS_SPEED_UP_DOMAIN: () => ACROSS_SPEED_UP_DOMAIN,
|
|
37
|
+
ACROSS_SPEED_UP_TYPE: () => ACROSS_SPEED_UP_TYPE,
|
|
38
|
+
ACROSS_SPEED_UP_TYPEHASH: () => ACROSS_SPEED_UP_TYPEHASH,
|
|
39
|
+
ACROSS_V5_MESSAGE_PREFIX: () => ACROSS_V5_MESSAGE_PREFIX,
|
|
40
|
+
across: () => across,
|
|
41
|
+
acrossChain: () => acrossChain,
|
|
42
|
+
acrossRouteOf: () => acrossRouteOf,
|
|
43
|
+
acrossToken: () => acrossToken
|
|
44
|
+
});
|
|
45
|
+
module.exports = __toCommonJS(config_exports);
|
|
46
|
+
var USDC = (address, symbol = "USDC") => Object.freeze({ asset: "USDC", address, symbol, decimals: 6 });
|
|
47
|
+
var USDT = (address, symbol = "USDT") => Object.freeze({ asset: "USDT", address, symbol, decimals: 6 });
|
|
48
|
+
var WETH = (address) => Object.freeze({ asset: "ETH", address, symbol: "WETH", decimals: 18 });
|
|
49
|
+
var WBTC = (address) => Object.freeze({ asset: "WBTC", address, symbol: "WBTC", decimals: 8 });
|
|
50
|
+
var OP_WETH = "0x4200000000000000000000000000000000000006";
|
|
51
|
+
function chain(chainId, key, name, spokePool, wrappedNative, nativeIsEth, tokens) {
|
|
52
|
+
return Object.freeze({ caip2: `eip155:${chainId}`, chainId, key, name, spokePool, wrappedNative, nativeIsEth, tokens: Object.freeze(tokens) });
|
|
53
|
+
}
|
|
54
|
+
var ACROSS_CHAINS = Object.freeze(Object.assign(/* @__PURE__ */ Object.create(null), Object.fromEntries([
|
|
55
|
+
chain(1, "ethereum", "Ethereum", "0x5c7bcd6e7de5423a257d81b442095a1a6ced35c5", "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", true, [
|
|
56
|
+
USDC("0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"),
|
|
57
|
+
USDT("0xdac17f958d2ee523a2206206994597c13d831ec7"),
|
|
58
|
+
WETH("0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"),
|
|
59
|
+
WBTC("0x2260fac5e5542a773aa44fbcfedf7c193bc2c599")
|
|
60
|
+
]),
|
|
61
|
+
chain(10, "optimism", "Optimism", "0x6f26bf09b1c792e3228e5467807a900a503c0281", OP_WETH, true, [
|
|
62
|
+
USDC("0x0b2c639c533813f4aa9d7837caf62653d097ff85"),
|
|
63
|
+
USDT("0x94b008aa00579c1307b0ef2c499ad98a8ce58e58"),
|
|
64
|
+
WETH(OP_WETH)
|
|
65
|
+
]),
|
|
66
|
+
chain(130, "unichain", "Unichain", "0x09aea4b2242abc8bb4bb78d537a67a245a7bec64", OP_WETH, true, [
|
|
67
|
+
USDC("0x078d782b760474a361dda0af3839290b0ef57ad6"),
|
|
68
|
+
USDT("0x9151434b16b9763660705744891fa906f660ecc5", "USDT0"),
|
|
69
|
+
WETH(OP_WETH)
|
|
70
|
+
]),
|
|
71
|
+
chain(137, "polygon", "Polygon", "0x9295ee1d8c5b022be115a2ad3c30c72e34e7f096", "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270", false, [
|
|
72
|
+
USDC("0x3c499c542cef5e3811e1192ce70d8cc03d5c3359"),
|
|
73
|
+
USDT("0xc2132d05d31c914a87c6611c10748aeb04b58e8f"),
|
|
74
|
+
WBTC("0x1bfd67037b42cf73acf2047067bd4f2c47d9bfd6")
|
|
75
|
+
]),
|
|
76
|
+
chain(143, "monad", "Monad", "0xd2ecb3afe598b746f8123cae365a598da831a449", "0x3bd359c1119da7da1d913d1c4d2b7c461115433a", false, [
|
|
77
|
+
USDC("0x754704bc059f8c67012fed69bc8a327a5aafb603"),
|
|
78
|
+
USDT("0xe7cd86e13ac4309349f30b3435a9d337750fc82d", "USDT0")
|
|
79
|
+
]),
|
|
80
|
+
chain(324, "zksync", "zkSync Era", "0xe0b015e54d54fc84a6cb9b666099c46ade9335ff", "0x5aea5775959fbc2557cc8789bc1bf90a239d9a91", true, [
|
|
81
|
+
USDT("0x493257fd37edb34451f62edf8d2a0c418852ba4c"),
|
|
82
|
+
WETH("0x5aea5775959fbc2557cc8789bc1bf90a239d9a91"),
|
|
83
|
+
WBTC("0xbbeb516fb02a01611cbbe0453fe3c580d7281011")
|
|
84
|
+
]),
|
|
85
|
+
chain(480, "worldchain", "World Chain", "0x09aea4b2242abc8bb4bb78d537a67a245a7bec64", OP_WETH, true, [
|
|
86
|
+
USDC("0x79a02482a880bce3f13e09da970dc34db4cd24d1"),
|
|
87
|
+
WETH(OP_WETH),
|
|
88
|
+
WBTC("0x03c7054bcb39f7b2e5b2c7acb37583e32d70cfa3")
|
|
89
|
+
]),
|
|
90
|
+
chain(999, "hyperevm", "HyperEVM", "0x35e63ea3eb0fb7a3bc543c71fb66412e1f6b0e04", "0x5555555555555555555555555555555555555555", false, [
|
|
91
|
+
USDC("0xb88339cb7199b77e23db6e890353e22632ba630f"),
|
|
92
|
+
USDT("0xb8ce59fc3717ada4c02eadf9682a9e934f625ebb", "USDT0")
|
|
93
|
+
]),
|
|
94
|
+
chain(4326, "megaeth", "MegaETH", "0x3db06da8f0a24a525f314eec954fc5c6a973d40e", OP_WETH, true, [
|
|
95
|
+
USDT("0xb8ce59fc3717ada4c02eadf9682a9e934f625ebb", "USDT0"),
|
|
96
|
+
WETH(OP_WETH)
|
|
97
|
+
]),
|
|
98
|
+
chain(4663, "robinhood", "Robinhood Chain", "0xd29c85f15df544ba632c9e25829fd29d767d7978", "0x0bd7d308f8e1639fab988df18a8011f41eacad73", true, [
|
|
99
|
+
WETH("0x0bd7d308f8e1639fab988df18a8011f41eacad73")
|
|
100
|
+
]),
|
|
101
|
+
// Arc's gas coin is USDC; 0x3600… is its 6-decimal ERC-20 interface, which is what Across moves. The SpokePool
|
|
102
|
+
// reports no wrapped native token, so no deposit or fill on Arc involves the native coin.
|
|
103
|
+
chain(5042, "arc", "Arc", "0x9b4a302a548c7e313c2b74c461db7b84d3074a84", null, false, [
|
|
104
|
+
USDC("0x3600000000000000000000000000000000000000")
|
|
105
|
+
]),
|
|
106
|
+
chain(8453, "base", "Base", "0x09aea4b2242abc8bb4bb78d537a67a245a7bec64", OP_WETH, true, [
|
|
107
|
+
USDC("0x833589fcd6edb6e08f4c7c32d4f71b54bda02913"),
|
|
108
|
+
USDT("0xfde4c96c8593536e31f229ea8f37b2ada2699bb2"),
|
|
109
|
+
WETH(OP_WETH)
|
|
110
|
+
]),
|
|
111
|
+
chain(9745, "plasma", "Plasma", "0x50039faefebef707cfd94d6d462fe6d10b39207a", "0x6100e367285b01f48d07953803a2d8dca5d19873", false, [
|
|
112
|
+
USDT("0xb8ce59fc3717ada4c02eadf9682a9e934f625ebb", "USDT0")
|
|
113
|
+
]),
|
|
114
|
+
chain(42161, "arbitrum", "Arbitrum", "0xe35e9842fceaca96570b734083f4a58e8f7c5f2a", "0x82af49447d8a07e3bd95bd0d56f35241523fbab1", true, [
|
|
115
|
+
USDC("0xaf88d065e77c8cc2239327c5edb3a432268e5831"),
|
|
116
|
+
USDT("0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9", "USDT0"),
|
|
117
|
+
WETH("0x82af49447d8a07e3bd95bd0d56f35241523fbab1"),
|
|
118
|
+
WBTC("0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f")
|
|
119
|
+
]),
|
|
120
|
+
chain(43114, "avalanche", "Avalanche", "0xfe9d541c92e4e90437c7152a00244886de37a658", "0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7", false, [
|
|
121
|
+
USDC("0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e"),
|
|
122
|
+
USDT("0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7")
|
|
123
|
+
]),
|
|
124
|
+
chain(57073, "ink", "Ink", "0xef684c38f94f48775959ecf2012d7e864ffb9dd4", OP_WETH, true, [
|
|
125
|
+
USDC("0x2d270e6886d130d724215a266106e6832161eaed"),
|
|
126
|
+
USDT("0x0200c29006150606b650577bbe7b6248f58470c1", "USDT0"),
|
|
127
|
+
WETH(OP_WETH)
|
|
128
|
+
]),
|
|
129
|
+
chain(59144, "linea", "Linea", "0x7e63a5f1a8f0b4d0934b2f2327daed3f6bb2ee75", "0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f", true, [
|
|
130
|
+
USDC("0x176211869ca2b568f2a7d4ee941e073a821ee1ff"),
|
|
131
|
+
USDT("0xa219439258ca9da29e9cc4ce5596924745e12b93"),
|
|
132
|
+
WETH("0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f"),
|
|
133
|
+
WBTC("0x3aab2285ddcddad8edf438c1bab47e1a9d05a9b4")
|
|
134
|
+
])
|
|
135
|
+
].map((x) => [x.caip2, x]))));
|
|
136
|
+
function acrossChain(caip2) {
|
|
137
|
+
return typeof caip2 === "string" && Object.prototype.hasOwnProperty.call(ACROSS_CHAINS, caip2) ? ACROSS_CHAINS[caip2] : void 0;
|
|
138
|
+
}
|
|
139
|
+
function acrossToken(chain2, address) {
|
|
140
|
+
if (typeof address !== "string") return void 0;
|
|
141
|
+
const a = address.toLowerCase();
|
|
142
|
+
return chain2.tokens.find((t) => t.address === a);
|
|
143
|
+
}
|
|
144
|
+
var ACROSS_HUB_POOL = "0xc186fa914353c44b2e33ebe05f21846f1048beda";
|
|
145
|
+
var ACROSS_HUB_CROSS_CHAIN_CONTRACTS = "0x09474ae2";
|
|
146
|
+
var ACROSS_DEPOSIT = "0xad5425c6";
|
|
147
|
+
var ACROSS_DEPOSIT_V3 = "0x7b939232";
|
|
148
|
+
var ACROSS_REFUSED_SELECTORS = Object.freeze({
|
|
149
|
+
"0x8b15788e": "unsafeDeposit",
|
|
150
|
+
"0xea86bd46": "depositNow",
|
|
151
|
+
"0x7aef642c": "depositV3Now",
|
|
152
|
+
"0xbabb6aac": "speedUpDeposit",
|
|
153
|
+
"0x577f51f8": "speedUpV3Deposit",
|
|
154
|
+
"0xac9650d8": "multicall"
|
|
155
|
+
});
|
|
156
|
+
var ACROSS_SPEED_UP_TYPEHASH = "0x8d1994e2bbbd77564cdca06dd819e7ee2a5efa06c80dcb59a4a7b6e39edc538f";
|
|
157
|
+
var ACROSS_SPEED_UP_TYPE = "UpdateDepositDetails";
|
|
158
|
+
var ACROSS_SPEED_UP_DOMAIN = "ACROSS-V2";
|
|
159
|
+
var ACROSS_FUNDS_DEPOSITED = "0x32ed1a409ef04c7b0227189c3a103dc5ac10e775a15b785dcc510201f7c25ad3";
|
|
160
|
+
var ACROSS_FILL_STATUSES = "0xc35c83fc";
|
|
161
|
+
var ACROSS_V5_MESSAGE_PREFIX = "0x89ae4bc75915265a3f10e926c3894a29534f1d6362ee8959cb0e5be00f3527fd";
|
|
162
|
+
var ACROSS_DEPOSIT_QUOTE_TIME_BUFFER_S = 3600;
|
|
163
|
+
var ACROSS_FILL_DEADLINE_BUFFER_S = 21600;
|
|
164
|
+
var ACROSS_MAX_EXCLUSIVITY_PERIOD_S = 31536e3;
|
|
165
|
+
var ACROSS_NATIVE = "0x0000000000000000000000000000000000000000";
|
|
166
|
+
var ACROSS_API = "https://api.across.to";
|
|
167
|
+
var ZERO = /^0x0{40}$/;
|
|
168
|
+
var isNativeRef = (token) => ZERO.test(token);
|
|
169
|
+
function acrossRouteOf(sourceChain, sourceToken, destChain, destToken) {
|
|
170
|
+
const src = acrossChain(sourceChain);
|
|
171
|
+
const dst = acrossChain(destChain);
|
|
172
|
+
if (!src) return { code: "chain-unsupported", detail: `source chain ${String(sourceChain)} is not a pinned Across chain` };
|
|
173
|
+
if (!dst) return { code: "chain-unsupported", detail: `destination chain ${String(destChain)} is not a pinned Across chain` };
|
|
174
|
+
if (src === dst) return { code: "chain-unsupported", detail: "source and destination are the same chain" };
|
|
175
|
+
if (typeof sourceToken !== "string" || typeof destToken !== "string") return { code: "token-unsupported", detail: "the tokens are not addresses" };
|
|
176
|
+
let input;
|
|
177
|
+
let asset;
|
|
178
|
+
if (isNativeRef(sourceToken)) {
|
|
179
|
+
if (!src.nativeIsEth || !src.wrappedNative) return { code: "native-unsupported", detail: `${src.name}'s native coin is not bridged by Across` };
|
|
180
|
+
input = { chain: src, token: src.wrappedNative, native: true, decimals: 18 };
|
|
181
|
+
asset = "ETH";
|
|
182
|
+
} else {
|
|
183
|
+
const t = acrossToken(src, sourceToken);
|
|
184
|
+
if (!t) return { code: "token-unsupported", detail: `${sourceToken.toLowerCase()} is not a token pinned on ${src.name}` };
|
|
185
|
+
input = { chain: src, token: t.address, native: false, decimals: t.decimals };
|
|
186
|
+
asset = t.asset;
|
|
187
|
+
}
|
|
188
|
+
let output;
|
|
189
|
+
if (isNativeRef(destToken)) {
|
|
190
|
+
if (!dst.nativeIsEth || !dst.wrappedNative) return { code: "native-unsupported", detail: `${dst.name}'s native coin is not bridged by Across` };
|
|
191
|
+
if (asset !== "ETH") return { code: "pair-unsupported", detail: `${asset} on ${src.name} is not bridged to ${dst.name}'s native coin` };
|
|
192
|
+
output = { chain: dst, token: dst.wrappedNative, native: true, decimals: 18 };
|
|
193
|
+
} else {
|
|
194
|
+
const t = acrossToken(dst, destToken);
|
|
195
|
+
if (!t) return { code: "token-unsupported", detail: `${destToken.toLowerCase()} is not a token pinned on ${dst.name}` };
|
|
196
|
+
if (dst.wrappedNative !== null && t.address === dst.wrappedNative) {
|
|
197
|
+
return { code: "wrapped-native-destination", detail: `a fill of ${t.symbol} on ${dst.name} pays an EOA the native coin, not ${t.symbol} \u2014 ask for the native coin` };
|
|
198
|
+
}
|
|
199
|
+
if (t.asset !== asset) return { code: "pair-unsupported", detail: `${asset} is only bridged to ${asset}, not to ${t.symbol}` };
|
|
200
|
+
output = { chain: dst, token: t.address, native: false, decimals: t.decimals };
|
|
201
|
+
}
|
|
202
|
+
if (input.decimals !== output.decimals) return { code: "pair-unsupported", detail: "the two sides have different decimals" };
|
|
203
|
+
return { asset, input, output };
|
|
204
|
+
}
|
|
205
|
+
var across = {
|
|
206
|
+
supportsChain(chain2) {
|
|
207
|
+
return acrossChain(chain2) !== void 0;
|
|
208
|
+
},
|
|
209
|
+
/** Two different pinned EVM chains. */
|
|
210
|
+
supports(from, to) {
|
|
211
|
+
return from !== to && acrossChain(from) !== void 0 && acrossChain(to) !== void 0;
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
//# sourceMappingURL=config.cjs.map
|