@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
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export { ACROSS_API, ACROSS_CHAINS, ACROSS_DEPOSIT, ACROSS_DEPOSIT_QUOTE_TIME_BUFFER_S, ACROSS_DEPOSIT_V3, ACROSS_FILL_DEADLINE_BUFFER_S, ACROSS_FILL_STATUSES, ACROSS_FUNDS_DEPOSITED, ACROSS_HUB_CROSS_CHAIN_CONTRACTS, ACROSS_HUB_POOL, ACROSS_MAX_EXCLUSIVITY_PERIOD_S, ACROSS_NATIVE, ACROSS_REFUSED_SELECTORS, ACROSS_SPEED_UP_DOMAIN, ACROSS_SPEED_UP_TYPE, ACROSS_SPEED_UP_TYPEHASH, ACROSS_V5_MESSAGE_PREFIX, AcrossAsset, AcrossChain, AcrossRoute, AcrossRouteMiss, AcrossRouteSide, AcrossToken, across, acrossChain, acrossRouteOf, acrossToken } from './config.cjs';
|
|
2
|
+
import { Swap2RefusalReason } from '@anywalletkit/protocol-swap2-core/errors';
|
|
3
|
+
export { ACROSS_MAX_MESSAGE_BYTES, AcrossDepositArgs, SPOKE_POOL_ABI, acrossAddressOf, acrossBytes32, decodeAcrossDeposit, encodeAcrossDeposit } from './deposit.cjs';
|
|
4
|
+
export { ACROSS_CLOCK_SKEW_S, ACROSS_DEFAULT_MAX_FEE_BPS, ACROSS_GAS_CAP, ACROSS_GAS_FLOOR, ACROSS_LANDING_WINDOW_S, ACROSS_MAX_FEE_BPS_LIMIT, ACROSS_MAX_FILL_WINDOW_S, ACROSS_MAX_QUOTE_LIFE_MS, ACROSS_MIN_FEE_PPM, ACROSS_MIN_FILL_WINDOW_S, ACROSS_PLACEHOLDER, ACROSS_QUOTE_TIME_AHEAD_S, AcrossDeposit, AcrossDepositTx, AcrossPinsOptions, AcrossRequest, CheckedAcrossRequest, VerifiedAcrossDeposit, acrossCheckBuild, acrossIntentId, acrossMinFeePpm, acrossPins, acrossPinsRequestOf, acrossPinsWith, acrossQuoteFeesOf, acrossQuoteTimeLimitMs, acrossRefusalReason, acrossRequestOf, acrossVerifyBuild, acrossVerifyQuote, checkAcrossQuote, checkAcrossRequest, checkAcrossTxShape, isAcrossSpeedUpTypedData, parseAcrossIntentId, verifyAcrossDeposit } from './verify.cjs';
|
|
5
|
+
export { AcrossFeeBreakdown, AcrossQuoteOptions, NormalizedAcrossQuote, acrossQuoteOf, buildAcrossDeposit } from './build.cjs';
|
|
6
|
+
export { ACROSS_FILL_STATUS, AcrossDepositEvent, AcrossFillState, AcrossRpc, AcrossTrack, AcrossTrackInput, acrossDepositIsIntent, acrossDepositsInReceipt, acrossFillState, acrossFillStatusCall, acrossRelayHash, acrossRpc, parseAcrossFillStatus, trackAcrossDeposit } from './status.cjs';
|
|
7
|
+
export { ACROSS_API_V1, ACROSS_SUGGESTED_FEES_MAX_AGE_S, ACROSS_SUGGESTED_FEES_MAX_AHEAD_S, ACROSS_SUGGESTED_FEES_URL, ACROSS_V5_PRICING_MAX_FEE_BPS, AcrossHttpAnswer, AcrossSuggestedFees, AcrossV5Error, AcrossV5Price, AcrossV5QuoteRequest, AcrossV5Token, acrossApiUrl, acrossHttp, acrossOriginOf, acrossSuggestedFeesQuery, acrossUsdToUnits, acrossV5QuoteRequest, parseAcrossV5Error, readAcrossSuggestedFees, readAcrossV5Quote } from './api.cjs';
|
|
8
|
+
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, AcrossPlainFee, acrossCbpsOf, acrossCheckRelayerFee, acrossFloorCbps, acrossFloorCovers, acrossFloorFee, acrossPlainFee, acrossQuoteTimeOf, acrossRouteUnpriced, acrossV5OtherRail } from './pricing.cjs';
|
|
9
|
+
export { AcrossProviderConfig, acrossProvider, acrossServesRoute } from './provider.cjs';
|
|
10
|
+
export { AcrossRemoteOptions, acrossRemoteProvider } from './remote.cjs';
|
|
11
|
+
export { AcrossSwap2Config, AcrossSwap2Protocol, AcrossSwap2Protocol as default } from './protocol.cjs';
|
|
12
|
+
export { ACROSS_MODULE, describeAcrossActivity } from './activity.cjs';
|
|
13
|
+
import 'viem';
|
|
14
|
+
import '@anywalletkit/protocol-swap2-core/types';
|
|
15
|
+
import '@anywalletkit/protocol-swap2-core/remote';
|
|
16
|
+
import '@anywalletkit/protocol-swap2-core/swap2/single';
|
|
17
|
+
import '@anywalletkit/protocol-swap2-core/swap2/base';
|
|
18
|
+
import '@anywalletkit/core';
|
|
19
|
+
|
|
20
|
+
/** Why a request, a deposit, a quote or an API answer was refused. One code per check; the message says what was found. */
|
|
21
|
+
type AcrossRefusalCode = "request-invalid" | "chain-unsupported" | "token-unsupported" | "pair-unsupported" | "native-unsupported" | "wrapped-native-destination" | "route-unpriced" | "quote-unavailable" | "quote-normalized" | "tx-shape" | "tx-chain" | "tx-target" | "tx-selector" | "tx-calldata" | "tx-depositor" | "tx-recipient" | "tx-input-token" | "tx-output-token" | "tx-input-amount" | "tx-output-amount" | "tx-fee" | "tx-destination" | "tx-message" | "tx-message-v5" | "tx-exclusivity" | "tx-quote-time" | "tx-fill-deadline" | "tx-value" | "tx-approval" | "speed-up" | "quote-shape" | "quote-amounts" | "quote-expiry" | "quote-gas" | "quote-intent" | "api-error" | "api-answer" | "relayer-price";
|
|
22
|
+
/**
|
|
23
|
+
* `code` names the check; `reason` (a `Swap2RefusalReason` from `@anywalletkit/protocol-swap2-core`) is the stable
|
|
24
|
+
* classification an app switches on. It is set where the refusal is raised, so one code can carry different reasons
|
|
25
|
+
* (a fill deadline too far ahead is `policy_refused`, one already too close is `quote_expired`); a malformed request
|
|
26
|
+
* from the caller (a programming error) carries none.
|
|
27
|
+
*/
|
|
28
|
+
declare class AcrossRefusal extends Error {
|
|
29
|
+
readonly code: AcrossRefusalCode;
|
|
30
|
+
readonly reason?: Swap2RefusalReason;
|
|
31
|
+
constructor(code: AcrossRefusalCode, detail: string, reason?: Swap2RefusalReason);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { AcrossRefusal, type AcrossRefusalCode };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export { ACROSS_API, ACROSS_CHAINS, ACROSS_DEPOSIT, ACROSS_DEPOSIT_QUOTE_TIME_BUFFER_S, ACROSS_DEPOSIT_V3, ACROSS_FILL_DEADLINE_BUFFER_S, ACROSS_FILL_STATUSES, ACROSS_FUNDS_DEPOSITED, ACROSS_HUB_CROSS_CHAIN_CONTRACTS, ACROSS_HUB_POOL, ACROSS_MAX_EXCLUSIVITY_PERIOD_S, ACROSS_NATIVE, ACROSS_REFUSED_SELECTORS, ACROSS_SPEED_UP_DOMAIN, ACROSS_SPEED_UP_TYPE, ACROSS_SPEED_UP_TYPEHASH, ACROSS_V5_MESSAGE_PREFIX, AcrossAsset, AcrossChain, AcrossRoute, AcrossRouteMiss, AcrossRouteSide, AcrossToken, across, acrossChain, acrossRouteOf, acrossToken } from './config.js';
|
|
2
|
+
import { Swap2RefusalReason } from '@anywalletkit/protocol-swap2-core/errors';
|
|
3
|
+
export { ACROSS_MAX_MESSAGE_BYTES, AcrossDepositArgs, SPOKE_POOL_ABI, acrossAddressOf, acrossBytes32, decodeAcrossDeposit, encodeAcrossDeposit } from './deposit.js';
|
|
4
|
+
export { ACROSS_CLOCK_SKEW_S, ACROSS_DEFAULT_MAX_FEE_BPS, ACROSS_GAS_CAP, ACROSS_GAS_FLOOR, ACROSS_LANDING_WINDOW_S, ACROSS_MAX_FEE_BPS_LIMIT, ACROSS_MAX_FILL_WINDOW_S, ACROSS_MAX_QUOTE_LIFE_MS, ACROSS_MIN_FEE_PPM, ACROSS_MIN_FILL_WINDOW_S, ACROSS_PLACEHOLDER, ACROSS_QUOTE_TIME_AHEAD_S, AcrossDeposit, AcrossDepositTx, AcrossPinsOptions, AcrossRequest, CheckedAcrossRequest, VerifiedAcrossDeposit, acrossCheckBuild, acrossIntentId, acrossMinFeePpm, acrossPins, acrossPinsRequestOf, acrossPinsWith, acrossQuoteFeesOf, acrossQuoteTimeLimitMs, acrossRefusalReason, acrossRequestOf, acrossVerifyBuild, acrossVerifyQuote, checkAcrossQuote, checkAcrossRequest, checkAcrossTxShape, isAcrossSpeedUpTypedData, parseAcrossIntentId, verifyAcrossDeposit } from './verify.js';
|
|
5
|
+
export { AcrossFeeBreakdown, AcrossQuoteOptions, NormalizedAcrossQuote, acrossQuoteOf, buildAcrossDeposit } from './build.js';
|
|
6
|
+
export { ACROSS_FILL_STATUS, AcrossDepositEvent, AcrossFillState, AcrossRpc, AcrossTrack, AcrossTrackInput, acrossDepositIsIntent, acrossDepositsInReceipt, acrossFillState, acrossFillStatusCall, acrossRelayHash, acrossRpc, parseAcrossFillStatus, trackAcrossDeposit } from './status.js';
|
|
7
|
+
export { ACROSS_API_V1, ACROSS_SUGGESTED_FEES_MAX_AGE_S, ACROSS_SUGGESTED_FEES_MAX_AHEAD_S, ACROSS_SUGGESTED_FEES_URL, ACROSS_V5_PRICING_MAX_FEE_BPS, AcrossHttpAnswer, AcrossSuggestedFees, AcrossV5Error, AcrossV5Price, AcrossV5QuoteRequest, AcrossV5Token, acrossApiUrl, acrossHttp, acrossOriginOf, acrossSuggestedFeesQuery, acrossUsdToUnits, acrossV5QuoteRequest, parseAcrossV5Error, readAcrossSuggestedFees, readAcrossV5Quote } from './api.js';
|
|
8
|
+
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, AcrossPlainFee, acrossCbpsOf, acrossCheckRelayerFee, acrossFloorCbps, acrossFloorCovers, acrossFloorFee, acrossPlainFee, acrossQuoteTimeOf, acrossRouteUnpriced, acrossV5OtherRail } from './pricing.js';
|
|
9
|
+
export { AcrossProviderConfig, acrossProvider, acrossServesRoute } from './provider.js';
|
|
10
|
+
export { AcrossRemoteOptions, acrossRemoteProvider } from './remote.js';
|
|
11
|
+
export { AcrossSwap2Config, AcrossSwap2Protocol, AcrossSwap2Protocol as default } from './protocol.js';
|
|
12
|
+
export { ACROSS_MODULE, describeAcrossActivity } from './activity.js';
|
|
13
|
+
import 'viem';
|
|
14
|
+
import '@anywalletkit/protocol-swap2-core/types';
|
|
15
|
+
import '@anywalletkit/protocol-swap2-core/remote';
|
|
16
|
+
import '@anywalletkit/protocol-swap2-core/swap2/single';
|
|
17
|
+
import '@anywalletkit/protocol-swap2-core/swap2/base';
|
|
18
|
+
import '@anywalletkit/core';
|
|
19
|
+
|
|
20
|
+
/** Why a request, a deposit, a quote or an API answer was refused. One code per check; the message says what was found. */
|
|
21
|
+
type AcrossRefusalCode = "request-invalid" | "chain-unsupported" | "token-unsupported" | "pair-unsupported" | "native-unsupported" | "wrapped-native-destination" | "route-unpriced" | "quote-unavailable" | "quote-normalized" | "tx-shape" | "tx-chain" | "tx-target" | "tx-selector" | "tx-calldata" | "tx-depositor" | "tx-recipient" | "tx-input-token" | "tx-output-token" | "tx-input-amount" | "tx-output-amount" | "tx-fee" | "tx-destination" | "tx-message" | "tx-message-v5" | "tx-exclusivity" | "tx-quote-time" | "tx-fill-deadline" | "tx-value" | "tx-approval" | "speed-up" | "quote-shape" | "quote-amounts" | "quote-expiry" | "quote-gas" | "quote-intent" | "api-error" | "api-answer" | "relayer-price";
|
|
22
|
+
/**
|
|
23
|
+
* `code` names the check; `reason` (a `Swap2RefusalReason` from `@anywalletkit/protocol-swap2-core`) is the stable
|
|
24
|
+
* classification an app switches on. It is set where the refusal is raised, so one code can carry different reasons
|
|
25
|
+
* (a fill deadline too far ahead is `policy_refused`, one already too close is `quote_expired`); a malformed request
|
|
26
|
+
* from the caller (a programming error) carries none.
|
|
27
|
+
*/
|
|
28
|
+
declare class AcrossRefusal extends Error {
|
|
29
|
+
readonly code: AcrossRefusalCode;
|
|
30
|
+
readonly reason?: Swap2RefusalReason;
|
|
31
|
+
constructor(code: AcrossRefusalCode, detail: string, reason?: Swap2RefusalReason);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { AcrossRefusal, type AcrossRefusalCode };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import {
|
|
2
|
+
acrossRemoteProvider
|
|
3
|
+
} from "./chunk-AWQT5S4V.js";
|
|
4
|
+
import {
|
|
5
|
+
AcrossSwap2Protocol
|
|
6
|
+
} from "./chunk-P32AW6XS.js";
|
|
7
|
+
import {
|
|
8
|
+
acrossProvider,
|
|
9
|
+
acrossServesRoute
|
|
10
|
+
} from "./chunk-PPPZIG7S.js";
|
|
11
|
+
import {
|
|
12
|
+
ACROSS_MODULE,
|
|
13
|
+
describeAcrossActivity
|
|
14
|
+
} from "./chunk-5BDZXOOP.js";
|
|
15
|
+
import {
|
|
16
|
+
acrossQuoteOf,
|
|
17
|
+
buildAcrossDeposit
|
|
18
|
+
} from "./chunk-SJOFLM27.js";
|
|
19
|
+
import {
|
|
20
|
+
ACROSS_CLOCK_SKEW_S,
|
|
21
|
+
ACROSS_DEFAULT_MAX_FEE_BPS,
|
|
22
|
+
ACROSS_GAS_CAP,
|
|
23
|
+
ACROSS_GAS_FLOOR,
|
|
24
|
+
ACROSS_LANDING_WINDOW_S,
|
|
25
|
+
ACROSS_MAX_FEE_BPS_LIMIT,
|
|
26
|
+
ACROSS_MAX_FILL_WINDOW_S,
|
|
27
|
+
ACROSS_MAX_QUOTE_LIFE_MS,
|
|
28
|
+
ACROSS_MIN_FEE_PPM,
|
|
29
|
+
ACROSS_MIN_FILL_WINDOW_S,
|
|
30
|
+
ACROSS_PLACEHOLDER,
|
|
31
|
+
ACROSS_QUOTE_TIME_AHEAD_S,
|
|
32
|
+
acrossCheckBuild,
|
|
33
|
+
acrossIntentId,
|
|
34
|
+
acrossMinFeePpm,
|
|
35
|
+
acrossPins,
|
|
36
|
+
acrossPinsRequestOf,
|
|
37
|
+
acrossPinsWith,
|
|
38
|
+
acrossQuoteFeesOf,
|
|
39
|
+
acrossQuoteTimeLimitMs,
|
|
40
|
+
acrossRefusalReason,
|
|
41
|
+
acrossRequestOf,
|
|
42
|
+
acrossVerifyBuild,
|
|
43
|
+
acrossVerifyQuote,
|
|
44
|
+
checkAcrossQuote,
|
|
45
|
+
checkAcrossRequest,
|
|
46
|
+
checkAcrossTxShape,
|
|
47
|
+
isAcrossSpeedUpTypedData,
|
|
48
|
+
parseAcrossIntentId,
|
|
49
|
+
verifyAcrossDeposit
|
|
50
|
+
} from "./chunk-KATEONJQ.js";
|
|
51
|
+
import {
|
|
52
|
+
ACROSS_FILL_STATUS,
|
|
53
|
+
acrossDepositIsIntent,
|
|
54
|
+
acrossDepositsInReceipt,
|
|
55
|
+
acrossFillState,
|
|
56
|
+
acrossFillStatusCall,
|
|
57
|
+
acrossRelayHash,
|
|
58
|
+
acrossRpc,
|
|
59
|
+
parseAcrossFillStatus,
|
|
60
|
+
trackAcrossDeposit
|
|
61
|
+
} from "./chunk-3UBRQ3ZE.js";
|
|
62
|
+
import {
|
|
63
|
+
ACROSS_MAX_MESSAGE_BYTES,
|
|
64
|
+
SPOKE_POOL_ABI,
|
|
65
|
+
acrossAddressOf,
|
|
66
|
+
acrossBytes32,
|
|
67
|
+
decodeAcrossDeposit,
|
|
68
|
+
encodeAcrossDeposit
|
|
69
|
+
} from "./chunk-32YJEBZX.js";
|
|
70
|
+
import {
|
|
71
|
+
ACROSS_API_V1,
|
|
72
|
+
ACROSS_SUGGESTED_FEES_MAX_AGE_S,
|
|
73
|
+
ACROSS_SUGGESTED_FEES_MAX_AHEAD_S,
|
|
74
|
+
ACROSS_SUGGESTED_FEES_URL,
|
|
75
|
+
ACROSS_V5_PRICING_MAX_FEE_BPS,
|
|
76
|
+
acrossApiUrl,
|
|
77
|
+
acrossHttp,
|
|
78
|
+
acrossOriginOf,
|
|
79
|
+
acrossSuggestedFeesQuery,
|
|
80
|
+
acrossUsdToUnits,
|
|
81
|
+
acrossV5QuoteRequest,
|
|
82
|
+
parseAcrossV5Error,
|
|
83
|
+
readAcrossSuggestedFees,
|
|
84
|
+
readAcrossV5Quote
|
|
85
|
+
} from "./chunk-YGNP7KPL.js";
|
|
86
|
+
import {
|
|
87
|
+
ACROSS_API,
|
|
88
|
+
ACROSS_CHAINS,
|
|
89
|
+
ACROSS_DEPOSIT,
|
|
90
|
+
ACROSS_DEPOSIT_QUOTE_TIME_BUFFER_S,
|
|
91
|
+
ACROSS_DEPOSIT_V3,
|
|
92
|
+
ACROSS_FILL_DEADLINE_BUFFER_S,
|
|
93
|
+
ACROSS_FILL_STATUSES,
|
|
94
|
+
ACROSS_FUNDS_DEPOSITED,
|
|
95
|
+
ACROSS_HUB_CROSS_CHAIN_CONTRACTS,
|
|
96
|
+
ACROSS_HUB_POOL,
|
|
97
|
+
ACROSS_MAX_EXCLUSIVITY_PERIOD_S,
|
|
98
|
+
ACROSS_NATIVE,
|
|
99
|
+
ACROSS_REFUSED_SELECTORS,
|
|
100
|
+
ACROSS_SPEED_UP_DOMAIN,
|
|
101
|
+
ACROSS_SPEED_UP_TYPE,
|
|
102
|
+
ACROSS_SPEED_UP_TYPEHASH,
|
|
103
|
+
ACROSS_V5_MESSAGE_PREFIX,
|
|
104
|
+
across,
|
|
105
|
+
acrossChain,
|
|
106
|
+
acrossRouteOf,
|
|
107
|
+
acrossToken
|
|
108
|
+
} from "./chunk-GX67FRPG.js";
|
|
109
|
+
import {
|
|
110
|
+
ACROSS_ETH_L2_CURVE,
|
|
111
|
+
ACROSS_ETH_L2_FLOOR_MAX_USD,
|
|
112
|
+
ACROSS_FILL_WINDOW_S,
|
|
113
|
+
ACROSS_FLOOR_CBPS,
|
|
114
|
+
ACROSS_FLOOR_DESTINATIONS,
|
|
115
|
+
ACROSS_FLOOR_ORIGINS,
|
|
116
|
+
ACROSS_QUOTE_TIME_LAG_S,
|
|
117
|
+
ACROSS_RELAYER_FEE_TOLERANCE_PCT,
|
|
118
|
+
ACROSS_V5_OTHER_RAIL_FILL_MS,
|
|
119
|
+
acrossCbpsOf,
|
|
120
|
+
acrossCheckRelayerFee,
|
|
121
|
+
acrossFloorCbps,
|
|
122
|
+
acrossFloorCovers,
|
|
123
|
+
acrossFloorFee,
|
|
124
|
+
acrossPlainFee,
|
|
125
|
+
acrossQuoteTimeOf,
|
|
126
|
+
acrossRouteUnpriced,
|
|
127
|
+
acrossV5OtherRail
|
|
128
|
+
} from "./chunk-6Z4GXNLE.js";
|
|
129
|
+
import {
|
|
130
|
+
AcrossRefusal
|
|
131
|
+
} from "./chunk-E5WFOPN2.js";
|
|
132
|
+
export {
|
|
133
|
+
ACROSS_API,
|
|
134
|
+
ACROSS_API_V1,
|
|
135
|
+
ACROSS_CHAINS,
|
|
136
|
+
ACROSS_CLOCK_SKEW_S,
|
|
137
|
+
ACROSS_DEFAULT_MAX_FEE_BPS,
|
|
138
|
+
ACROSS_DEPOSIT,
|
|
139
|
+
ACROSS_DEPOSIT_QUOTE_TIME_BUFFER_S,
|
|
140
|
+
ACROSS_DEPOSIT_V3,
|
|
141
|
+
ACROSS_ETH_L2_CURVE,
|
|
142
|
+
ACROSS_ETH_L2_FLOOR_MAX_USD,
|
|
143
|
+
ACROSS_FILL_DEADLINE_BUFFER_S,
|
|
144
|
+
ACROSS_FILL_STATUS,
|
|
145
|
+
ACROSS_FILL_STATUSES,
|
|
146
|
+
ACROSS_FILL_WINDOW_S,
|
|
147
|
+
ACROSS_FLOOR_CBPS,
|
|
148
|
+
ACROSS_FLOOR_DESTINATIONS,
|
|
149
|
+
ACROSS_FLOOR_ORIGINS,
|
|
150
|
+
ACROSS_FUNDS_DEPOSITED,
|
|
151
|
+
ACROSS_GAS_CAP,
|
|
152
|
+
ACROSS_GAS_FLOOR,
|
|
153
|
+
ACROSS_HUB_CROSS_CHAIN_CONTRACTS,
|
|
154
|
+
ACROSS_HUB_POOL,
|
|
155
|
+
ACROSS_LANDING_WINDOW_S,
|
|
156
|
+
ACROSS_MAX_EXCLUSIVITY_PERIOD_S,
|
|
157
|
+
ACROSS_MAX_FEE_BPS_LIMIT,
|
|
158
|
+
ACROSS_MAX_FILL_WINDOW_S,
|
|
159
|
+
ACROSS_MAX_MESSAGE_BYTES,
|
|
160
|
+
ACROSS_MAX_QUOTE_LIFE_MS,
|
|
161
|
+
ACROSS_MIN_FEE_PPM,
|
|
162
|
+
ACROSS_MIN_FILL_WINDOW_S,
|
|
163
|
+
ACROSS_MODULE,
|
|
164
|
+
ACROSS_NATIVE,
|
|
165
|
+
ACROSS_PLACEHOLDER,
|
|
166
|
+
ACROSS_QUOTE_TIME_AHEAD_S,
|
|
167
|
+
ACROSS_QUOTE_TIME_LAG_S,
|
|
168
|
+
ACROSS_REFUSED_SELECTORS,
|
|
169
|
+
ACROSS_RELAYER_FEE_TOLERANCE_PCT,
|
|
170
|
+
ACROSS_SPEED_UP_DOMAIN,
|
|
171
|
+
ACROSS_SPEED_UP_TYPE,
|
|
172
|
+
ACROSS_SPEED_UP_TYPEHASH,
|
|
173
|
+
ACROSS_SUGGESTED_FEES_MAX_AGE_S,
|
|
174
|
+
ACROSS_SUGGESTED_FEES_MAX_AHEAD_S,
|
|
175
|
+
ACROSS_SUGGESTED_FEES_URL,
|
|
176
|
+
ACROSS_V5_MESSAGE_PREFIX,
|
|
177
|
+
ACROSS_V5_OTHER_RAIL_FILL_MS,
|
|
178
|
+
ACROSS_V5_PRICING_MAX_FEE_BPS,
|
|
179
|
+
AcrossRefusal,
|
|
180
|
+
AcrossSwap2Protocol,
|
|
181
|
+
SPOKE_POOL_ABI,
|
|
182
|
+
across,
|
|
183
|
+
acrossAddressOf,
|
|
184
|
+
acrossApiUrl,
|
|
185
|
+
acrossBytes32,
|
|
186
|
+
acrossCbpsOf,
|
|
187
|
+
acrossChain,
|
|
188
|
+
acrossCheckBuild,
|
|
189
|
+
acrossCheckRelayerFee,
|
|
190
|
+
acrossDepositIsIntent,
|
|
191
|
+
acrossDepositsInReceipt,
|
|
192
|
+
acrossFillState,
|
|
193
|
+
acrossFillStatusCall,
|
|
194
|
+
acrossFloorCbps,
|
|
195
|
+
acrossFloorCovers,
|
|
196
|
+
acrossFloorFee,
|
|
197
|
+
acrossHttp,
|
|
198
|
+
acrossIntentId,
|
|
199
|
+
acrossMinFeePpm,
|
|
200
|
+
acrossOriginOf,
|
|
201
|
+
acrossPins,
|
|
202
|
+
acrossPinsRequestOf,
|
|
203
|
+
acrossPinsWith,
|
|
204
|
+
acrossPlainFee,
|
|
205
|
+
acrossProvider,
|
|
206
|
+
acrossQuoteFeesOf,
|
|
207
|
+
acrossQuoteOf,
|
|
208
|
+
acrossQuoteTimeLimitMs,
|
|
209
|
+
acrossQuoteTimeOf,
|
|
210
|
+
acrossRefusalReason,
|
|
211
|
+
acrossRelayHash,
|
|
212
|
+
acrossRemoteProvider,
|
|
213
|
+
acrossRequestOf,
|
|
214
|
+
acrossRouteOf,
|
|
215
|
+
acrossRouteUnpriced,
|
|
216
|
+
acrossRpc,
|
|
217
|
+
acrossServesRoute,
|
|
218
|
+
acrossSuggestedFeesQuery,
|
|
219
|
+
acrossToken,
|
|
220
|
+
acrossUsdToUnits,
|
|
221
|
+
acrossV5OtherRail,
|
|
222
|
+
acrossV5QuoteRequest,
|
|
223
|
+
acrossVerifyBuild,
|
|
224
|
+
acrossVerifyQuote,
|
|
225
|
+
buildAcrossDeposit,
|
|
226
|
+
checkAcrossQuote,
|
|
227
|
+
checkAcrossRequest,
|
|
228
|
+
checkAcrossTxShape,
|
|
229
|
+
decodeAcrossDeposit,
|
|
230
|
+
AcrossSwap2Protocol as default,
|
|
231
|
+
describeAcrossActivity,
|
|
232
|
+
encodeAcrossDeposit,
|
|
233
|
+
isAcrossSpeedUpTypedData,
|
|
234
|
+
parseAcrossFillStatus,
|
|
235
|
+
parseAcrossIntentId,
|
|
236
|
+
parseAcrossV5Error,
|
|
237
|
+
readAcrossSuggestedFees,
|
|
238
|
+
readAcrossV5Quote,
|
|
239
|
+
trackAcrossDeposit,
|
|
240
|
+
verifyAcrossDeposit
|
|
241
|
+
};
|
|
242
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/pricing.cjs
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
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/pricing.ts
|
|
21
|
+
var pricing_exports = {};
|
|
22
|
+
__export(pricing_exports, {
|
|
23
|
+
ACROSS_ETH_L2_CURVE: () => ACROSS_ETH_L2_CURVE,
|
|
24
|
+
ACROSS_ETH_L2_FLOOR_MAX_USD: () => ACROSS_ETH_L2_FLOOR_MAX_USD,
|
|
25
|
+
ACROSS_FILL_WINDOW_S: () => ACROSS_FILL_WINDOW_S,
|
|
26
|
+
ACROSS_FLOOR_CBPS: () => ACROSS_FLOOR_CBPS,
|
|
27
|
+
ACROSS_FLOOR_DESTINATIONS: () => ACROSS_FLOOR_DESTINATIONS,
|
|
28
|
+
ACROSS_FLOOR_ORIGINS: () => ACROSS_FLOOR_ORIGINS,
|
|
29
|
+
ACROSS_QUOTE_TIME_LAG_S: () => ACROSS_QUOTE_TIME_LAG_S,
|
|
30
|
+
ACROSS_RELAYER_FEE_TOLERANCE_PCT: () => ACROSS_RELAYER_FEE_TOLERANCE_PCT,
|
|
31
|
+
ACROSS_V5_OTHER_RAIL_FILL_MS: () => ACROSS_V5_OTHER_RAIL_FILL_MS,
|
|
32
|
+
acrossCbpsOf: () => acrossCbpsOf,
|
|
33
|
+
acrossCheckRelayerFee: () => acrossCheckRelayerFee,
|
|
34
|
+
acrossFloorCbps: () => acrossFloorCbps,
|
|
35
|
+
acrossFloorCovers: () => acrossFloorCovers,
|
|
36
|
+
acrossFloorFee: () => acrossFloorFee,
|
|
37
|
+
acrossPlainFee: () => acrossPlainFee,
|
|
38
|
+
acrossQuoteTimeOf: () => acrossQuoteTimeOf,
|
|
39
|
+
acrossRouteUnpriced: () => acrossRouteUnpriced,
|
|
40
|
+
acrossV5OtherRail: () => acrossV5OtherRail
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(pricing_exports);
|
|
43
|
+
|
|
44
|
+
// src/refusal.ts
|
|
45
|
+
var import_errors = require("@anywalletkit/protocol-swap2-core/errors");
|
|
46
|
+
var AcrossRefusal = class extends Error {
|
|
47
|
+
code;
|
|
48
|
+
constructor(code, detail, reason) {
|
|
49
|
+
super(`across: ${detail} [${code}]`);
|
|
50
|
+
this.name = "AcrossRefusal";
|
|
51
|
+
this.code = code;
|
|
52
|
+
if (reason !== void 0) (0, import_errors.withReason)(this, reason);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// src/pricing.ts
|
|
57
|
+
var ACROSS_FILL_WINDOW_S = 7200;
|
|
58
|
+
var ACROSS_QUOTE_TIME_LAG_S = 60;
|
|
59
|
+
var ACROSS_FLOOR_CBPS = Object.freeze({ stable: 100, wbtc: 310, ethFromEthereum: 100 });
|
|
60
|
+
var ACROSS_ETH_L2_CURVE = Object.freeze([
|
|
61
|
+
[0, 477],
|
|
62
|
+
[1e3, 515],
|
|
63
|
+
[2e3, 540],
|
|
64
|
+
[4e3, 605],
|
|
65
|
+
[8e3, 715],
|
|
66
|
+
[16e3, 850],
|
|
67
|
+
[36e3, 920]
|
|
68
|
+
].map((p) => Object.freeze(p)));
|
|
69
|
+
var ACROSS_ETH_L2_FLOOR_MAX_USD = 36e3;
|
|
70
|
+
var ACROSS_FLOOR_ORIGINS = Object.freeze([1, 10, 8453, 42161]);
|
|
71
|
+
var ACROSS_FLOOR_DESTINATIONS = Object.freeze([10, 8453, 42161]);
|
|
72
|
+
function acrossFloorCovers(route) {
|
|
73
|
+
return ACROSS_FLOOR_ORIGINS.includes(route.input.chain.chainId) && ACROSS_FLOOR_DESTINATIONS.includes(route.output.chain.chainId);
|
|
74
|
+
}
|
|
75
|
+
var ACROSS_V5_OTHER_RAIL_FILL_MS = 6e4;
|
|
76
|
+
var acrossV5OtherRail = (expectedFillTimeMs) => expectedFillTimeMs > ACROSS_V5_OTHER_RAIL_FILL_MS;
|
|
77
|
+
function acrossRouteUnpriced(route) {
|
|
78
|
+
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";
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
function acrossFloorCbps(route, amountUsd) {
|
|
82
|
+
const src = route.input.chain.chainId;
|
|
83
|
+
if (!acrossFloorCovers(route)) {
|
|
84
|
+
return `without Across's relayer fee quote there is no relayer price for ${route.input.chain.name} \u2192 ${route.output.chain.name} (the pinned floor covers Ethereum, Optimism, Base and Arbitrum to Optimism, Base and Arbitrum)`;
|
|
85
|
+
}
|
|
86
|
+
if (route.asset === "USDC" || route.asset === "USDT") return ACROSS_FLOOR_CBPS.stable;
|
|
87
|
+
if (route.asset === "WBTC") return ACROSS_FLOOR_CBPS.wbtc;
|
|
88
|
+
if (src === 1) return ACROSS_FLOOR_CBPS.ethFromEthereum;
|
|
89
|
+
if (amountUsd === void 0 || !Number.isFinite(amountUsd) || amountUsd < 0) return "without Across's relayer fee quote the ETH floor needs the transfer's size in dollars, and the V5 quote states none";
|
|
90
|
+
if (amountUsd > ACROSS_ETH_L2_FLOOR_MAX_USD) return `without Across's relayer fee quote ETH from an L2 is priced up to $${ACROSS_ETH_L2_FLOOR_MAX_USD} (no larger plain deposit was seen)`;
|
|
91
|
+
const c = ACROSS_ETH_L2_CURVE;
|
|
92
|
+
for (let i = 1; i < c.length; i++) {
|
|
93
|
+
const [x1, y1] = c[i];
|
|
94
|
+
if (amountUsd <= x1) {
|
|
95
|
+
const [x0, y0] = c[i - 1];
|
|
96
|
+
return Math.ceil(y0 + (y1 - y0) * (amountUsd - x0) / (x1 - x0));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return c[c.length - 1][1];
|
|
100
|
+
}
|
|
101
|
+
var acrossCbpsOf = (amount, cbps) => (amount * BigInt(cbps) + 999999n) / 1000000n;
|
|
102
|
+
function acrossFloorFee(route, amount, amountUsd, destinationGas) {
|
|
103
|
+
const cbps = acrossFloorCbps(route, amountUsd);
|
|
104
|
+
if (typeof cbps === "string") {
|
|
105
|
+
const tooLarge = acrossFloorCovers(route) && route.asset === "ETH" && route.input.chain.chainId !== 1 && amountUsd !== void 0 && amountUsd > ACROSS_ETH_L2_FLOOR_MAX_USD;
|
|
106
|
+
throw new AcrossRefusal("relayer-price", cbps, tooLarge ? "amount_too_large" : "upstream_unavailable");
|
|
107
|
+
}
|
|
108
|
+
if (destinationGas === null) throw new AcrossRefusal("relayer-price", "without Across's relayer fee quote the floor needs V5's destination gas, and it does not read", "upstream_unavailable");
|
|
109
|
+
return acrossCbpsOf(amount, cbps) + (destinationGas * 3n + 1n) / 2n;
|
|
110
|
+
}
|
|
111
|
+
function acrossPlainFee(amount, v5, need, otherRail = false) {
|
|
112
|
+
const f5 = v5.totalFee - (v5.originGas > v5.totalFee ? v5.totalFee : v5.originGas);
|
|
113
|
+
const fee = otherRail || need > f5 ? need : f5;
|
|
114
|
+
if (fee >= amount) throw new AcrossRefusal("relayer-price", `relayers would keep all of the ${amount} sent (fee ${fee})`, "amount_too_small");
|
|
115
|
+
return { fee, f5, need };
|
|
116
|
+
}
|
|
117
|
+
var ACROSS_RELAYER_FEE_TOLERANCE_PCT = 10;
|
|
118
|
+
function acrossCheckRelayerFee(route, amount, fee, answer) {
|
|
119
|
+
if (answer.kind === "refused") throw new AcrossRefusal("relayer-price", `${answer.detail} (read on this device)`, answer.reason);
|
|
120
|
+
if (answer.kind === "unavailable") {
|
|
121
|
+
if (acrossFloorCovers(route)) return;
|
|
122
|
+
throw new AcrossRefusal("relayer-price", `Across's relayer fee quote did not answer on this device (${answer.detail.slice(0, 120)}), and ${route.input.chain.name} \u2192 ${route.output.chain.name} has no studied floor to stand on`, "upstream_unavailable");
|
|
123
|
+
}
|
|
124
|
+
const need = answer.totalRelayFee;
|
|
125
|
+
if (fee * 100n < need * BigInt(100 - ACROSS_RELAYER_FEE_TOLERANCE_PCT)) {
|
|
126
|
+
throw new AcrossRefusal("relayer-price", `the deposit leaves relayers ${fee} of ${amount}, under the ${need} Across's own relayer fee quote names for it (read on this device) \u2014 relayers would leave it unfilled, and the funds wait for a refund`, "price_check_failed");
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function acrossQuoteTimeOf(ethereumBlockTime, originBlockTime) {
|
|
130
|
+
return Math.min(ethereumBlockTime - ACROSS_QUOTE_TIME_LAG_S, originBlockTime);
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=pricing.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/pricing.ts","../src/refusal.ts"],"sourcesContent":["/**\n * How much a plain SpokePool deposit leaves to relayers — the one number a quote source decides.\n *\n * The risk is two-sided. Asking relayers for too much (`outputAmount` too high) and nobody fills: the funds wait for\n * the fill deadline (two hours) and then Across's refund bundles (hours more). Asking for too little and the user\n * overpays. Across API V5 is the price source, but it prices V5's OWN route, not a plain deposit: an execution step on\n * the origin chain through Across's Gateway that a plain deposit does not have (the user's own wallet pays the\n * deposit's gas), sometimes another rail (USDT Ethereum → Arbitrum went to a 20-minute rail on 2026-11-14), and an\n * auction whose relayers fill large ETH L2 → L2 transfers at ~1 bp, well below what plain deposits are filled at.\n *\n * The rule (study of 2026-11-15: 27 V5 / suggested-fees pairs and 8 272 deposits on Ethereum, Optimism, Base and\n * Arbitrum over 24 h — 1 369 of 1 369 organic plain deposits to Base, Arbitrum and Optimism priced at or above the\n * relayer fee were filled, p50 2 s, p90 13 s):\n *\n * ```\n * F5 = V5 fee.totalFee − Σ V5 gasEstimates[origin, included_in_transfer_fee] (the add-back rounded down)\n * Fneed = /suggested-fees totalRelayFee.total while Across answers it\n * = floor(asset, origin, size) + 1.5 × V5's destination gas otherwise (studied routes only)\n * fee = max(F5, Fneed); outputAmount = input − fee\n * = Fneed, from /suggested-fees only, when V5's fill estimate is over a minute (V5 prices another rail)\n * quoteTimestamp = /suggested-fees `timestamp` (the LP fee was priced there; never ahead of the server's clock), else\n * min(latest Ethereum block time − 60 s, latest origin block time)\n * fillDeadline = quoteTimestamp + 7200; no exclusivity\n * ```\n *\n * `max()` keeps both bounds: never more than V5 charges for the same transfer (net of the step a plain deposit does\n * not have), never less than plain deposits are filled at today. When V5's fill estimate is over a minute its price\n * is another rail's (a CCTP or OFT transfer, 1 216 s for USDT Ethereum → Arbitrum on 2026-11-15, at 12× the relayer\n * fee), not a bound on a plain deposit: the deposit is then priced on Across's relayer fee alone, and refused without it.\n *\n * The device holds whatever a server says to its own checks (`verify.ts`, `remote.ts`): the user's cap, a per-asset\n * fee floor, and — through `acrossRemoteProvider` — Across's keyless relayer fee read on the device itself\n * ({@link acrossCheckRelayerFee}), so a server can neither take a deposit nor get one signed that relayers leave unfilled.\n */\nimport type {AcrossSuggestedFees} from \"./api.js\";\nimport type {AcrossRoute} from \"./config.js\";\nimport {AcrossRefusal} from \"./refusal.js\";\n\n/** The fill deadline after the quote time: what Across's own quotes give (3 923 of 6 982 plain deposits, 2026-11-14). */\nexport const ACROSS_FILL_WINDOW_S = 7_200;\n/** Without `/suggested-fees`, the quote time lags Ethereum's latest block by this much (the LP fee is priced at a HubPool block). */\nexport const ACROSS_QUOTE_TIME_LAG_S = 60;\n\n/**\n * The relayer-fee floor without `/suggested-fees`, in hundredths of a basis point (millionths) of the input, read off 24 h of\n * fills priced by it (2026-11-14): stablecoins 1.00 bp, WBTC 3.10 bps, ETH from Ethereum 1.00 bp (fills seen at\n * 0.74–0.84), ETH from an L2 on a size curve. Plus 1.5 × V5's destination gas.\n */\nexport const ACROSS_FLOOR_CBPS = Object.freeze({stable: 100, wbtc: 310, ethFromEthereum: 100});\n/** 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. */\nexport const ACROSS_ETH_L2_CURVE: readonly (readonly [number, number])[] = Object.freeze([\n [0, 477], [1_000, 515], [2_000, 540], [4_000, 605], [8_000, 715], [16_000, 850], [36_000, 920],\n].map((p) => Object.freeze(p as [number, number])));\n/** Above this size (USD) no plain ETH L2 deposit was seen: refused when the floor is what prices it. */\nexport const ACROSS_ETH_L2_FLOOR_MAX_USD = 36_000;\n/**\n * The chains the floor was derived on: deposits from Ethereum, Optimism, Base and Arbitrum to Optimism, Base and\n * Arbitrum. Without `/suggested-fees` any other route has no relayer price this module can stand behind.\n */\nexport const ACROSS_FLOOR_ORIGINS: readonly number[] = Object.freeze([1, 10, 8453, 42161]);\nexport const ACROSS_FLOOR_DESTINATIONS: readonly number[] = Object.freeze([10, 8453, 42161]);\n\n/** Whether the pinned floor covers a route (its origin and destination are among the studied chains). */\nexport function acrossFloorCovers(route: AcrossRoute): boolean {\n return ACROSS_FLOOR_ORIGINS.includes(route.input.chain.chainId) && ACROSS_FLOOR_DESTINATIONS.includes(route.output.chain.chainId);\n}\n\n/**\n * Over this fill estimate (ms) a V5 quote prices another rail than an Across relayer fill: Across-rail fills were\n * estimated at 1.3–14 s on every recorded cell, the OFT rail for USDT Ethereum → Arbitrum at 1 216 s (2026-11-15).\n */\nexport const ACROSS_V5_OTHER_RAIL_FILL_MS = 60_000;\n/** True when a V5 fill estimate says V5 priced another rail. */\nexport const acrossV5OtherRail = (expectedFillTimeMs: number): boolean => expectedFillTimeMs > ACROSS_V5_OTHER_RAIL_FILL_MS;\n\n/**\n * Why a route is not priced at all, or null. Ethereum as the destination: small plain deposits to Ethereum went\n * unfilled in the study's window (some paying more than filled ones), for reasons the data does not show — kept out\n * until studied rather than priced on a guess.\n */\nexport function acrossRouteUnpriced(route: AcrossRoute): string | null {\n if (route.output.chain.chainId === 1) return \"plain deposits to Ethereum are not priced yet — small ones went unfilled in the 2026-11-14 study for reasons the data does not show\";\n return null;\n}\n\n/** The floor in hundredths of a bp for a route and size (USD), or a refusal text. */\nexport function acrossFloorCbps(route: AcrossRoute, amountUsd: number | undefined): number | string {\n const src = route.input.chain.chainId;\n if (!acrossFloorCovers(route)) {\n return `without Across's relayer fee quote there is no relayer price for ${route.input.chain.name} → ${route.output.chain.name} (the pinned floor covers Ethereum, Optimism, Base and Arbitrum to Optimism, Base and Arbitrum)`;\n }\n if (route.asset === \"USDC\" || route.asset === \"USDT\") return ACROSS_FLOOR_CBPS.stable;\n if (route.asset === \"WBTC\") return ACROSS_FLOOR_CBPS.wbtc;\n if (src === 1) return ACROSS_FLOOR_CBPS.ethFromEthereum;\n if (amountUsd === undefined || !Number.isFinite(amountUsd) || amountUsd < 0) return \"without Across's relayer fee quote the ETH floor needs the transfer's size in dollars, and the V5 quote states none\";\n if (amountUsd > ACROSS_ETH_L2_FLOOR_MAX_USD) return `without Across's relayer fee quote ETH from an L2 is priced up to $${ACROSS_ETH_L2_FLOOR_MAX_USD} (no larger plain deposit was seen)`;\n const c = ACROSS_ETH_L2_CURVE;\n for (let i = 1; i < c.length; i++) {\n const [x1, y1] = c[i]!;\n if (amountUsd <= x1) {\n const [x0, y0] = c[i - 1]!;\n return Math.ceil(y0 + ((y1 - y0) * (amountUsd - x0)) / (x1 - x0));\n }\n }\n return c[c.length - 1]![1];\n}\n\n/** `amount × cbps / 1 000 000`, rounded up. */\nexport const acrossCbpsOf = (amount: bigint, cbps: number): bigint => (amount * BigInt(cbps) + 999_999n) / 1_000_000n;\n\n/** The pinned-floor relayer need for a route without `/suggested-fees`: floor + 1.5 × V5's destination gas, rounded up. */\nexport function acrossFloorFee(route: AcrossRoute, amount: bigint, amountUsd: number | undefined, destinationGas: bigint | null): bigint {\n const cbps = acrossFloorCbps(route, amountUsd);\n if (typeof cbps === \"string\") {\n // Too large only where the floor covers the route and the size is what it lacks; elsewhere the relayer price is.\n const tooLarge = acrossFloorCovers(route) && route.asset === \"ETH\" && route.input.chain.chainId !== 1 && amountUsd !== undefined && amountUsd > ACROSS_ETH_L2_FLOOR_MAX_USD;\n throw new AcrossRefusal(\"relayer-price\", cbps, tooLarge ? \"amount_too_large\" : \"upstream_unavailable\");\n }\n if (destinationGas === null) throw new AcrossRefusal(\"relayer-price\", \"without Across's relayer fee quote the floor needs V5's destination gas, and it does not read\", \"upstream_unavailable\");\n return acrossCbpsOf(amount, cbps) + (destinationGas * 3n + 1n) / 2n;\n}\n\n/** The fee of a plain deposit: `max(F5, Fneed)`, with both terms. */\nexport interface AcrossPlainFee {\n fee: bigint;\n /** V5's fee net of its origin execution step. */\n f5: bigint;\n /** What a relayer needs (`/suggested-fees`, or the floor). */\n need: bigint;\n}\n\n/**\n * `max(F5, Fneed)`; `Fneed` alone when V5 priced another rail (`otherRail`: F5 is then that rail's price, kept for\n * display only). Refuses a fee that eats the whole input (`amount_too_small`).\n */\nexport function acrossPlainFee(amount: bigint, v5: {totalFee: bigint; originGas: bigint}, need: bigint, otherRail = false): AcrossPlainFee {\n const f5 = v5.totalFee - (v5.originGas > v5.totalFee ? v5.totalFee : v5.originGas);\n const fee = otherRail || need > f5 ? need : f5;\n if (fee >= amount) throw new AcrossRefusal(\"relayer-price\", `relayers would keep all of the ${amount} sent (fee ${fee})`, \"amount_too_small\");\n return {fee, f5, need};\n}\n\n/**\n * How far under Across's own relayer fee a deposit's fee may sit when the device reads that fee itself, in percent of\n * it: the server's read and the device's are seconds apart, and the same quote moved at most 2.2 % over a minute\n * (five corridors, 2026-11-15).\n */\nexport const ACROSS_RELAYER_FEE_TOLERANCE_PCT = 10;\n\n/**\n * The device's own check of a deposit's fee against Across's keyless relayer fee for it, read on the device\n * (`acrossRemoteProvider`): a fee more than {@link ACROSS_RELAYER_FEE_TOLERANCE_PCT} % under it is refused\n * (`price_check_failed` — relayers would leave the deposit unfilled for its two-hour deadline and the refund after);\n * Across refusing the deposit refuses it with Across's reason. Without an answer only a route the pinned floor covers\n * stands, on the per-asset floor the verifier already held it to; any other route is refused (`upstream_unavailable`).\n * Throws {@link AcrossRefusal} `relayer-price`.\n */\nexport function acrossCheckRelayerFee(route: AcrossRoute, amount: bigint, fee: bigint, answer: AcrossSuggestedFees): void {\n if (answer.kind === \"refused\") throw new AcrossRefusal(\"relayer-price\", `${answer.detail} (read on this device)`, answer.reason);\n if (answer.kind === \"unavailable\") {\n if (acrossFloorCovers(route)) return;\n throw new AcrossRefusal(\"relayer-price\", `Across's relayer fee quote did not answer on this device (${answer.detail.slice(0, 120)}), and ${route.input.chain.name} → ${route.output.chain.name} has no studied floor to stand on`, \"upstream_unavailable\");\n }\n const need = answer.totalRelayFee;\n if (fee * 100n < need * BigInt(100 - ACROSS_RELAYER_FEE_TOLERANCE_PCT)) {\n throw new AcrossRefusal(\"relayer-price\", `the deposit leaves relayers ${fee} of ${amount}, under the ${need} Across's own relayer fee quote names for it (read on this device) — relayers would leave it unfilled, and the funds wait for a refund`, \"price_check_failed\");\n }\n}\n\n/** The deposit's quote time without `/suggested-fees`: `min(Ethereum − 60 s, origin)`, from the chains' latest blocks. */\nexport function acrossQuoteTimeOf(ethereumBlockTime: number, originBlockTime: number): number {\n return Math.min(ethereumBlockTime - ACROSS_QUOTE_TIME_LAG_S, originBlockTime);\n}\n","import {withReason, type Swap2RefusalReason} from \"@anywalletkit/protocol-swap2-core/errors\";\n\n/** Why a request, a deposit, a quote or an API answer was refused. One code per check; the message says what was found. */\nexport type AcrossRefusalCode =\n | \"request-invalid\"\n | \"chain-unsupported\"\n | \"token-unsupported\"\n | \"pair-unsupported\"\n | \"native-unsupported\"\n | \"wrapped-native-destination\"\n | \"route-unpriced\"\n | \"quote-unavailable\"\n | \"quote-normalized\"\n | \"tx-shape\"\n | \"tx-chain\"\n | \"tx-target\"\n | \"tx-selector\"\n | \"tx-calldata\"\n | \"tx-depositor\"\n | \"tx-recipient\"\n | \"tx-input-token\"\n | \"tx-output-token\"\n | \"tx-input-amount\"\n | \"tx-output-amount\"\n | \"tx-fee\"\n | \"tx-destination\"\n | \"tx-message\"\n | \"tx-message-v5\"\n | \"tx-exclusivity\"\n | \"tx-quote-time\"\n | \"tx-fill-deadline\"\n | \"tx-value\"\n | \"tx-approval\"\n | \"speed-up\"\n | \"quote-shape\"\n | \"quote-amounts\"\n | \"quote-expiry\"\n | \"quote-gas\"\n | \"quote-intent\"\n | \"api-error\"\n | \"api-answer\"\n | \"relayer-price\";\n\n/**\n * `code` names the check; `reason` (a `Swap2RefusalReason` from `@anywalletkit/protocol-swap2-core`) is the stable\n * classification an app switches on. It is set where the refusal is raised, so one code can carry different reasons\n * (a fill deadline too far ahead is `policy_refused`, one already too close is `quote_expired`); a malformed request\n * from the caller (a programming error) carries none.\n */\nexport class AcrossRefusal extends Error {\n readonly code: AcrossRefusalCode;\n declare readonly reason?: Swap2RefusalReason;\n constructor(code: AcrossRefusalCode, detail: string, reason?: Swap2RefusalReason) {\n super(`across: ${detail} [${code}]`);\n this.name = \"AcrossRefusal\";\n this.code = code;\n if (reason !== undefined) withReason(this, reason);\n }\n}\n"],"mappings":"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","names":[]}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { AcrossSuggestedFees } from './api.cjs';
|
|
2
|
+
import { AcrossRoute } from './config.cjs';
|
|
3
|
+
import '@anywalletkit/protocol-swap2-core/errors';
|
|
4
|
+
import './verify.cjs';
|
|
5
|
+
import 'viem';
|
|
6
|
+
import '@anywalletkit/protocol-swap2-core/types';
|
|
7
|
+
import './deposit.cjs';
|
|
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 };
|