@glacislabs/stablegenie-zerodelta 3.0.2 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{chunk-TR2XMP7X.js → chunk-NSH3PT2J.js} +6 -4
- package/dist/{chunk-AZPTL3KD.js → chunk-OOURZ5DL.js} +191 -58
- package/dist/core/index.cjs +196 -57
- package/dist/core/index.d.cts +60 -7
- package/dist/core/index.d.ts +60 -7
- package/dist/core/index.js +1 -1
- package/dist/index.cjs +195 -60
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/{mount-BC5gY1X6.d.cts → mount-DNvmtX0y.d.cts} +1 -1
- package/dist/{mount-8nchcNbL.d.ts → mount-jxrT-DMe.d.ts} +1 -1
- package/dist/mount.cjs +195 -60
- package/dist/mount.d.cts +2 -2
- package/dist/mount.d.ts +2 -2
- package/dist/mount.js +2 -2
- package/dist/standalone.global.js +6 -6
- package/dist/{verify-DFTuQ2g3.d.cts → verify-7lk90Ado.d.cts} +11 -3
- package/dist/{verify-DFTuQ2g3.d.ts → verify-7lk90Ado.d.ts} +11 -3
- package/package.json +2 -1
package/dist/mount.cjs
CHANGED
|
@@ -13,13 +13,14 @@ function useMergedConfig(local) {
|
|
|
13
13
|
|
|
14
14
|
// src/core/constants.ts
|
|
15
15
|
var DEFAULT_WIDGET_API_BASE = "/api/widget/v1";
|
|
16
|
-
var SUPPORTED_CHAIN_IDS = /* @__PURE__ */ new Set([1, 10, 42161, 8453, 57073, 130, 9745, 146]);
|
|
16
|
+
var SUPPORTED_CHAIN_IDS = /* @__PURE__ */ new Set([1, 10, 42161, 8453, 57073, 130, 9745, 146, 98866]);
|
|
17
17
|
var SUPPORTED_ASSETS = /* @__PURE__ */ new Set(["USDC", "USDT", "USDE", "XAUT"]);
|
|
18
18
|
var API_CACHE_TTL_MS = 6e4;
|
|
19
19
|
var MAX_QUOTE_CANDIDATES = 8;
|
|
20
20
|
var QUOTE_BUFFER_BPS = 50;
|
|
21
21
|
var LZ_FEE_BUFFER_BPS = 1500n;
|
|
22
|
-
var SUBMIT_ORDER_SELECTOR = "
|
|
22
|
+
var SUBMIT_ORDER_SELECTOR = "0xaf439ecd";
|
|
23
|
+
var NO_PARTNER_ID = `0x${"0".repeat(64)}`;
|
|
23
24
|
var ERC20_APPROVE_SELECTOR = "0x095ea7b3";
|
|
24
25
|
var ERC20_TRANSFER_SELECTOR = "0xa9059cbb";
|
|
25
26
|
var ERC20_ALLOWANCE_SELECTOR = "0xdd62ed3e";
|
|
@@ -28,22 +29,24 @@ var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
|
28
29
|
var PREVIEW_OWNER = "0x1111111111111111111111111111111111111111";
|
|
29
30
|
var CANONICAL_DECIMALS = { USDC: 6, USDT: 6, USDE: 18, XAUT: 6 };
|
|
30
31
|
var CANONICAL_ESCROW = Object.freeze({
|
|
31
|
-
1: "
|
|
32
|
-
// Ethereum
|
|
33
|
-
10: "
|
|
34
|
-
// Optimism
|
|
35
|
-
130: "
|
|
36
|
-
// Unichain
|
|
37
|
-
146: "
|
|
38
|
-
// Sonic
|
|
39
|
-
8453: "
|
|
40
|
-
// Base
|
|
41
|
-
9745: "
|
|
42
|
-
// Plasma
|
|
43
|
-
57073: "
|
|
44
|
-
// Ink
|
|
45
|
-
42161: "
|
|
46
|
-
// Arbitrum
|
|
32
|
+
1: "0x5e25c8ABc19b88d6A7Ab0D805C77A34987a68b40",
|
|
33
|
+
// Ethereum
|
|
34
|
+
10: "0x5e25c8ABc19b88d6A7Ab0D805C77A34987a68b40",
|
|
35
|
+
// Optimism
|
|
36
|
+
130: "0x5e25c8ABc19b88d6A7Ab0D805C77A34987a68b40",
|
|
37
|
+
// Unichain
|
|
38
|
+
146: "0x5e25c8ABc19b88d6A7Ab0D805C77A34987a68b40",
|
|
39
|
+
// Sonic
|
|
40
|
+
8453: "0x5e25c8ABc19b88d6A7Ab0D805C77A34987a68b40",
|
|
41
|
+
// Base
|
|
42
|
+
9745: "0x5e25c8ABc19b88d6A7Ab0D805C77A34987a68b40",
|
|
43
|
+
// Plasma
|
|
44
|
+
57073: "0x5e25c8ABc19b88d6A7Ab0D805C77A34987a68b40",
|
|
45
|
+
// Ink
|
|
46
|
+
42161: "0x5e25c8ABc19b88d6A7Ab0D805C77A34987a68b40",
|
|
47
|
+
// Arbitrum
|
|
48
|
+
98866: "0x5e25c8ABc19b88d6A7Ab0D805C77A34987a68b40"
|
|
49
|
+
// Plume
|
|
47
50
|
});
|
|
48
51
|
var MAX_LZ_MSG_VALUE_WEI = 10n ** 18n;
|
|
49
52
|
var MAX_LZ_MSG_VALUE_WEI_BY_CHAIN = {};
|
|
@@ -65,7 +68,8 @@ var BUNDLED_NATIVE_SYMBOL = {
|
|
|
65
68
|
146: "S",
|
|
66
69
|
8453: "ETH",
|
|
67
70
|
57073: "ETH",
|
|
68
|
-
42161: "ETH"
|
|
71
|
+
42161: "ETH",
|
|
72
|
+
98866: "PLUME"
|
|
69
73
|
};
|
|
70
74
|
var BUNDLED_RPC = {
|
|
71
75
|
1: "https://ethereum-rpc.publicnode.com",
|
|
@@ -75,7 +79,8 @@ var BUNDLED_RPC = {
|
|
|
75
79
|
8453: "https://mainnet.base.org",
|
|
76
80
|
9745: "https://rpc.plasma.to",
|
|
77
81
|
57073: "https://rpc-gel.inkonchain.com",
|
|
78
|
-
42161: "https://arb1.arbitrum.io/rpc"
|
|
82
|
+
42161: "https://arb1.arbitrum.io/rpc",
|
|
83
|
+
98866: "https://rpc.plume.org"
|
|
79
84
|
};
|
|
80
85
|
|
|
81
86
|
// src/core/address.ts
|
|
@@ -167,13 +172,25 @@ function uintWord(value) {
|
|
|
167
172
|
if (hex.length > 64) throw new Error("uint256 value is too large.");
|
|
168
173
|
return hex.padStart(64, "0");
|
|
169
174
|
}
|
|
175
|
+
var MAX_UINT64 = (1n << 64n) - 1n;
|
|
176
|
+
function uint64Word(value) {
|
|
177
|
+
const n = BigInt(value || 0);
|
|
178
|
+
if (n < 0n) throw new Error("Cannot encode a negative uint64.");
|
|
179
|
+
if (n > MAX_UINT64) throw new Error("uint64 value is too large.");
|
|
180
|
+
return n.toString(16).padStart(64, "0");
|
|
181
|
+
}
|
|
182
|
+
function bytes32Word(value) {
|
|
183
|
+
const hex = strip0x(value);
|
|
184
|
+
if (!/^[a-fA-F0-9]{64}$/.test(hex)) throw new Error("bytes32 value must be exactly 32 bytes of hex.");
|
|
185
|
+
return hex.toLowerCase();
|
|
186
|
+
}
|
|
170
187
|
function addressWord(address) {
|
|
171
188
|
return strip0x(assertAddress(address, "Address")).padStart(64, "0");
|
|
172
189
|
}
|
|
173
190
|
function bytesPayload(value) {
|
|
174
|
-
const hex = strip0x(value);
|
|
175
|
-
if (hex.length % 2) throw new Error("
|
|
176
|
-
if (!/^[a-fA-F0-9]*$/.test(hex)) throw new Error("
|
|
191
|
+
const hex = strip0x(value || "0x");
|
|
192
|
+
if (hex.length % 2) throw new Error("Bytes payload has an odd-length hex value; refusing to encode.");
|
|
193
|
+
if (!/^[a-fA-F0-9]*$/.test(hex)) throw new Error("Bytes payload is not valid hex.");
|
|
177
194
|
const byteLength = hex.length / 2;
|
|
178
195
|
const paddedLength = Math.ceil(hex.length / 64) * 64;
|
|
179
196
|
return `${uintWord(byteLength)}${hex.padEnd(paddedLength, "0")}`;
|
|
@@ -190,19 +207,96 @@ function encodeAllowance(owner, spender) {
|
|
|
190
207
|
function encodeBalanceOf(account) {
|
|
191
208
|
return `${ERC20_BALANCEOF_SELECTOR}${addressWord(account)}`;
|
|
192
209
|
}
|
|
193
|
-
|
|
194
|
-
|
|
210
|
+
var ORDER_HEAD_WORDS = 9n;
|
|
211
|
+
var ORDER_HEAD_BYTES = ORDER_HEAD_WORDS * 32n;
|
|
212
|
+
function encodeOrderTuple(order) {
|
|
213
|
+
const askToken = bytesPayload(order.askToken);
|
|
214
|
+
const receiver = bytesPayload(order.destinationReceiver);
|
|
215
|
+
const receiverOffset = ORDER_HEAD_BYTES + BigInt(askToken.length / 2);
|
|
216
|
+
const head = [
|
|
195
217
|
addressWord(order.owner),
|
|
196
218
|
addressWord(order.bidToken),
|
|
197
219
|
uintWord(order.bidTokenAmount),
|
|
198
|
-
|
|
220
|
+
uintWord(ORDER_HEAD_BYTES),
|
|
199
221
|
uintWord(order.askTokenAmount),
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
222
|
+
uintWord(receiverOffset),
|
|
223
|
+
uint64Word(order.destinationChainId),
|
|
224
|
+
uint64Word(order.executionChainId),
|
|
225
|
+
uint64Word(order.deadline)
|
|
204
226
|
].join("");
|
|
205
|
-
return
|
|
227
|
+
return `${head}${askToken}${receiver}`;
|
|
228
|
+
}
|
|
229
|
+
function encodeSubmitOrder(orders, partnerId = NO_PARTNER_ID) {
|
|
230
|
+
if (!orders.length) throw new Error("Cannot encode an empty order request array.");
|
|
231
|
+
const tuples = orders.map(encodeOrderTuple);
|
|
232
|
+
let offset = 32n * BigInt(tuples.length);
|
|
233
|
+
const offsets = tuples.map((tuple) => {
|
|
234
|
+
const word = uintWord(offset);
|
|
235
|
+
offset += BigInt(tuple.length / 2);
|
|
236
|
+
return word;
|
|
237
|
+
}).join("");
|
|
238
|
+
return `0x${SUBMIT_ORDER_SELECTOR.slice(2)}${uintWord(64)}${bytes32Word(partnerId)}${uintWord(tuples.length)}${offsets}${tuples.join("")}`;
|
|
239
|
+
}
|
|
240
|
+
var EVM_BYTES_PAYLOAD_BYTES = 64;
|
|
241
|
+
var EVM_ORDER_TUPLE_BYTES = Number(ORDER_HEAD_BYTES) + 2 * EVM_BYTES_PAYLOAD_BYTES;
|
|
242
|
+
var MAX_DECODED_ORDERS = 16;
|
|
243
|
+
function decodeSubmitOrderCalldata(data) {
|
|
244
|
+
const hex = strip0x(String(data || "")).toLowerCase();
|
|
245
|
+
if (hex.length < 8 || hex.length % 2 !== 0 || !/^[a-f0-9]*$/.test(hex)) return null;
|
|
246
|
+
if (`0x${hex.slice(0, 8)}` !== SUBMIT_ORDER_SELECTOR) return null;
|
|
247
|
+
const body = hex.slice(8);
|
|
248
|
+
const totalBytes = body.length / 2;
|
|
249
|
+
const word = (byteOffset) => {
|
|
250
|
+
if (!Number.isSafeInteger(byteOffset) || byteOffset < 0 || byteOffset + 32 > totalBytes) return null;
|
|
251
|
+
return BigInt(`0x${body.slice(byteOffset * 2, byteOffset * 2 + 64)}`);
|
|
252
|
+
};
|
|
253
|
+
const addressAt = (byteOffset) => {
|
|
254
|
+
const w = word(byteOffset);
|
|
255
|
+
if (w === null || w >= 1n << 160n) return null;
|
|
256
|
+
return `0x${w.toString(16).padStart(40, "0")}`;
|
|
257
|
+
};
|
|
258
|
+
const uint64At = (byteOffset) => {
|
|
259
|
+
const w = word(byteOffset);
|
|
260
|
+
return w === null || w > MAX_UINT64 ? null : w;
|
|
261
|
+
};
|
|
262
|
+
const evmBytesAt = (byteOffset) => {
|
|
263
|
+
const len = word(byteOffset);
|
|
264
|
+
if (len !== 20n) return null;
|
|
265
|
+
const content = body.slice((byteOffset + 32) * 2, (byteOffset + 64) * 2);
|
|
266
|
+
if (content.length !== 64 || !content.endsWith("0".repeat(24))) return null;
|
|
267
|
+
return `0x${content.slice(0, 40)}`;
|
|
268
|
+
};
|
|
269
|
+
if (word(0) !== 64n) return null;
|
|
270
|
+
if (word(32) === null) return null;
|
|
271
|
+
const partnerId = `0x${body.slice(64, 128)}`;
|
|
272
|
+
const count = word(64);
|
|
273
|
+
if (count === null || count < 1n || count > BigInt(MAX_DECODED_ORDERS)) return null;
|
|
274
|
+
const n = Number(count);
|
|
275
|
+
const arrayBase = 96;
|
|
276
|
+
if (totalBytes !== arrayBase + 32 * n + EVM_ORDER_TUPLE_BYTES * n) return null;
|
|
277
|
+
const orders = [];
|
|
278
|
+
for (let i = 0; i < n; i += 1) {
|
|
279
|
+
const rel = word(arrayBase + i * 32);
|
|
280
|
+
if (rel === null || rel !== BigInt(32 * n + EVM_ORDER_TUPLE_BYTES * i)) return null;
|
|
281
|
+
const base = arrayBase + Number(rel);
|
|
282
|
+
const owner = addressAt(base);
|
|
283
|
+
const bidToken = addressAt(base + 32);
|
|
284
|
+
const bidTokenAmount = word(base + 64);
|
|
285
|
+
const askOffset = word(base + 96);
|
|
286
|
+
const askTokenAmount = word(base + 128);
|
|
287
|
+
const receiverOffset = word(base + 160);
|
|
288
|
+
const destinationChainId = uint64At(base + 192);
|
|
289
|
+
const executionChainId = uint64At(base + 224);
|
|
290
|
+
const deadline = uint64At(base + 256);
|
|
291
|
+
if (owner === null || bidToken === null || bidTokenAmount === null || askTokenAmount === null || destinationChainId === null || executionChainId === null || deadline === null || askOffset !== ORDER_HEAD_BYTES || receiverOffset !== ORDER_HEAD_BYTES + BigInt(EVM_BYTES_PAYLOAD_BYTES)) {
|
|
292
|
+
return null;
|
|
293
|
+
}
|
|
294
|
+
const askToken = evmBytesAt(base + Number(askOffset));
|
|
295
|
+
const destinationReceiver = evmBytesAt(base + Number(receiverOffset));
|
|
296
|
+
if (askToken === null || destinationReceiver === null) return null;
|
|
297
|
+
orders.push({ owner, bidToken, bidTokenAmount, askToken, askTokenAmount, destinationReceiver, destinationChainId, executionChainId, deadline });
|
|
298
|
+
}
|
|
299
|
+
return { partnerId, orders };
|
|
206
300
|
}
|
|
207
301
|
function toHexQuantity(value) {
|
|
208
302
|
const n = BigInt(value || 0);
|
|
@@ -393,7 +487,7 @@ async function solveExactOut({ option, destination, destinationToken, payer, fet
|
|
|
393
487
|
estimatedDuration: 0,
|
|
394
488
|
gasCostSource: "0",
|
|
395
489
|
gasCostDest: "0",
|
|
396
|
-
|
|
490
|
+
orderRequests: null
|
|
397
491
|
},
|
|
398
492
|
youPayRaw: targetRaw.toString(),
|
|
399
493
|
recipientReceivesRaw: targetRaw.toString(),
|
|
@@ -505,9 +599,13 @@ async function solveExactIn({ option, destination, destinationToken, payer, fetc
|
|
|
505
599
|
}
|
|
506
600
|
|
|
507
601
|
// src/core/order.ts
|
|
508
|
-
|
|
602
|
+
var DEFAULT_DEADLINE_SECONDS = 1800;
|
|
603
|
+
var MAX_DEADLINE_SECONDS = 60 * 60;
|
|
604
|
+
function normalizeOrderRequest(order, payer, destination, fallbackExecutionChainId, deadlineOverride) {
|
|
509
605
|
const apiDeadline = Number(order.deadline);
|
|
510
|
-
const deadline = Number.isFinite(apiDeadline) && apiDeadline > 0 ? String(order.deadline) : String(Math.floor(Date.now() / 1e3) +
|
|
606
|
+
const deadline = deadlineOverride ?? (Number.isFinite(apiDeadline) && apiDeadline > 0 ? String(order.deadline) : String(Math.floor(Date.now() / 1e3) + DEFAULT_DEADLINE_SECONDS));
|
|
607
|
+
const executionChainId = String(order.executionChainId || fallbackExecutionChainId || "0");
|
|
608
|
+
if (!/^\d+$/.test(executionChainId) || BigInt(executionChainId) <= 0n) throw new Error("ZeroDelta quote did not include an execution chain.");
|
|
511
609
|
return {
|
|
512
610
|
owner: assertAddress(order.owner || payer, "Order owner"),
|
|
513
611
|
bidToken: assertAddress(order.bidToken, "Bid token"),
|
|
@@ -516,26 +614,40 @@ function normalizeOrderRequest(order, payer, destination) {
|
|
|
516
614
|
askTokenAmount: String(order.askTokenAmount || "0"),
|
|
517
615
|
destinationReceiver: assertAddress(order.destinationReceiver || destination.address, "Destination receiver"),
|
|
518
616
|
destinationChainId: String(order.destinationChainId || destination.chainId),
|
|
519
|
-
|
|
520
|
-
|
|
617
|
+
executionChainId,
|
|
618
|
+
deadline
|
|
521
619
|
};
|
|
522
620
|
}
|
|
523
|
-
function
|
|
621
|
+
function normalizeOrderRequests(requests, payer, destination, fallbackExecutionChainId) {
|
|
622
|
+
if (!requests.length) throw new Error("ZeroDelta quote did not include any order requests.");
|
|
623
|
+
return requests.map(
|
|
624
|
+
(request, index) => index === 0 ? normalizeOrderRequest(request, payer, destination, fallbackExecutionChainId) : normalizeOrderRequest(request, payer, destination, fallbackExecutionChainId, String(request.deadline || "0"))
|
|
625
|
+
);
|
|
626
|
+
}
|
|
627
|
+
function assertQuoteMatchesSelection({ quote, order, orders, option, destinationToken, destination, payer, result }) {
|
|
628
|
+
const list = orders?.length ? orders : [order];
|
|
629
|
+
const sourceOrder = list[0];
|
|
630
|
+
const finalOrder = list[list.length - 1];
|
|
524
631
|
const now = Math.floor(Date.now() / 1e3);
|
|
525
|
-
const deadline = Number(
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
632
|
+
const deadline = Number(sourceOrder.deadline || 0);
|
|
633
|
+
for (const current of list) {
|
|
634
|
+
if (normalizeAddress(current.owner) !== normalizeAddress(payer)) {
|
|
635
|
+
throw new Error("ZeroDelta quote returned an owner that does not match the connected wallet.");
|
|
636
|
+
}
|
|
637
|
+
if (normalizeAddress(current.destinationReceiver) !== normalizeAddress(destination.address)) {
|
|
638
|
+
throw new Error("ZeroDelta quote returned a receiver that does not match the detected destination.");
|
|
639
|
+
}
|
|
640
|
+
if (!/^\d+$/.test(current.executionChainId || "") || BigInt(current.executionChainId) <= 0n) {
|
|
641
|
+
throw new Error("ZeroDelta quote returned an order without an execution chain.");
|
|
642
|
+
}
|
|
531
643
|
}
|
|
532
|
-
if (normalizeAddress(
|
|
644
|
+
if (normalizeAddress(sourceOrder.bidToken) !== normalizeAddress(option.address)) {
|
|
533
645
|
throw new Error("ZeroDelta quote returned a bid token that does not match the selected route.");
|
|
534
646
|
}
|
|
535
|
-
if (normalizeAddress(
|
|
647
|
+
if (normalizeAddress(finalOrder.askToken) !== normalizeAddress(destinationToken.address)) {
|
|
536
648
|
throw new Error("ZeroDelta quote returned an ask token that does not match the destination asset.");
|
|
537
649
|
}
|
|
538
|
-
if (Number(
|
|
650
|
+
if (Number(finalOrder.destinationChainId) !== Number(destination.chainId) || Number(quote.toChainId) !== Number(destination.chainId)) {
|
|
539
651
|
throw new Error("ZeroDelta quote returned a destination chain that does not match the payment request.");
|
|
540
652
|
}
|
|
541
653
|
if (Number(quote.fromChainId) !== Number(option.chainId)) {
|
|
@@ -544,24 +656,38 @@ function assertQuoteMatchesSelection({ quote, order, option, destinationToken, d
|
|
|
544
656
|
if (symbolKey(quote.fromToken) !== option.symbolKey || symbolKey(quote.toToken) !== symbolKey(destinationToken.symbol)) {
|
|
545
657
|
throw new Error("ZeroDelta quote returned token symbols that do not match the selected route.");
|
|
546
658
|
}
|
|
547
|
-
if (BigInt(
|
|
659
|
+
if (BigInt(sourceOrder.bidTokenAmount || "0") !== BigInt(result.youPayRaw || "0")) {
|
|
548
660
|
throw new Error("ZeroDelta quote returned a bid amount that does not match the displayed payment amount.");
|
|
549
661
|
}
|
|
550
|
-
if (BigInt(
|
|
662
|
+
if (BigInt(finalOrder.askTokenAmount || "0") !== BigInt(quote.toAmount || "0")) {
|
|
551
663
|
throw new Error("ZeroDelta quote returned an ask amount that does not match the quoted output.");
|
|
552
664
|
}
|
|
553
|
-
if (BigInt(
|
|
665
|
+
if (BigInt(finalOrder.askTokenAmount || "0") <= 0n || BigInt(quote.toAmount || "0") <= 0n) {
|
|
554
666
|
throw new Error("ZeroDelta quote returned a non-positive output amount.");
|
|
555
667
|
}
|
|
556
|
-
if (BigInt(
|
|
668
|
+
if (BigInt(finalOrder.askTokenAmount || "0") < BigInt(result.targetRaw || "0")) {
|
|
557
669
|
throw new Error("ZeroDelta quote would not cover the requested destination amount.");
|
|
558
670
|
}
|
|
559
|
-
if (BigInt(
|
|
671
|
+
if (BigInt(finalOrder.askTokenAmount || "0") < BigInt(result.recipientReceivesRaw || "0")) {
|
|
560
672
|
throw new Error("ZeroDelta order guarantees less than the displayed receive amount.");
|
|
561
673
|
}
|
|
562
|
-
if (!Number.isFinite(deadline) || deadline <= now || deadline > now +
|
|
674
|
+
if (!Number.isFinite(deadline) || deadline <= now || deadline > now + MAX_DEADLINE_SECONDS) {
|
|
563
675
|
throw new Error("ZeroDelta quote deadline is invalid or too far in the future.");
|
|
564
676
|
}
|
|
677
|
+
for (let index = 1; index < list.length; index += 1) {
|
|
678
|
+
const previous = list[index - 1];
|
|
679
|
+
const current = list[index];
|
|
680
|
+
if (normalizeAddress(previous.askToken) !== normalizeAddress(current.bidToken)) {
|
|
681
|
+
throw new Error("ZeroDelta chained quote returned disconnected order tokens.");
|
|
682
|
+
}
|
|
683
|
+
if (Number(previous.destinationChainId) !== Number(current.executionChainId)) {
|
|
684
|
+
throw new Error("ZeroDelta chained quote returned disconnected execution chains.");
|
|
685
|
+
}
|
|
686
|
+
const followupDeadline = Number(current.deadline || 0);
|
|
687
|
+
if (followupDeadline !== 0 && (!Number.isFinite(followupDeadline) || followupDeadline <= now || followupDeadline > now + MAX_DEADLINE_SECONDS)) {
|
|
688
|
+
throw new Error("ZeroDelta chained quote returned an invalid follow-up deadline.");
|
|
689
|
+
}
|
|
690
|
+
}
|
|
565
691
|
}
|
|
566
692
|
|
|
567
693
|
// src/core/route.ts
|
|
@@ -628,11 +754,13 @@ async function buildRoute({ option, destination, destinationToken, chains, payer
|
|
|
628
754
|
}
|
|
629
755
|
};
|
|
630
756
|
}
|
|
631
|
-
|
|
757
|
+
const requestList = quote.orderRequests?.length ? quote.orderRequests : quote.orderRequest ? [quote.orderRequest] : [];
|
|
758
|
+
if (!requestList.length) throw new Error("ZeroDelta quote did not include an order request.");
|
|
632
759
|
const sourceChain = chainById(chains, option.chainId);
|
|
633
760
|
const escrow = checkEscrow(option.chainId, quote.escrowAddress, sourceChain?.escrowContract);
|
|
634
|
-
const
|
|
635
|
-
|
|
761
|
+
const orders = normalizeOrderRequests(requestList, payer, destination, quote.executionChainId);
|
|
762
|
+
const order = orders[0];
|
|
763
|
+
assertQuoteMatchesSelection({ quote, order, orders, option, destinationToken, destination, payer, result });
|
|
636
764
|
const needsNativeFee = requiresNativeBridgeFee(quote, option);
|
|
637
765
|
if (needsNativeFee) {
|
|
638
766
|
let rawFee;
|
|
@@ -693,7 +821,7 @@ async function buildRoute({ option, destination, destinationToken, chains, payer
|
|
|
693
821
|
label: "Submit ZeroDelta order",
|
|
694
822
|
chainId: option.chainId,
|
|
695
823
|
to: escrow,
|
|
696
|
-
data: encodeSubmitOrder(
|
|
824
|
+
data: encodeSubmitOrder(orders),
|
|
697
825
|
value: toHexQuantity(valueRaw),
|
|
698
826
|
escrow,
|
|
699
827
|
amountRaw: order.bidTokenAmount
|
|
@@ -1133,7 +1261,12 @@ function validatePlannedTransaction(tx, route, expectedRecipient) {
|
|
|
1133
1261
|
if (tx.kind === "submitOrder") {
|
|
1134
1262
|
const expected = planMsgValueHex(route);
|
|
1135
1263
|
if (expected === null || value !== lower(expected)) return false;
|
|
1136
|
-
|
|
1264
|
+
if (selector !== SUBMIT_ORDER_SELECTOR || !isHexAddress(tx.escrow) || lower(tx.to) !== lower(tx.escrow)) return false;
|
|
1265
|
+
const decoded = decodeSubmitOrderCalldata(data);
|
|
1266
|
+
if (!decoded) return false;
|
|
1267
|
+
const first = decoded.orders[0];
|
|
1268
|
+
const last = decoded.orders[decoded.orders.length - 1];
|
|
1269
|
+
return decoded.partnerId === NO_PARTNER_ID && lower(first.bidToken) === lower(route.source.tokenAddress) && rawEquals(first.bidTokenAmount, tx.amountRaw) && lower(last.askToken) === lower(route.receive.tokenAddress) && Number(last.destinationChainId) === Number(route.receive.chainId) && lower(last.destinationReceiver) === lower(expectedRecipient);
|
|
1137
1270
|
}
|
|
1138
1271
|
return false;
|
|
1139
1272
|
}
|
|
@@ -2539,9 +2672,10 @@ var CHAIN_LABELS = {
|
|
|
2539
2672
|
8453: "Base",
|
|
2540
2673
|
9745: "Plasma",
|
|
2541
2674
|
57073: "Ink",
|
|
2542
|
-
42161: "Arbitrum"
|
|
2675
|
+
42161: "Arbitrum",
|
|
2676
|
+
98866: "Plume"
|
|
2543
2677
|
};
|
|
2544
|
-
var SUPPORTED_CHAINS = [1, 10, 42161, 8453, 57073, 130, 9745, 146];
|
|
2678
|
+
var SUPPORTED_CHAINS = [1, 10, 42161, 8453, 57073, 130, 9745, 146, 98866];
|
|
2545
2679
|
var SUPPORTED_ASSETS2 = ["USDC", "USDT", "USDE", "XAUT"];
|
|
2546
2680
|
function Button(props) {
|
|
2547
2681
|
const soft = !!props.softDisabled && !props.disabled;
|
|
@@ -2740,7 +2874,8 @@ var CHAIN_SHORT = {
|
|
|
2740
2874
|
8453: "BASE",
|
|
2741
2875
|
9745: "PLS",
|
|
2742
2876
|
57073: "INK",
|
|
2743
|
-
42161: "ARB"
|
|
2877
|
+
42161: "ARB",
|
|
2878
|
+
98866: "PLM"
|
|
2744
2879
|
};
|
|
2745
2880
|
function isHttpsUrl(u) {
|
|
2746
2881
|
return typeof u === "string" && /^https:\/\//i.test(u);
|
package/dist/mount.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { M as MountConfig, q as mount } from './mount-
|
|
1
|
+
export { M as MountConfig, q as mount } from './mount-DNvmtX0y.cjs';
|
|
2
2
|
import 'react';
|
|
3
|
-
import './verify-
|
|
3
|
+
import './verify-7lk90Ado.cjs';
|
package/dist/mount.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { M as MountConfig, q as mount } from './mount-
|
|
1
|
+
export { M as MountConfig, q as mount } from './mount-jxrT-DMe.js';
|
|
2
2
|
import 'react';
|
|
3
|
-
import './verify-
|
|
3
|
+
import './verify-7lk90Ado.js';
|
package/dist/mount.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { mount } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { mount } from './chunk-NSH3PT2J.js';
|
|
2
|
+
import './chunk-OOURZ5DL.js';
|