@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
package/dist/build.cjs
ADDED
|
@@ -0,0 +1,776 @@
|
|
|
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/build.ts
|
|
21
|
+
var build_exports = {};
|
|
22
|
+
__export(build_exports, {
|
|
23
|
+
acrossQuoteOf: () => acrossQuoteOf,
|
|
24
|
+
buildAcrossDeposit: () => buildAcrossDeposit
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(build_exports);
|
|
27
|
+
|
|
28
|
+
// src/deposit.ts
|
|
29
|
+
var import_viem = require("viem");
|
|
30
|
+
|
|
31
|
+
// src/config.ts
|
|
32
|
+
var USDC = (address, symbol = "USDC") => Object.freeze({ asset: "USDC", address, symbol, decimals: 6 });
|
|
33
|
+
var USDT = (address, symbol = "USDT") => Object.freeze({ asset: "USDT", address, symbol, decimals: 6 });
|
|
34
|
+
var WETH = (address) => Object.freeze({ asset: "ETH", address, symbol: "WETH", decimals: 18 });
|
|
35
|
+
var WBTC = (address) => Object.freeze({ asset: "WBTC", address, symbol: "WBTC", decimals: 8 });
|
|
36
|
+
var OP_WETH = "0x4200000000000000000000000000000000000006";
|
|
37
|
+
function chain(chainId, key, name, spokePool, wrappedNative, nativeIsEth, tokens) {
|
|
38
|
+
return Object.freeze({ caip2: `eip155:${chainId}`, chainId, key, name, spokePool, wrappedNative, nativeIsEth, tokens: Object.freeze(tokens) });
|
|
39
|
+
}
|
|
40
|
+
var ACROSS_CHAINS = Object.freeze(Object.assign(/* @__PURE__ */ Object.create(null), Object.fromEntries([
|
|
41
|
+
chain(1, "ethereum", "Ethereum", "0x5c7bcd6e7de5423a257d81b442095a1a6ced35c5", "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", true, [
|
|
42
|
+
USDC("0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"),
|
|
43
|
+
USDT("0xdac17f958d2ee523a2206206994597c13d831ec7"),
|
|
44
|
+
WETH("0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"),
|
|
45
|
+
WBTC("0x2260fac5e5542a773aa44fbcfedf7c193bc2c599")
|
|
46
|
+
]),
|
|
47
|
+
chain(10, "optimism", "Optimism", "0x6f26bf09b1c792e3228e5467807a900a503c0281", OP_WETH, true, [
|
|
48
|
+
USDC("0x0b2c639c533813f4aa9d7837caf62653d097ff85"),
|
|
49
|
+
USDT("0x94b008aa00579c1307b0ef2c499ad98a8ce58e58"),
|
|
50
|
+
WETH(OP_WETH)
|
|
51
|
+
]),
|
|
52
|
+
chain(130, "unichain", "Unichain", "0x09aea4b2242abc8bb4bb78d537a67a245a7bec64", OP_WETH, true, [
|
|
53
|
+
USDC("0x078d782b760474a361dda0af3839290b0ef57ad6"),
|
|
54
|
+
USDT("0x9151434b16b9763660705744891fa906f660ecc5", "USDT0"),
|
|
55
|
+
WETH(OP_WETH)
|
|
56
|
+
]),
|
|
57
|
+
chain(137, "polygon", "Polygon", "0x9295ee1d8c5b022be115a2ad3c30c72e34e7f096", "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270", false, [
|
|
58
|
+
USDC("0x3c499c542cef5e3811e1192ce70d8cc03d5c3359"),
|
|
59
|
+
USDT("0xc2132d05d31c914a87c6611c10748aeb04b58e8f"),
|
|
60
|
+
WBTC("0x1bfd67037b42cf73acf2047067bd4f2c47d9bfd6")
|
|
61
|
+
]),
|
|
62
|
+
chain(143, "monad", "Monad", "0xd2ecb3afe598b746f8123cae365a598da831a449", "0x3bd359c1119da7da1d913d1c4d2b7c461115433a", false, [
|
|
63
|
+
USDC("0x754704bc059f8c67012fed69bc8a327a5aafb603"),
|
|
64
|
+
USDT("0xe7cd86e13ac4309349f30b3435a9d337750fc82d", "USDT0")
|
|
65
|
+
]),
|
|
66
|
+
chain(324, "zksync", "zkSync Era", "0xe0b015e54d54fc84a6cb9b666099c46ade9335ff", "0x5aea5775959fbc2557cc8789bc1bf90a239d9a91", true, [
|
|
67
|
+
USDT("0x493257fd37edb34451f62edf8d2a0c418852ba4c"),
|
|
68
|
+
WETH("0x5aea5775959fbc2557cc8789bc1bf90a239d9a91"),
|
|
69
|
+
WBTC("0xbbeb516fb02a01611cbbe0453fe3c580d7281011")
|
|
70
|
+
]),
|
|
71
|
+
chain(480, "worldchain", "World Chain", "0x09aea4b2242abc8bb4bb78d537a67a245a7bec64", OP_WETH, true, [
|
|
72
|
+
USDC("0x79a02482a880bce3f13e09da970dc34db4cd24d1"),
|
|
73
|
+
WETH(OP_WETH),
|
|
74
|
+
WBTC("0x03c7054bcb39f7b2e5b2c7acb37583e32d70cfa3")
|
|
75
|
+
]),
|
|
76
|
+
chain(999, "hyperevm", "HyperEVM", "0x35e63ea3eb0fb7a3bc543c71fb66412e1f6b0e04", "0x5555555555555555555555555555555555555555", false, [
|
|
77
|
+
USDC("0xb88339cb7199b77e23db6e890353e22632ba630f"),
|
|
78
|
+
USDT("0xb8ce59fc3717ada4c02eadf9682a9e934f625ebb", "USDT0")
|
|
79
|
+
]),
|
|
80
|
+
chain(4326, "megaeth", "MegaETH", "0x3db06da8f0a24a525f314eec954fc5c6a973d40e", OP_WETH, true, [
|
|
81
|
+
USDT("0xb8ce59fc3717ada4c02eadf9682a9e934f625ebb", "USDT0"),
|
|
82
|
+
WETH(OP_WETH)
|
|
83
|
+
]),
|
|
84
|
+
chain(4663, "robinhood", "Robinhood Chain", "0xd29c85f15df544ba632c9e25829fd29d767d7978", "0x0bd7d308f8e1639fab988df18a8011f41eacad73", true, [
|
|
85
|
+
WETH("0x0bd7d308f8e1639fab988df18a8011f41eacad73")
|
|
86
|
+
]),
|
|
87
|
+
// Arc's gas coin is USDC; 0x3600… is its 6-decimal ERC-20 interface, which is what Across moves. The SpokePool
|
|
88
|
+
// reports no wrapped native token, so no deposit or fill on Arc involves the native coin.
|
|
89
|
+
chain(5042, "arc", "Arc", "0x9b4a302a548c7e313c2b74c461db7b84d3074a84", null, false, [
|
|
90
|
+
USDC("0x3600000000000000000000000000000000000000")
|
|
91
|
+
]),
|
|
92
|
+
chain(8453, "base", "Base", "0x09aea4b2242abc8bb4bb78d537a67a245a7bec64", OP_WETH, true, [
|
|
93
|
+
USDC("0x833589fcd6edb6e08f4c7c32d4f71b54bda02913"),
|
|
94
|
+
USDT("0xfde4c96c8593536e31f229ea8f37b2ada2699bb2"),
|
|
95
|
+
WETH(OP_WETH)
|
|
96
|
+
]),
|
|
97
|
+
chain(9745, "plasma", "Plasma", "0x50039faefebef707cfd94d6d462fe6d10b39207a", "0x6100e367285b01f48d07953803a2d8dca5d19873", false, [
|
|
98
|
+
USDT("0xb8ce59fc3717ada4c02eadf9682a9e934f625ebb", "USDT0")
|
|
99
|
+
]),
|
|
100
|
+
chain(42161, "arbitrum", "Arbitrum", "0xe35e9842fceaca96570b734083f4a58e8f7c5f2a", "0x82af49447d8a07e3bd95bd0d56f35241523fbab1", true, [
|
|
101
|
+
USDC("0xaf88d065e77c8cc2239327c5edb3a432268e5831"),
|
|
102
|
+
USDT("0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9", "USDT0"),
|
|
103
|
+
WETH("0x82af49447d8a07e3bd95bd0d56f35241523fbab1"),
|
|
104
|
+
WBTC("0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f")
|
|
105
|
+
]),
|
|
106
|
+
chain(43114, "avalanche", "Avalanche", "0xfe9d541c92e4e90437c7152a00244886de37a658", "0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7", false, [
|
|
107
|
+
USDC("0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e"),
|
|
108
|
+
USDT("0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7")
|
|
109
|
+
]),
|
|
110
|
+
chain(57073, "ink", "Ink", "0xef684c38f94f48775959ecf2012d7e864ffb9dd4", OP_WETH, true, [
|
|
111
|
+
USDC("0x2d270e6886d130d724215a266106e6832161eaed"),
|
|
112
|
+
USDT("0x0200c29006150606b650577bbe7b6248f58470c1", "USDT0"),
|
|
113
|
+
WETH(OP_WETH)
|
|
114
|
+
]),
|
|
115
|
+
chain(59144, "linea", "Linea", "0x7e63a5f1a8f0b4d0934b2f2327daed3f6bb2ee75", "0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f", true, [
|
|
116
|
+
USDC("0x176211869ca2b568f2a7d4ee941e073a821ee1ff"),
|
|
117
|
+
USDT("0xa219439258ca9da29e9cc4ce5596924745e12b93"),
|
|
118
|
+
WETH("0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f"),
|
|
119
|
+
WBTC("0x3aab2285ddcddad8edf438c1bab47e1a9d05a9b4")
|
|
120
|
+
])
|
|
121
|
+
].map((x) => [x.caip2, x]))));
|
|
122
|
+
function acrossChain(caip2) {
|
|
123
|
+
return typeof caip2 === "string" && Object.prototype.hasOwnProperty.call(ACROSS_CHAINS, caip2) ? ACROSS_CHAINS[caip2] : void 0;
|
|
124
|
+
}
|
|
125
|
+
function acrossToken(chain2, address) {
|
|
126
|
+
if (typeof address !== "string") return void 0;
|
|
127
|
+
const a = address.toLowerCase();
|
|
128
|
+
return chain2.tokens.find((t) => t.address === a);
|
|
129
|
+
}
|
|
130
|
+
var ACROSS_DEPOSIT = "0xad5425c6";
|
|
131
|
+
var ACROSS_REFUSED_SELECTORS = Object.freeze({
|
|
132
|
+
"0x8b15788e": "unsafeDeposit",
|
|
133
|
+
"0xea86bd46": "depositNow",
|
|
134
|
+
"0x7aef642c": "depositV3Now",
|
|
135
|
+
"0xbabb6aac": "speedUpDeposit",
|
|
136
|
+
"0x577f51f8": "speedUpV3Deposit",
|
|
137
|
+
"0xac9650d8": "multicall"
|
|
138
|
+
});
|
|
139
|
+
var ACROSS_SPEED_UP_TYPE = "UpdateDepositDetails";
|
|
140
|
+
var ACROSS_SPEED_UP_DOMAIN = "ACROSS-V2";
|
|
141
|
+
var ACROSS_V5_MESSAGE_PREFIX = "0x89ae4bc75915265a3f10e926c3894a29534f1d6362ee8959cb0e5be00f3527fd";
|
|
142
|
+
var ACROSS_DEPOSIT_QUOTE_TIME_BUFFER_S = 3600;
|
|
143
|
+
var ACROSS_FILL_DEADLINE_BUFFER_S = 21600;
|
|
144
|
+
var ACROSS_NATIVE = "0x0000000000000000000000000000000000000000";
|
|
145
|
+
var ZERO = /^0x0{40}$/;
|
|
146
|
+
var isNativeRef = (token) => ZERO.test(token);
|
|
147
|
+
function acrossRouteOf(sourceChain, sourceToken, destChain, destToken) {
|
|
148
|
+
const src = acrossChain(sourceChain);
|
|
149
|
+
const dst = acrossChain(destChain);
|
|
150
|
+
if (!src) return { code: "chain-unsupported", detail: `source chain ${String(sourceChain)} is not a pinned Across chain` };
|
|
151
|
+
if (!dst) return { code: "chain-unsupported", detail: `destination chain ${String(destChain)} is not a pinned Across chain` };
|
|
152
|
+
if (src === dst) return { code: "chain-unsupported", detail: "source and destination are the same chain" };
|
|
153
|
+
if (typeof sourceToken !== "string" || typeof destToken !== "string") return { code: "token-unsupported", detail: "the tokens are not addresses" };
|
|
154
|
+
let input;
|
|
155
|
+
let asset;
|
|
156
|
+
if (isNativeRef(sourceToken)) {
|
|
157
|
+
if (!src.nativeIsEth || !src.wrappedNative) return { code: "native-unsupported", detail: `${src.name}'s native coin is not bridged by Across` };
|
|
158
|
+
input = { chain: src, token: src.wrappedNative, native: true, decimals: 18 };
|
|
159
|
+
asset = "ETH";
|
|
160
|
+
} else {
|
|
161
|
+
const t = acrossToken(src, sourceToken);
|
|
162
|
+
if (!t) return { code: "token-unsupported", detail: `${sourceToken.toLowerCase()} is not a token pinned on ${src.name}` };
|
|
163
|
+
input = { chain: src, token: t.address, native: false, decimals: t.decimals };
|
|
164
|
+
asset = t.asset;
|
|
165
|
+
}
|
|
166
|
+
let output;
|
|
167
|
+
if (isNativeRef(destToken)) {
|
|
168
|
+
if (!dst.nativeIsEth || !dst.wrappedNative) return { code: "native-unsupported", detail: `${dst.name}'s native coin is not bridged by Across` };
|
|
169
|
+
if (asset !== "ETH") return { code: "pair-unsupported", detail: `${asset} on ${src.name} is not bridged to ${dst.name}'s native coin` };
|
|
170
|
+
output = { chain: dst, token: dst.wrappedNative, native: true, decimals: 18 };
|
|
171
|
+
} else {
|
|
172
|
+
const t = acrossToken(dst, destToken);
|
|
173
|
+
if (!t) return { code: "token-unsupported", detail: `${destToken.toLowerCase()} is not a token pinned on ${dst.name}` };
|
|
174
|
+
if (dst.wrappedNative !== null && t.address === dst.wrappedNative) {
|
|
175
|
+
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` };
|
|
176
|
+
}
|
|
177
|
+
if (t.asset !== asset) return { code: "pair-unsupported", detail: `${asset} is only bridged to ${asset}, not to ${t.symbol}` };
|
|
178
|
+
output = { chain: dst, token: t.address, native: false, decimals: t.decimals };
|
|
179
|
+
}
|
|
180
|
+
if (input.decimals !== output.decimals) return { code: "pair-unsupported", detail: "the two sides have different decimals" };
|
|
181
|
+
return { asset, input, output };
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// src/refusal.ts
|
|
185
|
+
var import_errors = require("@anywalletkit/protocol-swap2-core/errors");
|
|
186
|
+
var AcrossRefusal = class extends Error {
|
|
187
|
+
code;
|
|
188
|
+
constructor(code, detail, reason) {
|
|
189
|
+
super(`across: ${detail} [${code}]`);
|
|
190
|
+
this.name = "AcrossRefusal";
|
|
191
|
+
this.code = code;
|
|
192
|
+
if (reason !== void 0) (0, import_errors.withReason)(this, reason);
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
// src/deposit.ts
|
|
197
|
+
var SPOKE_POOL_ABI = (0, import_viem.parseAbi)([
|
|
198
|
+
"function deposit(bytes32 depositor, bytes32 recipient, bytes32 inputToken, bytes32 outputToken, uint256 inputAmount, uint256 outputAmount, uint256 destinationChainId, bytes32 exclusiveRelayer, uint32 quoteTimestamp, uint32 fillDeadline, uint32 exclusivityParameter, bytes message) payable"
|
|
199
|
+
]);
|
|
200
|
+
var ADDRESS = /^0x[0-9a-fA-F]{40}$/;
|
|
201
|
+
var HEX = /^0x(?:[0-9a-fA-F]{2})*$/;
|
|
202
|
+
var U256_MAX = (1n << 256n) - 1n;
|
|
203
|
+
var U32_MAX = 4294967295;
|
|
204
|
+
var HEAD_WORDS = 12;
|
|
205
|
+
var MESSAGE_OFFSET = HEAD_WORDS * 32;
|
|
206
|
+
var ACROSS_MAX_MESSAGE_BYTES = 65536;
|
|
207
|
+
function acrossBytes32(address) {
|
|
208
|
+
if (typeof address !== "string" || !ADDRESS.test(address)) throw new AcrossRefusal("request-invalid", `${String(address)} is not an EVM address`);
|
|
209
|
+
return `0x${"0".repeat(24)}${address.slice(2).toLowerCase()}`;
|
|
210
|
+
}
|
|
211
|
+
function acrossAddressOf(word) {
|
|
212
|
+
const w = word.startsWith("0x") ? word.slice(2) : word;
|
|
213
|
+
if (!/^[0-9a-fA-F]{64}$/.test(w) || !/^0{24}/.test(w)) return null;
|
|
214
|
+
return `0x${w.slice(24).toLowerCase()}`;
|
|
215
|
+
}
|
|
216
|
+
function checkArgs(a) {
|
|
217
|
+
const bad = (what) => {
|
|
218
|
+
throw new AcrossRefusal("request-invalid", `the deposit's ${what}`);
|
|
219
|
+
};
|
|
220
|
+
if (a === null || typeof a !== "object") bad("arguments are missing");
|
|
221
|
+
for (const [k, v] of [["depositor", a.depositor], ["recipient", a.recipient], ["inputToken", a.inputToken], ["outputToken", a.outputToken], ["exclusiveRelayer", a.exclusiveRelayer]]) {
|
|
222
|
+
if (typeof v !== "string" || !ADDRESS.test(v)) bad(`${k} is not an EVM address`);
|
|
223
|
+
}
|
|
224
|
+
for (const [k, v] of [["inputAmount", a.inputAmount], ["outputAmount", a.outputAmount], ["destinationChainId", a.destinationChainId]]) {
|
|
225
|
+
if (typeof v !== "bigint" || v < 0n || v > U256_MAX) bad(`${k} is not a uint256`);
|
|
226
|
+
}
|
|
227
|
+
for (const [k, v] of [["quoteTimestamp", a.quoteTimestamp], ["fillDeadline", a.fillDeadline], ["exclusivityParameter", a.exclusivityParameter]]) {
|
|
228
|
+
if (!Number.isInteger(v) || v < 0 || v > U32_MAX) bad(`${k} is not a uint32`);
|
|
229
|
+
}
|
|
230
|
+
if (typeof a.message !== "string" || !HEX.test(a.message) || (a.message.length - 2) / 2 > ACROSS_MAX_MESSAGE_BYTES) bad("message is not bytes");
|
|
231
|
+
}
|
|
232
|
+
function encodeAcrossDeposit(a) {
|
|
233
|
+
checkArgs(a);
|
|
234
|
+
return (0, import_viem.encodeFunctionData)({
|
|
235
|
+
abi: SPOKE_POOL_ABI,
|
|
236
|
+
functionName: "deposit",
|
|
237
|
+
args: [
|
|
238
|
+
acrossBytes32(a.depositor),
|
|
239
|
+
acrossBytes32(a.recipient),
|
|
240
|
+
acrossBytes32(a.inputToken),
|
|
241
|
+
acrossBytes32(a.outputToken),
|
|
242
|
+
a.inputAmount,
|
|
243
|
+
a.outputAmount,
|
|
244
|
+
a.destinationChainId,
|
|
245
|
+
acrossBytes32(a.exclusiveRelayer),
|
|
246
|
+
a.quoteTimestamp,
|
|
247
|
+
a.fillDeadline,
|
|
248
|
+
a.exclusivityParameter,
|
|
249
|
+
a.message.toLowerCase()
|
|
250
|
+
]
|
|
251
|
+
}).toLowerCase();
|
|
252
|
+
}
|
|
253
|
+
function word32(word) {
|
|
254
|
+
return /^0{56}[0-9a-f]{8}$/.test(word) ? parseInt(word.slice(56), 16) : null;
|
|
255
|
+
}
|
|
256
|
+
function decodeAcrossDeposit(data) {
|
|
257
|
+
const malformed = (what) => {
|
|
258
|
+
throw new AcrossRefusal("tx-calldata", `the deposit calldata ${what}`, "policy_refused");
|
|
259
|
+
};
|
|
260
|
+
if (typeof data !== "string" || !HEX.test(data) || data.length < 10) malformed("is not hex calldata");
|
|
261
|
+
const hex = data.toLowerCase();
|
|
262
|
+
const selector = hex.slice(0, 10);
|
|
263
|
+
if (selector !== ACROSS_DEPOSIT) {
|
|
264
|
+
const name = Object.prototype.hasOwnProperty.call(ACROSS_REFUSED_SELECTORS, selector) ? ACROSS_REFUSED_SELECTORS[selector] : void 0;
|
|
265
|
+
throw new AcrossRefusal("tx-selector", name ? `the call is ${name} (${selector}), which this module never signs` : `the call is ${selector}, not deposit (${ACROSS_DEPOSIT})`, "policy_refused");
|
|
266
|
+
}
|
|
267
|
+
const body = hex.slice(10);
|
|
268
|
+
if (body.length < (HEAD_WORDS + 1) * 64) malformed(`is ${(hex.length - 2) / 2} bytes, shorter than a deposit`);
|
|
269
|
+
const word = (i) => body.slice(64 * i, 64 * i + 64);
|
|
270
|
+
const addr = (i, what) => acrossAddressOf(word(i)) ?? malformed(`carries a ${what} that is not an EVM address`);
|
|
271
|
+
const u32 = (i, what) => word32(word(i)) ?? malformed(`carries a ${what} wider than 32 bits`);
|
|
272
|
+
const offset = BigInt(`0x${word(11)}`);
|
|
273
|
+
if (offset !== BigInt(MESSAGE_OFFSET)) malformed(`puts the message at offset ${offset}, not ${MESSAGE_OFFSET}`);
|
|
274
|
+
const lengthWord = word(HEAD_WORDS);
|
|
275
|
+
if (!/^0{56}/.test(lengthWord)) malformed("states an impossible message length");
|
|
276
|
+
const length = parseInt(lengthWord.slice(56), 16);
|
|
277
|
+
if (length > ACROSS_MAX_MESSAGE_BYTES) malformed(`carries a ${length}-byte message, over ${ACROSS_MAX_MESSAGE_BYTES}`);
|
|
278
|
+
const padded = Math.ceil(length / 32) * 64;
|
|
279
|
+
const expected = (HEAD_WORDS + 1) * 64 + padded;
|
|
280
|
+
if (body.length !== expected) {
|
|
281
|
+
malformed(body.length > expected ? `has ${(body.length - expected) / 2} bytes after the encoded call` : `is ${(hex.length - 2) / 2} bytes, the encoding needs ${4 + expected / 2}`);
|
|
282
|
+
}
|
|
283
|
+
const tail = body.slice((HEAD_WORDS + 1) * 64);
|
|
284
|
+
if (!/^0*$/.test(tail.slice(length * 2))) malformed("pads the message with non-zero bytes");
|
|
285
|
+
const args = {
|
|
286
|
+
depositor: addr(0, "depositor"),
|
|
287
|
+
recipient: addr(1, "recipient"),
|
|
288
|
+
inputToken: addr(2, "input token"),
|
|
289
|
+
outputToken: addr(3, "output token"),
|
|
290
|
+
inputAmount: BigInt(`0x${word(4)}`),
|
|
291
|
+
outputAmount: BigInt(`0x${word(5)}`),
|
|
292
|
+
destinationChainId: BigInt(`0x${word(6)}`),
|
|
293
|
+
exclusiveRelayer: addr(7, "exclusive relayer"),
|
|
294
|
+
quoteTimestamp: u32(8, "quote timestamp"),
|
|
295
|
+
fillDeadline: u32(9, "fill deadline"),
|
|
296
|
+
exclusivityParameter: u32(10, "exclusivity parameter"),
|
|
297
|
+
message: `0x${tail.slice(0, length * 2)}`
|
|
298
|
+
};
|
|
299
|
+
if (encodeAcrossDeposit(args) !== hex) malformed("is not the canonical encoding of its arguments");
|
|
300
|
+
return args;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// src/verify.ts
|
|
304
|
+
var import_viem2 = require("viem");
|
|
305
|
+
var import_core = require("@anywalletkit/core");
|
|
306
|
+
var import_errors2 = require("@anywalletkit/protocol-swap2-core/errors");
|
|
307
|
+
var import_util = require("@anywalletkit/protocol-swap2-core/util");
|
|
308
|
+
|
|
309
|
+
// src/pricing.ts
|
|
310
|
+
var ACROSS_FLOOR_CBPS = Object.freeze({ stable: 100, wbtc: 310, ethFromEthereum: 100 });
|
|
311
|
+
var ACROSS_ETH_L2_CURVE = Object.freeze([
|
|
312
|
+
[0, 477],
|
|
313
|
+
[1e3, 515],
|
|
314
|
+
[2e3, 540],
|
|
315
|
+
[4e3, 605],
|
|
316
|
+
[8e3, 715],
|
|
317
|
+
[16e3, 850],
|
|
318
|
+
[36e3, 920]
|
|
319
|
+
].map((p) => Object.freeze(p)));
|
|
320
|
+
var ACROSS_FLOOR_ORIGINS = Object.freeze([1, 10, 8453, 42161]);
|
|
321
|
+
var ACROSS_FLOOR_DESTINATIONS = Object.freeze([10, 8453, 42161]);
|
|
322
|
+
function acrossRouteUnpriced(route) {
|
|
323
|
+
if (route.output.chain.chainId === 1) return "plain deposits to Ethereum are not priced yet \u2014 small ones went unfilled in the 2026-11-14 study for reasons the data does not show";
|
|
324
|
+
return null;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// src/verify.ts
|
|
328
|
+
var ACROSS_DEFAULT_MAX_FEE_BPS = 1e3;
|
|
329
|
+
var ACROSS_MAX_FEE_BPS_LIMIT = 5e3;
|
|
330
|
+
var ACROSS_CLOCK_SKEW_S = 120;
|
|
331
|
+
var ACROSS_QUOTE_TIME_AHEAD_S = 15;
|
|
332
|
+
var ACROSS_LANDING_WINDOW_S = 300;
|
|
333
|
+
var ACROSS_MIN_FILL_WINDOW_S = 1800;
|
|
334
|
+
var ACROSS_MAX_FILL_WINDOW_S = 7800;
|
|
335
|
+
var ACROSS_MIN_FEE_PPM = Object.freeze({ stable: 100, ethFromEthereum: 70, ethFromL2: 450, ethFromOtherL2: 70, wbtc: 250 });
|
|
336
|
+
function acrossMinFeePpm(route) {
|
|
337
|
+
if (route.asset === "ETH") {
|
|
338
|
+
const src = route.input.chain.chainId;
|
|
339
|
+
if (src === 1) return ACROSS_MIN_FEE_PPM.ethFromEthereum;
|
|
340
|
+
return ACROSS_FLOOR_ORIGINS.includes(src) ? ACROSS_MIN_FEE_PPM.ethFromL2 : ACROSS_MIN_FEE_PPM.ethFromOtherL2;
|
|
341
|
+
}
|
|
342
|
+
if (route.asset === "WBTC") return ACROSS_MIN_FEE_PPM.wbtc;
|
|
343
|
+
return ACROSS_MIN_FEE_PPM.stable;
|
|
344
|
+
}
|
|
345
|
+
var ACROSS_GAS_FLOOR = 90000n;
|
|
346
|
+
var ACROSS_GAS_CAP = 60000000n;
|
|
347
|
+
var ACROSS_MAX_QUOTE_LIFE_MS = 3e5 + ACROSS_CLOCK_SKEW_S * 1e3;
|
|
348
|
+
var acrossQuoteTimeLimitMs = (quoteTimestamp) => (quoteTimestamp + ACROSS_DEPOSIT_QUOTE_TIME_BUFFER_S - ACROSS_LANDING_WINDOW_S) * 1e3;
|
|
349
|
+
var ACROSS_PLACEHOLDER = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045";
|
|
350
|
+
var ADDRESS2 = /^0x[0-9a-fA-F]{40}$/;
|
|
351
|
+
var ZERO2 = /^0x0{40}$/;
|
|
352
|
+
var U256_MAX2 = (1n << 256n) - 1n;
|
|
353
|
+
var UINT = /^(?:0|[1-9]\d{0,77})$/;
|
|
354
|
+
var lower = (s) => s.toLowerCase();
|
|
355
|
+
function checkAcrossRequest(r) {
|
|
356
|
+
const invalid = (what, reason) => {
|
|
357
|
+
throw new AcrossRefusal("request-invalid", what, reason);
|
|
358
|
+
};
|
|
359
|
+
if (r === null || typeof r !== "object") invalid("no request to check the deposit against");
|
|
360
|
+
for (const [what, v] of [["input token", r.sourceToken], ["output token", r.destToken], ["depositor", r.depositor], ["recipient", r.recipient]]) {
|
|
361
|
+
if (typeof v !== "string" || !ADDRESS2.test(v)) invalid(`the ${what} is not an address`);
|
|
362
|
+
}
|
|
363
|
+
const route = acrossRouteOf(r.sourceChain, r.sourceToken, r.destChain, r.destToken);
|
|
364
|
+
if ("code" in route) throw new AcrossRefusal(route.code, route.detail, "unsupported_pair");
|
|
365
|
+
if (ZERO2.test(r.depositor)) invalid("the depositor is the zero address", "recipient_mismatch");
|
|
366
|
+
if (ZERO2.test(r.recipient)) invalid("the recipient is the zero address", "recipient_mismatch");
|
|
367
|
+
if (typeof r.amount !== "bigint" || r.amount <= 0n || r.amount > U256_MAX2) invalid("the amount is not a positive integer");
|
|
368
|
+
if (r.minAmountOut !== void 0 && (typeof r.minAmountOut !== "bigint" || r.minAmountOut < 0n || r.minAmountOut > U256_MAX2)) invalid("the output floor is not an unsigned integer");
|
|
369
|
+
const maxFeeBps = r.maxFeeBps ?? ACROSS_DEFAULT_MAX_FEE_BPS;
|
|
370
|
+
if (!Number.isInteger(maxFeeBps) || maxFeeBps < 0 || maxFeeBps > ACROSS_MAX_FEE_BPS_LIMIT) {
|
|
371
|
+
invalid(`the fee cap must be a whole number of basis points up to ${ACROSS_MAX_FEE_BPS_LIMIT}`, "policy_refused");
|
|
372
|
+
}
|
|
373
|
+
const nowMs = r.nowMs ?? Date.now();
|
|
374
|
+
if (!Number.isFinite(nowMs) || nowMs <= 0) invalid("the clock is not a time");
|
|
375
|
+
return { route, nowS: Math.floor(nowMs / 1e3), maxFeeBps };
|
|
376
|
+
}
|
|
377
|
+
function checkTarget(tx, route) {
|
|
378
|
+
if (tx === null || typeof tx !== "object") throw new AcrossRefusal("tx-shape", "there is no deposit transaction", "policy_refused");
|
|
379
|
+
const src = route.input.chain;
|
|
380
|
+
if (tx.chainId !== src.chainId) throw new AcrossRefusal("tx-chain", `the deposit is for chain ${String(tx.chainId)}, not ${src.name} (${src.chainId})`, "vault_mismatch");
|
|
381
|
+
if (typeof tx.to !== "string" || !ADDRESS2.test(tx.to) || lower(tx.to) !== src.spokePool) {
|
|
382
|
+
throw new AcrossRefusal("tx-target", `the deposit calls ${String(tx.to)}, not the ${src.name} SpokePool ${src.spokePool} \u2014 periphery, swap and CCTP / OFT routes are not signed by this module`, "vault_mismatch");
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
function checkExclusivity(a) {
|
|
386
|
+
if (!ZERO2.test(a.exclusiveRelayer) || a.exclusivityParameter !== 0) {
|
|
387
|
+
throw new AcrossRefusal("tx-exclusivity", `the deposit names an exclusive relayer or window (${a.exclusiveRelayer}, ${a.exclusivityParameter}) \u2014 this module signs plain deposits any relayer may fill`, "policy_refused");
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
function checkDeadlines(a, nowS) {
|
|
391
|
+
const age = nowS - a.quoteTimestamp;
|
|
392
|
+
if (age < -ACROSS_QUOTE_TIME_AHEAD_S) throw new AcrossRefusal("tx-quote-time", `the quote time is ${-age} s in the future (the deposit reverts)`, "policy_refused");
|
|
393
|
+
if (age > ACROSS_DEPOSIT_QUOTE_TIME_BUFFER_S - ACROSS_LANDING_WINDOW_S) {
|
|
394
|
+
throw new AcrossRefusal("tx-quote-time", `the quote time is ${age} s old: the SpokePool takes at most ${ACROSS_DEPOSIT_QUOTE_TIME_BUFFER_S} s, with ${ACROSS_LANDING_WINDOW_S} s kept to land`, "quote_expired");
|
|
395
|
+
}
|
|
396
|
+
const left = a.fillDeadline - nowS;
|
|
397
|
+
if (left > ACROSS_FILL_DEADLINE_BUFFER_S - ACROSS_CLOCK_SKEW_S) {
|
|
398
|
+
throw new AcrossRefusal("tx-fill-deadline", `the fill deadline is ${left} s away, past the ${ACROSS_FILL_DEADLINE_BUFFER_S} s the SpokePool allows`, "policy_refused");
|
|
399
|
+
}
|
|
400
|
+
const window = a.fillDeadline - a.quoteTimestamp;
|
|
401
|
+
if (window > ACROSS_MAX_FILL_WINDOW_S) {
|
|
402
|
+
throw new AcrossRefusal("tx-fill-deadline", `the fill deadline is ${window} s after the quote time, more than the ${ACROSS_MAX_FILL_WINDOW_S} s an Across quote gives \u2014 unfilled, the deposit would hold the funds that long before its refund`, "policy_refused");
|
|
403
|
+
}
|
|
404
|
+
if (left < ACROSS_MIN_FILL_WINDOW_S) {
|
|
405
|
+
throw new AcrossRefusal("tx-fill-deadline", `the fill deadline is ${left} s away, under the ${ACROSS_MIN_FILL_WINDOW_S} s a relayer is given \u2014 the deposit would expire into a refund`, "quote_expired");
|
|
406
|
+
}
|
|
407
|
+
if (window < ACROSS_DEPOSIT_QUOTE_TIME_BUFFER_S + ACROSS_MIN_FILL_WINDOW_S) {
|
|
408
|
+
throw new AcrossRefusal("tx-fill-deadline", `the fill deadline is ${window} s after the quote time: a deposit landing as late as the SpokePool takes it (${ACROSS_DEPOSIT_QUOTE_TIME_BUFFER_S} s) would leave a relayer under ${ACROSS_MIN_FILL_WINDOW_S} s`, "policy_refused");
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
function verifyAcrossDeposit(request, tx) {
|
|
412
|
+
const { route, nowS, maxFeeBps } = checkAcrossRequest(request);
|
|
413
|
+
checkTarget(tx, route);
|
|
414
|
+
const a = decodeAcrossDeposit(tx.data);
|
|
415
|
+
const src = route.input.chain;
|
|
416
|
+
const dst = route.output.chain;
|
|
417
|
+
if (a.depositor !== lower(request.depositor)) {
|
|
418
|
+
throw new AcrossRefusal("tx-depositor", `the deposit is credited to ${a.depositor}, not to the signing account ${lower(request.depositor)} \u2014 the depositor is refunded and can redirect the output`, "recipient_mismatch");
|
|
419
|
+
}
|
|
420
|
+
if (a.recipient !== lower(request.recipient)) throw new AcrossRefusal("tx-recipient", `the deposit pays ${a.recipient}, not the recipient ${lower(request.recipient)}`, "recipient_mismatch");
|
|
421
|
+
if (a.destinationChainId !== BigInt(dst.chainId)) {
|
|
422
|
+
throw new AcrossRefusal("tx-destination", `the deposit is for chain ${a.destinationChainId}, not ${dst.name} (${dst.chainId})`, "recipient_mismatch");
|
|
423
|
+
}
|
|
424
|
+
if (a.inputToken !== route.input.token) throw new AcrossRefusal("tx-input-token", `the deposit takes ${a.inputToken}, the request sends ${route.input.token}${route.input.native ? " (the wrapped native token, for the native coin)" : ""}`, "policy_refused");
|
|
425
|
+
if (a.inputAmount !== request.amount) throw new AcrossRefusal("tx-input-amount", `the deposit takes ${a.inputAmount}, the request sends ${request.amount}`, "policy_refused");
|
|
426
|
+
if (a.outputToken !== route.output.token) throw new AcrossRefusal("tx-output-token", `the deposit pays ${a.outputToken} on ${dst.name}, the request is for ${route.output.token}${route.output.native ? " (the wrapped native token, paid out as the native coin)" : ""}`, "price_check_failed");
|
|
427
|
+
if (a.outputAmount <= 0n) throw new AcrossRefusal("tx-output-amount", "the deposit's output is zero", "price_check_failed");
|
|
428
|
+
if (request.minAmountOut !== void 0 && a.outputAmount < request.minAmountOut) {
|
|
429
|
+
throw new AcrossRefusal("tx-output-amount", `the deposit pays ${a.outputAmount}, under the caller's floor ${request.minAmountOut}`, "price_check_failed");
|
|
430
|
+
}
|
|
431
|
+
if (a.outputAmount > a.inputAmount) {
|
|
432
|
+
throw new AcrossRefusal("tx-output-amount", `the deposit asks relayers for ${a.outputAmount}, more than its ${a.inputAmount} input \u2014 nobody fills it, and the funds wait for a refund`, "price_check_failed");
|
|
433
|
+
}
|
|
434
|
+
const fee = a.inputAmount - a.outputAmount;
|
|
435
|
+
if (fee === 0n) {
|
|
436
|
+
throw new AcrossRefusal("tx-fee", "the deposit leaves relayers no fee \u2014 nobody fills it, and the funds wait for a refund", "price_check_failed");
|
|
437
|
+
}
|
|
438
|
+
const minPpm = acrossMinFeePpm(route);
|
|
439
|
+
if (fee * 1000000n < a.inputAmount * BigInt(minPpm)) {
|
|
440
|
+
throw new AcrossRefusal("tx-fee", `the deposit leaves relayers ${fee} of ${a.inputAmount}, under the ${minPpm}-per-million floor for ${route.asset} from ${src.name} \u2014 relayers do not fill it, and the funds wait for a refund`, "price_check_failed");
|
|
441
|
+
}
|
|
442
|
+
if (fee * 10000n > a.inputAmount * BigInt(maxFeeBps)) {
|
|
443
|
+
throw new AcrossRefusal("tx-fee", `the deposit leaves ${fee} of ${a.inputAmount} as fees, over the ${maxFeeBps} bps cap`, "price_check_failed");
|
|
444
|
+
}
|
|
445
|
+
if (a.message !== "0x") {
|
|
446
|
+
if (a.message.length >= 66 && a.message.slice(0, 66) === ACROSS_V5_MESSAGE_PREFIX) {
|
|
447
|
+
throw new AcrossRefusal("tx-message-v5", "the deposit carries an Across V5 witness message, consumable only through the V5 Gateway", "policy_refused");
|
|
448
|
+
}
|
|
449
|
+
throw new AcrossRefusal("tx-message", `the deposit carries a ${(a.message.length - 2) / 2}-byte message for the destination \u2014 only plain transfers are signed`, "policy_refused");
|
|
450
|
+
}
|
|
451
|
+
checkExclusivity(a);
|
|
452
|
+
checkDeadlines(a, nowS);
|
|
453
|
+
const value = typeof tx.value === "string" && UINT.test(tx.value) ? BigInt(tx.value) : null;
|
|
454
|
+
const wantValue = route.input.native ? a.inputAmount : 0n;
|
|
455
|
+
if (value === null || value !== wantValue) throw new AcrossRefusal("tx-value", `the deposit sends ${String(tx.value)} wei, it must send ${wantValue}`, "policy_refused");
|
|
456
|
+
const approval = tx.approvalAddress;
|
|
457
|
+
if (route.input.native) {
|
|
458
|
+
if (approval !== void 0 && approval !== "") throw new AcrossRefusal("tx-approval", `a native deposit approves nothing, the transaction approves ${String(approval)}`, "vault_mismatch");
|
|
459
|
+
} else if (typeof approval !== "string" || lower(approval) !== src.spokePool) {
|
|
460
|
+
throw new AcrossRefusal("tx-approval", `the deposit approves ${String(approval)}, it must approve the ${src.name} SpokePool ${src.spokePool}`, "vault_mismatch");
|
|
461
|
+
}
|
|
462
|
+
return {
|
|
463
|
+
route,
|
|
464
|
+
args: a,
|
|
465
|
+
deposit: {
|
|
466
|
+
to: src.spokePool,
|
|
467
|
+
data: lower(tx.data),
|
|
468
|
+
value: wantValue.toString(10),
|
|
469
|
+
chainId: src.chainId,
|
|
470
|
+
...route.input.native ? {} : { approvalAddress: src.spokePool }
|
|
471
|
+
},
|
|
472
|
+
fee
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
function acrossIntentId(sourceChainId, destChainId, data) {
|
|
476
|
+
return `across:${sourceChainId}:${destChainId}:${(0, import_viem2.keccak256)(lower(data)).slice(2, 34)}`;
|
|
477
|
+
}
|
|
478
|
+
function parseAcrossIntentId(intentId) {
|
|
479
|
+
if (typeof intentId !== "string") return null;
|
|
480
|
+
const m = /^across:([1-9]\d{0,15}):([1-9]\d{0,15}):([0-9a-f]{32})(?:~[0-9a-f]{32})?$/.exec(intentId);
|
|
481
|
+
if (!m) return null;
|
|
482
|
+
return { sourceChainId: Number(m[1]), destChainId: Number(m[2]), digest: m[3] };
|
|
483
|
+
}
|
|
484
|
+
function isAcrossSpeedUpTypedData(typedData) {
|
|
485
|
+
let v = typedData;
|
|
486
|
+
if (typeof v === "string") {
|
|
487
|
+
try {
|
|
488
|
+
v = JSON.parse(v);
|
|
489
|
+
} catch {
|
|
490
|
+
return /UpdateDepositDetails|ACROSS-V2/.test(v);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
if (v === null || typeof v !== "object") return false;
|
|
494
|
+
const t = v;
|
|
495
|
+
if (t.primaryType === ACROSS_SPEED_UP_TYPE) return true;
|
|
496
|
+
if (t.types !== null && typeof t.types === "object" && Object.prototype.hasOwnProperty.call(t.types, ACROSS_SPEED_UP_TYPE)) return true;
|
|
497
|
+
return t.domain !== null && typeof t.domain === "object" && t.domain.name === ACROSS_SPEED_UP_DOMAIN;
|
|
498
|
+
}
|
|
499
|
+
function checkAcrossTxShape(tx) {
|
|
500
|
+
if (tx.typedData !== void 0) {
|
|
501
|
+
if (isAcrossSpeedUpTypedData(tx.typedData)) throw new AcrossRefusal("speed-up", "the request is an Across speed-up signature, which can redirect a deposit's output \u2014 never signed", "policy_refused");
|
|
502
|
+
throw new AcrossRefusal("tx-shape", "an Across deposit is one EVM call, not typed data", "policy_refused");
|
|
503
|
+
}
|
|
504
|
+
if (tx.serializedTx !== void 0 || tx.memo !== void 0 || tx.bodyBoc !== void 0 || tx.stateInitBoc !== void 0 || tx.orderExtension !== void 0) {
|
|
505
|
+
throw new AcrossRefusal("tx-shape", "an Across deposit is one EVM call", "policy_refused");
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
function acrossRefusalReason(err) {
|
|
509
|
+
if (err instanceof AcrossRefusal) return err.message;
|
|
510
|
+
throw err;
|
|
511
|
+
}
|
|
512
|
+
function acrossRequestOf(params, opts = {}) {
|
|
513
|
+
const invalid = (what, reason) => {
|
|
514
|
+
throw new AcrossRefusal("request-invalid", what, reason);
|
|
515
|
+
};
|
|
516
|
+
if (params === null || typeof params !== "object") invalid("no request");
|
|
517
|
+
if (params.flex) invalid("the amount is part of the deposit (no flexible deposits)", "unsupported_pair");
|
|
518
|
+
if (!acrossChain(params.sourceChain)) throw new AcrossRefusal("chain-unsupported", `source chain ${String(params.sourceChain)} is not a pinned Across chain`, "unsupported_pair");
|
|
519
|
+
if (!acrossChain(params.destChain)) throw new AcrossRefusal("chain-unsupported", `destination chain ${String(params.destChain)} is not a pinned Across chain`, "unsupported_pair");
|
|
520
|
+
if (params.sourceChain === params.destChain) throw new AcrossRefusal("chain-unsupported", "same-chain swaps are not served through a SpokePool", "unsupported_pair");
|
|
521
|
+
let sourceToken;
|
|
522
|
+
if (typeof params.sourceToken === "string" && ADDRESS2.test(params.sourceToken)) sourceToken = params.sourceToken;
|
|
523
|
+
else {
|
|
524
|
+
const asset = (0, import_util.sourceAssetOf)(params);
|
|
525
|
+
if (!asset) invalid(`source token ${String(params.sourceToken)} is not known on ${params.sourceChain}`, "unsupported_pair");
|
|
526
|
+
sourceToken = asset.contract ?? ACROSS_NATIVE;
|
|
527
|
+
if (!ADDRESS2.test(sourceToken)) invalid(`source token ${String(params.sourceToken)} has no EVM contract`, "unsupported_pair");
|
|
528
|
+
}
|
|
529
|
+
if (typeof params.destToken !== "string" || !ADDRESS2.test(params.destToken)) invalid("the destination token must be an EVM address (zero for the native coin)", "unsupported_pair");
|
|
530
|
+
const route = acrossRouteOf(params.sourceChain, sourceToken, params.destChain, params.destToken);
|
|
531
|
+
if ("code" in route) throw new AcrossRefusal(route.code, route.detail, "unsupported_pair");
|
|
532
|
+
const unpriced = acrossRouteUnpriced(route);
|
|
533
|
+
if (unpriced) throw new AcrossRefusal("route-unpriced", unpriced, "unsupported_pair");
|
|
534
|
+
if (typeof params.amountIn !== "string" || !/^[1-9]\d{0,77}$/.test(params.amountIn)) invalid("amount must be a positive base-unit integer");
|
|
535
|
+
if (params.minAmountOut !== void 0 && !UINT.test(params.minAmountOut)) invalid("the output floor must be a base-unit integer");
|
|
536
|
+
const recipient = params.destAddress || opts.placeholder || "";
|
|
537
|
+
if (!recipient) invalid("a live quote needs a recipient");
|
|
538
|
+
if (!ADDRESS2.test(recipient)) invalid("the recipient must be an EVM address");
|
|
539
|
+
const sender = params.sender || "";
|
|
540
|
+
const refund = params.refundAddress || "";
|
|
541
|
+
if (sender && !ADDRESS2.test(sender)) invalid("the signing account (sender) must be an EVM address");
|
|
542
|
+
if (refund && !ADDRESS2.test(refund)) invalid("the refund address must be an EVM address");
|
|
543
|
+
if (sender && refund && lower(sender) !== lower(refund)) {
|
|
544
|
+
throw new AcrossRefusal("request-invalid", `an Across deposit refunds its depositor, the signing account ${lower(sender)}: refund address ${lower(refund)} is another account, and as the depositor it could also sign a speed-up that re-points the output`, "recipient_mismatch");
|
|
545
|
+
}
|
|
546
|
+
const depositor = sender || (opts.placeholder ? refund || opts.placeholder : "");
|
|
547
|
+
if (!depositor) invalid("a live quote needs the signing account (sender)");
|
|
548
|
+
if (!ADDRESS2.test(depositor)) invalid("the depositor must be an EVM address");
|
|
549
|
+
return {
|
|
550
|
+
sourceChain: params.sourceChain,
|
|
551
|
+
destChain: params.destChain,
|
|
552
|
+
sourceToken,
|
|
553
|
+
destToken: params.destToken,
|
|
554
|
+
amount: BigInt(params.amountIn),
|
|
555
|
+
depositor,
|
|
556
|
+
recipient,
|
|
557
|
+
...params.minAmountOut !== void 0 ? { minAmountOut: BigInt(params.minAmountOut) } : {},
|
|
558
|
+
...opts.maxFeeBps !== void 0 ? { maxFeeBps: opts.maxFeeBps } : {},
|
|
559
|
+
...opts.nowMs !== void 0 ? { nowMs: opts.nowMs } : {}
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
function acrossQuoteFeesOf(route, fee) {
|
|
563
|
+
const usd = route.asset === "USDC" || route.asset === "USDT";
|
|
564
|
+
return {
|
|
565
|
+
feeUsd: usd ? (0, import_core.bigintToUnits)(fee, route.input.decimals) : 0,
|
|
566
|
+
fees: fee > 0n ? [{ type: "protocol", amount: fee.toString(10), token: route.input.native ? ACROSS_NATIVE : route.input.token, included: true, description: "Across relayer and LP fee" }] : []
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
function checkAcrossQuote(request, quote, tx) {
|
|
570
|
+
if (quote === null || typeof quote !== "object" || quote.provider !== "across") throw new AcrossRefusal("quote-shape", "not an Across quote", "policy_refused");
|
|
571
|
+
const t = tx ?? quote.txRequest;
|
|
572
|
+
if (!t) throw new AcrossRefusal("quote-shape", "the quote has no transaction", "policy_refused");
|
|
573
|
+
if (quote.depositAddress) throw new AcrossRefusal("quote-shape", "an Across quote pays the SpokePool through its calldata, never a deposit address", "vault_mismatch");
|
|
574
|
+
const extra = quote.txRequest;
|
|
575
|
+
if (extra?.serializedTx !== void 0 || extra?.nativeFee !== void 0) {
|
|
576
|
+
throw new AcrossRefusal("quote-shape", "an Across deposit carries no extra native fee and no serialized transaction", "policy_refused");
|
|
577
|
+
}
|
|
578
|
+
const v = verifyAcrossDeposit(request, t);
|
|
579
|
+
if (quote.sourceAmount !== v.args.inputAmount.toString(10) || quote.minDestAmount !== v.args.outputAmount.toString(10) || quote.destAmount !== v.args.outputAmount.toString(10) || quote.destDecimals !== v.route.output.decimals) {
|
|
580
|
+
throw new AcrossRefusal("quote-amounts", "the amounts the quote shows are not the deposit's", "price_check_failed");
|
|
581
|
+
}
|
|
582
|
+
const shown = acrossQuoteFeesOf(v.route, v.fee);
|
|
583
|
+
const w = shown.fees[0];
|
|
584
|
+
const g = Array.isArray(quote.fees) && quote.fees.length === 1 ? quote.fees[0] : void 0;
|
|
585
|
+
if (!g || g.type !== w.type || g.amount !== w.amount || typeof g.token !== "string" || lower(g.token) !== w.token || g.included !== true || quote.feeUsd !== shown.feeUsd) {
|
|
586
|
+
throw new AcrossRefusal("quote-amounts", `the fees the quote shows are not the deposit's fee of ${v.fee} (the engine's fee caps read them)`, "price_check_failed");
|
|
587
|
+
}
|
|
588
|
+
const gas = t.gasLimit;
|
|
589
|
+
if (gas !== void 0) {
|
|
590
|
+
if (typeof gas !== "string" || !/^[1-9]\d{0,10}$/.test(gas) || BigInt(gas) < ACROSS_GAS_FLOOR || BigInt(gas) > ACROSS_GAS_CAP) {
|
|
591
|
+
throw new AcrossRefusal("quote-gas", `the gas limit ${String(gas).slice(0, 40)} is outside ${ACROSS_GAS_FLOOR}\u2013${ACROSS_GAS_CAP}`, "policy_refused");
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
const now = request.nowMs ?? Date.now();
|
|
595
|
+
if (typeof quote.validUntilMs !== "number" || !Number.isFinite(quote.validUntilMs) || quote.validUntilMs > now + ACROSS_MAX_QUOTE_LIFE_MS) {
|
|
596
|
+
throw new AcrossRefusal("quote-expiry", "the quote claims to live longer than an Across quote may", "policy_refused");
|
|
597
|
+
}
|
|
598
|
+
if (quote.validUntilMs > acrossQuoteTimeLimitMs(v.args.quoteTimestamp)) {
|
|
599
|
+
throw new AcrossRefusal("quote-expiry", `the quote claims to live past ${ACROSS_DEPOSIT_QUOTE_TIME_BUFFER_S - ACROSS_LANDING_WINDOW_S} s after its quote time \u2014 signed then, the deposit would revert on it`, "policy_refused");
|
|
600
|
+
}
|
|
601
|
+
const intent = parseAcrossIntentId(quote.intentId);
|
|
602
|
+
const want = acrossIntentId(v.route.input.chain.chainId, v.route.output.chain.chainId, v.deposit.data);
|
|
603
|
+
if (!intent || `across:${intent.sourceChainId}:${intent.destChainId}:${intent.digest}` !== want) {
|
|
604
|
+
throw new AcrossRefusal("quote-intent", "the quote's id does not name its deposit", "policy_refused");
|
|
605
|
+
}
|
|
606
|
+
return v;
|
|
607
|
+
}
|
|
608
|
+
var pinNotes = (0, import_errors2.refusalNotes)();
|
|
609
|
+
function notedReason(err) {
|
|
610
|
+
const text = acrossRefusalReason(err);
|
|
611
|
+
const info = (0, import_errors2.refusalOf)(err);
|
|
612
|
+
return info ? pinNotes.note(text, info) : text;
|
|
613
|
+
}
|
|
614
|
+
var acrossPinsRequestOf = (params, cap = {}) => acrossRequestOf(params, params.dry !== false ? { ...cap, placeholder: ACROSS_PLACEHOLDER } : cap);
|
|
615
|
+
function verifyQuoteWith(params, quote, cap) {
|
|
616
|
+
try {
|
|
617
|
+
checkAcrossQuote(acrossPinsRequestOf(params, cap), quote);
|
|
618
|
+
return null;
|
|
619
|
+
} catch (err) {
|
|
620
|
+
return notedReason(err);
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
function acrossCheckBuild(quote, tx, params, cap = {}) {
|
|
624
|
+
if (!params) throw new AcrossRefusal("request-invalid", "the request this quote answered is not known on this side \u2014 quote again", "policy_refused");
|
|
625
|
+
if (tx.chain !== params.sourceChain) throw new AcrossRefusal("tx-chain", `the build is for ${tx.chain}, not ${params.sourceChain}`, "vault_mismatch");
|
|
626
|
+
checkAcrossTxShape(tx);
|
|
627
|
+
return checkAcrossQuote(acrossRequestOf(params, cap), quote, tx);
|
|
628
|
+
}
|
|
629
|
+
function verifyBuildWith(quote, tx, params, cap) {
|
|
630
|
+
try {
|
|
631
|
+
acrossCheckBuild(quote, tx, params, cap);
|
|
632
|
+
return null;
|
|
633
|
+
} catch (err) {
|
|
634
|
+
return notedReason(err);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
function acrossPinsWith(opts = {}) {
|
|
638
|
+
const maxFeeBps = opts.maxFeeBps;
|
|
639
|
+
if (maxFeeBps !== void 0 && (!Number.isInteger(maxFeeBps) || maxFeeBps < 0 || maxFeeBps > ACROSS_MAX_FEE_BPS_LIMIT)) {
|
|
640
|
+
throw new Error(`across: maxFeeBps must be an integer between 0 and ${ACROSS_MAX_FEE_BPS_LIMIT}`);
|
|
641
|
+
}
|
|
642
|
+
const cap = Object.freeze(maxFeeBps !== void 0 ? { maxFeeBps } : {});
|
|
643
|
+
return Object.freeze({
|
|
644
|
+
callTargets: (chain2) => {
|
|
645
|
+
const c = acrossChain(chain2);
|
|
646
|
+
return c ? [c.spokePool] : [];
|
|
647
|
+
},
|
|
648
|
+
spenders: (chain2) => {
|
|
649
|
+
const c = acrossChain(chain2);
|
|
650
|
+
return c ? [c.spokePool] : [];
|
|
651
|
+
},
|
|
652
|
+
verifyQuote: (params, quote) => verifyQuoteWith(params, quote, cap),
|
|
653
|
+
verifyBuild: (quote, tx, params) => verifyBuildWith(quote, tx, params, cap),
|
|
654
|
+
reasonOf: pinNotes.reasonOf
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
var acrossPins = acrossPinsWith();
|
|
658
|
+
|
|
659
|
+
// src/build.ts
|
|
660
|
+
var UINT2 = /^(?:0|[1-9]\d{0,77})$/;
|
|
661
|
+
var ADDRESS3 = /^0x[0-9a-fA-F]{40}$/;
|
|
662
|
+
var U32_MAX2 = 4294967295;
|
|
663
|
+
function checkNormalized(request, q, sourceChainId, destChainId) {
|
|
664
|
+
const bad = (what) => {
|
|
665
|
+
throw new AcrossRefusal("quote-normalized", `the quote ${what}`, "upstream_unavailable");
|
|
666
|
+
};
|
|
667
|
+
if (q === null || typeof q !== "object") bad("is missing");
|
|
668
|
+
if (q.sourceChainId !== sourceChainId || q.destinationChainId !== destChainId) {
|
|
669
|
+
throw new AcrossRefusal("quote-normalized", `the quote is for ${String(q.sourceChainId)} \u2192 ${String(q.destinationChainId)}, the request for ${sourceChainId} \u2192 ${destChainId}`, "policy_refused");
|
|
670
|
+
}
|
|
671
|
+
for (const [k, v] of [["input token", q.inputToken], ["output token", q.outputToken], ["exclusive relayer", q.exclusiveRelayer]]) {
|
|
672
|
+
if (typeof v !== "string" || !ADDRESS3.test(v)) bad(`names a ${k} that is not an address`);
|
|
673
|
+
}
|
|
674
|
+
if (q.inputToken.toLowerCase() !== request.sourceToken.toLowerCase() || q.outputToken.toLowerCase() !== request.destToken.toLowerCase()) {
|
|
675
|
+
throw new AcrossRefusal("quote-normalized", "the quote is for other tokens than the request", "policy_refused");
|
|
676
|
+
}
|
|
677
|
+
for (const [k, v] of [["input amount", q.inputAmount], ["output amount", q.outputAmount]]) {
|
|
678
|
+
if (typeof v !== "string" || !UINT2.test(v)) bad(`states an ${k} that is not a base-unit integer`);
|
|
679
|
+
}
|
|
680
|
+
if (BigInt(q.inputAmount) !== request.amount) throw new AcrossRefusal("quote-normalized", `the quote sends ${q.inputAmount}, the request ${request.amount}`, "policy_refused");
|
|
681
|
+
if (q.expectedOutputAmount !== void 0 && (typeof q.expectedOutputAmount !== "string" || !UINT2.test(q.expectedOutputAmount))) bad("states an expected output that is not a base-unit integer");
|
|
682
|
+
if (q.expectedOutputAmount !== void 0 && BigInt(q.expectedOutputAmount) > BigInt(q.outputAmount)) {
|
|
683
|
+
throw new AcrossRefusal("quote-normalized", `the quote expects ${q.expectedOutputAmount} to arrive, more than the ${q.outputAmount} the deposit asks relayers for`, "price_check_failed");
|
|
684
|
+
}
|
|
685
|
+
for (const [k, v] of [["quote time", q.quoteTimestamp], ["fill deadline", q.fillDeadline], ["exclusivity", q.exclusivityParameter]]) {
|
|
686
|
+
if (!Number.isInteger(v) || v < 0 || v > U32_MAX2) bad(`states a ${k} that is not a uint32`);
|
|
687
|
+
}
|
|
688
|
+
if (!Number.isFinite(q.expectedFillTimeSec) || q.expectedFillTimeSec < 0) bad("states no fill time");
|
|
689
|
+
if (q.expiresAtMs !== void 0 && (!Number.isFinite(q.expiresAtMs) || q.expiresAtMs <= 0)) bad("states an expiry that is not a time");
|
|
690
|
+
if (q.orderId !== void 0 && (typeof q.orderId !== "string" || !/^[\x21-\x7e]{1,128}$/.test(q.orderId))) bad("carries an order id that is not printable");
|
|
691
|
+
const f = q.fees;
|
|
692
|
+
if (f !== void 0) {
|
|
693
|
+
if (f === null || typeof f !== "object" || typeof f.total !== "string" || !UINT2.test(f.total)) bad("itemizes fees without a total");
|
|
694
|
+
for (const v of [f.relayerCapital, f.destinationGas, f.lp]) if (v !== void 0 && (typeof v !== "string" || !UINT2.test(v))) bad("itemizes a fee that is not a base-unit integer");
|
|
695
|
+
if (f.totalUsd !== void 0 && (!Number.isFinite(f.totalUsd) || f.totalUsd < 0)) bad("prices its fees in a number that is not a price");
|
|
696
|
+
if (BigInt(q.outputAmount) <= BigInt(q.inputAmount) && BigInt(f.total) !== BigInt(q.inputAmount) - BigInt(q.outputAmount)) {
|
|
697
|
+
throw new AcrossRefusal("quote-normalized", "the quote's fee total is not its input minus its output", "price_check_failed");
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
function buildAcrossDeposit(request, quote) {
|
|
702
|
+
const { route } = checkAcrossRequest(request);
|
|
703
|
+
const src = route.input.chain;
|
|
704
|
+
const dst = route.output.chain;
|
|
705
|
+
checkNormalized(request, quote, src.chainId, dst.chainId);
|
|
706
|
+
const data = encodeAcrossDeposit({
|
|
707
|
+
depositor: request.depositor.toLowerCase(),
|
|
708
|
+
recipient: request.recipient.toLowerCase(),
|
|
709
|
+
inputToken: route.input.token,
|
|
710
|
+
outputToken: route.output.token,
|
|
711
|
+
inputAmount: request.amount,
|
|
712
|
+
outputAmount: BigInt(quote.outputAmount),
|
|
713
|
+
destinationChainId: BigInt(dst.chainId),
|
|
714
|
+
exclusiveRelayer: quote.exclusiveRelayer.toLowerCase(),
|
|
715
|
+
quoteTimestamp: quote.quoteTimestamp,
|
|
716
|
+
fillDeadline: quote.fillDeadline,
|
|
717
|
+
exclusivityParameter: quote.exclusivityParameter,
|
|
718
|
+
message: "0x"
|
|
719
|
+
});
|
|
720
|
+
return verifyAcrossDeposit(request, {
|
|
721
|
+
to: src.spokePool,
|
|
722
|
+
data,
|
|
723
|
+
value: route.input.native ? request.amount.toString(10) : "0",
|
|
724
|
+
chainId: src.chainId,
|
|
725
|
+
...route.input.native ? {} : { approvalAddress: src.spokePool }
|
|
726
|
+
});
|
|
727
|
+
}
|
|
728
|
+
function acrossQuoteOf(request, quote, opts = {}) {
|
|
729
|
+
const v = buildAcrossDeposit(request, quote);
|
|
730
|
+
const ttl = opts.quoteTtlMs ?? 6e4;
|
|
731
|
+
if (!Number.isInteger(ttl) || ttl <= 0 || ttl > 3e5) throw new AcrossRefusal("request-invalid", "quoteTtlMs must be an integer between 1 and 300000");
|
|
732
|
+
const now = request.nowMs ?? Date.now();
|
|
733
|
+
const validUntilMs = Math.min(now + ttl, now + ACROSS_MAX_QUOTE_LIFE_MS, quote.expiresAtMs ?? Number.POSITIVE_INFINITY, acrossQuoteTimeLimitMs(v.args.quoteTimestamp));
|
|
734
|
+
const reliability = opts.reliability ?? 0.97;
|
|
735
|
+
return {
|
|
736
|
+
provider: "across",
|
|
737
|
+
intentId: acrossIntentId(v.route.input.chain.chainId, v.route.output.chain.chainId, v.deposit.data),
|
|
738
|
+
depositAddress: "",
|
|
739
|
+
depositMemo: null,
|
|
740
|
+
txRequest: {
|
|
741
|
+
to: v.deposit.to,
|
|
742
|
+
data: v.deposit.data,
|
|
743
|
+
value: v.deposit.value,
|
|
744
|
+
chainId: v.deposit.chainId,
|
|
745
|
+
...v.deposit.approvalAddress ? { approvalAddress: v.deposit.approvalAddress } : {}
|
|
746
|
+
},
|
|
747
|
+
sourceAmount: v.args.inputAmount.toString(10),
|
|
748
|
+
destAmount: v.args.outputAmount.toString(10),
|
|
749
|
+
minDestAmount: v.args.outputAmount.toString(10),
|
|
750
|
+
destDecimals: v.route.output.decimals,
|
|
751
|
+
...acrossQuoteFeesOf(v.route, v.fee),
|
|
752
|
+
etaSeconds: Math.min(Math.max(Math.ceil(quote.expectedFillTimeSec), 1), 86400),
|
|
753
|
+
reliability: Number.isFinite(reliability) && reliability >= 0 && reliability <= 1 ? reliability : 0.97,
|
|
754
|
+
validUntilMs,
|
|
755
|
+
providerData: {
|
|
756
|
+
sourceChain: request.sourceChain,
|
|
757
|
+
destChain: request.destChain,
|
|
758
|
+
sourceToken: request.sourceToken.toLowerCase(),
|
|
759
|
+
destToken: request.destToken.toLowerCase(),
|
|
760
|
+
amount: request.amount.toString(10),
|
|
761
|
+
depositor: request.depositor.toLowerCase(),
|
|
762
|
+
recipient: request.recipient.toLowerCase(),
|
|
763
|
+
outputAmount: v.args.outputAmount.toString(10),
|
|
764
|
+
quoteTimestamp: String(v.args.quoteTimestamp),
|
|
765
|
+
fillDeadline: String(v.args.fillDeadline),
|
|
766
|
+
exclusiveRelayer: v.args.exclusiveRelayer,
|
|
767
|
+
exclusivityParameter: String(v.args.exclusivityParameter),
|
|
768
|
+
...request.minAmountOut !== void 0 ? { minAmountOut: request.minAmountOut.toString(10) } : {},
|
|
769
|
+
...request.maxFeeBps !== void 0 ? { maxFeeBps: String(request.maxFeeBps) } : {},
|
|
770
|
+
...quote.expectedOutputAmount !== void 0 ? { expectedOutputAmount: quote.expectedOutputAmount } : {},
|
|
771
|
+
...quote.orderId !== void 0 ? { orderId: quote.orderId } : {},
|
|
772
|
+
...opts.placeholder ? { placeholder: "1" } : {}
|
|
773
|
+
}
|
|
774
|
+
};
|
|
775
|
+
}
|
|
776
|
+
//# sourceMappingURL=build.cjs.map
|