@hyperbridge/sdk 2.8.11 → 2.8.12

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.
@@ -3570,13 +3570,6 @@ interface FillerConfig {
3570
3570
  * Example: { 1: true, 56: false } - watch-only on Ethereum, normal execution on BSC
3571
3571
  */
3572
3572
  watchOnly?: Record<number, boolean>;
3573
- /**
3574
- * Source chains (state machine ids, e.g. "EVM-8453") this filler accepts payment from when
3575
- * filling cross-chain orders, declared inside its phantom bids' paymasterAndData. Omit to
3576
- * declare nothing, which downstream consumers read as "accepts all CCTP/USDT0-covered
3577
- * chains"; an empty array declares that no source chain is accepted.
3578
- */
3579
- acceptedSourceChains?: string[];
3580
3573
  /**
3581
3574
  * Uniswap V4 position tokenIds this filler holds, per chain (state machine id -> tokenIds as
3582
3575
  * decimal strings), declared inside its phantom bids' paymasterAndData for the bid's own chain.
@@ -6542,19 +6535,24 @@ declare function decodeAcceptedSourceChains(paymasterAndData: string | undefined
6542
6535
  * paid its cost of goods.
6543
6536
  */
6544
6537
  declare const UNISWAP_QUOTE_HAIRCUT_BPS = 10n;
6538
+ /** Applies {@link UNISWAP_QUOTE_HAIRCUT_BPS} to a quoted output amount, rounding down. */
6539
+ declare function applyUniswapQuoteHaircut(amount: bigint): bigint;
6545
6540
  /**
6546
- * Haircut applied to every phantom quote that is NOT priced off a Uniswap V4 pool, in basis points.
6541
+ * The protocol fee haircut: the fee the IntentGateway at `gatewayAddress` charges on order inputs,
6542
+ * in basis points, read live from its `params()`.
6543
+ *
6544
+ * A wallet-funded quote is shaded by exactly this, so the published rate is the one a taker
6545
+ * actually realizes after the gateway takes its cut, and it moves with governance rather than
6546
+ * with a constant someone has to remember to keep in step. Read on the phantom order's own chain,
6547
+ * which is the chain whose gateway will collect the fee on the fills this rate is published for.
6547
6548
  *
6548
- * A wallet-funded quote is still the best case the solver sees at bid time; the published rate is
6549
- * what the protocol tells takers they can trade against, so it is shaded by this margin rather
6550
- * than being the most optimistic number any bidder named. Pool-priced quotes pay
6551
- * {@link UNISWAP_QUOTE_HAIRCUT_BPS} instead of this — not on top of it.
6549
+ * Fails loudly rather than defaulting: a gateway that returns no code, or a fee at or above 100%,
6550
+ * is a misconfiguration, and pricing a window unhaircut on the back of it would publish a rate
6551
+ * nobody can trade at. The `PhantomRpcError` lets the run's retry loop have another go first.
6552
6552
  */
6553
- declare const PHANTOM_QUOTE_HAIRCUT_BPS = 5n;
6554
- /** Applies {@link UNISWAP_QUOTE_HAIRCUT_BPS} to a quoted output amount, rounding down. */
6555
- declare function applyUniswapQuoteHaircut(amount: bigint): bigint;
6556
- /** Applies {@link PHANTOM_QUOTE_HAIRCUT_BPS} to a quoted output amount, rounding down. */
6557
- declare function applyPhantomQuoteHaircut(amount: bigint): bigint;
6553
+ declare function readProtocolFeeHaircutBps(evmRpcUrl: string, gatewayAddress: string): Promise<bigint>;
6554
+ /** Applies the protocol fee haircut (see {@link readProtocolFeeHaircutBps}) to a quoted output amount, rounding down. */
6555
+ declare function applyProtocolFeeHaircut(amount: bigint, protocolFeeBps: bigint): bigint;
6558
6556
 
6559
6557
  declare const ABI$1: readonly [{
6560
6558
  readonly type: "constructor";
@@ -11582,4 +11580,4 @@ declare function teleport(teleport_param: {
11582
11580
  extrinsics?: Array<SubmittableExtrinsic<"promise", ISubmittableResult>>;
11583
11581
  }): Promise<ReadableStream<HyperbridgeTxEvents>>;
11584
11582
 
11585
- export { ADDRESS_ZERO, type AllStatusKey, type AssetTeleported, type AssetTeleportedResponse, type AvailableLiquidity, type Bid, type BidStorageEntry, type BidSubmissionResult, type BlockMetadata, type BridgeParams, type BridgeStep, type BundlerGasEstimate, BundlerMethod, type BuyAndSellRates, type BytesLikeHex, CHAINS_WITHOUT_VALID_UNTIL, type CancelEvent, type CancelOptions, type CancelOrderOptions, type CancelQuote, type ChainConfig, type ChainConfigData, ChainConfigService, Chains, type ClientConfig, type ConfiguredAssetSymbol, type ConfiguredAssetSymbolInput, CryptoUtils, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DOMAIN_TYPEHASH, DUMMY_PRIVATE_KEY, type DecodedOrderPlacedLog, type DecodedPostRequestEvent, type DecodedPostResponseEvent, type Deployment, type DispatchGet, type DispatchInfo, type DispatchPost, ERC20Method, type ERC7821Call, ERC7821_BATCH_MODE, type Erc4626VaultConfigData, type EstimateFillOrderParams, type EstimateGasCallData, EvmChain, type EvmChainParams, ABI as EvmHostABI, EvmLanguage, type ExecuteIntentOrderOptions, type ExecutionResult, FILL_ORDER_V1_ABI, type FillOptions, type FillOptionsVersion, type FillOrderEstimate, type FillerBid, type FillerConfig, type GetRequestResponse, type GetRequestWithStatus, type GetResponseByRequestIdResponse, type GetResponseStorageValues, type HexString$1 as HexString, type HostParams, HyperClientStatus, HyperFungibleToken, HyperFungibleTokenABI, type HyperbridgeTxEvents, type IBatchConsensusAndGetResponseMessage, type IBatchConsensusAndPostRequestMessage, type IChain, type IConfig, type IConsensusMessage, type IEvmChain, type IEvmConfig, type IGetRequest, type IGetRequestMessage, type IGetResponse, type IGetResponseMessage, type IHyperbridgeConfig, type IIsmpMessage, type IMessage, INCLUSION_TIMEOUT_MS, type IPharosConfig, type IPolkadotHubConfig, type IPostRequest, type IPostResponse, type IProof, type IRequestMessage, type ISubstrateConfig, type ITimeoutPostRequestMessage, type IndexedRateIntentQuoteMetadata, type IndexedRateQuoteIntentResult, type IndexedRateSide, IndexedRateUnavailableError, type IndexerQueryClient, IntentGateway, ABI$1 as IntentGatewayABI, type IntentGatewayContext, type IntentGatewayParams, IntentOrderStatus, type IntentOrderStatusKey, type IntentOrderStatusUpdate, type IntentQuoteStrategy, type IntentQuoteTradeType, IntentsCoprocessor, InvalidIndexedRateError, InvalidLiquidityIndexerResponseError, InvalidPhantomSnapshotError, IsmpClient, type IsmpRequest, LEGACY_FILL_OPTIONS_IMPLEMENTATIONS, type LiquiditySlice, MOCK_ADDRESS, ORDER_V2_PARAM_TYPE, type Order, type OrderFeesQuote, type OrderResponse, OrderStatus, OrderStatusChecker, type OrderStatusMetadata, type OrderWithStatus, PACKED_USEROP_TYPEHASH, PHANTOM_QUOTE_HAIRCUT_BPS, PLACE_ORDER_SELECTOR, type PackedUserOperation, type Params, type PaymentInfo, type PhantomBid, type PhantomBidBatchResult, type PhantomBidDeclaration, type PhantomBidOutcome, type PhantomOrderEvent, type PhantomOrderLeg, type PhantomOrderPriceSnapshot, type PhantomOrderPriceSnapshotsResponse, type PhantomSnapshotIntentQuoteMetadata, type PhantomSnapshotQuoteIntentResult, PhantomSnapshotUnavailableError, type PhantomTimings, PharosChain, type PharosChainParams, PolkadotHubChain, type PolkadotHubChainParams, type PollPhantomOrdersOptions, type PostRequestStatus, type PostRequestTimeoutStatus, type PostRequestWithStatus, type QueryBuyAndSellRatesParams, type QuoteIntentParams, type QuoteIntentResult, type QuoteNativeResult, type QuoteResult, type QuoteUniswapParams, type QuoteUniswapResult, REQUEST_COMMITMENTS_SLOT, REQUEST_RECEIPTS_SLOT, RESPONSE_COMMITMENTS_SLOT, RESPONSE_RECEIPTS_SLOT, type RequestBody, type RequestCommitment, RequestKind, type RequestResponse, RequestStatus, type RequestStatusKey, type RequestStatusWithMetadata, type ResponseCommitmentWithValues, type ResumeIntentOrderOptions, type RetryConfig, SELECT_SOLVER_TYPEHASH, STATE_COMMITMENTS_SLOT, type SelectBidResult, type SelectOptions, type SigningAccount, type StateMachineHeight, type StateMachineId, type StateMachineIdParams, type StateMachineResponse, type StateMachineUpdate, type StorageFacade, type SubmitBidOptions, SubstrateChain, Swap, TESTNET_CHAINS, type TeleportParams, TeleportStatus, TimeoutStatus, type TimeoutStatusKey, TokenGateway, type TokenGatewayAssetTeleportedResponse, type TokenGatewayAssetTeleportedWithStatus, type TokenInfo, type TokenPrice, type TokenPricesResponse, type Transaction, TronChain, type TronChainParams, UNISWAP_QUOTE_HAIRCUT_BPS, USE_ETHERSCAN_CHAINS, type UniswapProtocol, type UniswapQuote, type UniswapQuoteToken, type UniswapTradeType, type UniswapV4IntentQuoteMetadata, type UniswapV4IntentQuoteOptions, type UniswapV4PoolConfigData, type UniswapV4PoolKey, type UniswapV4QuoteIntentResult, UnsupportedIntentQuotePairError, UnsupportedIntentQuoteStrategyError, UnsupportedLiquidityAssetError, UnsupportedLiquidityChainError, WrappedHyperFungibleTokenABI, type XcmGatewayParams, __test, adjustDecimals, applyPhantomQuoteHaircut, applyUniswapQuoteHaircut, bytes20ToBytes32, bytes32ToBytes20, calculateAllowanceMappingLocation, calculateBalanceMappingLocation, chainConfigs, constructRedeemEscrowRequestBody, constructRefundEscrowRequestBody, convertCodecToIGetRequest, convertCodecToIProof, convertIGetRequestToCodec, convertIProofToCodec, convertStateIdToStateMachineId, convertStateMachineEnumToString, convertStateMachineIdToEnum, createEvmChain, createQueryClient, decodeAcceptedSourceChains, decodeERC7821ExecuteBatch, decodeFillOrder, decodePhantomBidDeclaration, decodeUserOpScale, deriveHttpUrl, encodeAcceptedSourceChains, encodeERC7821ExecuteBatch, encodeFillOrder, encodeISMPMessage, encodePhantomBidDeclaration, encodeStateMachineId, encodeUserOpScale, encodeWithdrawalRequest, estimateGasForPost, fetchPrice, fetchSourceProof, generateRootWithProof, getChainId, getConfigByStateMachineId, getContractCallInput, getContractCallInputs, getFillOptionsVersion, getGasPriceFromEtherscan, getOrFetchStorageSlot, getOrderPlacedFromTx, getPostRequestEventFromTx, getPostResponseEventFromTx, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, getViemChain, hexToString, hyperbridgeAddress, maxBigInt, normalizeAddressForEvmBytes32, normalizeAddressForStateMachine, normalizeEvmAddress, normalizeEvmChainId, normalizeStateMachineId, orderCommitment, parseStateMachineId, pharosAtlantic, pharosMainnet, polkadotAssetHubPaseo, polkadotHubMainnet, poolSlug, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, quoteUniswap, requestCommitmentKey, resetFillOptionsVersionCache, responseCommitmentKey, retryPromise, sortPoolSymbols, teleport, teleportDot, transformOrderForContract, tronChainIds, tronNile };
11583
+ export { ADDRESS_ZERO, type AllStatusKey, type AssetTeleported, type AssetTeleportedResponse, type AvailableLiquidity, type Bid, type BidStorageEntry, type BidSubmissionResult, type BlockMetadata, type BridgeParams, type BridgeStep, type BundlerGasEstimate, BundlerMethod, type BuyAndSellRates, type BytesLikeHex, CHAINS_WITHOUT_VALID_UNTIL, type CancelEvent, type CancelOptions, type CancelOrderOptions, type CancelQuote, type ChainConfig, type ChainConfigData, ChainConfigService, Chains, type ClientConfig, type ConfiguredAssetSymbol, type ConfiguredAssetSymbolInput, CryptoUtils, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DOMAIN_TYPEHASH, DUMMY_PRIVATE_KEY, type DecodedOrderPlacedLog, type DecodedPostRequestEvent, type DecodedPostResponseEvent, type Deployment, type DispatchGet, type DispatchInfo, type DispatchPost, ERC20Method, type ERC7821Call, ERC7821_BATCH_MODE, type Erc4626VaultConfigData, type EstimateFillOrderParams, type EstimateGasCallData, EvmChain, type EvmChainParams, ABI as EvmHostABI, EvmLanguage, type ExecuteIntentOrderOptions, type ExecutionResult, FILL_ORDER_V1_ABI, type FillOptions, type FillOptionsVersion, type FillOrderEstimate, type FillerBid, type FillerConfig, type GetRequestResponse, type GetRequestWithStatus, type GetResponseByRequestIdResponse, type GetResponseStorageValues, type HexString$1 as HexString, type HostParams, HyperClientStatus, HyperFungibleToken, HyperFungibleTokenABI, type HyperbridgeTxEvents, type IBatchConsensusAndGetResponseMessage, type IBatchConsensusAndPostRequestMessage, type IChain, type IConfig, type IConsensusMessage, type IEvmChain, type IEvmConfig, type IGetRequest, type IGetRequestMessage, type IGetResponse, type IGetResponseMessage, type IHyperbridgeConfig, type IIsmpMessage, type IMessage, INCLUSION_TIMEOUT_MS, type IPharosConfig, type IPolkadotHubConfig, type IPostRequest, type IPostResponse, type IProof, type IRequestMessage, type ISubstrateConfig, type ITimeoutPostRequestMessage, type IndexedRateIntentQuoteMetadata, type IndexedRateQuoteIntentResult, type IndexedRateSide, IndexedRateUnavailableError, type IndexerQueryClient, IntentGateway, ABI$1 as IntentGatewayABI, type IntentGatewayContext, type IntentGatewayParams, IntentOrderStatus, type IntentOrderStatusKey, type IntentOrderStatusUpdate, type IntentQuoteStrategy, type IntentQuoteTradeType, IntentsCoprocessor, InvalidIndexedRateError, InvalidLiquidityIndexerResponseError, InvalidPhantomSnapshotError, IsmpClient, type IsmpRequest, LEGACY_FILL_OPTIONS_IMPLEMENTATIONS, type LiquiditySlice, MOCK_ADDRESS, ORDER_V2_PARAM_TYPE, type Order, type OrderFeesQuote, type OrderResponse, OrderStatus, OrderStatusChecker, type OrderStatusMetadata, type OrderWithStatus, PACKED_USEROP_TYPEHASH, PLACE_ORDER_SELECTOR, type PackedUserOperation, type Params, type PaymentInfo, type PhantomBid, type PhantomBidBatchResult, type PhantomBidDeclaration, type PhantomBidOutcome, type PhantomOrderEvent, type PhantomOrderLeg, type PhantomOrderPriceSnapshot, type PhantomOrderPriceSnapshotsResponse, type PhantomSnapshotIntentQuoteMetadata, type PhantomSnapshotQuoteIntentResult, PhantomSnapshotUnavailableError, type PhantomTimings, PharosChain, type PharosChainParams, PolkadotHubChain, type PolkadotHubChainParams, type PollPhantomOrdersOptions, type PostRequestStatus, type PostRequestTimeoutStatus, type PostRequestWithStatus, type QueryBuyAndSellRatesParams, type QuoteIntentParams, type QuoteIntentResult, type QuoteNativeResult, type QuoteResult, type QuoteUniswapParams, type QuoteUniswapResult, REQUEST_COMMITMENTS_SLOT, REQUEST_RECEIPTS_SLOT, RESPONSE_COMMITMENTS_SLOT, RESPONSE_RECEIPTS_SLOT, type RequestBody, type RequestCommitment, RequestKind, type RequestResponse, RequestStatus, type RequestStatusKey, type RequestStatusWithMetadata, type ResponseCommitmentWithValues, type ResumeIntentOrderOptions, type RetryConfig, SELECT_SOLVER_TYPEHASH, STATE_COMMITMENTS_SLOT, type SelectBidResult, type SelectOptions, type SigningAccount, type StateMachineHeight, type StateMachineId, type StateMachineIdParams, type StateMachineResponse, type StateMachineUpdate, type StorageFacade, type SubmitBidOptions, SubstrateChain, Swap, TESTNET_CHAINS, type TeleportParams, TeleportStatus, TimeoutStatus, type TimeoutStatusKey, TokenGateway, type TokenGatewayAssetTeleportedResponse, type TokenGatewayAssetTeleportedWithStatus, type TokenInfo, type TokenPrice, type TokenPricesResponse, type Transaction, TronChain, type TronChainParams, UNISWAP_QUOTE_HAIRCUT_BPS, USE_ETHERSCAN_CHAINS, type UniswapProtocol, type UniswapQuote, type UniswapQuoteToken, type UniswapTradeType, type UniswapV4IntentQuoteMetadata, type UniswapV4IntentQuoteOptions, type UniswapV4PoolConfigData, type UniswapV4PoolKey, type UniswapV4QuoteIntentResult, UnsupportedIntentQuotePairError, UnsupportedIntentQuoteStrategyError, UnsupportedLiquidityAssetError, UnsupportedLiquidityChainError, WrappedHyperFungibleTokenABI, type XcmGatewayParams, __test, adjustDecimals, applyProtocolFeeHaircut, applyUniswapQuoteHaircut, bytes20ToBytes32, bytes32ToBytes20, calculateAllowanceMappingLocation, calculateBalanceMappingLocation, chainConfigs, constructRedeemEscrowRequestBody, constructRefundEscrowRequestBody, convertCodecToIGetRequest, convertCodecToIProof, convertIGetRequestToCodec, convertIProofToCodec, convertStateIdToStateMachineId, convertStateMachineEnumToString, convertStateMachineIdToEnum, createEvmChain, createQueryClient, decodeAcceptedSourceChains, decodeERC7821ExecuteBatch, decodeFillOrder, decodePhantomBidDeclaration, decodeUserOpScale, deriveHttpUrl, encodeAcceptedSourceChains, encodeERC7821ExecuteBatch, encodeFillOrder, encodeISMPMessage, encodePhantomBidDeclaration, encodeStateMachineId, encodeUserOpScale, encodeWithdrawalRequest, estimateGasForPost, fetchPrice, fetchSourceProof, generateRootWithProof, getChainId, getConfigByStateMachineId, getContractCallInput, getContractCallInputs, getFillOptionsVersion, getGasPriceFromEtherscan, getOrFetchStorageSlot, getOrderPlacedFromTx, getPostRequestEventFromTx, getPostResponseEventFromTx, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, getViemChain, hexToString, hyperbridgeAddress, maxBigInt, normalizeAddressForEvmBytes32, normalizeAddressForStateMachine, normalizeEvmAddress, normalizeEvmChainId, normalizeStateMachineId, orderCommitment, parseStateMachineId, pharosAtlantic, pharosMainnet, polkadotAssetHubPaseo, polkadotHubMainnet, poolSlug, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, quoteUniswap, readProtocolFeeHaircutBps, requestCommitmentKey, resetFillOptionsVersionCache, responseCommitmentKey, retryPromise, sortPoolSymbols, teleport, teleportDot, transformOrderForContract, tronChainIds, tronNile };
@@ -20606,8 +20606,52 @@ var IntentGateway = class _IntentGateway {
20606
20606
  }
20607
20607
  }
20608
20608
  };
20609
-
20610
- // src/protocols/intents/phantom-aggregation.ts
20609
+ function rpcFetch() {
20610
+ const f = globalThis.fetch;
20611
+ if (typeof f !== "function") {
20612
+ throw new Error("No fetch available; call setAggregationFetch() before using the aggregation helpers");
20613
+ }
20614
+ return f;
20615
+ }
20616
+ var PhantomRpcError = class extends Error {
20617
+ constructor(message, cause) {
20618
+ super(message);
20619
+ this.cause = cause;
20620
+ this.name = "PhantomRpcError";
20621
+ }
20622
+ cause;
20623
+ };
20624
+ async function rpcCall(url, payload) {
20625
+ let lastErr;
20626
+ for (let attempt = 0; attempt < 4; attempt++) {
20627
+ if (attempt > 0) await new Promise((resolve) => setTimeout(resolve, 150 * attempt));
20628
+ let timer;
20629
+ try {
20630
+ const timeout = new Promise((_, reject) => {
20631
+ timer = setTimeout(() => reject(new Error(`rpc timeout: ${url}`)), 12e3);
20632
+ });
20633
+ const response = await Promise.race([
20634
+ rpcFetch()(url, {
20635
+ method: "POST",
20636
+ headers: { accept: "application/json", "content-type": "application/json" },
20637
+ body: JSON.stringify(payload)
20638
+ }),
20639
+ timeout
20640
+ ]);
20641
+ const body = await response.json();
20642
+ if (body?.error) {
20643
+ lastErr = new Error(`rpc error: ${JSON.stringify(body.error).slice(0, 200)}`);
20644
+ continue;
20645
+ }
20646
+ return body;
20647
+ } catch (err) {
20648
+ lastErr = err;
20649
+ } finally {
20650
+ if (timer) clearTimeout(timer);
20651
+ }
20652
+ }
20653
+ throw new PhantomRpcError(`RPC call failed after 4 attempts: ${url}`, lastErr);
20654
+ }
20611
20655
  var FILL_ORDER_ABI = IntentGatewayV2_default.ABI;
20612
20656
  var DECLARATION_V1 = 1;
20613
20657
  var DECLARATION_V2 = 2;
@@ -20696,15 +20740,35 @@ function decodeAcceptedSourceChains(paymasterAndData) {
20696
20740
  return decodePhantomBidDeclaration(paymasterAndData).acceptedSources;
20697
20741
  }
20698
20742
  var UNISWAP_QUOTE_HAIRCUT_BPS = 10n;
20699
- var PHANTOM_QUOTE_HAIRCUT_BPS = 5n;
20700
20743
  function haircut(amount, bps) {
20701
20744
  return amount * (10000n - bps) / 10000n;
20702
20745
  }
20703
20746
  function applyUniswapQuoteHaircut(amount) {
20704
20747
  return haircut(amount, UNISWAP_QUOTE_HAIRCUT_BPS);
20705
20748
  }
20706
- function applyPhantomQuoteHaircut(amount) {
20707
- return haircut(amount, PHANTOM_QUOTE_HAIRCUT_BPS);
20749
+ var SELECTOR_GATEWAY_PARAMS = "0xcff0ab96";
20750
+ var GATEWAY_PARAMS_WORDS = 6;
20751
+ var GATEWAY_PARAMS_FEE_WORD = 4;
20752
+ async function readProtocolFeeHaircutBps(evmRpcUrl, gatewayAddress) {
20753
+ const result = await rpcCall(evmRpcUrl, {
20754
+ id: 1,
20755
+ jsonrpc: "2.0",
20756
+ method: "eth_call",
20757
+ params: [{ to: gatewayAddress, data: SELECTOR_GATEWAY_PARAMS }, "latest"]
20758
+ });
20759
+ const hex = result.result;
20760
+ if (typeof hex !== "string" || hex.length < 2 + 64 * GATEWAY_PARAMS_WORDS) {
20761
+ throw new PhantomRpcError(`IntentGateway.params() returned no usable result from ${gatewayAddress} on ${evmRpcUrl}`);
20762
+ }
20763
+ const start = 2 + 64 * GATEWAY_PARAMS_FEE_WORD;
20764
+ const protocolFeeBps = BigInt(`0x${hex.slice(start, start + 64)}`);
20765
+ if (protocolFeeBps >= 10000n) {
20766
+ throw new PhantomRpcError(`IntentGateway ${gatewayAddress} reports an implausible protocol fee: ${protocolFeeBps} bps`);
20767
+ }
20768
+ return protocolFeeBps;
20769
+ }
20770
+ function applyProtocolFeeHaircut(amount, protocolFeeBps) {
20771
+ return haircut(amount, protocolFeeBps);
20708
20772
  }
20709
20773
  FILL_ORDER_ABI.find(
20710
20774
  (item) => item?.type === "function" && item?.name === "fillOrder"
@@ -25179,6 +25243,6 @@ async function teleportDot(param_) {
25179
25243
  return stream;
25180
25244
  }
25181
25245
 
25182
- export { ADDRESS_ZERO2 as ADDRESS_ZERO, BundlerMethod, CHAINS_WITHOUT_VALID_UNTIL, ChainConfigService, Chains, CryptoUtils, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DOMAIN_TYPEHASH, DUMMY_PRIVATE_KEY, ERC20Method, ERC7821_BATCH_MODE, EvmChain, ABI as EvmHostABI, EvmLanguage, FILL_ORDER_V1_ABI, HyperClientStatus, HyperFungibleToken, HyperFungibleTokenABI, INCLUSION_TIMEOUT_MS, IndexedRateUnavailableError, IntentGateway, ABI3 as IntentGatewayABI, IntentOrderStatus, IntentsCoprocessor, InvalidIndexedRateError, InvalidLiquidityIndexerResponseError, InvalidPhantomSnapshotError, IsmpClient, LEGACY_FILL_OPTIONS_IMPLEMENTATIONS, MOCK_ADDRESS, ORDER_V2_PARAM_TYPE, OrderStatus, OrderStatusChecker, PACKED_USEROP_TYPEHASH, PHANTOM_QUOTE_HAIRCUT_BPS, PLACE_ORDER_SELECTOR, PhantomSnapshotUnavailableError, PharosChain, PolkadotHubChain, REQUEST_COMMITMENTS_SLOT, REQUEST_RECEIPTS_SLOT, RESPONSE_COMMITMENTS_SLOT, RESPONSE_RECEIPTS_SLOT, RequestKind, RequestStatus, SELECT_SOLVER_TYPEHASH, STATE_COMMITMENTS_SLOT, SubstrateChain, Swap, TESTNET_CHAINS, TeleportStatus, TimeoutStatus, TokenGateway, TronChain, UNISWAP_QUOTE_HAIRCUT_BPS, USE_ETHERSCAN_CHAINS, UnsupportedIntentQuotePairError, UnsupportedIntentQuoteStrategyError, UnsupportedLiquidityAssetError, UnsupportedLiquidityChainError, WrappedHyperFungibleTokenABI, __test, adjustDecimals, applyPhantomQuoteHaircut, applyUniswapQuoteHaircut, bytes20ToBytes32, bytes32ToBytes20, calculateAllowanceMappingLocation, calculateBalanceMappingLocation, chainConfigs, constructRedeemEscrowRequestBody, constructRefundEscrowRequestBody, convertCodecToIGetRequest, convertCodecToIProof, convertIGetRequestToCodec, convertIProofToCodec, convertStateIdToStateMachineId, convertStateMachineEnumToString, convertStateMachineIdToEnum, createEvmChain, createQueryClient, decodeAcceptedSourceChains, decodeERC7821ExecuteBatch, decodeFillOrder, decodePhantomBidDeclaration, decodeUserOpScale, deriveHttpUrl, encodeAcceptedSourceChains, encodeERC7821ExecuteBatch, encodeFillOrder, encodeISMPMessage, encodePhantomBidDeclaration, encodeStateMachineId, encodeUserOpScale, encodeWithdrawalRequest, estimateGasForPost, fetchPrice, fetchSourceProof, generateRootWithProof, getChainId, getConfigByStateMachineId, getContractCallInput, getContractCallInputs, getFillOptionsVersion, getGasPriceFromEtherscan, getOrFetchStorageSlot, getOrderPlacedFromTx, getPostRequestEventFromTx, getPostResponseEventFromTx, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, getViemChain, hexToString, hyperbridgeAddress, maxBigInt, normalizeAddressForEvmBytes32, normalizeAddressForStateMachine, normalizeEvmAddress, normalizeEvmChainId, normalizeStateMachineId, orderCommitment, parseStateMachineId, pharosAtlantic, pharosMainnet, polkadotAssetHubPaseo, polkadotHubMainnet, poolSlug, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, quoteUniswap, requestCommitmentKey, resetFillOptionsVersionCache, responseCommitmentKey, retryPromise, sortPoolSymbols, teleport, teleportDot, transformOrderForContract, tronChainIds, tronNile };
25246
+ export { ADDRESS_ZERO2 as ADDRESS_ZERO, BundlerMethod, CHAINS_WITHOUT_VALID_UNTIL, ChainConfigService, Chains, CryptoUtils, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DOMAIN_TYPEHASH, DUMMY_PRIVATE_KEY, ERC20Method, ERC7821_BATCH_MODE, EvmChain, ABI as EvmHostABI, EvmLanguage, FILL_ORDER_V1_ABI, HyperClientStatus, HyperFungibleToken, HyperFungibleTokenABI, INCLUSION_TIMEOUT_MS, IndexedRateUnavailableError, IntentGateway, ABI3 as IntentGatewayABI, IntentOrderStatus, IntentsCoprocessor, InvalidIndexedRateError, InvalidLiquidityIndexerResponseError, InvalidPhantomSnapshotError, IsmpClient, LEGACY_FILL_OPTIONS_IMPLEMENTATIONS, MOCK_ADDRESS, ORDER_V2_PARAM_TYPE, OrderStatus, OrderStatusChecker, PACKED_USEROP_TYPEHASH, PLACE_ORDER_SELECTOR, PhantomSnapshotUnavailableError, PharosChain, PolkadotHubChain, REQUEST_COMMITMENTS_SLOT, REQUEST_RECEIPTS_SLOT, RESPONSE_COMMITMENTS_SLOT, RESPONSE_RECEIPTS_SLOT, RequestKind, RequestStatus, SELECT_SOLVER_TYPEHASH, STATE_COMMITMENTS_SLOT, SubstrateChain, Swap, TESTNET_CHAINS, TeleportStatus, TimeoutStatus, TokenGateway, TronChain, UNISWAP_QUOTE_HAIRCUT_BPS, USE_ETHERSCAN_CHAINS, UnsupportedIntentQuotePairError, UnsupportedIntentQuoteStrategyError, UnsupportedLiquidityAssetError, UnsupportedLiquidityChainError, WrappedHyperFungibleTokenABI, __test, adjustDecimals, applyProtocolFeeHaircut, applyUniswapQuoteHaircut, bytes20ToBytes32, bytes32ToBytes20, calculateAllowanceMappingLocation, calculateBalanceMappingLocation, chainConfigs, constructRedeemEscrowRequestBody, constructRefundEscrowRequestBody, convertCodecToIGetRequest, convertCodecToIProof, convertIGetRequestToCodec, convertIProofToCodec, convertStateIdToStateMachineId, convertStateMachineEnumToString, convertStateMachineIdToEnum, createEvmChain, createQueryClient, decodeAcceptedSourceChains, decodeERC7821ExecuteBatch, decodeFillOrder, decodePhantomBidDeclaration, decodeUserOpScale, deriveHttpUrl, encodeAcceptedSourceChains, encodeERC7821ExecuteBatch, encodeFillOrder, encodeISMPMessage, encodePhantomBidDeclaration, encodeStateMachineId, encodeUserOpScale, encodeWithdrawalRequest, estimateGasForPost, fetchPrice, fetchSourceProof, generateRootWithProof, getChainId, getConfigByStateMachineId, getContractCallInput, getContractCallInputs, getFillOptionsVersion, getGasPriceFromEtherscan, getOrFetchStorageSlot, getOrderPlacedFromTx, getPostRequestEventFromTx, getPostResponseEventFromTx, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, getViemChain, hexToString, hyperbridgeAddress, maxBigInt, normalizeAddressForEvmBytes32, normalizeAddressForStateMachine, normalizeEvmAddress, normalizeEvmChainId, normalizeStateMachineId, orderCommitment, parseStateMachineId, pharosAtlantic, pharosMainnet, polkadotAssetHubPaseo, polkadotHubMainnet, poolSlug, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, quoteUniswap, readProtocolFeeHaircutBps, requestCommitmentKey, resetFillOptionsVersionCache, responseCommitmentKey, retryPromise, sortPoolSymbols, teleport, teleportDot, transformOrderForContract, tronChainIds, tronNile };
25183
25247
  //# sourceMappingURL=index.js.map
25184
25248
  //# sourceMappingURL=index.js.map