@anywalletkit/protocol-swap2-across 0.0.0-stage → 0.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/LICENSE +202 -0
- package/README.md +177 -2
- package/dist/activity.cjs +142 -0
- package/dist/activity.cjs.map +1 -0
- package/dist/activity.d.cts +16 -0
- package/dist/activity.d.ts +16 -0
- package/dist/activity.js +10 -0
- package/dist/activity.js.map +1 -0
- package/dist/api.cjs +441 -0
- package/dist/api.cjs.map +1 -0
- package/dist/api.d.cts +207 -0
- package/dist/api.d.ts +207 -0
- package/dist/api.js +35 -0
- package/dist/api.js.map +1 -0
- package/dist/build.cjs +776 -0
- package/dist/build.cjs.map +1 -0
- package/dist/build.d.cts +93 -0
- package/dist/build.d.ts +93 -0
- package/dist/build.js +14 -0
- package/dist/build.js.map +1 -0
- package/dist/chunk-32YJEBZX.js +125 -0
- package/dist/chunk-32YJEBZX.js.map +1 -0
- package/dist/chunk-3UBRQ3ZE.js +255 -0
- package/dist/chunk-3UBRQ3ZE.js.map +1 -0
- package/dist/chunk-5BDZXOOP.js +21 -0
- package/dist/chunk-5BDZXOOP.js.map +1 -0
- package/dist/chunk-6Z4GXNLE.js +102 -0
- package/dist/chunk-6Z4GXNLE.js.map +1 -0
- package/dist/chunk-AWQT5S4V.js +101 -0
- package/dist/chunk-AWQT5S4V.js.map +1 -0
- package/dist/chunk-E5WFOPN2.js +16 -0
- package/dist/chunk-E5WFOPN2.js.map +1 -0
- package/dist/chunk-GX67FRPG.js +194 -0
- package/dist/chunk-GX67FRPG.js.map +1 -0
- package/dist/chunk-KATEONJQ.js +396 -0
- package/dist/chunk-KATEONJQ.js.map +1 -0
- package/dist/chunk-P32AW6XS.js +27 -0
- package/dist/chunk-P32AW6XS.js.map +1 -0
- package/dist/chunk-PPPZIG7S.js +265 -0
- package/dist/chunk-PPPZIG7S.js.map +1 -0
- package/dist/chunk-SJOFLM27.js +138 -0
- package/dist/chunk-SJOFLM27.js.map +1 -0
- package/dist/chunk-YGNP7KPL.js +311 -0
- package/dist/chunk-YGNP7KPL.js.map +1 -0
- package/dist/config.cjs +214 -0
- package/dist/config.cjs.map +1 -0
- package/dist/config.d.cts +119 -0
- package/dist/config.d.ts +119 -0
- package/dist/config.js +47 -0
- package/dist/config.js.map +1 -0
- package/dist/deposit.cjs +252 -0
- package/dist/deposit.cjs.map +1 -0
- package/dist/deposit.d.cts +95 -0
- package/dist/deposit.d.ts +95 -0
- package/dist/deposit.js +19 -0
- package/dist/deposit.js.map +1 -0
- package/dist/index.cjs +1789 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +34 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +242 -0
- package/dist/index.js.map +1 -0
- package/dist/pricing.cjs +132 -0
- package/dist/pricing.cjs.map +1 -0
- package/dist/pricing.d.cts +123 -0
- package/dist/pricing.d.ts +123 -0
- package/dist/pricing.js +42 -0
- package/dist/pricing.js.map +1 -0
- package/dist/protocol.cjs +1596 -0
- package/dist/protocol.cjs.map +1 -0
- package/dist/protocol.d.cts +20 -0
- package/dist/protocol.d.ts +20 -0
- package/dist/protocol.js +17 -0
- package/dist/protocol.js.map +1 -0
- package/dist/provider.cjs +1581 -0
- package/dist/provider.cjs.map +1 -0
- package/dist/provider.d.cts +45 -0
- package/dist/provider.d.ts +45 -0
- package/dist/provider.js +18 -0
- package/dist/provider.js.map +1 -0
- package/dist/remote.cjs +1659 -0
- package/dist/remote.cjs.map +1 -0
- package/dist/remote.d.cts +55 -0
- package/dist/remote.d.ts +55 -0
- package/dist/remote.js +17 -0
- package/dist/remote.js.map +1 -0
- package/dist/status.cjs +443 -0
- package/dist/status.cjs.map +1 -0
- package/dist/status.d.cts +109 -0
- package/dist/status.d.ts +109 -0
- package/dist/status.js +26 -0
- package/dist/status.js.map +1 -0
- package/dist/verify.cjs +690 -0
- package/dist/verify.cjs.map +1 -0
- package/dist/verify.d.cts +245 -0
- package/dist/verify.d.ts +245 -0
- package/dist/verify.js +69 -0
- package/dist/verify.js.map +1 -0
- package/module.json +32 -0
- package/package.json +124 -3
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { AcrossSuggestedFees } from './api.js';
|
|
2
|
+
import { AcrossRoute } from './config.js';
|
|
3
|
+
import '@anywalletkit/protocol-swap2-core/errors';
|
|
4
|
+
import './verify.js';
|
|
5
|
+
import 'viem';
|
|
6
|
+
import '@anywalletkit/protocol-swap2-core/types';
|
|
7
|
+
import './deposit.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* How much a plain SpokePool deposit leaves to relayers — the one number a quote source decides.
|
|
11
|
+
*
|
|
12
|
+
* The risk is two-sided. Asking relayers for too much (`outputAmount` too high) and nobody fills: the funds wait for
|
|
13
|
+
* the fill deadline (two hours) and then Across's refund bundles (hours more). Asking for too little and the user
|
|
14
|
+
* overpays. Across API V5 is the price source, but it prices V5's OWN route, not a plain deposit: an execution step on
|
|
15
|
+
* the origin chain through Across's Gateway that a plain deposit does not have (the user's own wallet pays the
|
|
16
|
+
* deposit's gas), sometimes another rail (USDT Ethereum → Arbitrum went to a 20-minute rail on 2026-11-14), and an
|
|
17
|
+
* auction whose relayers fill large ETH L2 → L2 transfers at ~1 bp, well below what plain deposits are filled at.
|
|
18
|
+
*
|
|
19
|
+
* The rule (study of 2026-11-15: 27 V5 / suggested-fees pairs and 8 272 deposits on Ethereum, Optimism, Base and
|
|
20
|
+
* Arbitrum over 24 h — 1 369 of 1 369 organic plain deposits to Base, Arbitrum and Optimism priced at or above the
|
|
21
|
+
* relayer fee were filled, p50 2 s, p90 13 s):
|
|
22
|
+
*
|
|
23
|
+
* ```
|
|
24
|
+
* F5 = V5 fee.totalFee − Σ V5 gasEstimates[origin, included_in_transfer_fee] (the add-back rounded down)
|
|
25
|
+
* Fneed = /suggested-fees totalRelayFee.total while Across answers it
|
|
26
|
+
* = floor(asset, origin, size) + 1.5 × V5's destination gas otherwise (studied routes only)
|
|
27
|
+
* fee = max(F5, Fneed); outputAmount = input − fee
|
|
28
|
+
* = Fneed, from /suggested-fees only, when V5's fill estimate is over a minute (V5 prices another rail)
|
|
29
|
+
* quoteTimestamp = /suggested-fees `timestamp` (the LP fee was priced there; never ahead of the server's clock), else
|
|
30
|
+
* min(latest Ethereum block time − 60 s, latest origin block time)
|
|
31
|
+
* fillDeadline = quoteTimestamp + 7200; no exclusivity
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* `max()` keeps both bounds: never more than V5 charges for the same transfer (net of the step a plain deposit does
|
|
35
|
+
* not have), never less than plain deposits are filled at today. When V5's fill estimate is over a minute its price
|
|
36
|
+
* is another rail's (a CCTP or OFT transfer, 1 216 s for USDT Ethereum → Arbitrum on 2026-11-15, at 12× the relayer
|
|
37
|
+
* fee), not a bound on a plain deposit: the deposit is then priced on Across's relayer fee alone, and refused without it.
|
|
38
|
+
*
|
|
39
|
+
* The device holds whatever a server says to its own checks (`verify.ts`, `remote.ts`): the user's cap, a per-asset
|
|
40
|
+
* fee floor, and — through `acrossRemoteProvider` — Across's keyless relayer fee read on the device itself
|
|
41
|
+
* ({@link acrossCheckRelayerFee}), so a server can neither take a deposit nor get one signed that relayers leave unfilled.
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
/** The fill deadline after the quote time: what Across's own quotes give (3 923 of 6 982 plain deposits, 2026-11-14). */
|
|
45
|
+
declare const ACROSS_FILL_WINDOW_S = 7200;
|
|
46
|
+
/** Without `/suggested-fees`, the quote time lags Ethereum's latest block by this much (the LP fee is priced at a HubPool block). */
|
|
47
|
+
declare const ACROSS_QUOTE_TIME_LAG_S = 60;
|
|
48
|
+
/**
|
|
49
|
+
* The relayer-fee floor without `/suggested-fees`, in hundredths of a basis point (millionths) of the input, read off 24 h of
|
|
50
|
+
* fills priced by it (2026-11-14): stablecoins 1.00 bp, WBTC 3.10 bps, ETH from Ethereum 1.00 bp (fills seen at
|
|
51
|
+
* 0.74–0.84), ETH from an L2 on a size curve. Plus 1.5 × V5's destination gas.
|
|
52
|
+
*/
|
|
53
|
+
declare const ACROSS_FLOOR_CBPS: Readonly<{
|
|
54
|
+
stable: 100;
|
|
55
|
+
wbtc: 310;
|
|
56
|
+
ethFromEthereum: 100;
|
|
57
|
+
}>;
|
|
58
|
+
/** ETH from an L2: [size in USD, hundredths of a bp], linear between points — the curve every plain ETH L2 → L2 deposit of $1 000+ paid. */
|
|
59
|
+
declare const ACROSS_ETH_L2_CURVE: readonly (readonly [number, number])[];
|
|
60
|
+
/** Above this size (USD) no plain ETH L2 deposit was seen: refused when the floor is what prices it. */
|
|
61
|
+
declare const ACROSS_ETH_L2_FLOOR_MAX_USD = 36000;
|
|
62
|
+
/**
|
|
63
|
+
* The chains the floor was derived on: deposits from Ethereum, Optimism, Base and Arbitrum to Optimism, Base and
|
|
64
|
+
* Arbitrum. Without `/suggested-fees` any other route has no relayer price this module can stand behind.
|
|
65
|
+
*/
|
|
66
|
+
declare const ACROSS_FLOOR_ORIGINS: readonly number[];
|
|
67
|
+
declare const ACROSS_FLOOR_DESTINATIONS: readonly number[];
|
|
68
|
+
/** Whether the pinned floor covers a route (its origin and destination are among the studied chains). */
|
|
69
|
+
declare function acrossFloorCovers(route: AcrossRoute): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Over this fill estimate (ms) a V5 quote prices another rail than an Across relayer fill: Across-rail fills were
|
|
72
|
+
* estimated at 1.3–14 s on every recorded cell, the OFT rail for USDT Ethereum → Arbitrum at 1 216 s (2026-11-15).
|
|
73
|
+
*/
|
|
74
|
+
declare const ACROSS_V5_OTHER_RAIL_FILL_MS = 60000;
|
|
75
|
+
/** True when a V5 fill estimate says V5 priced another rail. */
|
|
76
|
+
declare const acrossV5OtherRail: (expectedFillTimeMs: number) => boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Why a route is not priced at all, or null. Ethereum as the destination: small plain deposits to Ethereum went
|
|
79
|
+
* unfilled in the study's window (some paying more than filled ones), for reasons the data does not show — kept out
|
|
80
|
+
* until studied rather than priced on a guess.
|
|
81
|
+
*/
|
|
82
|
+
declare function acrossRouteUnpriced(route: AcrossRoute): string | null;
|
|
83
|
+
/** The floor in hundredths of a bp for a route and size (USD), or a refusal text. */
|
|
84
|
+
declare function acrossFloorCbps(route: AcrossRoute, amountUsd: number | undefined): number | string;
|
|
85
|
+
/** `amount × cbps / 1 000 000`, rounded up. */
|
|
86
|
+
declare const acrossCbpsOf: (amount: bigint, cbps: number) => bigint;
|
|
87
|
+
/** The pinned-floor relayer need for a route without `/suggested-fees`: floor + 1.5 × V5's destination gas, rounded up. */
|
|
88
|
+
declare function acrossFloorFee(route: AcrossRoute, amount: bigint, amountUsd: number | undefined, destinationGas: bigint | null): bigint;
|
|
89
|
+
/** The fee of a plain deposit: `max(F5, Fneed)`, with both terms. */
|
|
90
|
+
interface AcrossPlainFee {
|
|
91
|
+
fee: bigint;
|
|
92
|
+
/** V5's fee net of its origin execution step. */
|
|
93
|
+
f5: bigint;
|
|
94
|
+
/** What a relayer needs (`/suggested-fees`, or the floor). */
|
|
95
|
+
need: bigint;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* `max(F5, Fneed)`; `Fneed` alone when V5 priced another rail (`otherRail`: F5 is then that rail's price, kept for
|
|
99
|
+
* display only). Refuses a fee that eats the whole input (`amount_too_small`).
|
|
100
|
+
*/
|
|
101
|
+
declare function acrossPlainFee(amount: bigint, v5: {
|
|
102
|
+
totalFee: bigint;
|
|
103
|
+
originGas: bigint;
|
|
104
|
+
}, need: bigint, otherRail?: boolean): AcrossPlainFee;
|
|
105
|
+
/**
|
|
106
|
+
* How far under Across's own relayer fee a deposit's fee may sit when the device reads that fee itself, in percent of
|
|
107
|
+
* it: the server's read and the device's are seconds apart, and the same quote moved at most 2.2 % over a minute
|
|
108
|
+
* (five corridors, 2026-11-15).
|
|
109
|
+
*/
|
|
110
|
+
declare const ACROSS_RELAYER_FEE_TOLERANCE_PCT = 10;
|
|
111
|
+
/**
|
|
112
|
+
* The device's own check of a deposit's fee against Across's keyless relayer fee for it, read on the device
|
|
113
|
+
* (`acrossRemoteProvider`): a fee more than {@link ACROSS_RELAYER_FEE_TOLERANCE_PCT} % under it is refused
|
|
114
|
+
* (`price_check_failed` — relayers would leave the deposit unfilled for its two-hour deadline and the refund after);
|
|
115
|
+
* Across refusing the deposit refuses it with Across's reason. Without an answer only a route the pinned floor covers
|
|
116
|
+
* stands, on the per-asset floor the verifier already held it to; any other route is refused (`upstream_unavailable`).
|
|
117
|
+
* Throws {@link AcrossRefusal} `relayer-price`.
|
|
118
|
+
*/
|
|
119
|
+
declare function acrossCheckRelayerFee(route: AcrossRoute, amount: bigint, fee: bigint, answer: AcrossSuggestedFees): void;
|
|
120
|
+
/** The deposit's quote time without `/suggested-fees`: `min(Ethereum − 60 s, origin)`, from the chains' latest blocks. */
|
|
121
|
+
declare function acrossQuoteTimeOf(ethereumBlockTime: number, originBlockTime: number): number;
|
|
122
|
+
|
|
123
|
+
export { ACROSS_ETH_L2_CURVE, ACROSS_ETH_L2_FLOOR_MAX_USD, ACROSS_FILL_WINDOW_S, ACROSS_FLOOR_CBPS, ACROSS_FLOOR_DESTINATIONS, ACROSS_FLOOR_ORIGINS, ACROSS_QUOTE_TIME_LAG_S, ACROSS_RELAYER_FEE_TOLERANCE_PCT, ACROSS_V5_OTHER_RAIL_FILL_MS, type AcrossPlainFee, acrossCbpsOf, acrossCheckRelayerFee, acrossFloorCbps, acrossFloorCovers, acrossFloorFee, acrossPlainFee, acrossQuoteTimeOf, acrossRouteUnpriced, acrossV5OtherRail };
|
package/dist/pricing.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ACROSS_ETH_L2_CURVE,
|
|
3
|
+
ACROSS_ETH_L2_FLOOR_MAX_USD,
|
|
4
|
+
ACROSS_FILL_WINDOW_S,
|
|
5
|
+
ACROSS_FLOOR_CBPS,
|
|
6
|
+
ACROSS_FLOOR_DESTINATIONS,
|
|
7
|
+
ACROSS_FLOOR_ORIGINS,
|
|
8
|
+
ACROSS_QUOTE_TIME_LAG_S,
|
|
9
|
+
ACROSS_RELAYER_FEE_TOLERANCE_PCT,
|
|
10
|
+
ACROSS_V5_OTHER_RAIL_FILL_MS,
|
|
11
|
+
acrossCbpsOf,
|
|
12
|
+
acrossCheckRelayerFee,
|
|
13
|
+
acrossFloorCbps,
|
|
14
|
+
acrossFloorCovers,
|
|
15
|
+
acrossFloorFee,
|
|
16
|
+
acrossPlainFee,
|
|
17
|
+
acrossQuoteTimeOf,
|
|
18
|
+
acrossRouteUnpriced,
|
|
19
|
+
acrossV5OtherRail
|
|
20
|
+
} from "./chunk-6Z4GXNLE.js";
|
|
21
|
+
import "./chunk-E5WFOPN2.js";
|
|
22
|
+
export {
|
|
23
|
+
ACROSS_ETH_L2_CURVE,
|
|
24
|
+
ACROSS_ETH_L2_FLOOR_MAX_USD,
|
|
25
|
+
ACROSS_FILL_WINDOW_S,
|
|
26
|
+
ACROSS_FLOOR_CBPS,
|
|
27
|
+
ACROSS_FLOOR_DESTINATIONS,
|
|
28
|
+
ACROSS_FLOOR_ORIGINS,
|
|
29
|
+
ACROSS_QUOTE_TIME_LAG_S,
|
|
30
|
+
ACROSS_RELAYER_FEE_TOLERANCE_PCT,
|
|
31
|
+
ACROSS_V5_OTHER_RAIL_FILL_MS,
|
|
32
|
+
acrossCbpsOf,
|
|
33
|
+
acrossCheckRelayerFee,
|
|
34
|
+
acrossFloorCbps,
|
|
35
|
+
acrossFloorCovers,
|
|
36
|
+
acrossFloorFee,
|
|
37
|
+
acrossPlainFee,
|
|
38
|
+
acrossQuoteTimeOf,
|
|
39
|
+
acrossRouteUnpriced,
|
|
40
|
+
acrossV5OtherRail
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=pricing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|