@hyperbridge/sdk 2.8.11 → 2.8.13
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/dist/browser/index.d.ts +76 -19
- package/dist/browser/index.js +202 -27
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +205 -27
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +2 -2
- package/dist/node/index.d.ts +2 -2
- package/dist/node/index.js +202 -27
- package/dist/node/index.js.map +1 -1
- package/dist/node/{intents-helpers-BRegx4yZ.d.cts → intents-helpers-fntBuoYM.d.cts} +76 -19
- package/dist/node/{intents-helpers-BRegx4yZ.d.ts → intents-helpers-fntBuoYM.d.ts} +76 -19
- package/dist/node/intents-helpers.cjs +162 -27
- package/dist/node/intents-helpers.cjs.map +1 -1
- package/dist/node/intents-helpers.d.cts +1 -1
- package/dist/node/intents-helpers.d.ts +1 -1
- package/dist/node/intents-helpers.js +159 -27
- package/dist/node/intents-helpers.js.map +1 -1
- package/package.json +1 -1
|
@@ -2812,13 +2812,6 @@ interface FillerConfig {
|
|
|
2812
2812
|
* Example: { 1: true, 56: false } - watch-only on Ethereum, normal execution on BSC
|
|
2813
2813
|
*/
|
|
2814
2814
|
watchOnly?: Record<number, boolean>;
|
|
2815
|
-
/**
|
|
2816
|
-
* Source chains (state machine ids, e.g. "EVM-8453") this filler accepts payment from when
|
|
2817
|
-
* filling cross-chain orders, declared inside its phantom bids' paymasterAndData. Omit to
|
|
2818
|
-
* declare nothing, which downstream consumers read as "accepts all CCTP/USDT0-covered
|
|
2819
|
-
* chains"; an empty array declares that no source chain is accepted.
|
|
2820
|
-
*/
|
|
2821
|
-
acceptedSourceChains?: string[];
|
|
2822
2815
|
/**
|
|
2823
2816
|
* Uniswap V4 position tokenIds this filler holds, per chain (state machine id -> tokenIds as
|
|
2824
2817
|
* decimal strings), declared inside its phantom bids' paymasterAndData for the bid's own chain.
|
|
@@ -5426,6 +5419,24 @@ declare const FILL_ORDER_ABI: readonly [{
|
|
|
5426
5419
|
readonly name: "WrongChain";
|
|
5427
5420
|
readonly inputs: readonly [];
|
|
5428
5421
|
}];
|
|
5422
|
+
/** A complete Permit2-sponsored paymasterAndData, before any declaration is appended. */
|
|
5423
|
+
declare const PERMIT2_SPONSORSHIP_BYTES: number;
|
|
5424
|
+
/**
|
|
5425
|
+
* The Permit2 sponsorship a bid's paymasterAndData carries when it was built on the real-bid path:
|
|
5426
|
+
* which paymaster it names and the fee-token permit it signed for that paymaster. Read for the
|
|
5427
|
+
* record only — the bid's authenticity comes from the solver signature over the userOpHash, which
|
|
5428
|
+
* covers these bytes, so nothing here is verified further and the permit signature is not kept.
|
|
5429
|
+
*/
|
|
5430
|
+
interface PhantomBidSponsorship {
|
|
5431
|
+
paymaster: HexString;
|
|
5432
|
+
/** The fee token the permit draws on. */
|
|
5433
|
+
token: HexString;
|
|
5434
|
+
permitAmount: bigint;
|
|
5435
|
+
/** Permit2 unordered nonce — random per op, which is what lets a solver's bids run in parallel. */
|
|
5436
|
+
nonce: bigint;
|
|
5437
|
+
/** Unix seconds after which the permit is unusable. */
|
|
5438
|
+
deadline: bigint;
|
|
5439
|
+
}
|
|
5429
5440
|
/** What a phantom bid's paymasterAndData declares about the solver behind it. */
|
|
5430
5441
|
interface PhantomBidDeclaration {
|
|
5431
5442
|
/**
|
|
@@ -5449,12 +5460,53 @@ declare function encodePhantomBidDeclaration(declaration: {
|
|
|
5449
5460
|
acceptedSourceChains?: string[];
|
|
5450
5461
|
uniswapV4Positions?: bigint[];
|
|
5451
5462
|
}): HexString;
|
|
5463
|
+
/** Everything a phantom bid's paymasterAndData was found to carry. */
|
|
5464
|
+
interface PhantomBidPaymasterAndData {
|
|
5465
|
+
/**
|
|
5466
|
+
* Which shape the field was read as: a bare declaration, a Permit2-sponsored bid (with or
|
|
5467
|
+
* without a declaration appended), or neither — empty, or bytes matching no known layout.
|
|
5468
|
+
*/
|
|
5469
|
+
mode: "declaration" | "permit2" | "none";
|
|
5470
|
+
/** Never null: an unreadable or missing declaration is the absent one (null sources, no positions). */
|
|
5471
|
+
declaration: PhantomBidDeclaration;
|
|
5472
|
+
/** The paymaster fields of a sponsored bid; null for the other two modes. */
|
|
5473
|
+
sponsorship: PhantomBidSponsorship | null;
|
|
5474
|
+
}
|
|
5452
5475
|
/**
|
|
5453
|
-
* Decodes a phantom bid's paymasterAndData
|
|
5476
|
+
* Decodes a phantom bid's paymasterAndData in whichever shape it takes.
|
|
5477
|
+
*
|
|
5478
|
+
* A bare declaration is tried first, so every bid placed before sponsored phantom bids existed
|
|
5479
|
+
* decodes to the byte exactly as it did. Failing that, a blob opening with a complete
|
|
5480
|
+
* Permit2-sponsored payload is read as a sponsored bid, and whatever follows the permit is parsed
|
|
5481
|
+
* as its declaration. Both parsers demand exact consumption — a bare declaration must end where
|
|
5482
|
+
* the bytes end, and a sponsored bid's tail must be a whole declaration or nothing — so neither
|
|
5483
|
+
* shape can be half-read as the other.
|
|
5484
|
+
*
|
|
5485
|
+
* A malformed tail on a sponsored bid yields the absent declaration but still reports the
|
|
5486
|
+
* sponsorship: the bid is still a bid, it just declared nothing readable.
|
|
5487
|
+
*/
|
|
5488
|
+
declare function decodePhantomBidPaymasterAndData(paymasterAndData: string | undefined | null): PhantomBidPaymasterAndData;
|
|
5489
|
+
/**
|
|
5490
|
+
* Decodes the declaration out of a phantom bid's paymasterAndData, whichever shape it takes (see
|
|
5491
|
+
* {@link decodePhantomBidPaymasterAndData}). Understands both declaration versions, so bids placed
|
|
5454
5492
|
* before positions existed keep decoding unchanged. Anything absent, unversioned or malformed
|
|
5455
5493
|
* yields a null `acceptedSources` with no positions — never a partial read.
|
|
5456
5494
|
*/
|
|
5457
5495
|
declare function decodePhantomBidDeclaration(paymasterAndData: string | undefined | null): PhantomBidDeclaration;
|
|
5496
|
+
/**
|
|
5497
|
+
* Builds a phantom bid's paymasterAndData: the declaration alone, or appended to a Permit2
|
|
5498
|
+
* sponsorship when the bid was built on the real-bid path and carries one.
|
|
5499
|
+
*
|
|
5500
|
+
* `sponsorship` is the packed EntryPoint v0.8 paymasterAndData the paymaster builder produced. It
|
|
5501
|
+
* must be exactly the Permit2-mode layout — the only one the decoder recognises — so a caller
|
|
5502
|
+
* cannot sign bytes the aggregation would read as "no declaration"; anything else throws. Empty
|
|
5503
|
+
* or omitted, the result is the bare declaration, byte-identical to what unsponsored bids carry.
|
|
5504
|
+
*/
|
|
5505
|
+
declare function encodePhantomBidPaymasterAndData(bid: {
|
|
5506
|
+
sponsorship?: HexString | null;
|
|
5507
|
+
acceptedSourceChains?: string[];
|
|
5508
|
+
uniswapV4Positions?: bigint[];
|
|
5509
|
+
}): HexString;
|
|
5458
5510
|
/** Back-compat wrapper: the source-chain half of {@link encodePhantomBidDeclaration}. */
|
|
5459
5511
|
declare function encodeAcceptedSourceChains(chains: string[]): HexString;
|
|
5460
5512
|
/** Back-compat wrapper: the source-chain half of {@link decodePhantomBidDeclaration}. */
|
|
@@ -5586,19 +5638,24 @@ interface AggregationLogger {
|
|
|
5586
5638
|
* paid its cost of goods.
|
|
5587
5639
|
*/
|
|
5588
5640
|
declare const UNISWAP_QUOTE_HAIRCUT_BPS = 10n;
|
|
5641
|
+
/** Applies {@link UNISWAP_QUOTE_HAIRCUT_BPS} to a quoted output amount, rounding down. */
|
|
5642
|
+
declare function applyUniswapQuoteHaircut(amount: bigint): bigint;
|
|
5589
5643
|
/**
|
|
5590
|
-
*
|
|
5644
|
+
* The protocol fee haircut: the fee the IntentGateway at `gatewayAddress` charges on order inputs,
|
|
5645
|
+
* in basis points, read live from its `params()`.
|
|
5591
5646
|
*
|
|
5592
|
-
* A wallet-funded quote is
|
|
5593
|
-
*
|
|
5594
|
-
*
|
|
5595
|
-
*
|
|
5647
|
+
* A wallet-funded quote is shaded by exactly this, so the published rate is the one a taker
|
|
5648
|
+
* actually realizes after the gateway takes its cut, and it moves with governance rather than
|
|
5649
|
+
* with a constant someone has to remember to keep in step. Read on the phantom order's own chain,
|
|
5650
|
+
* which is the chain whose gateway will collect the fee on the fills this rate is published for.
|
|
5651
|
+
*
|
|
5652
|
+
* Fails loudly rather than defaulting: a gateway that returns no code, or a fee at or above 100%,
|
|
5653
|
+
* is a misconfiguration, and pricing a window unhaircut on the back of it would publish a rate
|
|
5654
|
+
* nobody can trade at. The `PhantomRpcError` lets the run's retry loop have another go first.
|
|
5596
5655
|
*/
|
|
5597
|
-
declare
|
|
5598
|
-
/** Applies {@link
|
|
5599
|
-
declare function
|
|
5600
|
-
/** Applies {@link PHANTOM_QUOTE_HAIRCUT_BPS} to a quoted output amount, rounding down. */
|
|
5601
|
-
declare function applyPhantomQuoteHaircut(amount: bigint): bigint;
|
|
5656
|
+
declare function readProtocolFeeHaircutBps(evmRpcUrl: string, gatewayAddress: string): Promise<bigint>;
|
|
5657
|
+
/** Applies the protocol fee haircut (see {@link readProtocolFeeHaircutBps}) to a quoted output amount, rounding down. */
|
|
5658
|
+
declare function applyProtocolFeeHaircut(amount: bigint, protocolFeeBps: bigint): bigint;
|
|
5602
5659
|
declare function weightedMedian(entries: {
|
|
5603
5660
|
price: bigint;
|
|
5604
5661
|
weight: bigint;
|
|
@@ -8845,4 +8902,4 @@ declare const _default: {
|
|
|
8845
8902
|
}];
|
|
8846
8903
|
};
|
|
8847
8904
|
|
|
8848
|
-
export { type DecodedPostResponseEvent as $, type AssetTeleported as A, type BuyAndSellRates as B, ChainConfigService as C, type SubmitBidOptions as D, type EstimateGasCallData as E, type PackedUserOperation as F, type GetRequestWithStatus as G, type HexString$2 as H, type IChain as I, type FillerBid as J, type Bid as K, type EstimateFillOrderParams as L, type FillOrderEstimate as M, type OrderFeesQuote as N, type Order as O, type PostRequestWithStatus as P, type QueryBuyAndSellRatesParams as Q, type RetryConfig as R, type StateMachineIdParams as S, type Transaction as T, type ERC7821Call as U, type OrderWithStatus as V, OrderStatus as W, type TokenGatewayAssetTeleportedWithStatus as X, TeleportStatus as Y, type DecodedOrderPlacedLog as Z, type DecodedPostRequestEvent as _, type IEvmConfig as a, type
|
|
8905
|
+
export { type DecodedPostResponseEvent as $, type AssetTeleported as A, type BuyAndSellRates as B, ChainConfigService as C, type SubmitBidOptions as D, type EstimateGasCallData as E, type PackedUserOperation as F, type GetRequestWithStatus as G, type HexString$2 as H, type IChain as I, type FillerBid as J, type Bid as K, type EstimateFillOrderParams as L, type FillOrderEstimate as M, type OrderFeesQuote as N, type Order as O, type PostRequestWithStatus as P, type QueryBuyAndSellRatesParams as Q, type RetryConfig as R, type StateMachineIdParams as S, type Transaction as T, type ERC7821Call as U, type OrderWithStatus as V, OrderStatus as W, type TokenGatewayAssetTeleportedWithStatus as X, TeleportStatus as Y, type DecodedOrderPlacedLog as Z, type DecodedPostRequestEvent as _, type IEvmConfig as a, type PostRequestStatus as a$, type AllStatusKey as a0, type AssetTeleportedResponse as a1, type BidStorageEntry as a2, type BidSubmissionResult as a3, type BlockMetadata as a4, type BytesLikeHex as a5, CHAINS_WITHOUT_VALID_UNTIL as a6, type CancelOptions as a7, type ChainConfig as a8, type ChainConfigData as a9, type IPostResponse as aA, type IRequestMessage as aB, type ISubstrateConfig as aC, type ITimeoutPostRequestMessage as aD, ABI as aE, type IntentGatewayParams as aF, IntentOrderStatus as aG, type IntentOrderStatusKey as aH, type IsmpRequest as aI, LEGACY_FILL_OPTIONS_IMPLEMENTATIONS as aJ, type LiquiditySlice as aK, type OrderResponse as aL, type OrderStatusMetadata as aM, PERMIT2_SPONSORSHIP_BYTES as aN, type PaymentInfo as aO, type PhantomBid as aP, type PhantomBidBatchResult as aQ, type PhantomBidDeclaration as aR, type PhantomBidOutcome as aS, type PhantomBidPaymasterAndData as aT, type PhantomBidSponsorship as aU, type PhantomOrderEvent as aV, type PhantomOrderLeg as aW, type PhantomOrderPriceSnapshot as aX, type PhantomOrderPriceSnapshotsResponse as aY, type PhantomTimings as aZ, type PollPhantomOrdersOptions as a_, type ConfiguredAssetSymbolInput as aa, type Deployment as ab, type DispatchGet as ac, type DispatchInfo as ad, type DispatchPost as ae, type Erc4626VaultConfigData as af, type ExecuteIntentOrderOptions as ag, type ExecutionResult as ah, FILL_ORDER_V1_ABI as ai, type FillOptions as aj, type FillOptionsVersion as ak, type FillerConfig as al, type GetRequestResponse as am, type GetResponseByRequestIdResponse as an, type GetResponseStorageValues as ao, type HostParams as ap, HyperClientStatus as aq, type IBatchConsensusAndGetResponseMessage as ar, type IBatchConsensusAndPostRequestMessage as as, type IConfig as at, type IConsensusMessage as au, type IGetRequestMessage as av, type IGetResponse as aw, type IGetResponseMessage as ax, type IHyperbridgeConfig as ay, INCLUSION_TIMEOUT_MS as az, type IMessage as b, type FetchLike as b$, type RequestBody as b0, type RequestCommitment as b1, RequestKind as b2, type RequestResponse as b3, RequestStatus as b4, type RequestStatusKey as b5, type SelectOptions as b6, type SigningAccount as b7, type StateMachineId as b8, type StateMachineResponse as b9, encodeAcceptedSourceChains as bA, encodeERC7821ExecuteBatch as bB, encodeFillOrder as bC, encodeISMPMessage as bD, encodePhantomBidDeclaration as bE, encodePhantomBidPaymasterAndData as bF, encodeUserOpScale as bG, getChainId as bH, getConfigByStateMachineId as bI, getFillOptionsVersion as bJ, getViemChain as bK, hyperbridgeAddress as bL, pharosAtlantic as bM, pharosMainnet as bN, polkadotAssetHubPaseo as bO, polkadotHubMainnet as bP, poolSlug as bQ, readProtocolFeeHaircutBps as bR, resetFillOptionsVersionCache as bS, sortPoolSymbols as bT, tronChainIds as bU, tronNile as bV, type AggregationLogger as bW, type BidNonceKeyFn as bX, type BidSignature as bY, ENTRY_POINT_V08_ADDRESS as bZ, FILL_ORDER_ABI as b_, type StorageFacade as ba, TimeoutStatus as bb, type TimeoutStatusKey as bc, type TokenGatewayAssetTeleportedResponse as bd, type TokenInfo as be, type TokenPrice as bf, type TokenPricesResponse as bg, UNISWAP_QUOTE_HAIRCUT_BPS as bh, type UniswapV4PoolConfigData as bi, applyProtocolFeeHaircut as bj, applyUniswapQuoteHaircut as bk, chainConfigs as bl, convertCodecToIGetRequest as bm, convertCodecToIProof as bn, convertIGetRequestToCodec as bo, convertIProofToCodec as bp, convertStateIdToStateMachineId as bq, convertStateMachineEnumToString as br, convertStateMachineIdToEnum as bs, decodeAcceptedSourceChains as bt, decodeERC7821ExecuteBatch as bu, decodeFillOrder as bv, decodePhantomBidDeclaration as bw, decodePhantomBidPaymasterAndData as bx, decodeUserOpScale as by, deriveHttpUrl as bz, type StateMachineHeight as c, type FillData as c0, type HexString as c1, _default as c2, type LpBalance as c3, type OrderCommitmentFn as c4, type PhantomAggregation as c5, type PhantomLegAggregation as c6, type PhantomLegBidder as c7, type PoolAndPositionInfo as c8, type RecoverBidSigner as c9, type RpcBidInfo as ca, type SolverBalanceReader as cb, type SolverV4Position as cc, type UniswapV4Contracts as cd, type V4PositionState as ce, type YieldVaultMap as cf, aggregatePhantomBids as cg, extractFillData as ch, fetchBidsForOrder as ci, getTotalSolverBalance as cj, memoizedSolverBalance as ck, orderCommitmentFromDecoded as cl, positionAmountOfToken as cm, readV4Position as cn, recoverBidSignerViem as co, setAggregationFetch as cp, splitBidSignature as cq, weightedMedian as cr, zipFillLegs as cs, type IIsmpMessage as d, type IPostRequest as e, type IGetRequest as f, type IPolkadotHubConfig as g, type IPharosConfig as h, type StateMachineUpdate as i, type ResponseCommitmentWithValues as j, type RequestStatusWithMetadata as k, type PostRequestTimeoutStatus as l, SubstrateChain as m, type ClientConfig as n, type IndexerQueryClient as o, type IProof as p, type IEvmChain as q, IntentsCoprocessor as r, Chains as s, type ConfiguredAssetSymbol as t, type AvailableLiquidity as u, type IntentOrderStatusUpdate as v, type SelectBidResult as w, type ResumeIntentOrderOptions as x, type CancelOrderOptions as y, type CancelQuote as z };
|
|
@@ -2812,13 +2812,6 @@ interface FillerConfig {
|
|
|
2812
2812
|
* Example: { 1: true, 56: false } - watch-only on Ethereum, normal execution on BSC
|
|
2813
2813
|
*/
|
|
2814
2814
|
watchOnly?: Record<number, boolean>;
|
|
2815
|
-
/**
|
|
2816
|
-
* Source chains (state machine ids, e.g. "EVM-8453") this filler accepts payment from when
|
|
2817
|
-
* filling cross-chain orders, declared inside its phantom bids' paymasterAndData. Omit to
|
|
2818
|
-
* declare nothing, which downstream consumers read as "accepts all CCTP/USDT0-covered
|
|
2819
|
-
* chains"; an empty array declares that no source chain is accepted.
|
|
2820
|
-
*/
|
|
2821
|
-
acceptedSourceChains?: string[];
|
|
2822
2815
|
/**
|
|
2823
2816
|
* Uniswap V4 position tokenIds this filler holds, per chain (state machine id -> tokenIds as
|
|
2824
2817
|
* decimal strings), declared inside its phantom bids' paymasterAndData for the bid's own chain.
|
|
@@ -5426,6 +5419,24 @@ declare const FILL_ORDER_ABI: readonly [{
|
|
|
5426
5419
|
readonly name: "WrongChain";
|
|
5427
5420
|
readonly inputs: readonly [];
|
|
5428
5421
|
}];
|
|
5422
|
+
/** A complete Permit2-sponsored paymasterAndData, before any declaration is appended. */
|
|
5423
|
+
declare const PERMIT2_SPONSORSHIP_BYTES: number;
|
|
5424
|
+
/**
|
|
5425
|
+
* The Permit2 sponsorship a bid's paymasterAndData carries when it was built on the real-bid path:
|
|
5426
|
+
* which paymaster it names and the fee-token permit it signed for that paymaster. Read for the
|
|
5427
|
+
* record only — the bid's authenticity comes from the solver signature over the userOpHash, which
|
|
5428
|
+
* covers these bytes, so nothing here is verified further and the permit signature is not kept.
|
|
5429
|
+
*/
|
|
5430
|
+
interface PhantomBidSponsorship {
|
|
5431
|
+
paymaster: HexString;
|
|
5432
|
+
/** The fee token the permit draws on. */
|
|
5433
|
+
token: HexString;
|
|
5434
|
+
permitAmount: bigint;
|
|
5435
|
+
/** Permit2 unordered nonce — random per op, which is what lets a solver's bids run in parallel. */
|
|
5436
|
+
nonce: bigint;
|
|
5437
|
+
/** Unix seconds after which the permit is unusable. */
|
|
5438
|
+
deadline: bigint;
|
|
5439
|
+
}
|
|
5429
5440
|
/** What a phantom bid's paymasterAndData declares about the solver behind it. */
|
|
5430
5441
|
interface PhantomBidDeclaration {
|
|
5431
5442
|
/**
|
|
@@ -5449,12 +5460,53 @@ declare function encodePhantomBidDeclaration(declaration: {
|
|
|
5449
5460
|
acceptedSourceChains?: string[];
|
|
5450
5461
|
uniswapV4Positions?: bigint[];
|
|
5451
5462
|
}): HexString;
|
|
5463
|
+
/** Everything a phantom bid's paymasterAndData was found to carry. */
|
|
5464
|
+
interface PhantomBidPaymasterAndData {
|
|
5465
|
+
/**
|
|
5466
|
+
* Which shape the field was read as: a bare declaration, a Permit2-sponsored bid (with or
|
|
5467
|
+
* without a declaration appended), or neither — empty, or bytes matching no known layout.
|
|
5468
|
+
*/
|
|
5469
|
+
mode: "declaration" | "permit2" | "none";
|
|
5470
|
+
/** Never null: an unreadable or missing declaration is the absent one (null sources, no positions). */
|
|
5471
|
+
declaration: PhantomBidDeclaration;
|
|
5472
|
+
/** The paymaster fields of a sponsored bid; null for the other two modes. */
|
|
5473
|
+
sponsorship: PhantomBidSponsorship | null;
|
|
5474
|
+
}
|
|
5452
5475
|
/**
|
|
5453
|
-
* Decodes a phantom bid's paymasterAndData
|
|
5476
|
+
* Decodes a phantom bid's paymasterAndData in whichever shape it takes.
|
|
5477
|
+
*
|
|
5478
|
+
* A bare declaration is tried first, so every bid placed before sponsored phantom bids existed
|
|
5479
|
+
* decodes to the byte exactly as it did. Failing that, a blob opening with a complete
|
|
5480
|
+
* Permit2-sponsored payload is read as a sponsored bid, and whatever follows the permit is parsed
|
|
5481
|
+
* as its declaration. Both parsers demand exact consumption — a bare declaration must end where
|
|
5482
|
+
* the bytes end, and a sponsored bid's tail must be a whole declaration or nothing — so neither
|
|
5483
|
+
* shape can be half-read as the other.
|
|
5484
|
+
*
|
|
5485
|
+
* A malformed tail on a sponsored bid yields the absent declaration but still reports the
|
|
5486
|
+
* sponsorship: the bid is still a bid, it just declared nothing readable.
|
|
5487
|
+
*/
|
|
5488
|
+
declare function decodePhantomBidPaymasterAndData(paymasterAndData: string | undefined | null): PhantomBidPaymasterAndData;
|
|
5489
|
+
/**
|
|
5490
|
+
* Decodes the declaration out of a phantom bid's paymasterAndData, whichever shape it takes (see
|
|
5491
|
+
* {@link decodePhantomBidPaymasterAndData}). Understands both declaration versions, so bids placed
|
|
5454
5492
|
* before positions existed keep decoding unchanged. Anything absent, unversioned or malformed
|
|
5455
5493
|
* yields a null `acceptedSources` with no positions — never a partial read.
|
|
5456
5494
|
*/
|
|
5457
5495
|
declare function decodePhantomBidDeclaration(paymasterAndData: string | undefined | null): PhantomBidDeclaration;
|
|
5496
|
+
/**
|
|
5497
|
+
* Builds a phantom bid's paymasterAndData: the declaration alone, or appended to a Permit2
|
|
5498
|
+
* sponsorship when the bid was built on the real-bid path and carries one.
|
|
5499
|
+
*
|
|
5500
|
+
* `sponsorship` is the packed EntryPoint v0.8 paymasterAndData the paymaster builder produced. It
|
|
5501
|
+
* must be exactly the Permit2-mode layout — the only one the decoder recognises — so a caller
|
|
5502
|
+
* cannot sign bytes the aggregation would read as "no declaration"; anything else throws. Empty
|
|
5503
|
+
* or omitted, the result is the bare declaration, byte-identical to what unsponsored bids carry.
|
|
5504
|
+
*/
|
|
5505
|
+
declare function encodePhantomBidPaymasterAndData(bid: {
|
|
5506
|
+
sponsorship?: HexString | null;
|
|
5507
|
+
acceptedSourceChains?: string[];
|
|
5508
|
+
uniswapV4Positions?: bigint[];
|
|
5509
|
+
}): HexString;
|
|
5458
5510
|
/** Back-compat wrapper: the source-chain half of {@link encodePhantomBidDeclaration}. */
|
|
5459
5511
|
declare function encodeAcceptedSourceChains(chains: string[]): HexString;
|
|
5460
5512
|
/** Back-compat wrapper: the source-chain half of {@link decodePhantomBidDeclaration}. */
|
|
@@ -5586,19 +5638,24 @@ interface AggregationLogger {
|
|
|
5586
5638
|
* paid its cost of goods.
|
|
5587
5639
|
*/
|
|
5588
5640
|
declare const UNISWAP_QUOTE_HAIRCUT_BPS = 10n;
|
|
5641
|
+
/** Applies {@link UNISWAP_QUOTE_HAIRCUT_BPS} to a quoted output amount, rounding down. */
|
|
5642
|
+
declare function applyUniswapQuoteHaircut(amount: bigint): bigint;
|
|
5589
5643
|
/**
|
|
5590
|
-
*
|
|
5644
|
+
* The protocol fee haircut: the fee the IntentGateway at `gatewayAddress` charges on order inputs,
|
|
5645
|
+
* in basis points, read live from its `params()`.
|
|
5591
5646
|
*
|
|
5592
|
-
* A wallet-funded quote is
|
|
5593
|
-
*
|
|
5594
|
-
*
|
|
5595
|
-
*
|
|
5647
|
+
* A wallet-funded quote is shaded by exactly this, so the published rate is the one a taker
|
|
5648
|
+
* actually realizes after the gateway takes its cut, and it moves with governance rather than
|
|
5649
|
+
* with a constant someone has to remember to keep in step. Read on the phantom order's own chain,
|
|
5650
|
+
* which is the chain whose gateway will collect the fee on the fills this rate is published for.
|
|
5651
|
+
*
|
|
5652
|
+
* Fails loudly rather than defaulting: a gateway that returns no code, or a fee at or above 100%,
|
|
5653
|
+
* is a misconfiguration, and pricing a window unhaircut on the back of it would publish a rate
|
|
5654
|
+
* nobody can trade at. The `PhantomRpcError` lets the run's retry loop have another go first.
|
|
5596
5655
|
*/
|
|
5597
|
-
declare
|
|
5598
|
-
/** Applies {@link
|
|
5599
|
-
declare function
|
|
5600
|
-
/** Applies {@link PHANTOM_QUOTE_HAIRCUT_BPS} to a quoted output amount, rounding down. */
|
|
5601
|
-
declare function applyPhantomQuoteHaircut(amount: bigint): bigint;
|
|
5656
|
+
declare function readProtocolFeeHaircutBps(evmRpcUrl: string, gatewayAddress: string): Promise<bigint>;
|
|
5657
|
+
/** Applies the protocol fee haircut (see {@link readProtocolFeeHaircutBps}) to a quoted output amount, rounding down. */
|
|
5658
|
+
declare function applyProtocolFeeHaircut(amount: bigint, protocolFeeBps: bigint): bigint;
|
|
5602
5659
|
declare function weightedMedian(entries: {
|
|
5603
5660
|
price: bigint;
|
|
5604
5661
|
weight: bigint;
|
|
@@ -8845,4 +8902,4 @@ declare const _default: {
|
|
|
8845
8902
|
}];
|
|
8846
8903
|
};
|
|
8847
8904
|
|
|
8848
|
-
export { type DecodedPostResponseEvent as $, type AssetTeleported as A, type BuyAndSellRates as B, ChainConfigService as C, type SubmitBidOptions as D, type EstimateGasCallData as E, type PackedUserOperation as F, type GetRequestWithStatus as G, type HexString$2 as H, type IChain as I, type FillerBid as J, type Bid as K, type EstimateFillOrderParams as L, type FillOrderEstimate as M, type OrderFeesQuote as N, type Order as O, type PostRequestWithStatus as P, type QueryBuyAndSellRatesParams as Q, type RetryConfig as R, type StateMachineIdParams as S, type Transaction as T, type ERC7821Call as U, type OrderWithStatus as V, OrderStatus as W, type TokenGatewayAssetTeleportedWithStatus as X, TeleportStatus as Y, type DecodedOrderPlacedLog as Z, type DecodedPostRequestEvent as _, type IEvmConfig as a, type
|
|
8905
|
+
export { type DecodedPostResponseEvent as $, type AssetTeleported as A, type BuyAndSellRates as B, ChainConfigService as C, type SubmitBidOptions as D, type EstimateGasCallData as E, type PackedUserOperation as F, type GetRequestWithStatus as G, type HexString$2 as H, type IChain as I, type FillerBid as J, type Bid as K, type EstimateFillOrderParams as L, type FillOrderEstimate as M, type OrderFeesQuote as N, type Order as O, type PostRequestWithStatus as P, type QueryBuyAndSellRatesParams as Q, type RetryConfig as R, type StateMachineIdParams as S, type Transaction as T, type ERC7821Call as U, type OrderWithStatus as V, OrderStatus as W, type TokenGatewayAssetTeleportedWithStatus as X, TeleportStatus as Y, type DecodedOrderPlacedLog as Z, type DecodedPostRequestEvent as _, type IEvmConfig as a, type PostRequestStatus as a$, type AllStatusKey as a0, type AssetTeleportedResponse as a1, type BidStorageEntry as a2, type BidSubmissionResult as a3, type BlockMetadata as a4, type BytesLikeHex as a5, CHAINS_WITHOUT_VALID_UNTIL as a6, type CancelOptions as a7, type ChainConfig as a8, type ChainConfigData as a9, type IPostResponse as aA, type IRequestMessage as aB, type ISubstrateConfig as aC, type ITimeoutPostRequestMessage as aD, ABI as aE, type IntentGatewayParams as aF, IntentOrderStatus as aG, type IntentOrderStatusKey as aH, type IsmpRequest as aI, LEGACY_FILL_OPTIONS_IMPLEMENTATIONS as aJ, type LiquiditySlice as aK, type OrderResponse as aL, type OrderStatusMetadata as aM, PERMIT2_SPONSORSHIP_BYTES as aN, type PaymentInfo as aO, type PhantomBid as aP, type PhantomBidBatchResult as aQ, type PhantomBidDeclaration as aR, type PhantomBidOutcome as aS, type PhantomBidPaymasterAndData as aT, type PhantomBidSponsorship as aU, type PhantomOrderEvent as aV, type PhantomOrderLeg as aW, type PhantomOrderPriceSnapshot as aX, type PhantomOrderPriceSnapshotsResponse as aY, type PhantomTimings as aZ, type PollPhantomOrdersOptions as a_, type ConfiguredAssetSymbolInput as aa, type Deployment as ab, type DispatchGet as ac, type DispatchInfo as ad, type DispatchPost as ae, type Erc4626VaultConfigData as af, type ExecuteIntentOrderOptions as ag, type ExecutionResult as ah, FILL_ORDER_V1_ABI as ai, type FillOptions as aj, type FillOptionsVersion as ak, type FillerConfig as al, type GetRequestResponse as am, type GetResponseByRequestIdResponse as an, type GetResponseStorageValues as ao, type HostParams as ap, HyperClientStatus as aq, type IBatchConsensusAndGetResponseMessage as ar, type IBatchConsensusAndPostRequestMessage as as, type IConfig as at, type IConsensusMessage as au, type IGetRequestMessage as av, type IGetResponse as aw, type IGetResponseMessage as ax, type IHyperbridgeConfig as ay, INCLUSION_TIMEOUT_MS as az, type IMessage as b, type FetchLike as b$, type RequestBody as b0, type RequestCommitment as b1, RequestKind as b2, type RequestResponse as b3, RequestStatus as b4, type RequestStatusKey as b5, type SelectOptions as b6, type SigningAccount as b7, type StateMachineId as b8, type StateMachineResponse as b9, encodeAcceptedSourceChains as bA, encodeERC7821ExecuteBatch as bB, encodeFillOrder as bC, encodeISMPMessage as bD, encodePhantomBidDeclaration as bE, encodePhantomBidPaymasterAndData as bF, encodeUserOpScale as bG, getChainId as bH, getConfigByStateMachineId as bI, getFillOptionsVersion as bJ, getViemChain as bK, hyperbridgeAddress as bL, pharosAtlantic as bM, pharosMainnet as bN, polkadotAssetHubPaseo as bO, polkadotHubMainnet as bP, poolSlug as bQ, readProtocolFeeHaircutBps as bR, resetFillOptionsVersionCache as bS, sortPoolSymbols as bT, tronChainIds as bU, tronNile as bV, type AggregationLogger as bW, type BidNonceKeyFn as bX, type BidSignature as bY, ENTRY_POINT_V08_ADDRESS as bZ, FILL_ORDER_ABI as b_, type StorageFacade as ba, TimeoutStatus as bb, type TimeoutStatusKey as bc, type TokenGatewayAssetTeleportedResponse as bd, type TokenInfo as be, type TokenPrice as bf, type TokenPricesResponse as bg, UNISWAP_QUOTE_HAIRCUT_BPS as bh, type UniswapV4PoolConfigData as bi, applyProtocolFeeHaircut as bj, applyUniswapQuoteHaircut as bk, chainConfigs as bl, convertCodecToIGetRequest as bm, convertCodecToIProof as bn, convertIGetRequestToCodec as bo, convertIProofToCodec as bp, convertStateIdToStateMachineId as bq, convertStateMachineEnumToString as br, convertStateMachineIdToEnum as bs, decodeAcceptedSourceChains as bt, decodeERC7821ExecuteBatch as bu, decodeFillOrder as bv, decodePhantomBidDeclaration as bw, decodePhantomBidPaymasterAndData as bx, decodeUserOpScale as by, deriveHttpUrl as bz, type StateMachineHeight as c, type FillData as c0, type HexString as c1, _default as c2, type LpBalance as c3, type OrderCommitmentFn as c4, type PhantomAggregation as c5, type PhantomLegAggregation as c6, type PhantomLegBidder as c7, type PoolAndPositionInfo as c8, type RecoverBidSigner as c9, type RpcBidInfo as ca, type SolverBalanceReader as cb, type SolverV4Position as cc, type UniswapV4Contracts as cd, type V4PositionState as ce, type YieldVaultMap as cf, aggregatePhantomBids as cg, extractFillData as ch, fetchBidsForOrder as ci, getTotalSolverBalance as cj, memoizedSolverBalance as ck, orderCommitmentFromDecoded as cl, positionAmountOfToken as cm, readV4Position as cn, recoverBidSignerViem as co, setAggregationFetch as cp, splitBidSignature as cq, weightedMedian as cr, zipFillLegs as cs, type IIsmpMessage as d, type IPostRequest as e, type IGetRequest as f, type IPolkadotHubConfig as g, type IPharosConfig as h, type StateMachineUpdate as i, type ResponseCommitmentWithValues as j, type RequestStatusWithMetadata as k, type PostRequestTimeoutStatus as l, SubstrateChain as m, type ClientConfig as n, type IndexerQueryClient as o, type IProof as p, type IEvmChain as q, IntentsCoprocessor as r, Chains as s, type ConfiguredAssetSymbol as t, type AvailableLiquidity as u, type IntentOrderStatusUpdate as v, type SelectBidResult as w, type ResumeIntentOrderOptions as x, type CancelOrderOptions as y, type CancelQuote as z };
|
|
@@ -2731,8 +2731,67 @@ async function rpcCall(url, payload) {
|
|
|
2731
2731
|
var FILL_ORDER_ABI = IntentGatewayV2_default.ABI;
|
|
2732
2732
|
var DECLARATION_V1 = 1;
|
|
2733
2733
|
var DECLARATION_V2 = 2;
|
|
2734
|
+
var PAYMASTER_ADDRESS_BYTES = 20;
|
|
2735
|
+
var PAYMASTER_GAS_LIMIT_BYTES = 16;
|
|
2736
|
+
var PAYMASTER_DATA_OFFSET = PAYMASTER_ADDRESS_BYTES + 2 * PAYMASTER_GAS_LIMIT_BYTES;
|
|
2737
|
+
var SIMPLEX_MODE_PERMIT2 = 2;
|
|
2738
|
+
var PERMIT2_DATA_BYTES = 1 + 20 + 32 + 32 + 32 + 1 + 32 + 32;
|
|
2739
|
+
var PERMIT2_SPONSORSHIP_BYTES = PAYMASTER_DATA_OFFSET + PERMIT2_DATA_BYTES;
|
|
2734
2740
|
var MAX_DECLARED_ENTRIES = 255;
|
|
2735
2741
|
var MAX_TOKEN_ID_BYTES = 32;
|
|
2742
|
+
function utf8Encode(text) {
|
|
2743
|
+
const bytes = [];
|
|
2744
|
+
for (const char of text) {
|
|
2745
|
+
const codePoint = char.codePointAt(0);
|
|
2746
|
+
if (codePoint < 128) bytes.push(codePoint);
|
|
2747
|
+
else if (codePoint < 2048) bytes.push(192 | codePoint >> 6, 128 | codePoint & 63);
|
|
2748
|
+
else if (codePoint < 65536) {
|
|
2749
|
+
bytes.push(224 | codePoint >> 12, 128 | codePoint >> 6 & 63, 128 | codePoint & 63);
|
|
2750
|
+
} else {
|
|
2751
|
+
bytes.push(
|
|
2752
|
+
240 | codePoint >> 18,
|
|
2753
|
+
128 | codePoint >> 12 & 63,
|
|
2754
|
+
128 | codePoint >> 6 & 63,
|
|
2755
|
+
128 | codePoint & 63
|
|
2756
|
+
);
|
|
2757
|
+
}
|
|
2758
|
+
}
|
|
2759
|
+
return bytes;
|
|
2760
|
+
}
|
|
2761
|
+
function utf8Decode(bytes) {
|
|
2762
|
+
let text = "";
|
|
2763
|
+
for (let offset = 0; offset < bytes.length; ) {
|
|
2764
|
+
const lead = bytes[offset];
|
|
2765
|
+
let codePoint;
|
|
2766
|
+
let continuations;
|
|
2767
|
+
if (lead < 128) {
|
|
2768
|
+
codePoint = lead;
|
|
2769
|
+
continuations = 0;
|
|
2770
|
+
} else if ((lead & 224) === 192) {
|
|
2771
|
+
codePoint = lead & 31;
|
|
2772
|
+
continuations = 1;
|
|
2773
|
+
} else if ((lead & 240) === 224) {
|
|
2774
|
+
codePoint = lead & 15;
|
|
2775
|
+
continuations = 2;
|
|
2776
|
+
} else if ((lead & 248) === 240) {
|
|
2777
|
+
codePoint = lead & 7;
|
|
2778
|
+
continuations = 3;
|
|
2779
|
+
} else {
|
|
2780
|
+
return null;
|
|
2781
|
+
}
|
|
2782
|
+
if (offset + continuations >= bytes.length) return null;
|
|
2783
|
+
for (let index = 1; index <= continuations; index++) {
|
|
2784
|
+
const byte = bytes[offset + index];
|
|
2785
|
+
if ((byte & 192) !== 128) return null;
|
|
2786
|
+
codePoint = codePoint << 6 | byte & 63;
|
|
2787
|
+
}
|
|
2788
|
+
const overlong = continuations === 1 && codePoint < 128 || continuations === 2 && codePoint < 2048 || continuations === 3 && codePoint < 65536;
|
|
2789
|
+
if (overlong || codePoint > 1114111 || codePoint >= 55296 && codePoint <= 57343) return null;
|
|
2790
|
+
text += String.fromCodePoint(codePoint);
|
|
2791
|
+
offset += continuations + 1;
|
|
2792
|
+
}
|
|
2793
|
+
return text;
|
|
2794
|
+
}
|
|
2736
2795
|
function tokenIdToBytes(tokenId) {
|
|
2737
2796
|
if (tokenId < 0n) throw new Error(`Uniswap V4 tokenId cannot be negative: ${tokenId}`);
|
|
2738
2797
|
const bytes = [];
|
|
@@ -2755,7 +2814,7 @@ function encodePhantomBidDeclaration(declaration) {
|
|
|
2755
2814
|
const version = positions.length > 0 ? DECLARATION_V2 : DECLARATION_V1;
|
|
2756
2815
|
const bytes = [version, chains.length];
|
|
2757
2816
|
for (const chain of chains) {
|
|
2758
|
-
const encoded =
|
|
2817
|
+
const encoded = utf8Encode(chain);
|
|
2759
2818
|
if (encoded.length === 0 || encoded.length > 255) {
|
|
2760
2819
|
throw new Error(`Invalid state machine id in source chain declaration: ${chain}`);
|
|
2761
2820
|
}
|
|
@@ -2773,42 +2832,94 @@ function encodePhantomBidDeclaration(declaration) {
|
|
|
2773
2832
|
}
|
|
2774
2833
|
return util.u8aToHex(new Uint8Array(bytes));
|
|
2775
2834
|
}
|
|
2776
|
-
function
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
if (bytes.length < 2) return absent;
|
|
2781
|
-
const version = bytes[0];
|
|
2782
|
-
if (version !== DECLARATION_V1 && version !== DECLARATION_V2) return absent;
|
|
2835
|
+
function parseDeclaration(bytes, start) {
|
|
2836
|
+
if (bytes.length - start < 2) return null;
|
|
2837
|
+
const version = bytes[start];
|
|
2838
|
+
if (version !== DECLARATION_V1 && version !== DECLARATION_V2) return null;
|
|
2783
2839
|
const chains = [];
|
|
2784
|
-
let offset = 2;
|
|
2785
|
-
for (let entry = 0; entry < bytes[1]; entry++) {
|
|
2786
|
-
if (offset >= bytes.length) return
|
|
2840
|
+
let offset = start + 2;
|
|
2841
|
+
for (let entry = 0; entry < bytes[start + 1]; entry++) {
|
|
2842
|
+
if (offset >= bytes.length) return null;
|
|
2787
2843
|
const length = bytes[offset];
|
|
2788
2844
|
offset += 1;
|
|
2789
|
-
if (length === 0 || offset + length > bytes.length) return
|
|
2790
|
-
|
|
2845
|
+
if (length === 0 || offset + length > bytes.length) return null;
|
|
2846
|
+
const chain = utf8Decode(bytes.subarray(offset, offset + length));
|
|
2847
|
+
if (chain === null) return null;
|
|
2848
|
+
chains.push(chain);
|
|
2791
2849
|
offset += length;
|
|
2792
2850
|
}
|
|
2793
2851
|
const positions = [];
|
|
2794
2852
|
if (version === DECLARATION_V2) {
|
|
2795
|
-
if (offset >= bytes.length) return
|
|
2853
|
+
if (offset >= bytes.length) return null;
|
|
2796
2854
|
const count = bytes[offset];
|
|
2797
2855
|
offset += 1;
|
|
2798
2856
|
for (let entry = 0; entry < count; entry++) {
|
|
2799
|
-
if (offset >= bytes.length) return
|
|
2857
|
+
if (offset >= bytes.length) return null;
|
|
2800
2858
|
const length = bytes[offset];
|
|
2801
2859
|
offset += 1;
|
|
2802
|
-
if (length === 0 || length > MAX_TOKEN_ID_BYTES || offset + length > bytes.length) return
|
|
2803
|
-
|
|
2804
|
-
for (const byte of bytes.subarray(offset, offset + length)) tokenId = tokenId << 8n | BigInt(byte);
|
|
2805
|
-
positions.push(tokenId);
|
|
2860
|
+
if (length === 0 || length > MAX_TOKEN_ID_BYTES || offset + length > bytes.length) return null;
|
|
2861
|
+
positions.push(bytesToBigInt2(bytes.subarray(offset, offset + length)));
|
|
2806
2862
|
offset += length;
|
|
2807
2863
|
}
|
|
2808
2864
|
}
|
|
2809
|
-
if (offset !== bytes.length) return
|
|
2865
|
+
if (offset !== bytes.length) return null;
|
|
2810
2866
|
return { acceptedSources: chains, uniswapV4Positions: positions };
|
|
2811
2867
|
}
|
|
2868
|
+
function bytesToBigInt2(bytes) {
|
|
2869
|
+
let value = 0n;
|
|
2870
|
+
for (const byte of bytes) value = value << 8n | BigInt(byte);
|
|
2871
|
+
return value;
|
|
2872
|
+
}
|
|
2873
|
+
function bytesToAddress(bytes) {
|
|
2874
|
+
return util.u8aToHex(bytes);
|
|
2875
|
+
}
|
|
2876
|
+
function hasPermit2Sponsorship(bytes) {
|
|
2877
|
+
return bytes.length >= PERMIT2_SPONSORSHIP_BYTES && bytes[PAYMASTER_DATA_OFFSET] === SIMPLEX_MODE_PERMIT2;
|
|
2878
|
+
}
|
|
2879
|
+
function parseSponsorship(bytes) {
|
|
2880
|
+
let offset = 0;
|
|
2881
|
+
const take = (length) => {
|
|
2882
|
+
const slice = bytes.subarray(offset, offset + length);
|
|
2883
|
+
offset += length;
|
|
2884
|
+
return slice;
|
|
2885
|
+
};
|
|
2886
|
+
const paymaster = bytesToAddress(take(PAYMASTER_ADDRESS_BYTES));
|
|
2887
|
+
take(2 * PAYMASTER_GAS_LIMIT_BYTES);
|
|
2888
|
+
take(1);
|
|
2889
|
+
const token = bytesToAddress(take(20));
|
|
2890
|
+
const permitAmount = bytesToBigInt2(take(32));
|
|
2891
|
+
const nonce = bytesToBigInt2(take(32));
|
|
2892
|
+
const deadline = bytesToBigInt2(take(32));
|
|
2893
|
+
return { paymaster, token, permitAmount, nonce, deadline };
|
|
2894
|
+
}
|
|
2895
|
+
var absentDeclaration = () => ({ acceptedSources: null, uniswapV4Positions: [] });
|
|
2896
|
+
function decodePhantomBidPaymasterAndData(paymasterAndData) {
|
|
2897
|
+
const none = { mode: "none", declaration: absentDeclaration(), sponsorship: null };
|
|
2898
|
+
if (!paymasterAndData || !util.isHex(paymasterAndData)) return none;
|
|
2899
|
+
const bytes = util.hexToU8a(paymasterAndData);
|
|
2900
|
+
const bare = parseDeclaration(bytes, 0);
|
|
2901
|
+
if (bare) return { mode: "declaration", declaration: bare, sponsorship: null };
|
|
2902
|
+
if (!hasPermit2Sponsorship(bytes)) return none;
|
|
2903
|
+
const sponsorship = parseSponsorship(bytes);
|
|
2904
|
+
const tail = bytes.length > PERMIT2_SPONSORSHIP_BYTES ? parseDeclaration(bytes, PERMIT2_SPONSORSHIP_BYTES) : null;
|
|
2905
|
+
return { mode: "permit2", declaration: tail ?? absentDeclaration(), sponsorship };
|
|
2906
|
+
}
|
|
2907
|
+
function decodePhantomBidDeclaration(paymasterAndData) {
|
|
2908
|
+
return decodePhantomBidPaymasterAndData(paymasterAndData).declaration;
|
|
2909
|
+
}
|
|
2910
|
+
function encodePhantomBidPaymasterAndData(bid) {
|
|
2911
|
+
const declaration = encodePhantomBidDeclaration(bid);
|
|
2912
|
+
const sponsorship = bid.sponsorship;
|
|
2913
|
+
if (!sponsorship || sponsorship === "0x") return declaration;
|
|
2914
|
+
if (!util.isHex(sponsorship)) throw new Error("Phantom bid sponsorship is not hex");
|
|
2915
|
+
const bytes = util.hexToU8a(sponsorship);
|
|
2916
|
+
if (bytes.length !== PERMIT2_SPONSORSHIP_BYTES || !hasPermit2Sponsorship(bytes)) {
|
|
2917
|
+
throw new Error(
|
|
2918
|
+
`Phantom bid sponsorship must be a ${PERMIT2_SPONSORSHIP_BYTES}-byte Permit2-mode paymasterAndData, got ${bytes.length} bytes`
|
|
2919
|
+
);
|
|
2920
|
+
}
|
|
2921
|
+
return `${sponsorship}${declaration.slice(2)}`;
|
|
2922
|
+
}
|
|
2812
2923
|
function encodeAcceptedSourceChains(chains) {
|
|
2813
2924
|
return encodePhantomBidDeclaration({ acceptedSourceChains: chains });
|
|
2814
2925
|
}
|
|
@@ -2825,15 +2936,35 @@ function zipFillLegs(assets, outputs) {
|
|
|
2825
2936
|
});
|
|
2826
2937
|
}
|
|
2827
2938
|
var UNISWAP_QUOTE_HAIRCUT_BPS = 10n;
|
|
2828
|
-
var PHANTOM_QUOTE_HAIRCUT_BPS = 5n;
|
|
2829
2939
|
function haircut(amount, bps) {
|
|
2830
2940
|
return amount * (10000n - bps) / 10000n;
|
|
2831
2941
|
}
|
|
2832
2942
|
function applyUniswapQuoteHaircut(amount) {
|
|
2833
2943
|
return haircut(amount, UNISWAP_QUOTE_HAIRCUT_BPS);
|
|
2834
2944
|
}
|
|
2835
|
-
|
|
2836
|
-
|
|
2945
|
+
var SELECTOR_GATEWAY_PARAMS = "0xcff0ab96";
|
|
2946
|
+
var GATEWAY_PARAMS_WORDS = 6;
|
|
2947
|
+
var GATEWAY_PARAMS_FEE_WORD = 4;
|
|
2948
|
+
async function readProtocolFeeHaircutBps(evmRpcUrl, gatewayAddress) {
|
|
2949
|
+
const result = await rpcCall(evmRpcUrl, {
|
|
2950
|
+
id: 1,
|
|
2951
|
+
jsonrpc: "2.0",
|
|
2952
|
+
method: "eth_call",
|
|
2953
|
+
params: [{ to: gatewayAddress, data: SELECTOR_GATEWAY_PARAMS }, "latest"]
|
|
2954
|
+
});
|
|
2955
|
+
const hex = result.result;
|
|
2956
|
+
if (typeof hex !== "string" || hex.length < 2 + 64 * GATEWAY_PARAMS_WORDS) {
|
|
2957
|
+
throw new PhantomRpcError(`IntentGateway.params() returned no usable result from ${gatewayAddress} on ${evmRpcUrl}`);
|
|
2958
|
+
}
|
|
2959
|
+
const start = 2 + 64 * GATEWAY_PARAMS_FEE_WORD;
|
|
2960
|
+
const protocolFeeBps = BigInt(`0x${hex.slice(start, start + 64)}`);
|
|
2961
|
+
if (protocolFeeBps >= 10000n) {
|
|
2962
|
+
throw new PhantomRpcError(`IntentGateway ${gatewayAddress} reports an implausible protocol fee: ${protocolFeeBps} bps`);
|
|
2963
|
+
}
|
|
2964
|
+
return protocolFeeBps;
|
|
2965
|
+
}
|
|
2966
|
+
function applyProtocolFeeHaircut(amount, protocolFeeBps) {
|
|
2967
|
+
return haircut(amount, protocolFeeBps);
|
|
2837
2968
|
}
|
|
2838
2969
|
function weightedMedian(entries) {
|
|
2839
2970
|
const sorted = [...entries].sort((a, b) => a.price < b.price ? -1 : a.price > b.price ? 1 : 0);
|
|
@@ -3155,6 +3286,7 @@ async function runAggregation(params, isDelegated) {
|
|
|
3155
3286
|
}
|
|
3156
3287
|
const bids = await fetchBidsForOrder(nodeUrl, commitment);
|
|
3157
3288
|
if (bids.length === 0) return null;
|
|
3289
|
+
const protocolFeeHaircutBps = await readProtocolFeeHaircutBps(destUrl, gatewayAddress);
|
|
3158
3290
|
const v4Contracts = params.uniswapV4?.[chain];
|
|
3159
3291
|
const readPosition = memoizedV4Position(params.keccak ?? viem.keccak256, logger);
|
|
3160
3292
|
const getBalance = params.getBalance ?? memoizedSolverBalance(yieldVaults);
|
|
@@ -3198,10 +3330,10 @@ async function runAggregation(params, isDelegated) {
|
|
|
3198
3330
|
continue;
|
|
3199
3331
|
}
|
|
3200
3332
|
countedSolvers.add(normalizedSolver);
|
|
3201
|
-
const declaration =
|
|
3333
|
+
const { declaration } = decodePhantomBidPaymasterAndData(decoded.paymasterAndData);
|
|
3202
3334
|
const acceptedSources = declaration.acceptedSources;
|
|
3203
3335
|
const poolPriced = declaration.uniswapV4Positions.length > 0;
|
|
3204
|
-
const applyHaircut = poolPriced ? applyUniswapQuoteHaircut :
|
|
3336
|
+
const applyHaircut = (amount) => poolPriced ? applyUniswapQuoteHaircut(amount) : applyProtocolFeeHaircut(amount, protocolFeeHaircutBps);
|
|
3205
3337
|
const quotedLegs = [...fillData.legs.entries()].map(([legIndex, leg]) => [
|
|
3206
3338
|
legIndex,
|
|
3207
3339
|
{ ...leg, solverAmount: applyHaircut(leg.solverAmount) }
|
|
@@ -3293,18 +3425,20 @@ exports.ENTRY_POINT_V08_ADDRESS = ENTRY_POINT_V08_ADDRESS;
|
|
|
3293
3425
|
exports.FILL_ORDER_ABI = FILL_ORDER_ABI;
|
|
3294
3426
|
exports.FILL_ORDER_V1_ABI = FILL_ORDER_V1_ABI;
|
|
3295
3427
|
exports.IntentGatewayV2 = IntentGatewayV2_default;
|
|
3296
|
-
exports.
|
|
3428
|
+
exports.PERMIT2_SPONSORSHIP_BYTES = PERMIT2_SPONSORSHIP_BYTES;
|
|
3297
3429
|
exports.UNISWAP_QUOTE_HAIRCUT_BPS = UNISWAP_QUOTE_HAIRCUT_BPS;
|
|
3298
3430
|
exports.aggregatePhantomBids = aggregatePhantomBids;
|
|
3299
|
-
exports.
|
|
3431
|
+
exports.applyProtocolFeeHaircut = applyProtocolFeeHaircut;
|
|
3300
3432
|
exports.applyUniswapQuoteHaircut = applyUniswapQuoteHaircut;
|
|
3301
3433
|
exports.decodeAcceptedSourceChains = decodeAcceptedSourceChains;
|
|
3302
3434
|
exports.decodeERC7821ExecuteBatch = decodeERC7821ExecuteBatch;
|
|
3303
3435
|
exports.decodePhantomBidDeclaration = decodePhantomBidDeclaration;
|
|
3436
|
+
exports.decodePhantomBidPaymasterAndData = decodePhantomBidPaymasterAndData;
|
|
3304
3437
|
exports.decodeUserOpScale = decodeUserOpScale;
|
|
3305
3438
|
exports.encodeAcceptedSourceChains = encodeAcceptedSourceChains;
|
|
3306
3439
|
exports.encodeERC7821ExecuteBatch = encodeERC7821ExecuteBatch;
|
|
3307
3440
|
exports.encodePhantomBidDeclaration = encodePhantomBidDeclaration;
|
|
3441
|
+
exports.encodePhantomBidPaymasterAndData = encodePhantomBidPaymasterAndData;
|
|
3308
3442
|
exports.encodeUserOpScale = encodeUserOpScale;
|
|
3309
3443
|
exports.extractFillData = extractFillData;
|
|
3310
3444
|
exports.fetchBidsForOrder = fetchBidsForOrder;
|
|
@@ -3313,6 +3447,7 @@ exports.memoizedSolverBalance = memoizedSolverBalance;
|
|
|
3313
3447
|
exports.orderCommitmentFromDecoded = orderCommitmentFromDecoded;
|
|
3314
3448
|
exports.poolSlug = poolSlug;
|
|
3315
3449
|
exports.positionAmountOfToken = positionAmountOfToken;
|
|
3450
|
+
exports.readProtocolFeeHaircutBps = readProtocolFeeHaircutBps;
|
|
3316
3451
|
exports.readV4Position = readV4Position;
|
|
3317
3452
|
exports.recoverBidSignerViem = recoverBidSignerViem;
|
|
3318
3453
|
exports.setAggregationFetch = setAggregationFetch;
|