@anywalletkit/protocol-swap2-router 0.0.0-stage → 0.2.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 +70 -2
- package/dist/chunk-6WXEWTIF.js +296 -0
- package/dist/chunk-6WXEWTIF.js.map +1 -0
- package/dist/chunk-ATQMEXTG.js +98 -0
- package/dist/chunk-ATQMEXTG.js.map +1 -0
- package/dist/chunk-VRUHVDAX.js +78 -0
- package/dist/chunk-VRUHVDAX.js.map +1 -0
- package/dist/index.cjs +487 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/router.cjs +316 -0
- package/dist/router.cjs.map +1 -0
- package/dist/router.d.cts +118 -0
- package/dist/router.d.ts +118 -0
- package/dist/router.js +7 -0
- package/dist/router.js.map +1 -0
- package/dist/swap2/router.cjs +386 -0
- package/dist/swap2/router.cjs.map +1 -0
- package/dist/swap2/router.d.cts +100 -0
- package/dist/swap2/router.d.ts +100 -0
- package/dist/swap2/router.js +8 -0
- package/dist/swap2/router.js.map +1 -0
- package/dist/value.cjs +118 -0
- package/dist/value.cjs.map +1 -0
- package/dist/value.d.cts +51 -0
- package/dist/value.d.ts +51 -0
- package/dist/value.js +9 -0
- package/dist/value.js.map +1 -0
- package/module.json +20 -0
- package/package.json +69 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,71 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @anywalletkit/protocol-swap2-router
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The optional swap2 aggregator. Every provider module (`-lifi`, `-near-intents`, `-thorchain`,
|
|
4
|
+
`-omniston`, `-cctp`, `-uniswap`, `-balancer`, `-wrap`) works on its own; install this package when
|
|
5
|
+
you want one protocol that auctions a route across the providers **you** pass in. It bundles none.
|
|
6
|
+
|
|
7
|
+
## Three ways to offer cross-chain swaps
|
|
8
|
+
|
|
9
|
+
**1. One protocol, no aggregator.** Install a single provider and use its own protocol class.
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import {LifiSwap2Protocol} from "@anywalletkit/protocol-swap2-lifi";
|
|
13
|
+
const swap2 = new LifiSwap2Protocol(account, {fromChain: "eip155:1"});
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
**2. Aggregator picks for the user.** Quotes every provider in parallel, validates each quote the
|
|
17
|
+
same way and executes the winner.
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import {RouterSwap2Protocol, usdValue} from "@anywalletkit/protocol-swap2-router";
|
|
21
|
+
|
|
22
|
+
const swap2 = new RouterSwap2Protocol(account, {
|
|
23
|
+
fromChain: "eip155:1",
|
|
24
|
+
providers: [lifiProvider({}), nearIntentsProvider({}), cctpProvider({rpcUrls})],
|
|
25
|
+
valueUsd: usdValue(prices), // optional: rank on net USD (see below)
|
|
26
|
+
prefer: "best", // or "fastest"
|
|
27
|
+
});
|
|
28
|
+
await swap2.swap2({fromToken: "USDC", toToken, toChain: "eip155:8453", fromTokenAmount, minAmountOut});
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**3. Aggregator with a route picker.** List every route with the best and the fastest tagged, let
|
|
32
|
+
the user choose, then execute exactly that provider.
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
const routes = await swap2.quoteSwap2Routes(options, {
|
|
36
|
+
// Called each time another provider answers: show the first price at once,
|
|
37
|
+
// a "searching…" hint while `pending` is non-empty.
|
|
38
|
+
onUpdate: (routes, pending) => render(routes, pending),
|
|
39
|
+
});
|
|
40
|
+
// routes[i] = {provider, quote, netValueUsd, relativeValue, tags: ["best"] | ["fastest"] | …}
|
|
41
|
+
await swap2.using(picked.provider).swap2({...options, minAmountOut: picked.quote.toTokenAmountMin});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
The same is available one level down on `CrossChainRouter#getQuotes(params, {onUpdate})`.
|
|
45
|
+
|
|
46
|
+
## How the winner is chosen
|
|
47
|
+
|
|
48
|
+
1. **Value.** With `valueUsd` (e.g. `usdValue(prices, {gasUsd})`) each quote is worth its guaranteed
|
|
49
|
+
output in USD minus what the route charges on top: a native bridge fee and, when you can say it,
|
|
50
|
+
the source gas. Without prices for every quote the auction compares guaranteed outputs.
|
|
51
|
+
2. **Price first.** Quotes within `tieBand` (default 0.2%) of the best value are the same price.
|
|
52
|
+
3. **Speed and reliability inside the tie.** Among equal prices the faster, then the more reliable,
|
|
53
|
+
route wins (`weights`, default `price:0.6,speed:0.3,reliability:0.1`). A sliver of extra output no
|
|
54
|
+
longer beats a route that lands twenty times faster; a real price gap still wins.
|
|
55
|
+
|
|
56
|
+
`fastest` is always the lowest ETA. Every quote passes the engine's checks before it is ranked, and
|
|
57
|
+
the executed route is re-validated against its sealed quote before anything is signed.
|
|
58
|
+
|
|
59
|
+
## Activity
|
|
60
|
+
|
|
61
|
+
The router executes through whichever provider wins, so it has no transactions
|
|
62
|
+
of its own: `describeActivity(tx, ctx)` asks every installed provider in order
|
|
63
|
+
and returns the first description (null when none claims the transaction, or
|
|
64
|
+
when the router holds no providers). Each provider package documents what it
|
|
65
|
+
recognizes (`@anywalletkit/protocol-swap2-lifi` → LI.FI Diamond calls,
|
|
66
|
+
`-thorchain` → router `depositWithExpiry` / `transferOut`, `-cctp` → burn and
|
|
67
|
+
claim, `-uniswap` / `-balancer` / `-wrap` → the DEX router / Vault / WETH9 calls,
|
|
68
|
+
`-omniston` → STON.fi router and Omniston escrow on TON, `-near-intents` → the
|
|
69
|
+
`intents.near` legs). The conformance fixture here is a public WETH9 deposit
|
|
70
|
+
recognized by an in-test provider, proving the delegation; the negative is a
|
|
71
|
+
LI.FI swap no installed provider claims.
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
// src/router.ts
|
|
2
|
+
import { validQuote } from "@anywalletkit/protocol-swap2-core/validate";
|
|
3
|
+
var DEFAULT_WEIGHTS = { price: 0.6, speed: 0.3, reliability: 0.1 };
|
|
4
|
+
var DEFAULT_TIE_BAND = 2e-3;
|
|
5
|
+
var QUOTE_TIMEOUT_MS = 8e3;
|
|
6
|
+
var SOLO_QUOTE_TIMEOUT_MS = 25e3;
|
|
7
|
+
function parseWeights(spec) {
|
|
8
|
+
if (!spec) return DEFAULT_WEIGHTS;
|
|
9
|
+
const w = { ...DEFAULT_WEIGHTS };
|
|
10
|
+
for (const part of spec.split(",")) {
|
|
11
|
+
const [k, v] = part.split(":");
|
|
12
|
+
const n = Number(v);
|
|
13
|
+
if ((k === "price" || k === "speed" || k === "reliability") && Number.isFinite(n)) {
|
|
14
|
+
w[k] = Math.max(0, n);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return w;
|
|
18
|
+
}
|
|
19
|
+
async function withTimeout(p, ms) {
|
|
20
|
+
return new Promise((resolve, reject) => {
|
|
21
|
+
const timer = setTimeout(() => reject(new Error(`quote timed out after ${ms}ms`)), ms);
|
|
22
|
+
p.then(resolve, reject).finally(() => clearTimeout(timer));
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
var CrossChainRouter = class _CrossChainRouter {
|
|
26
|
+
providers;
|
|
27
|
+
/** Why the venues of the LAST getBestQuote call sat out — for error surfaces. */
|
|
28
|
+
_lastRejections = [];
|
|
29
|
+
/** Why providers sat out the last auction, one line each. */
|
|
30
|
+
get lastRejections() {
|
|
31
|
+
return this._lastRejections;
|
|
32
|
+
}
|
|
33
|
+
weights;
|
|
34
|
+
valueUsd;
|
|
35
|
+
tieBand;
|
|
36
|
+
options;
|
|
37
|
+
constructor(providers, options) {
|
|
38
|
+
const opts = typeof options === "string" ? { weights: options } : { ...options ?? {} };
|
|
39
|
+
if (opts.tieBand !== void 0 && !(Number.isFinite(opts.tieBand) && opts.tieBand >= 0 && opts.tieBand < 1)) {
|
|
40
|
+
throw new Error("cross-chain router: tieBand must be a fraction in [0, 1)");
|
|
41
|
+
}
|
|
42
|
+
const names = /* @__PURE__ */ new Set();
|
|
43
|
+
for (const provider of providers) {
|
|
44
|
+
if (typeof provider.name !== "string" || !/^[A-Za-z0-9_-]+$/.test(provider.name) || names.has(provider.name)) {
|
|
45
|
+
throw new Error(`cross-chain router: invalid or duplicate provider name '${String(provider.name)}'`);
|
|
46
|
+
}
|
|
47
|
+
names.add(provider.name);
|
|
48
|
+
}
|
|
49
|
+
this.providers = providers.map((provider) => ({
|
|
50
|
+
name: provider.name,
|
|
51
|
+
enabled: provider.enabled.bind(provider),
|
|
52
|
+
supportsRoute: provider.supportsRoute.bind(provider),
|
|
53
|
+
getQuote: provider.getQuote.bind(provider),
|
|
54
|
+
buildDeposit: provider.buildDeposit.bind(provider),
|
|
55
|
+
trackIntent: provider.trackIntent.bind(provider),
|
|
56
|
+
...provider.preflightDeposit ? { preflightDeposit: provider.preflightDeposit.bind(provider) } : {},
|
|
57
|
+
...provider.notifyDeposit ? { notifyDeposit: provider.notifyDeposit.bind(provider) } : {},
|
|
58
|
+
...provider.registerSignedOrder ? { registerSignedOrder: provider.registerSignedOrder.bind(provider) } : {},
|
|
59
|
+
// Two-phase routes (CCTP): the destination claim. Missing here, the engine
|
|
60
|
+
// and the server both reported "provider 'cctp' has no claim step" (2026-10-13).
|
|
61
|
+
...provider.buildClaim ? { buildClaim: provider.buildClaim.bind(provider) } : {},
|
|
62
|
+
...provider.close ? { close: provider.close.bind(provider) } : {},
|
|
63
|
+
...provider.supportsChain ? { supportsChain: provider.supportsChain.bind(provider) } : {},
|
|
64
|
+
...provider.supportsChainPair ? { supportsChainPair: provider.supportsChainPair.bind(provider) } : {},
|
|
65
|
+
...provider.describeActivity ? { describeActivity: provider.describeActivity.bind(provider) } : {},
|
|
66
|
+
...provider.supportsSameChain !== void 0 ? { supportsSameChain: provider.supportsSameChain } : {}
|
|
67
|
+
}));
|
|
68
|
+
this.weights = parseWeights(opts.weights);
|
|
69
|
+
this.valueUsd = opts.valueUsd;
|
|
70
|
+
this.tieBand = opts.tieBand ?? DEFAULT_TIE_BAND;
|
|
71
|
+
this.options = opts;
|
|
72
|
+
}
|
|
73
|
+
/** The same auction restricted to one provider — to execute the route a user picked. */
|
|
74
|
+
only(name) {
|
|
75
|
+
const provider = this.getProvider(name);
|
|
76
|
+
if (!provider) throw new Error(`cross-chain router: provider '${name}' is not registered`);
|
|
77
|
+
return new _CrossChainRouter([provider], this.options);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Activity recognition across the installed providers: the first one that
|
|
81
|
+
* claims the transaction describes it. Null when none does (or none is held).
|
|
82
|
+
*/
|
|
83
|
+
describeActivity(tx, ctx) {
|
|
84
|
+
for (const provider of this.providers) {
|
|
85
|
+
const item = provider.describeActivity?.(tx, ctx);
|
|
86
|
+
if (item) return item;
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
/** A provider by name. */
|
|
91
|
+
getProvider(name) {
|
|
92
|
+
return this.providers.find((p) => p.name === name);
|
|
93
|
+
}
|
|
94
|
+
/** True when a provider of that name is installed. */
|
|
95
|
+
hasProvider(name) {
|
|
96
|
+
return this.providers.some((p) => p.name === name);
|
|
97
|
+
}
|
|
98
|
+
/** True when that provider is installed and enabled. */
|
|
99
|
+
hasEnabledProvider(name) {
|
|
100
|
+
return this.providers.some((p) => {
|
|
101
|
+
try {
|
|
102
|
+
return p.name === name && p.enabled();
|
|
103
|
+
} catch {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
/** True when any enabled provider declares the chain. */
|
|
109
|
+
supportsChain(caip2) {
|
|
110
|
+
return this.providers.some((p) => {
|
|
111
|
+
try {
|
|
112
|
+
return p.enabled() && !!p.supportsChain?.(caip2);
|
|
113
|
+
} catch {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
/** True when any enabled provider declares the chain pair. */
|
|
119
|
+
supportsChainPair(fromChain, toChain) {
|
|
120
|
+
return this.providers.some((p) => {
|
|
121
|
+
try {
|
|
122
|
+
return p.enabled() && (p.supportsChainPair?.(fromChain, toChain) ?? false);
|
|
123
|
+
} catch {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* The auction's pick: the best price (net of native fees and gas when
|
|
130
|
+
* `valueUsd` is set; faster, then more reliable, among equal prices), or
|
|
131
|
+
* the fastest route with `prefer: "fastest"`.
|
|
132
|
+
*/
|
|
133
|
+
async getBestQuote(params, options) {
|
|
134
|
+
const set = await this.getQuotes(params, options);
|
|
135
|
+
if (!set) return null;
|
|
136
|
+
const pick = options?.prefer === "fastest" ? set.fastest : set.best;
|
|
137
|
+
const { netValueUsd: _n, relativeValue: _r, tags: _t, ...quote } = pick;
|
|
138
|
+
return {
|
|
139
|
+
...quote,
|
|
140
|
+
routeScore: {
|
|
141
|
+
score: pick.relativeValue,
|
|
142
|
+
weights: this.weights,
|
|
143
|
+
candidates: set.quotes.map((q) => ({
|
|
144
|
+
provider: q.provider,
|
|
145
|
+
sourceAmount: q.sourceAmount,
|
|
146
|
+
etaSeconds: q.etaSeconds,
|
|
147
|
+
score: q.relativeValue,
|
|
148
|
+
minDestAmount: q.minDestAmount,
|
|
149
|
+
netValueUsd: q.netValueUsd
|
|
150
|
+
}))
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Every validated route, ranked — for a route picker that shows the best and
|
|
156
|
+
* the fastest and lets the user choose. Providers run in parallel; with
|
|
157
|
+
* `onUpdate` each one that answers re-publishes the ranked set at once (the
|
|
158
|
+
* first price shows in the time of the fastest venue, not the slowest).
|
|
159
|
+
*/
|
|
160
|
+
async getQuotes(params, options) {
|
|
161
|
+
const rejections = [];
|
|
162
|
+
this._lastRejections = rejections;
|
|
163
|
+
const snapshot = Object.freeze({ ...params });
|
|
164
|
+
const from = Object.freeze({ chain: snapshot.sourceChain, token: snapshot.sourceToken });
|
|
165
|
+
const to = Object.freeze({ chain: snapshot.destChain, token: snapshot.destToken });
|
|
166
|
+
let eligible = this.providers.filter((p) => {
|
|
167
|
+
try {
|
|
168
|
+
return p.enabled() && p.supportsRoute(from, to);
|
|
169
|
+
} catch {
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
if (snapshot.sourceChain === snapshot.destChain) {
|
|
174
|
+
eligible = eligible.filter((p) => p.supportsSameChain === true);
|
|
175
|
+
}
|
|
176
|
+
if (eligible.length === 0) return null;
|
|
177
|
+
const timeoutMs = eligible.length === 1 ? SOLO_QUOTE_TIMEOUT_MS : QUOTE_TIMEOUT_MS;
|
|
178
|
+
const refusals = [];
|
|
179
|
+
const accepted = [];
|
|
180
|
+
const pending = new Set(eligible.map((p) => p.name));
|
|
181
|
+
const publish = () => {
|
|
182
|
+
if (!options?.onUpdate || accepted.length === 0) return;
|
|
183
|
+
const set = this.rank(accepted, snapshot, [...pending], rejections);
|
|
184
|
+
try {
|
|
185
|
+
options.onUpdate(set);
|
|
186
|
+
} catch {
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
await Promise.all(eligible.map(async (p, i) => {
|
|
190
|
+
const controller = new AbortController();
|
|
191
|
+
const own = Object.freeze({ ...snapshot, onRefusal: (reason) => {
|
|
192
|
+
refusals[i] ??= reason.startsWith(`${p.name}:`) ? reason : `${p.name}: ${reason}`;
|
|
193
|
+
try {
|
|
194
|
+
snapshot.onRefusal?.(reason);
|
|
195
|
+
} catch {
|
|
196
|
+
}
|
|
197
|
+
} });
|
|
198
|
+
let q = null;
|
|
199
|
+
try {
|
|
200
|
+
q = await withTimeout(p.getQuote(own, controller.signal), timeoutMs);
|
|
201
|
+
if (!q) {
|
|
202
|
+
rejections.push(refusals[i] ?? `${p.name}: returned no quote`);
|
|
203
|
+
} else if (!validQuote(q, snapshot, p.name)) {
|
|
204
|
+
const reason = `${p.name}: rejected by validation (minDest=${q.minDestAmount} vs floor=${snapshot.minAmountOut ?? "-"}, validUntil=${q.validUntilMs}, now=${Date.now()})`;
|
|
205
|
+
rejections.push(reason);
|
|
206
|
+
console.warn(`swap2-router: ${reason}`);
|
|
207
|
+
q = null;
|
|
208
|
+
} else if (options?.requireImmediateExecution && !(q.depositAddress.length > 0 || q.txRequest !== void 0)) {
|
|
209
|
+
q = null;
|
|
210
|
+
}
|
|
211
|
+
} catch (err) {
|
|
212
|
+
const reason = `${p.name}: ${err instanceof Error ? err.message.slice(0, 160) : String(err).slice(0, 160)}`;
|
|
213
|
+
rejections.push(reason);
|
|
214
|
+
console.warn(`swap2-router: quote failed \u2014 ${reason}`);
|
|
215
|
+
q = null;
|
|
216
|
+
} finally {
|
|
217
|
+
controller.abort();
|
|
218
|
+
}
|
|
219
|
+
pending.delete(p.name);
|
|
220
|
+
if (q) accepted.push({ ...q, provider: p.name });
|
|
221
|
+
publish();
|
|
222
|
+
}));
|
|
223
|
+
if (accepted.length === 0) return null;
|
|
224
|
+
return this.rank(accepted, snapshot, [], rejections);
|
|
225
|
+
}
|
|
226
|
+
/** Status from the named provider; `failed` when it is not installed. */
|
|
227
|
+
async trackIntent(providerName, ref) {
|
|
228
|
+
const provider = this.getProvider(providerName);
|
|
229
|
+
if (!provider) return { state: "failed" };
|
|
230
|
+
return provider.trackIntent(ref);
|
|
231
|
+
}
|
|
232
|
+
/** Forward a source-broadcast notification to the intent's provider. */
|
|
233
|
+
async notifyDeposit(providerName, intentId, txHash) {
|
|
234
|
+
await this.getProvider(providerName)?.notifyDeposit?.(intentId, txHash);
|
|
235
|
+
}
|
|
236
|
+
/** Release every provider's resources. */
|
|
237
|
+
close() {
|
|
238
|
+
for (const provider of this.providers) provider.close?.();
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Price first: each quote's value is its net USD (`valueUsd`) — or, when any
|
|
242
|
+
* quote cannot be priced, its guaranteed output — against the best one.
|
|
243
|
+
* Quotes within `tieBand` of the best are the same price; among those the
|
|
244
|
+
* weights order speed and reliability. A $0.01 edge no longer beats a route
|
|
245
|
+
* that lands in seconds instead of twenty minutes, and a route that charges
|
|
246
|
+
* a native bridge fee on top no longer wins on its gross output.
|
|
247
|
+
*/
|
|
248
|
+
rank(quotes, params, pending, rejections) {
|
|
249
|
+
const usd = this.valueUsd ? quotes.map((q) => {
|
|
250
|
+
try {
|
|
251
|
+
const v = this.valueUsd(q, params);
|
|
252
|
+
return typeof v === "number" && Number.isFinite(v) ? v : null;
|
|
253
|
+
} catch {
|
|
254
|
+
return null;
|
|
255
|
+
}
|
|
256
|
+
}) : quotes.map(() => null);
|
|
257
|
+
const priced = usd.every((v) => v !== null);
|
|
258
|
+
let relative;
|
|
259
|
+
if (priced) {
|
|
260
|
+
const values = usd;
|
|
261
|
+
const max = Math.max(...values);
|
|
262
|
+
relative = values.map((v) => max > 0 ? Math.max(0, v) / max : v >= max ? 1 : 0);
|
|
263
|
+
} else {
|
|
264
|
+
const outs = quotes.map((q) => BigInt(q.minDestAmount));
|
|
265
|
+
const max = outs.reduce((a, b) => b > a ? b : a);
|
|
266
|
+
relative = outs.map((o) => fraction(o, max));
|
|
267
|
+
}
|
|
268
|
+
const ranked = quotes.map((q, i) => ({
|
|
269
|
+
...q,
|
|
270
|
+
netValueUsd: priced ? usd[i] : null,
|
|
271
|
+
relativeValue: relative[i],
|
|
272
|
+
tags: []
|
|
273
|
+
}));
|
|
274
|
+
const tier = ranked.filter((q) => q.relativeValue >= 1 - this.tieBand - 1e-12);
|
|
275
|
+
const etas = tier.map((q) => q.etaSeconds);
|
|
276
|
+
const minEta = Math.min(...etas);
|
|
277
|
+
const maxEta = Math.max(...etas);
|
|
278
|
+
const w = this.weights;
|
|
279
|
+
const tieScore = (q) => w.price * q.relativeValue + w.speed * (maxEta === minEta ? 1 : (maxEta - q.etaSeconds) / (maxEta - minEta)) + w.reliability * q.reliability;
|
|
280
|
+
const best = tier.reduce((a, b) => tieScore(b) > tieScore(a) ? b : a);
|
|
281
|
+
const fastest = ranked.reduce((a, b) => b.etaSeconds < a.etaSeconds || b.etaSeconds === a.etaSeconds && b.relativeValue > a.relativeValue ? b : a);
|
|
282
|
+
best.tags.push("best");
|
|
283
|
+
fastest.tags.push("fastest");
|
|
284
|
+
ranked.sort((a, b) => a === best ? -1 : b === best ? 1 : b.relativeValue - a.relativeValue || a.etaSeconds - b.etaSeconds);
|
|
285
|
+
return { quotes: ranked, best, fastest, pending, rejections: [...rejections] };
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
function fraction(num, den) {
|
|
289
|
+
if (den === 0n) return 1;
|
|
290
|
+
return Number(num * 10000n / den) / 1e4;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export {
|
|
294
|
+
CrossChainRouter
|
|
295
|
+
};
|
|
296
|
+
//# sourceMappingURL=chunk-6WXEWTIF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/router.ts"],"sourcesContent":["/**\n * The auction engine of the optional aggregator: routes a cross-chain delivery\n * over whichever providers the caller installed and passed in. Protocol\n * modules never need it — each one runs standalone on @anywalletkit/protocol-swap2-core.\n */\nimport type {\n CrossChainProvider,\n IntentRef,\n IntentStatus,\n Quote,\n QuoteParams,\n RoutedQuote,\n ScoreWeights,\n} from \"@anywalletkit/protocol-swap2-core/types\";\nimport {validQuote} from \"@anywalletkit/protocol-swap2-core/validate\";\nimport type {ActivityItem, ChainTx, DescribeActivityContext} from \"@anywalletkit/core\";\n\nconst DEFAULT_WEIGHTS: ScoreWeights = {price: 0.6, speed: 0.3, reliability: 0.1};\n/** Quotes within 0.2% of the best net value count as the same price. */\nconst DEFAULT_TIE_BAND = 0.002;\n\nexport interface RouterOptions {\n /**\n * \"price:0.6,speed:0.3,reliability:0.1\" — how quotes inside the tie band\n * (same price, within `tieBand`) are ordered. Price itself always leads.\n */\n weights?: string;\n /**\n * What a quote is worth to the user in USD: its guaranteed output minus what\n * the route charges on top (a native bridge fee, the source gas). Return null\n * when it cannot be priced — the auction then compares guaranteed outputs.\n * `usdValue(prices)` builds one from a symbol → USD price map.\n */\n valueUsd?: (quote: Quote, params: QuoteParams) => number | null;\n /** Fraction of the best net value inside which quotes tie on price (default 0.002). */\n tieBand?: number;\n}\n\n/** A validated quote with its place in the auction. */\nexport interface RankedQuote extends Quote {\n /** Net USD value (`valueUsd`), or null when the auction compared raw outputs. */\n netValueUsd: number | null;\n /** This quote's value against the best one, 0..1 (1 = the best price). */\n relativeValue: number;\n /** \"best\": the pick (best price; faster/more reliable among equal prices). \"fastest\": the lowest ETA. */\n tags: (\"best\" | \"fastest\")[];\n}\n\n/** Every validated route for one request, ranked by value. */\nexport interface RouteSet {\n /** Every validated route, best first. */\n quotes: RankedQuote[];\n /** Most delivered value (net of fees when priced) within the tie band. */\n best: RankedQuote;\n /** Lowest ETA. */\n fastest: RankedQuote;\n /** Providers still quoting (only non-empty in progressive `onUpdate` snapshots). */\n pending: string[];\n /** Why the venues that sat out did (same as `lastRejections`). */\n rejections: string[];\n}\n// LI.FI's /quote routinely takes ~3.5s (it builds executable calldata) — 4s\n// raced it out of every round. All providers still run in parallel.\nconst QUOTE_TIMEOUT_MS = 8000;\n/** Pinned single-venue (execution) budget — see the comment at the call site. */\nconst SOLO_QUOTE_TIMEOUT_MS = 25_000;\n\nfunction parseWeights(spec?: string): ScoreWeights {\n if (!spec) return DEFAULT_WEIGHTS;\n const w = {...DEFAULT_WEIGHTS};\n for (const part of spec.split(\",\")) {\n const [k, v] = part.split(\":\");\n const n = Number(v);\n if ((k === \"price\" || k === \"speed\" || k === \"reliability\") && Number.isFinite(n)) {\n w[k] = Math.max(0, n);\n }\n }\n return w;\n}\n\nasync function withTimeout<T>(p: Promise<T>, ms: number): Promise<T | null> {\n return new Promise((resolve, reject) => {\n // Timeouts and failures must REJECT: the old `() => resolve(null)` arm\n // swallowed every provider error — including forwarded venue refusals —\n // into a null indistinguishable from \"no route\", which made execution\n // failures undiagnosable from the surface (the '(c2)' hunt of 2026-08-31).\n const timer = setTimeout(() => reject(new Error(`quote timed out after ${ms}ms`)), ms);\n p.then(resolve, reject).finally(() => clearTimeout(timer));\n });\n}\n\n/**\n * Routes a cross-chain delivery over pluggable providers: queries all that\n * support the route in parallel (with a timeout so a slow provider can't block),\n * normalizes their quotes, scores by configurable weights, and returns the best\n * tagged with `routeScore`. A failed/slow provider simply doesn't participate.\n */\nexport class CrossChainRouter {\n private readonly providers: CrossChainProvider[];\n /** Why the venues of the LAST getBestQuote call sat out — for error surfaces. */\n private _lastRejections: string[] = [];\n /** Why providers sat out the last auction, one line each. */\n get lastRejections(): readonly string[] {\n return this._lastRejections;\n }\n private readonly weights: ScoreWeights;\n private readonly valueUsd: RouterOptions[\"valueUsd\"];\n private readonly tieBand: number;\n private readonly options: RouterOptions;\n\n constructor(providers: CrossChainProvider[], options?: string | RouterOptions) {\n const opts: RouterOptions = typeof options === \"string\" ? {weights: options} : {...(options ?? {})};\n if (opts.tieBand !== undefined && !(Number.isFinite(opts.tieBand) && opts.tieBand >= 0 && opts.tieBand < 1)) {\n throw new Error(\"cross-chain router: tieBand must be a fraction in [0, 1)\");\n }\n const names = new Set<string>();\n for (const provider of providers) {\n if (typeof provider.name !== \"string\" || !/^[A-Za-z0-9_-]+$/.test(provider.name) || names.has(provider.name)) {\n throw new Error(`cross-chain router: invalid or duplicate provider name '${String(provider.name)}'`);\n }\n names.add(provider.name);\n }\n // Snapshot the dispatch surface. A caller mutating provider.name or method\n // properties after construction must not redirect quote→build/status.\n this.providers = providers.map((provider) => ({\n name: provider.name,\n enabled: provider.enabled.bind(provider),\n supportsRoute: provider.supportsRoute.bind(provider),\n getQuote: provider.getQuote.bind(provider),\n buildDeposit: provider.buildDeposit.bind(provider),\n trackIntent: provider.trackIntent.bind(provider),\n ...(provider.preflightDeposit ? {preflightDeposit: provider.preflightDeposit.bind(provider)} : {}),\n ...(provider.notifyDeposit ? {notifyDeposit: provider.notifyDeposit.bind(provider)} : {}),\n ...(provider.registerSignedOrder ? {registerSignedOrder: provider.registerSignedOrder.bind(provider)} : {}),\n // Two-phase routes (CCTP): the destination claim. Missing here, the engine\n // and the server both reported \"provider 'cctp' has no claim step\" (2026-10-13).\n ...(provider.buildClaim ? {buildClaim: provider.buildClaim.bind(provider)} : {}),\n ...(provider.close ? {close: provider.close.bind(provider)} : {}),\n ...(provider.supportsChain ? {supportsChain: provider.supportsChain.bind(provider)} : {}),\n ...(provider.supportsChainPair ? {supportsChainPair: provider.supportsChainPair.bind(provider)} : {}),\n ...(provider.describeActivity ? {describeActivity: provider.describeActivity.bind(provider)} : {}),\n ...(provider.supportsSameChain !== undefined ? {supportsSameChain: provider.supportsSameChain} : {}),\n }));\n this.weights = parseWeights(opts.weights);\n this.valueUsd = opts.valueUsd;\n this.tieBand = opts.tieBand ?? DEFAULT_TIE_BAND;\n this.options = opts;\n }\n\n /** The same auction restricted to one provider — to execute the route a user picked. */\n only(name: string): CrossChainRouter {\n const provider = this.getProvider(name);\n if (!provider) throw new Error(`cross-chain router: provider '${name}' is not registered`);\n return new CrossChainRouter([provider], this.options);\n }\n\n /**\n * Activity recognition across the installed providers: the first one that\n * claims the transaction describes it. Null when none does (or none is held).\n */\n describeActivity(tx: ChainTx, ctx: DescribeActivityContext): ActivityItem | null {\n for (const provider of this.providers) {\n const item = provider.describeActivity?.(tx, ctx);\n if (item) return item;\n }\n return null;\n }\n\n /** A provider by name. */\n getProvider(name: string): CrossChainProvider | undefined {\n return this.providers.find((p) => p.name === name);\n }\n\n /** True when a provider of that name is installed. */\n hasProvider(name: string): boolean {\n return this.providers.some((p) => p.name === name);\n }\n\n /** True when that provider is installed and enabled. */\n hasEnabledProvider(name: string): boolean {\n return this.providers.some((p) => {\n try { return p.name === name && p.enabled(); } catch { return false; }\n });\n }\n\n /** True when any enabled provider declares the chain. */\n supportsChain(caip2: string): boolean {\n return this.providers.some((p) => {\n try { return p.enabled() && !!p.supportsChain?.(caip2); } catch { return false; }\n });\n }\n\n /** True when any enabled provider declares the chain pair. */\n supportsChainPair(fromChain: string, toChain: string): boolean {\n return this.providers.some((p) => {\n try {\n return p.enabled() && (p.supportsChainPair?.(fromChain, toChain) ?? false);\n } catch { return false; }\n });\n }\n\n /**\n * The auction's pick: the best price (net of native fees and gas when\n * `valueUsd` is set; faster, then more reliable, among equal prices), or\n * the fastest route with `prefer: \"fastest\"`.\n */\n async getBestQuote(\n params: QuoteParams,\n options?: {requireImmediateExecution?: boolean; prefer?: \"best\" | \"fastest\"},\n ): Promise<RoutedQuote | null> {\n const set = await this.getQuotes(params, options);\n if (!set) return null;\n const pick = options?.prefer === \"fastest\" ? set.fastest : set.best;\n const {netValueUsd: _n, relativeValue: _r, tags: _t, ...quote} = pick;\n return {\n ...quote,\n routeScore: {\n score: pick.relativeValue,\n weights: this.weights,\n candidates: set.quotes.map((q) => ({\n provider: q.provider,\n sourceAmount: q.sourceAmount,\n etaSeconds: q.etaSeconds,\n score: q.relativeValue,\n minDestAmount: q.minDestAmount,\n netValueUsd: q.netValueUsd,\n })),\n },\n };\n }\n\n /**\n * Every validated route, ranked — for a route picker that shows the best and\n * the fastest and lets the user choose. Providers run in parallel; with\n * `onUpdate` each one that answers re-publishes the ranked set at once (the\n * first price shows in the time of the fastest venue, not the slowest).\n */\n async getQuotes(\n params: QuoteParams,\n options?: {requireImmediateExecution?: boolean; onUpdate?: (set: RouteSet) => void},\n ): Promise<RouteSet | null> {\n // A public engine caller — or one provider running in the same auction —\n // must not be able to rewrite another provider's request while async quote\n // work is in flight. QuoteParams is intentionally flat, so a frozen copy is\n // a complete execution snapshot.\n const rejections: string[] = [];\n this._lastRejections = rejections;\n const snapshot = Object.freeze({...params});\n const from = Object.freeze({chain: snapshot.sourceChain, token: snapshot.sourceToken});\n const to = Object.freeze({chain: snapshot.destChain, token: snapshot.destToken});\n // Only enabled (validated) providers that can serve the route participate.\n let eligible = this.providers.filter((p) => {\n try { return p.enabled() && p.supportsRoute(from, to); } catch { return false; }\n });\n if (snapshot.sourceChain === snapshot.destChain) {\n eligible = eligible.filter((p) => p.supportsSameChain === true);\n }\n if (eligible.length === 0) return null;\n\n // The short timeout protects the AUCTION — one slow venue must not hold\n // the others hostage. With a single eligible provider (a pinned execution\n // re-quote) there is nobody to protect, and a live deposit-creating quote\n // legitimately takes longer than a dry one (serverless hop + upstream\n // retries) — starving it surfaced as a terminal \"no route\" on execution.\n const timeoutMs = eligible.length === 1 ? SOLO_QUOTE_TIMEOUT_MS : QUOTE_TIMEOUT_MS;\n // Each venue names its own refusal (per call, so concurrent quotes cannot race).\n const refusals: (string | undefined)[] = [];\n const accepted: Quote[] = [];\n const pending = new Set(eligible.map((p) => p.name));\n const publish = () => {\n if (!options?.onUpdate || accepted.length === 0) return;\n const set = this.rank(accepted, snapshot, [...pending], rejections);\n try { options.onUpdate(set); } catch { /* an observer must not break the auction */ }\n };\n await Promise.all(eligible.map(async (p, i) => {\n const controller = new AbortController();\n const own = Object.freeze({...snapshot, onRefusal: (reason: string) => {\n refusals[i] ??= reason.startsWith(`${p.name}:`) ? reason : `${p.name}: ${reason}`;\n try { snapshot.onRefusal?.(reason); } catch { /* diagnostics only */ }\n }});\n let q: Quote | null = null;\n try {\n q = await withTimeout(p.getQuote(own, controller.signal), timeoutMs);\n if (!q) {\n // A provider RETURNING null (vs throwing) was the one silent path\n // left — record it so the surfaced no-route error names the venue.\n rejections.push(refusals[i] ?? `${p.name}: returned no quote`);\n } else if (!validQuote(q, snapshot, p.name)) {\n const reason = `${p.name}: rejected by validation (minDest=${q.minDestAmount} vs floor=${snapshot.minAmountOut ?? \"-\"}, validUntil=${q.validUntilMs}, now=${Date.now()})`;\n rejections.push(reason);\n console.warn(`swap2-router: ${reason}`);\n q = null;\n } else if (options?.requireImmediateExecution && !(q.depositAddress.length > 0 || q.txRequest !== undefined)) {\n // Legacy deposit-address screens cannot execute order-based quotes that\n // require a separate build/sign/register lifecycle.\n q = null;\n }\n } catch (err) {\n // A failed venue sitting out silently is indistinguishable from \"no\n // route\" — record why (surfaced through lastRejections) and say it in\n // the console (same posture as onModuleSkipped).\n const reason = `${p.name}: ${err instanceof Error ? err.message.slice(0, 160) : String(err).slice(0, 160)}`;\n rejections.push(reason);\n console.warn(`swap2-router: quote failed — ${reason}`);\n q = null;\n } finally {\n controller.abort();\n }\n pending.delete(p.name);\n // Provider identity is an execution security boundary. Never trust the\n // provider field returned by an untrusted adapter; bind it to its slot.\n if (q) accepted.push({...q, provider: p.name});\n publish();\n }));\n if (accepted.length === 0) return null;\n return this.rank(accepted, snapshot, [], rejections);\n }\n\n /** Status from the named provider; `failed` when it is not installed. */\n async trackIntent(providerName: string, ref: IntentRef): Promise<IntentStatus> {\n const provider = this.getProvider(providerName);\n if (!provider) return {state: \"failed\"};\n return provider.trackIntent(ref);\n }\n\n /** Forward a source-broadcast notification to the intent's provider. */\n async notifyDeposit(providerName: string, intentId: string, txHash: string): Promise<void> {\n await this.getProvider(providerName)?.notifyDeposit?.(intentId, txHash);\n }\n\n /** Release every provider's resources. */\n close(): void {\n for (const provider of this.providers) provider.close?.();\n }\n\n /**\n * Price first: each quote's value is its net USD (`valueUsd`) — or, when any\n * quote cannot be priced, its guaranteed output — against the best one.\n * Quotes within `tieBand` of the best are the same price; among those the\n * weights order speed and reliability. A $0.01 edge no longer beats a route\n * that lands in seconds instead of twenty minutes, and a route that charges\n * a native bridge fee on top no longer wins on its gross output.\n */\n private rank(quotes: Quote[], params: QuoteParams, pending: string[], rejections: string[]): RouteSet {\n const usd = this.valueUsd ? quotes.map((q) => {\n try {\n const v = this.valueUsd!(q, params);\n return typeof v === \"number\" && Number.isFinite(v) ? v : null;\n } catch { return null; }\n }) : quotes.map(() => null);\n const priced = usd.every((v) => v !== null);\n let relative: number[];\n if (priced) {\n const values = usd as number[];\n const max = Math.max(...values);\n relative = values.map((v) => (max > 0 ? Math.max(0, v) / max : v >= max ? 1 : 0));\n } else {\n const outs = quotes.map((q) => BigInt(q.minDestAmount));\n const max = outs.reduce((a, b) => (b > a ? b : a));\n relative = outs.map((o) => fraction(o, max));\n }\n const ranked: RankedQuote[] = quotes.map((q, i) => ({\n ...q,\n netValueUsd: priced ? usd[i]! : null,\n relativeValue: relative[i]!,\n tags: [],\n }));\n\n const tier = ranked.filter((q) => q.relativeValue >= 1 - this.tieBand - 1e-12);\n const etas = tier.map((q) => q.etaSeconds);\n const minEta = Math.min(...etas);\n const maxEta = Math.max(...etas);\n const w = this.weights;\n const tieScore = (q: RankedQuote) =>\n w.price * q.relativeValue +\n w.speed * (maxEta === minEta ? 1 : (maxEta - q.etaSeconds) / (maxEta - minEta)) +\n w.reliability * q.reliability;\n const best = tier.reduce((a, b) => (tieScore(b) > tieScore(a) ? b : a));\n const fastest = ranked.reduce((a, b) =>\n b.etaSeconds < a.etaSeconds || (b.etaSeconds === a.etaSeconds && b.relativeValue > a.relativeValue) ? b : a);\n best.tags.push(\"best\");\n fastest.tags.push(\"fastest\");\n\n // The list reads top-down by value; the pick leads its price tier.\n ranked.sort((a, b) => (a === best ? -1 : b === best ? 1 : b.relativeValue - a.relativeValue || a.etaSeconds - b.etaSeconds));\n return {quotes: ranked, best, fastest, pending, rejections: [...rejections]};\n }\n}\n\n/** Ratio of two non-negative bigints as a 0..1 number. */\nfunction fraction(num: bigint, den: bigint): number {\n if (den === 0n) return 1;\n // scale to keep precision, then to float\n return Number((num * 10_000n) / den) / 10_000;\n}\n"],"mappings":";AAcA,SAAQ,kBAAiB;AAGzB,IAAM,kBAAgC,EAAC,OAAO,KAAK,OAAO,KAAK,aAAa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