@hyperbridge/sdk 2.6.1 → 2.7.2
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 +104 -10
- package/dist/browser/index.js +193 -52
- package/dist/browser/index.js.map +1 -1
- package/dist/node/{IntentGatewayV2-BJUF1dsr.d.cts → IntentGatewayV2-MxUcNZNs.d.cts} +64 -2
- package/dist/node/{IntentGatewayV2-BJUF1dsr.d.ts → IntentGatewayV2-MxUcNZNs.d.ts} +64 -2
- package/dist/node/index.cjs +193 -52
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +43 -11
- package/dist/node/index.d.ts +43 -11
- package/dist/node/index.js +193 -52
- package/dist/node/index.js.map +1 -1
- package/dist/node/intents-helpers.d.cts +2 -2
- package/dist/node/intents-helpers.d.ts +2 -2
- package/package.json +1 -1
package/dist/browser/index.d.ts
CHANGED
|
@@ -898,6 +898,14 @@ interface UniswapV4PoolConfigData {
|
|
|
898
898
|
tickSpacing: number;
|
|
899
899
|
hooks?: `0x${string}`;
|
|
900
900
|
}
|
|
901
|
+
/** A known ERC-4626 vault fillers can use as a stablecoin treasury. */
|
|
902
|
+
interface Erc4626VaultConfigData {
|
|
903
|
+
/** Display label, e.g. "Aave stataUSDC" */
|
|
904
|
+
label: string;
|
|
905
|
+
address: `0x${string}`;
|
|
906
|
+
/** Underlying asset symbol; the on-chain vault resolves the address. */
|
|
907
|
+
asset: ConfiguredAssetSymbol;
|
|
908
|
+
}
|
|
901
909
|
interface ChainConfigData {
|
|
902
910
|
chainId: number;
|
|
903
911
|
stateMachineId: Chains;
|
|
@@ -914,6 +922,7 @@ interface ChainConfigData {
|
|
|
914
922
|
EURC?: string;
|
|
915
923
|
XSGD?: string;
|
|
916
924
|
TRYB?: string;
|
|
925
|
+
USDR?: string;
|
|
917
926
|
};
|
|
918
927
|
tokenDecimals?: {
|
|
919
928
|
USDC: number;
|
|
@@ -976,6 +985,8 @@ interface ChainConfigData {
|
|
|
976
985
|
coingeckoId: string;
|
|
977
986
|
popularTokens?: string[];
|
|
978
987
|
uniswapV4Pools?: UniswapV4PoolConfigData[];
|
|
988
|
+
/** Known ERC-4626 treasury vaults on this chain */
|
|
989
|
+
erc4626Vaults?: Erc4626VaultConfigData[];
|
|
979
990
|
/** LayerZero Endpoint ID for cross-chain messaging */
|
|
980
991
|
layerZeroEid?: number;
|
|
981
992
|
}
|
|
@@ -1024,6 +1035,14 @@ declare class ChainConfigService {
|
|
|
1024
1035
|
getCNgnDecimals(chain: string): number | undefined;
|
|
1025
1036
|
getExtAsset(chain: string): HexString | undefined;
|
|
1026
1037
|
getExtDecimals(chain: string): number | undefined;
|
|
1038
|
+
/** Configured exotic (non-USD) tokens on a chain, for selection UIs. EXT is a test asset and is not offered. */
|
|
1039
|
+
getKnownExoticTokens(chain: string): Array<{
|
|
1040
|
+
symbol: string;
|
|
1041
|
+
address: HexString;
|
|
1042
|
+
decimals?: number;
|
|
1043
|
+
}>;
|
|
1044
|
+
/** Known ERC-4626 treasury vaults on a chain, for selection UIs. */
|
|
1045
|
+
getKnownVaults(chain: string): Erc4626VaultConfigData[];
|
|
1027
1046
|
getChainId(chain: string): number;
|
|
1028
1047
|
getConsensusStateId(chain: string): string;
|
|
1029
1048
|
getHyperbridgeChainId(): number;
|
|
@@ -3610,6 +3629,33 @@ interface FillOrderEstimate {
|
|
|
3610
3629
|
*/
|
|
3611
3630
|
relayerFeeInSourceFeeToken: bigint;
|
|
3612
3631
|
}
|
|
3632
|
+
/**
|
|
3633
|
+
* Solver-fee quote for an order, priced with the same policy `execute()` /
|
|
3634
|
+
* `executeBest()` apply when `order.fees` is `0n`.
|
|
3635
|
+
*/
|
|
3636
|
+
interface OrderFeesQuote {
|
|
3637
|
+
/**
|
|
3638
|
+
* The amount to set as `Order.fees`, denominated in the source-chain fee
|
|
3639
|
+
* token. Same-chain fills carry a 2x margin over the estimated fill gas without
|
|
3640
|
+
* a gas-price bump. Cross-chain gas is priced with 10% SDK-only headroom before
|
|
3641
|
+
* adding the settlement relayer fee and a further 5% buffer over the whole sum.
|
|
3642
|
+
*/
|
|
3643
|
+
fees: bigint;
|
|
3644
|
+
/**
|
|
3645
|
+
* The native value attached to the placement transaction when the fee is
|
|
3646
|
+
* paid in the native token: the estimated fill gas cost in source-chain
|
|
3647
|
+
* wei plus a 2% buffer. The gateway swaps it for the fee token and refunds
|
|
3648
|
+
* any unused amount.
|
|
3649
|
+
*/
|
|
3650
|
+
nativeValue: bigint;
|
|
3651
|
+
/**
|
|
3652
|
+
* The source-chain fee token `fees` is denominated in — check the user's
|
|
3653
|
+
* balance and allowance against this address when paying the fee directly.
|
|
3654
|
+
*/
|
|
3655
|
+
feeToken: HexString;
|
|
3656
|
+
/** The underlying gas estimate the quote was derived from. */
|
|
3657
|
+
estimate: FillOrderEstimate;
|
|
3658
|
+
}
|
|
3613
3659
|
/**
|
|
3614
3660
|
* Result of submitting a bid to Hyperbridge
|
|
3615
3661
|
*/
|
|
@@ -3733,8 +3779,24 @@ type IntentOrderStatusUpdate = {
|
|
|
3733
3779
|
status: "AWAITING_PLACE_ORDER";
|
|
3734
3780
|
to: HexString;
|
|
3735
3781
|
data: HexString;
|
|
3736
|
-
|
|
3782
|
+
/**
|
|
3783
|
+
* The order's native-token input amounts. Native inputs cannot be
|
|
3784
|
+
* pulled via allowance, so this must be part of the placement
|
|
3785
|
+
* transaction's `msg.value`. Does not include the solver fee.
|
|
3786
|
+
*/
|
|
3787
|
+
value: bigint;
|
|
3788
|
+
/**
|
|
3789
|
+
* The native amount that funds `order.fees`: what the gateway swaps
|
|
3790
|
+
* into the fee token at placement. Add it to `value` when paying the
|
|
3791
|
+
* fee in native token. `0n` when `order.fees` was set by the caller
|
|
3792
|
+
* (fee-token rail).
|
|
3793
|
+
*/
|
|
3794
|
+
nativeFee: bigint;
|
|
3737
3795
|
sessionPrivateKey: HexString;
|
|
3796
|
+
/** Exact source-chain fee-token amount encoded in `data`. */
|
|
3797
|
+
feeTokenAmount: bigint;
|
|
3798
|
+
/** Source-chain ERC-20 token charged for `feeTokenAmount`. */
|
|
3799
|
+
feeTokenAddress: HexString;
|
|
3738
3800
|
} | {
|
|
3739
3801
|
status: "ORDER_PLACED";
|
|
3740
3802
|
order: Order;
|
|
@@ -4988,14 +5050,22 @@ declare class IntentGateway {
|
|
|
4988
5050
|
* placement, fee estimation, bid collection, and execution.
|
|
4989
5051
|
*
|
|
4990
5052
|
* **Yield/receive protocol:**
|
|
4991
|
-
* 1. If `order.fees` is unset or zero,
|
|
4992
|
-
*
|
|
4993
|
-
*
|
|
4994
|
-
*
|
|
4995
|
-
* the whole sum — strictly above the solver's
|
|
4996
|
-
*
|
|
4997
|
-
*
|
|
4998
|
-
*
|
|
5053
|
+
* 1. If `order.fees` is unset or zero, prices the fee on an internal copy
|
|
5054
|
+
* via {@link quoteOrderFees}: same-chain fees are twice the fill-gas
|
|
5055
|
+
* estimate without a gas-price bump; cross-chain gas is priced 10% above
|
|
5056
|
+
* the live price before attaching (fill gas + the settlement relayer fee)
|
|
5057
|
+
* with a further 5% buffer over the whole sum — strictly above the solver's
|
|
5058
|
+
* unpadded requirement. Direct solver estimates remain unbumped. The wei
|
|
5059
|
+
* cost used for the `value` field receives a 2% buffer.
|
|
5060
|
+
* 2. Yields `AWAITING_PLACE_ORDER` with `{ to, data, value, nativeFee,
|
|
5061
|
+
* feeTokenAmount, feeTokenAddress, sessionPrivateKey }`. `value` carries
|
|
5062
|
+
* only the order's native-token input amounts; `nativeFee` is the native
|
|
5063
|
+
* amount that funds `order.fees` (`0n` when the caller set `order.fees`);
|
|
5064
|
+
* `feeTokenAmount`/`feeTokenAddress` are the exact fee encoded in `data`
|
|
5065
|
+
* and the source-chain token it is charged in. To pay the fee in native
|
|
5066
|
+
* token, sign the transaction with `value + nativeFee`; with a fee-token
|
|
5067
|
+
* allowance, `value` alone. Pass the signed transaction back via
|
|
5068
|
+
* `gen.next(signedTx)`.
|
|
4999
5069
|
* 3. Yields `ORDER_PLACED` with the finalised order and transaction hash once
|
|
5000
5070
|
* the `OrderPlaced` event is confirmed.
|
|
5001
5071
|
* 4. Delegates to {@link OrderExecutor.executeOrder} and forwards all
|
|
@@ -5208,6 +5278,30 @@ declare class IntentGateway {
|
|
|
5208
5278
|
* @returns A {@link FillOrderEstimate} with all gas components.
|
|
5209
5279
|
*/
|
|
5210
5280
|
estimateFillOrder(params: EstimateFillOrderParams): Promise<FillOrderEstimate>;
|
|
5281
|
+
/**
|
|
5282
|
+
* Quotes the solver fee for an order using the same policy {@link execute} /
|
|
5283
|
+
* {@link executeBest} apply when `order.fees` is `0n`.
|
|
5284
|
+
*
|
|
5285
|
+
* Use this before placing to display the fee, or to check what the user can
|
|
5286
|
+
* afford: pay `fees` in the source-chain fee token (check balance and
|
|
5287
|
+
* allowance, then set `order.fees` and submit with `value: 0`), or leave
|
|
5288
|
+
* `order.fees` at `0n` and let the SDK attach `nativeValue` to the placement
|
|
5289
|
+
* transaction (check the native balance).
|
|
5290
|
+
*
|
|
5291
|
+
* @param order - The order to quote. `order.fees` is ignored and not mutated.
|
|
5292
|
+
* Gas prices used to derive cross-chain `fees` receive 10% SDK-only headroom.
|
|
5293
|
+
* Same-chain quotes and direct calls to {@link estimateFillOrder}, including
|
|
5294
|
+
* Simplex solver estimates, remain unbumped.
|
|
5295
|
+
*
|
|
5296
|
+
* @param options - Optional transaction gas-price bump percentages, as in {@link execute}.
|
|
5297
|
+
* @returns An {@link OrderFeesQuote} with the fee-token amount, the native
|
|
5298
|
+
* value for the native rail, and the underlying estimate.
|
|
5299
|
+
* @throws If gas estimation returns zero.
|
|
5300
|
+
*/
|
|
5301
|
+
quoteOrderFees(order: Order, options?: {
|
|
5302
|
+
maxPriorityFeePerGasBumpPercent?: number;
|
|
5303
|
+
maxFeePerGasBumpPercent?: number;
|
|
5304
|
+
}): Promise<OrderFeesQuote>;
|
|
5211
5305
|
/**
|
|
5212
5306
|
* Encodes a list of calls into ERC-7821 `execute` calldata using
|
|
5213
5307
|
* single-batch mode.
|
|
@@ -10487,4 +10581,4 @@ declare function teleport(teleport_param: {
|
|
|
10487
10581
|
extrinsics?: Array<SubmittableExtrinsic<"promise", ISubmittableResult>>;
|
|
10488
10582
|
}): Promise<ReadableStream<HyperbridgeTxEvents>>;
|
|
10489
10583
|
|
|
10490
|
-
export { ADDRESS_ZERO, type AllStatusKey, type AssetTeleported, type AssetTeleportedResponse, type AvailableLiquidityByChain, type AvailableLiquiditySnapshot, type Bid, type BidStorageEntry, type BidSubmissionResult, type BlockMetadata, type BridgeParams, type BridgeStep, type BundlerGasEstimate, BundlerMethod, type BytesLikeHex, type CancelEvent, type CancelOptions, type CancelOrderOptions, type CancelQuote, type ChainConfig, type ChainConfigData, ChainConfigService, Chains, type ClientConfig, type ConfiguredAssetSymbol, 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 EstimateFillOrderParams, type EstimateGasCallData, EvmChain, type EvmChainParams, ABI as EvmHostABI, EvmLanguage, type ExecuteIntentOrderOptions, type ExecutionResult, type FillOptions, type FillOrderEstimate, type FillerBid, type FillerConfig, type GetRequestResponse, type GetRequestWithStatus, type GetResponseByRequestIdResponse, type GetResponseStorageValues, type 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, type IPharosConfig, type IPolkadotHubConfig, type IPostRequest, type IPostResponse, type IProof, type IRequestMessage, type ISubstrateConfig, type ITimeoutPostRequestMessage, type IndexerQueryClient, IntentGateway, ABI$1 as IntentGatewayABI, type IntentGatewayContext, type IntentGatewayParams, IntentOrderStatus, type IntentOrderStatusKey, type IntentOrderStatusUpdate, type IntentQuoteStrategy, type IntentQuoteTradeType, IntentsCoprocessor, InvalidPhantomSnapshotError, IsmpClient, type IsmpRequest, MOCK_ADDRESS, ORDER_V2_PARAM_TYPE, type Order, type OrderResponse, OrderStatus, OrderStatusChecker, type OrderStatusMetadata, type OrderWithStatus, PACKED_USEROP_TYPEHASH, PLACE_ORDER_SELECTOR, type PackedUserOperation, type Params, type PaymentInfo, type PhantomOrderEvent, type PhantomOrderPriceSnapshot, type PhantomOrderPriceSnapshotsResponse, type PhantomSnapshotIntentQuoteMetadata, type PhantomSnapshotQuoteIntentResult, PhantomSnapshotUnavailableError, PharosChain, type PharosChainParams, PolkadotHubChain, type PolkadotHubChainParams, type PollPhantomOrdersOptions, type PostRequestStatus, type PostRequestTimeoutStatus, type PostRequestWithStatus, 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, USE_ETHERSCAN_CHAINS, type UniswapProtocol, type UniswapQuote, type UniswapQuoteToken, type UniswapTradeType, type UniswapV4IntentQuoteMetadata, type UniswapV4IntentQuoteOptions, type UniswapV4PoolConfigData, type UniswapV4PoolKey, type UniswapV4QuoteIntentResult, UnsupportedIntentQuotePairError, UnsupportedIntentQuoteStrategyError, WrappedHyperFungibleTokenABI, type XcmGatewayParams, __test, adjustDecimals, bytes20ToBytes32, bytes32ToBytes20, calculateAllowanceMappingLocation, calculateBalanceMappingLocation, chainConfigs, constructRedeemEscrowRequestBody, constructRefundEscrowRequestBody, convertCodecToIGetRequest, convertCodecToIProof, convertIGetRequestToCodec, convertIProofToCodec, convertStateIdToStateMachineId, convertStateMachineEnumToString, convertStateMachineIdToEnum, createEvmChain, createQueryClient, decodeERC7821ExecuteBatch, decodeUserOpScale, encodeERC7821ExecuteBatch, encodeISMPMessage, encodeStateMachineId, encodeUserOpScale, encodeWithdrawalRequest, estimateGasForPost, fetchPrice, fetchSourceProof, generateRootWithProof, getChainId, getConfigByStateMachineId, getContractCallInput, getContractCallInputs, getGasPriceFromEtherscan, getOrFetchStorageSlot, getOrderPlacedFromTx, getPostRequestEventFromTx, getPostResponseEventFromTx, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, getViemChain, hexToString, hyperbridgeAddress, maxBigInt, normalizeAddressForEvmBytes32, normalizeAddressForStateMachine, normalizeEvmAddress, normalizeEvmChainId, normalizeStateMachineId, orderCommitment, parseStateMachineId, pharosAtlantic, pharosMainnet, polkadotAssetHubPaseo, polkadotHubMainnet, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, quoteUniswap, requestCommitmentKey, responseCommitmentKey, retryPromise, teleport, teleportDot, transformOrderForContract, tronChainIds, tronNile };
|
|
10584
|
+
export { ADDRESS_ZERO, type AllStatusKey, type AssetTeleported, type AssetTeleportedResponse, type AvailableLiquidityByChain, type AvailableLiquiditySnapshot, type Bid, type BidStorageEntry, type BidSubmissionResult, type BlockMetadata, type BridgeParams, type BridgeStep, type BundlerGasEstimate, BundlerMethod, type BytesLikeHex, type CancelEvent, type CancelOptions, type CancelOrderOptions, type CancelQuote, type ChainConfig, type ChainConfigData, ChainConfigService, Chains, type ClientConfig, type ConfiguredAssetSymbol, 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, type FillOptions, type FillOrderEstimate, type FillerBid, type FillerConfig, type GetRequestResponse, type GetRequestWithStatus, type GetResponseByRequestIdResponse, type GetResponseStorageValues, type 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, type IPharosConfig, type IPolkadotHubConfig, type IPostRequest, type IPostResponse, type IProof, type IRequestMessage, type ISubstrateConfig, type ITimeoutPostRequestMessage, type IndexerQueryClient, IntentGateway, ABI$1 as IntentGatewayABI, type IntentGatewayContext, type IntentGatewayParams, IntentOrderStatus, type IntentOrderStatusKey, type IntentOrderStatusUpdate, type IntentQuoteStrategy, type IntentQuoteTradeType, IntentsCoprocessor, InvalidPhantomSnapshotError, IsmpClient, type IsmpRequest, 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 PhantomOrderEvent, type PhantomOrderPriceSnapshot, type PhantomOrderPriceSnapshotsResponse, type PhantomSnapshotIntentQuoteMetadata, type PhantomSnapshotQuoteIntentResult, PhantomSnapshotUnavailableError, PharosChain, type PharosChainParams, PolkadotHubChain, type PolkadotHubChainParams, type PollPhantomOrdersOptions, type PostRequestStatus, type PostRequestTimeoutStatus, type PostRequestWithStatus, 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, USE_ETHERSCAN_CHAINS, type UniswapProtocol, type UniswapQuote, type UniswapQuoteToken, type UniswapTradeType, type UniswapV4IntentQuoteMetadata, type UniswapV4IntentQuoteOptions, type UniswapV4PoolConfigData, type UniswapV4PoolKey, type UniswapV4QuoteIntentResult, UnsupportedIntentQuotePairError, UnsupportedIntentQuoteStrategyError, WrappedHyperFungibleTokenABI, type XcmGatewayParams, __test, adjustDecimals, bytes20ToBytes32, bytes32ToBytes20, calculateAllowanceMappingLocation, calculateBalanceMappingLocation, chainConfigs, constructRedeemEscrowRequestBody, constructRefundEscrowRequestBody, convertCodecToIGetRequest, convertCodecToIProof, convertIGetRequestToCodec, convertIProofToCodec, convertStateIdToStateMachineId, convertStateMachineEnumToString, convertStateMachineIdToEnum, createEvmChain, createQueryClient, decodeERC7821ExecuteBatch, decodeUserOpScale, encodeERC7821ExecuteBatch, encodeISMPMessage, encodeStateMachineId, encodeUserOpScale, encodeWithdrawalRequest, estimateGasForPost, fetchPrice, fetchSourceProof, generateRootWithProof, getChainId, getConfigByStateMachineId, getContractCallInput, getContractCallInputs, getGasPriceFromEtherscan, getOrFetchStorageSlot, getOrderPlacedFromTx, getPostRequestEventFromTx, getPostResponseEventFromTx, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, getViemChain, hexToString, hyperbridgeAddress, maxBigInt, normalizeAddressForEvmBytes32, normalizeAddressForStateMachine, normalizeEvmAddress, normalizeEvmChainId, normalizeStateMachineId, orderCommitment, parseStateMachineId, pharosAtlantic, pharosMainnet, polkadotAssetHubPaseo, polkadotHubMainnet, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, quoteUniswap, requestCommitmentKey, responseCommitmentKey, retryPromise, teleport, teleportDot, transformOrderForContract, tronChainIds, tronNile };
|
package/dist/browser/index.js
CHANGED
|
@@ -2732,7 +2732,8 @@ var chainConfigs = {
|
|
|
2732
2732
|
ZARP: "0xb755506531786C8aC63B756BaB1ac387bACB0C04",
|
|
2733
2733
|
EURC: "0x1aBaEA1f7C830bD89Acc67eC4af516284b1bC33c",
|
|
2734
2734
|
XSGD: "0x70e8dE73cE538DA2bEEd35d14187F6959a8ecA96",
|
|
2735
|
-
TRYB: "0x2C537E5624e4af88A7ae4060C022609376C8D0EB"
|
|
2735
|
+
TRYB: "0x2C537E5624e4af88A7ae4060C022609376C8D0EB",
|
|
2736
|
+
USDR: "0x9623DfB044D5612Ce0c0F1606973CCAEFd03CD05"
|
|
2736
2737
|
},
|
|
2737
2738
|
tokenDecimals: {
|
|
2738
2739
|
USDC: 6,
|
|
@@ -2771,6 +2772,10 @@ var chainConfigs = {
|
|
|
2771
2772
|
consensusStateId: "ETH0",
|
|
2772
2773
|
coingeckoId: "ethereum",
|
|
2773
2774
|
layerZeroEid: 30101,
|
|
2775
|
+
erc4626Vaults: [
|
|
2776
|
+
{ label: "Aave stataUSDC", address: "0xD4fa2D31b7968E448877f69A96DE69f5de8cD23E", asset: "USDC" },
|
|
2777
|
+
{ label: "Aave stataUSDT", address: "0x7Bc3485026Ac48b6cf9BaF0A377477Fff5703Af8", asset: "USDT" }
|
|
2778
|
+
],
|
|
2774
2779
|
popularTokens: [
|
|
2775
2780
|
"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
|
2776
2781
|
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
@@ -2825,6 +2830,10 @@ var chainConfigs = {
|
|
|
2825
2830
|
defaultRpcUrl: "https://binance.llamarpc.com",
|
|
2826
2831
|
consensusStateId: "BSC0",
|
|
2827
2832
|
coingeckoId: "binance-smart-chain",
|
|
2833
|
+
erc4626Vaults: [
|
|
2834
|
+
{ label: "Aave stataUSDC", address: "0x3906cDdfb781f02B21f21BD81ed7Fd8DC37075E1", asset: "USDC" },
|
|
2835
|
+
{ label: "Aave stataUSDT", address: "0x0471D185cc7Be61E154277cAB2396cD397663da6", asset: "USDT" }
|
|
2836
|
+
],
|
|
2828
2837
|
popularTokens: [
|
|
2829
2838
|
"0x0E09FaBB73Bd3Ade0a17ECC321fD13a19e81cE82",
|
|
2830
2839
|
"0x000Ae314E2A2172a039B26378814C252734f556A",
|
|
@@ -2884,6 +2893,10 @@ var chainConfigs = {
|
|
|
2884
2893
|
consensusStateId: "ETH0",
|
|
2885
2894
|
coingeckoId: "arbitrum-one",
|
|
2886
2895
|
layerZeroEid: 30110,
|
|
2896
|
+
erc4626Vaults: [
|
|
2897
|
+
{ label: "Aave stataUSDC", address: "0x7F6501d3B98eE91f9b9535E4b0ac710Fb0f9e0bc", asset: "USDC" },
|
|
2898
|
+
{ label: "Aave stataUSDT", address: "0xa6D12574eFB239FC1D2099732bd8b5dC6306897F", asset: "USDT" }
|
|
2899
|
+
],
|
|
2887
2900
|
popularTokens: [
|
|
2888
2901
|
"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
|
|
2889
2902
|
"0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
@@ -2904,7 +2917,8 @@ var chainConfigs = {
|
|
|
2904
2917
|
EXT: "0x0e668E5127087e236578893a0e01E41837A28469",
|
|
2905
2918
|
cNGN: "0x46C85152bFe9f96829aA94755D9f915F9B10EF5F",
|
|
2906
2919
|
ZARP: "0xb755506531786C8aC63B756BaB1ac387bACB0C04",
|
|
2907
|
-
EURC: "0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42"
|
|
2920
|
+
EURC: "0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42",
|
|
2921
|
+
USDR: "0x3B5F2810fB2168FfA9C73160F97BF9f2461fFa5c"
|
|
2908
2922
|
},
|
|
2909
2923
|
tokenDecimals: {
|
|
2910
2924
|
USDC: 6,
|
|
@@ -2946,6 +2960,10 @@ var chainConfigs = {
|
|
|
2946
2960
|
coingeckoId: "base",
|
|
2947
2961
|
layerZeroEid: 30184,
|
|
2948
2962
|
uniswapV4Pools: [{ tokens: ["USDC", "cNGN"], fee: 1500, tickSpacing: 30 }],
|
|
2963
|
+
erc4626Vaults: [
|
|
2964
|
+
{ label: "Aave stataUSDC", address: "0xC768c589647798a6EE01A91FdE98EF2ed046DBD6", asset: "USDC" },
|
|
2965
|
+
{ label: "Yield Bearing cNGN", address: "0xa82A3531021317240Fb32E67f9c7bC091F737D3b", asset: "cNGN" }
|
|
2966
|
+
],
|
|
2949
2967
|
popularTokens: [
|
|
2950
2968
|
"0x4200000000000000000000000000000000000006",
|
|
2951
2969
|
"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
@@ -2966,7 +2984,8 @@ var chainConfigs = {
|
|
|
2966
2984
|
EXT: "0x7C8c11ADb8EF7cd3CFa718008Ea048445C6E7209",
|
|
2967
2985
|
cNGN: "0x52828daa48C1a9A06F37500882b42daf0bE04C3B",
|
|
2968
2986
|
ZARP: "0xb755506531786C8aC63B756BaB1ac387bACB0C04",
|
|
2969
|
-
XSGD: "0xDC3326e71D45186F113a2F448984CA0e8D201995"
|
|
2987
|
+
XSGD: "0xDC3326e71D45186F113a2F448984CA0e8D201995",
|
|
2988
|
+
USDR: "0x3B5F2810fB2168FfA9C73160F97BF9f2461fFa5c"
|
|
2970
2989
|
},
|
|
2971
2990
|
tokenDecimals: {
|
|
2972
2991
|
USDC: 6,
|
|
@@ -3006,6 +3025,10 @@ var chainConfigs = {
|
|
|
3006
3025
|
consensusStateId: "POLY",
|
|
3007
3026
|
coingeckoId: "polygon-pos",
|
|
3008
3027
|
layerZeroEid: 30109,
|
|
3028
|
+
erc4626Vaults: [
|
|
3029
|
+
{ label: "Aave stataUSDC", address: "0x79261231698B26Ed9085b59ae89d59843Ae925a8", asset: "USDC" },
|
|
3030
|
+
{ label: "Aave stataUSDT", address: "0x2eaD203C5C1C00612B1DdbBb20e4180dA822d6ff", asset: "USDT" }
|
|
3031
|
+
],
|
|
3009
3032
|
popularTokens: [
|
|
3010
3033
|
"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",
|
|
3011
3034
|
"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",
|
|
@@ -3052,7 +3075,7 @@ var chainConfigs = {
|
|
|
3052
3075
|
WETH: "0x360ad4f9a9A8EFe9A8DCB5f461c4Cc1047E1Dcf9",
|
|
3053
3076
|
//wmatic, change it to wpol
|
|
3054
3077
|
DAI: "0x0000000000000000000000000000000000000000",
|
|
3055
|
-
USDC: "
|
|
3078
|
+
USDC: "0xBE97E73126D66188d72fbF99029126D0340a7f18",
|
|
3056
3079
|
USDT: "0x0000000000000000000000000000000000000000"
|
|
3057
3080
|
},
|
|
3058
3081
|
tokenDecimals: {
|
|
@@ -3061,7 +3084,7 @@ var chainConfigs = {
|
|
|
3061
3084
|
},
|
|
3062
3085
|
tokenStorageSlots: {
|
|
3063
3086
|
USDT: { balanceSlot: 0, allowanceSlot: 1 },
|
|
3064
|
-
USDC: { balanceSlot:
|
|
3087
|
+
USDC: { balanceSlot: 0, allowanceSlot: 1 }
|
|
3065
3088
|
},
|
|
3066
3089
|
addresses: {
|
|
3067
3090
|
IntentGateway: "0x6CF42FA9BecbC5b6a26884964956b113530f7cFA",
|
|
@@ -5227,6 +5250,19 @@ var ChainConfigService = class {
|
|
|
5227
5250
|
getExtDecimals(chain) {
|
|
5228
5251
|
return this.getConfig(chain)?.tokenDecimals?.EXT;
|
|
5229
5252
|
}
|
|
5253
|
+
/** Configured exotic (non-USD) tokens on a chain, for selection UIs. EXT is a test asset and is not offered. */
|
|
5254
|
+
getKnownExoticTokens(chain) {
|
|
5255
|
+
const config = this.getConfig(chain);
|
|
5256
|
+
const tokens = [];
|
|
5257
|
+
if (config?.assets?.cNGN) {
|
|
5258
|
+
tokens.push({ symbol: "cNGN", address: config.assets.cNGN, decimals: config.tokenDecimals?.cNGN });
|
|
5259
|
+
}
|
|
5260
|
+
return tokens;
|
|
5261
|
+
}
|
|
5262
|
+
/** Known ERC-4626 treasury vaults on a chain, for selection UIs. */
|
|
5263
|
+
getKnownVaults(chain) {
|
|
5264
|
+
return this.getConfig(chain)?.erc4626Vaults ?? [];
|
|
5265
|
+
}
|
|
5230
5266
|
getChainId(chain) {
|
|
5231
5267
|
return this.getConfig(chain)?.chainId ?? 0;
|
|
5232
5268
|
}
|
|
@@ -7516,17 +7552,30 @@ var SubstrateChain = class _SubstrateChain {
|
|
|
7516
7552
|
rotationMap.set(BigInt(setId.toString()), BigInt(height.toString()));
|
|
7517
7553
|
}
|
|
7518
7554
|
const proofs = [];
|
|
7519
|
-
let epoch = currentEpoch
|
|
7555
|
+
let epoch = currentEpoch + 1n;
|
|
7520
7556
|
while (rotationMap.has(epoch)) {
|
|
7521
|
-
const
|
|
7522
|
-
|
|
7523
|
-
|
|
7557
|
+
const key = rotationOffchainKey(epoch);
|
|
7558
|
+
let proof = await this.rpcClient.call("offchain_localStorageGet", ["PERSISTENT", key]);
|
|
7559
|
+
if (!proof) {
|
|
7560
|
+
const legacyKey = messagingOffchainKey(rotationMap.get(epoch));
|
|
7561
|
+
proof = await this.rpcClient.call("offchain_localStorageGet", ["PERSISTENT", legacyKey]);
|
|
7562
|
+
}
|
|
7524
7563
|
if (!proof) return void 0;
|
|
7525
7564
|
proofs.push(proof);
|
|
7526
7565
|
epoch++;
|
|
7527
7566
|
}
|
|
7528
|
-
const messagingKey =
|
|
7529
|
-
|
|
7567
|
+
const messagingKey = messagingOffchainKey(lastProvenHeight);
|
|
7568
|
+
let messagingProof = await this.rpcClient.call("offchain_localStorageGet", ["PERSISTENT", messagingKey]);
|
|
7569
|
+
if (!messagingProof) {
|
|
7570
|
+
for (const [setId, height] of rotationMap) {
|
|
7571
|
+
if (height !== lastProvenHeight) continue;
|
|
7572
|
+
messagingProof = await this.rpcClient.call("offchain_localStorageGet", [
|
|
7573
|
+
"PERSISTENT",
|
|
7574
|
+
rotationOffchainKey(setId)
|
|
7575
|
+
]);
|
|
7576
|
+
break;
|
|
7577
|
+
}
|
|
7578
|
+
}
|
|
7530
7579
|
if (!messagingProof) return void 0;
|
|
7531
7580
|
proofs.push(messagingProof);
|
|
7532
7581
|
return { proofs, provenHeight: lastProvenHeight };
|
|
@@ -7543,11 +7592,17 @@ var SubstrateChain = class _SubstrateChain {
|
|
|
7543
7592
|
throw new Error(`${name} not found in runtime`);
|
|
7544
7593
|
}
|
|
7545
7594
|
};
|
|
7546
|
-
function beefyOffchainKey(
|
|
7547
|
-
const
|
|
7548
|
-
const
|
|
7549
|
-
new DataView(
|
|
7550
|
-
return toHex(new Uint8Array([...
|
|
7595
|
+
function beefyOffchainKey(prefix, id) {
|
|
7596
|
+
const prefixBytes = new TextEncoder().encode(prefix);
|
|
7597
|
+
const idBytes = new Uint8Array(8);
|
|
7598
|
+
new DataView(idBytes.buffer).setBigUint64(0, id, false);
|
|
7599
|
+
return toHex(new Uint8Array([...prefixBytes, ...idBytes]));
|
|
7600
|
+
}
|
|
7601
|
+
function messagingOffchainKey(provenHeight) {
|
|
7602
|
+
return beefyOffchainKey("beefy_consensus_proofs::", provenHeight);
|
|
7603
|
+
}
|
|
7604
|
+
function rotationOffchainKey(setId) {
|
|
7605
|
+
return beefyOffchainKey("beefy_consensus_proofs::rotation::", setId);
|
|
7551
7606
|
}
|
|
7552
7607
|
function requestCommitmentStorageKey(key) {
|
|
7553
7608
|
const prefix = new TextEncoder().encode("RequestCommitments");
|
|
@@ -15445,14 +15500,21 @@ function orderCommitment(order) {
|
|
|
15445
15500
|
const encoded = encodeAbiParameters([orderType], [transformOrderForContract(order)]);
|
|
15446
15501
|
return keccak256(encoded);
|
|
15447
15502
|
}
|
|
15448
|
-
|
|
15503
|
+
function bumpGasPrice(gasPrice, bumpPercent) {
|
|
15504
|
+
if (bumpPercent < 0n) {
|
|
15505
|
+
throw new Error("Gas price bump percent cannot be negative");
|
|
15506
|
+
}
|
|
15507
|
+
return (gasPrice * (100n + bumpPercent) + 99n) / 100n;
|
|
15508
|
+
}
|
|
15509
|
+
async function convertGasToFeeToken(ctx, gasEstimate, gasEstimateIn, evmChainID, gasPriceOverride, gasPriceBumpPercent = 0n) {
|
|
15449
15510
|
if (TESTNET_CHAINS.has(evmChainID)) return 1n;
|
|
15450
15511
|
const chain = ctx[gasEstimateIn];
|
|
15451
15512
|
const client = chain.client;
|
|
15452
|
-
const
|
|
15513
|
+
const baseGasPrice = gasPriceOverride ?? await retryPromise(() => client.getGasPrice(), {
|
|
15453
15514
|
maxRetries: 3,
|
|
15454
15515
|
backoffMs: 250
|
|
15455
15516
|
});
|
|
15517
|
+
const gasPrice = bumpGasPrice(baseGasPrice, gasPriceBumpPercent);
|
|
15456
15518
|
const gasCostInWei = gasEstimate * gasPrice;
|
|
15457
15519
|
const wethAddr = chain.configService.getWrappedNativeAssetWithDecimals(evmChainID).asset;
|
|
15458
15520
|
const feeToken = await getFeeToken(ctx, evmChainID, chain);
|
|
@@ -15953,6 +16015,12 @@ var OrderCanceller = class _OrderCanceller {
|
|
|
15953
16015
|
static DEFAULT_MAX_RECOVERY_RESTARTS = 1;
|
|
15954
16016
|
static PROOF_FRESHNESS_MAX_RETRIES = 3;
|
|
15955
16017
|
static PROOF_FRESHNESS_BACKOFF_MS = 500;
|
|
16018
|
+
/**
|
|
16019
|
+
* Gas budget used to size the relayer fee for a cross-chain cancellation
|
|
16020
|
+
* message (the GET response or RefundEscrow POST executed on the source
|
|
16021
|
+
* chain), priced at the source chain's gas price.
|
|
16022
|
+
*/
|
|
16023
|
+
static CANCEL_MESSAGE_GAS = 800000n;
|
|
15956
16024
|
logger = createConsola({
|
|
15957
16025
|
level: LogLevels.info,
|
|
15958
16026
|
formatOptions: { columns: 80, colors: true, compact: true, date: false }
|
|
@@ -16011,9 +16079,14 @@ var OrderCanceller = class _OrderCanceller {
|
|
|
16011
16079
|
timeoutTimestamp: 0n,
|
|
16012
16080
|
context
|
|
16013
16081
|
};
|
|
16014
|
-
const feeInSourceFeeToken = await convertGasToFeeToken(
|
|
16082
|
+
const feeInSourceFeeToken = await convertGasToFeeToken(
|
|
16083
|
+
this.ctx,
|
|
16084
|
+
_OrderCanceller.CANCEL_MESSAGE_GAS,
|
|
16085
|
+
"source",
|
|
16086
|
+
sourceStateMachine
|
|
16087
|
+
);
|
|
16015
16088
|
const relayerFee = feeInSourceFeeToken * 1005n / 1000n;
|
|
16016
|
-
const nativeValue = await this.ctx.source.quoteNative(getRequest, relayerFee);
|
|
16089
|
+
const nativeValue = await this.ctx.source.quoteNative(getRequest, relayerFee) * 101n / 100n;
|
|
16017
16090
|
return { nativeValue, relayerFee };
|
|
16018
16091
|
}
|
|
16019
16092
|
/**
|
|
@@ -16272,7 +16345,7 @@ var OrderCanceller = class _OrderCanceller {
|
|
|
16272
16345
|
body,
|
|
16273
16346
|
timeoutTimestamp: 0n
|
|
16274
16347
|
};
|
|
16275
|
-
const nativeValue = await this.ctx.dest.quoteNative(postRequest, relayerFee);
|
|
16348
|
+
const nativeValue = await this.ctx.dest.quoteNative(postRequest, relayerFee) * 101n / 100n;
|
|
16276
16349
|
return { nativeValue, relayerFee };
|
|
16277
16350
|
}
|
|
16278
16351
|
/**
|
|
@@ -16602,8 +16675,12 @@ var OrderCanceller = class _OrderCanceller {
|
|
|
16602
16675
|
* Converts estimated gas on the source chain into the dest chain's fee token.
|
|
16603
16676
|
*/
|
|
16604
16677
|
async estimateRelayerFee(sourceChainId, destChainId) {
|
|
16605
|
-
const
|
|
16606
|
-
|
|
16678
|
+
const feeInSourceFeeToken = await convertGasToFeeToken(
|
|
16679
|
+
this.ctx,
|
|
16680
|
+
_OrderCanceller.CANCEL_MESSAGE_GAS,
|
|
16681
|
+
"source",
|
|
16682
|
+
sourceChainId
|
|
16683
|
+
);
|
|
16607
16684
|
const sourceFeeToken = await getFeeToken(this.ctx, sourceChainId, this.ctx.source);
|
|
16608
16685
|
const destFeeToken = await getFeeToken(this.ctx, destChainId, this.ctx.dest);
|
|
16609
16686
|
const feeInDestFeeToken = adjustDecimals(feeInSourceFeeToken, sourceFeeToken.decimals, destFeeToken.decimals);
|
|
@@ -17362,12 +17439,15 @@ var GasEstimator = class {
|
|
|
17362
17439
|
*
|
|
17363
17440
|
* @param params - Parameters including the order to estimate and optional
|
|
17364
17441
|
* percentage bumps for `maxPriorityFeePerGas` and `maxFeePerGas`.
|
|
17442
|
+
* @param pricingOptions - Internal fee-pricing policy. Direct estimates use
|
|
17443
|
+
* the default zero gas-price bump; SDK order-fee quotes opt into headroom.
|
|
17365
17444
|
* @returns A {@link FillOrderEstimate} containing all gas components,
|
|
17366
17445
|
* EIP-1559 fee values, total cost in wei, and total cost in the source
|
|
17367
17446
|
* chain's fee token.
|
|
17368
17447
|
*/
|
|
17369
|
-
async estimateFillOrder(params) {
|
|
17448
|
+
async estimateFillOrder(params, pricingOptions = {}) {
|
|
17370
17449
|
const { order } = params;
|
|
17450
|
+
const orderFeeGasPriceBumpPercent = pricingOptions.orderFeeGasPriceBumpPercent ?? 0n;
|
|
17371
17451
|
const solverPrivateKey = generatePrivateKey();
|
|
17372
17452
|
const solverAccountAddress = privateKeyToAddress(solverPrivateKey);
|
|
17373
17453
|
const souceStateMachineId = isHex(order.source) ? hexToString$1(order.source) : order.source;
|
|
@@ -17398,7 +17478,12 @@ var GasEstimator = class {
|
|
|
17398
17478
|
intentGatewayV2Address,
|
|
17399
17479
|
entryPointAddress
|
|
17400
17480
|
}),
|
|
17401
|
-
isSameChain ? Promise.resolve({ postRequestFee: 0n, relayerFeeInSourceFeeToken: 0n }) : this.estimateCrossChainFees(
|
|
17481
|
+
isSameChain ? Promise.resolve({ postRequestFee: 0n, relayerFeeInSourceFeeToken: 0n }) : this.estimateCrossChainFees(
|
|
17482
|
+
sourceFeeToken,
|
|
17483
|
+
destFeeToken,
|
|
17484
|
+
souceStateMachineId,
|
|
17485
|
+
orderFeeGasPriceBumpPercent
|
|
17486
|
+
)
|
|
17402
17487
|
]);
|
|
17403
17488
|
const { viem: stateOverrides, bundler: bundlerStateOverrides } = stateOverridesResult;
|
|
17404
17489
|
const fillOptions = {
|
|
@@ -17563,7 +17648,8 @@ var GasEstimator = class {
|
|
|
17563
17648
|
totalGas,
|
|
17564
17649
|
"dest",
|
|
17565
17650
|
destStateMachineId,
|
|
17566
|
-
gasPrice
|
|
17651
|
+
gasPrice,
|
|
17652
|
+
orderFeeGasPriceBumpPercent
|
|
17567
17653
|
);
|
|
17568
17654
|
const totalGasInSourceFeeToken = isSameChain ? totalGasInDestFeeToken : adjustDecimals(totalGasInDestFeeToken, destFeeToken.decimals, sourceFeeToken.decimals);
|
|
17569
17655
|
const totalGasCostWei = isSameChain ? rawTotalGasCostWei : await convertFeeTokenToWei(this.ctx, totalGasInSourceFeeToken, "source", souceStateMachineId);
|
|
@@ -17587,12 +17673,14 @@ var GasEstimator = class {
|
|
|
17587
17673
|
* The dispatch is always paid in the fee token — the native rail was
|
|
17588
17674
|
* removed because it silently drew on a native balance nothing guarantees.
|
|
17589
17675
|
*/
|
|
17590
|
-
async estimateCrossChainFees(sourceFeeToken, destFeeToken, sourceChainId) {
|
|
17676
|
+
async estimateCrossChainFees(sourceFeeToken, destFeeToken, sourceChainId, orderFeeGasPriceBumpPercent) {
|
|
17591
17677
|
const postRequestFeeInSourceFeeToken = await convertGasToFeeToken(
|
|
17592
17678
|
this.ctx,
|
|
17593
17679
|
RELAYER_MESSAGE_GAS,
|
|
17594
17680
|
"source",
|
|
17595
|
-
sourceChainId
|
|
17681
|
+
sourceChainId,
|
|
17682
|
+
void 0,
|
|
17683
|
+
orderFeeGasPriceBumpPercent
|
|
17596
17684
|
);
|
|
17597
17685
|
const postRequestFeeInDestFeeToken = adjustDecimals(
|
|
17598
17686
|
postRequestFeeInSourceFeeToken,
|
|
@@ -18362,6 +18450,7 @@ function isConfiguredAddress(address) {
|
|
|
18362
18450
|
}
|
|
18363
18451
|
|
|
18364
18452
|
// src/protocols/intents/IntentGateway.ts
|
|
18453
|
+
var CROSS_CHAIN_ORDER_FEE_GAS_PRICE_BUMP_PERCENT = 10n;
|
|
18365
18454
|
var IntentGateway = class _IntentGateway {
|
|
18366
18455
|
/** EVM chain on which orders are placed and escrowed. */
|
|
18367
18456
|
source;
|
|
@@ -18548,14 +18637,22 @@ var IntentGateway = class _IntentGateway {
|
|
|
18548
18637
|
* placement, fee estimation, bid collection, and execution.
|
|
18549
18638
|
*
|
|
18550
18639
|
* **Yield/receive protocol:**
|
|
18551
|
-
* 1. If `order.fees` is unset or zero,
|
|
18552
|
-
*
|
|
18553
|
-
*
|
|
18554
|
-
*
|
|
18555
|
-
* the whole sum — strictly above the solver's
|
|
18556
|
-
*
|
|
18557
|
-
*
|
|
18558
|
-
*
|
|
18640
|
+
* 1. If `order.fees` is unset or zero, prices the fee on an internal copy
|
|
18641
|
+
* via {@link quoteOrderFees}: same-chain fees are twice the fill-gas
|
|
18642
|
+
* estimate without a gas-price bump; cross-chain gas is priced 10% above
|
|
18643
|
+
* the live price before attaching (fill gas + the settlement relayer fee)
|
|
18644
|
+
* with a further 5% buffer over the whole sum — strictly above the solver's
|
|
18645
|
+
* unpadded requirement. Direct solver estimates remain unbumped. The wei
|
|
18646
|
+
* cost used for the `value` field receives a 2% buffer.
|
|
18647
|
+
* 2. Yields `AWAITING_PLACE_ORDER` with `{ to, data, value, nativeFee,
|
|
18648
|
+
* feeTokenAmount, feeTokenAddress, sessionPrivateKey }`. `value` carries
|
|
18649
|
+
* only the order's native-token input amounts; `nativeFee` is the native
|
|
18650
|
+
* amount that funds `order.fees` (`0n` when the caller set `order.fees`);
|
|
18651
|
+
* `feeTokenAmount`/`feeTokenAddress` are the exact fee encoded in `data`
|
|
18652
|
+
* and the source-chain token it is charged in. To pay the fee in native
|
|
18653
|
+
* token, sign the transaction with `value + nativeFee`; with a fee-token
|
|
18654
|
+
* allowance, `value` alone. Pass the signed transaction back via
|
|
18655
|
+
* `gen.next(signedTx)`.
|
|
18559
18656
|
* 3. Yields `ORDER_PLACED` with the finalised order and transaction hash once
|
|
18560
18657
|
* the `OrderPlaced` event is confirmed.
|
|
18561
18658
|
* 4. Delegates to {@link OrderExecutor.executeOrder} and forwards all
|
|
@@ -18576,33 +18673,33 @@ var IntentGateway = class _IntentGateway {
|
|
|
18576
18673
|
*/
|
|
18577
18674
|
async *execute(order, graffiti = DEFAULT_GRAFFITI, options) {
|
|
18578
18675
|
const executionOrder = { ...order };
|
|
18579
|
-
let
|
|
18676
|
+
let nativeFee = 0n;
|
|
18580
18677
|
if (!executionOrder.fees || executionOrder.fees === 0n) {
|
|
18581
|
-
const
|
|
18582
|
-
order: executionOrder,
|
|
18678
|
+
const feesQuote = await this.quoteOrderFees(executionOrder, {
|
|
18583
18679
|
maxPriorityFeePerGasBumpPercent: options?.maxPriorityFeePerGasBumpPercent,
|
|
18584
18680
|
maxFeePerGasBumpPercent: options?.maxFeePerGasBumpPercent
|
|
18585
18681
|
});
|
|
18586
|
-
|
|
18587
|
-
|
|
18588
|
-
}
|
|
18589
|
-
const isSameChain = this.source.config.stateMachineId === this.dest.config.stateMachineId;
|
|
18590
|
-
value = estimate.totalGasCostWei + estimate.totalGasCostWei * 2n / 100n;
|
|
18591
|
-
const crossChainFeeBump = isSameChain ? 0n : await convertGasToFeeToken(
|
|
18592
|
-
this.ctx,
|
|
18593
|
-
RELAYER_MESSAGE_GAS,
|
|
18594
|
-
"source",
|
|
18595
|
-
this.source.config.stateMachineId
|
|
18596
|
-
);
|
|
18597
|
-
executionOrder.fees = isSameChain ? estimate.totalGasInFeeToken * 2n : (estimate.totalGasInFeeToken + crossChainFeeBump) * 105n / 100n;
|
|
18682
|
+
nativeFee = feesQuote.nativeValue;
|
|
18683
|
+
executionOrder.fees = feesQuote.fees;
|
|
18598
18684
|
}
|
|
18685
|
+
const value = executionOrder.inputs.filter((input) => bytes32ToBytes20(input.token) === ADDRESS_ZERO2).reduce((sum, input) => sum + input.amount, 0n);
|
|
18599
18686
|
const placeOrderGen = this.orderPlacer.placeOrder(executionOrder, graffiti);
|
|
18600
18687
|
const placeOrderFirst = await placeOrderGen.next();
|
|
18601
18688
|
if (placeOrderFirst.done) {
|
|
18602
18689
|
throw new Error("placeOrder generator completed without yielding");
|
|
18603
18690
|
}
|
|
18604
18691
|
const { to, data, sessionPrivateKey } = placeOrderFirst.value;
|
|
18605
|
-
const
|
|
18692
|
+
const { address: feeTokenAddress } = await getFeeToken(this.ctx, this.source.config.stateMachineId, this.source);
|
|
18693
|
+
const signedTransaction = yield {
|
|
18694
|
+
status: "AWAITING_PLACE_ORDER",
|
|
18695
|
+
to,
|
|
18696
|
+
data,
|
|
18697
|
+
value,
|
|
18698
|
+
nativeFee,
|
|
18699
|
+
sessionPrivateKey,
|
|
18700
|
+
feeTokenAmount: executionOrder.fees,
|
|
18701
|
+
feeTokenAddress
|
|
18702
|
+
};
|
|
18606
18703
|
const placeOrderSecond = await placeOrderGen.next(signedTransaction);
|
|
18607
18704
|
if (placeOrderSecond.done === false) {
|
|
18608
18705
|
throw new Error("placeOrder generator yielded unexpectedly after signing");
|
|
@@ -18902,6 +18999,50 @@ var IntentGateway = class _IntentGateway {
|
|
|
18902
18999
|
async estimateFillOrder(params) {
|
|
18903
19000
|
return this.gasEstimator.estimateFillOrder(params);
|
|
18904
19001
|
}
|
|
19002
|
+
/**
|
|
19003
|
+
* Quotes the solver fee for an order using the same policy {@link execute} /
|
|
19004
|
+
* {@link executeBest} apply when `order.fees` is `0n`.
|
|
19005
|
+
*
|
|
19006
|
+
* Use this before placing to display the fee, or to check what the user can
|
|
19007
|
+
* afford: pay `fees` in the source-chain fee token (check balance and
|
|
19008
|
+
* allowance, then set `order.fees` and submit with `value: 0`), or leave
|
|
19009
|
+
* `order.fees` at `0n` and let the SDK attach `nativeValue` to the placement
|
|
19010
|
+
* transaction (check the native balance).
|
|
19011
|
+
*
|
|
19012
|
+
* @param order - The order to quote. `order.fees` is ignored and not mutated.
|
|
19013
|
+
* Gas prices used to derive cross-chain `fees` receive 10% SDK-only headroom.
|
|
19014
|
+
* Same-chain quotes and direct calls to {@link estimateFillOrder}, including
|
|
19015
|
+
* Simplex solver estimates, remain unbumped.
|
|
19016
|
+
*
|
|
19017
|
+
* @param options - Optional transaction gas-price bump percentages, as in {@link execute}.
|
|
19018
|
+
* @returns An {@link OrderFeesQuote} with the fee-token amount, the native
|
|
19019
|
+
* value for the native rail, and the underlying estimate.
|
|
19020
|
+
* @throws If gas estimation returns zero.
|
|
19021
|
+
*/
|
|
19022
|
+
async quoteOrderFees(order, options) {
|
|
19023
|
+
const isSameChain = this.source.config.stateMachineId === this.dest.config.stateMachineId;
|
|
19024
|
+
const estimate = await this.gasEstimator.estimateFillOrder(
|
|
19025
|
+
{
|
|
19026
|
+
order,
|
|
19027
|
+
maxPriorityFeePerGasBumpPercent: options?.maxPriorityFeePerGasBumpPercent,
|
|
19028
|
+
maxFeePerGasBumpPercent: options?.maxFeePerGasBumpPercent
|
|
19029
|
+
},
|
|
19030
|
+
{
|
|
19031
|
+
orderFeeGasPriceBumpPercent: isSameChain ? 0n : CROSS_CHAIN_ORDER_FEE_GAS_PRICE_BUMP_PERCENT
|
|
19032
|
+
}
|
|
19033
|
+
);
|
|
19034
|
+
if (estimate.totalGasCostWei === 0n || estimate.totalGasInFeeToken === 0n) {
|
|
19035
|
+
throw new Error("Gas estimation failed");
|
|
19036
|
+
}
|
|
19037
|
+
const fees = isSameChain ? estimate.totalGasInFeeToken * 2n : (estimate.totalGasInFeeToken + estimate.relayerFeeInSourceFeeToken) * 105n / 100n;
|
|
19038
|
+
const { address: feeToken } = await this.source.getFeeTokenWithDecimals();
|
|
19039
|
+
return {
|
|
19040
|
+
fees,
|
|
19041
|
+
nativeValue: estimate.totalGasCostWei + estimate.totalGasCostWei * 2n / 100n,
|
|
19042
|
+
feeToken,
|
|
19043
|
+
estimate
|
|
19044
|
+
};
|
|
19045
|
+
}
|
|
18905
19046
|
/**
|
|
18906
19047
|
* Encodes a list of calls into ERC-7821 `execute` calldata using
|
|
18907
19048
|
* single-batch mode.
|