@hyperbridge/sdk 2.8.6 → 2.8.8
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 +68 -23
- package/dist/browser/index.js +209 -74
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +212 -73
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +55 -22
- package/dist/node/index.d.ts +55 -22
- package/dist/node/index.js +209 -74
- package/dist/node/index.js.map +1 -1
- package/dist/node/{intents-helpers-BFc6YnD3.d.cts → intents-helpers-BCsIHRts.d.cts} +16 -4
- package/dist/node/{intents-helpers-BFc6YnD3.d.ts → intents-helpers-BCsIHRts.d.ts} +16 -4
- package/dist/node/intents-helpers.cjs +10 -1
- 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 +9 -2
- package/dist/node/intents-helpers.js.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.d.ts
CHANGED
|
@@ -3750,9 +3750,9 @@ interface AvailableLiquidity {
|
|
|
3750
3750
|
}) | null;
|
|
3751
3751
|
}
|
|
3752
3752
|
/**
|
|
3753
|
-
*
|
|
3754
|
-
* base token. The quote token is the less valuable currency when the
|
|
3755
|
-
*
|
|
3753
|
+
* Aggregate indexed pool buy and sell rates expressed as quote-token units per
|
|
3754
|
+
* one base token. The quote token is the less valuable currency when the rates
|
|
3755
|
+
* establish an ordering (for example, cNGN in a USDC/cNGN pair).
|
|
3756
3756
|
*/
|
|
3757
3757
|
interface BuyAndSellRates {
|
|
3758
3758
|
baseTokenSymbol: ConfiguredAssetSymbol;
|
|
@@ -5128,8 +5128,9 @@ interface IntentGatewayContext {
|
|
|
5128
5128
|
swap: Swap;
|
|
5129
5129
|
}
|
|
5130
5130
|
|
|
5131
|
-
type IntentQuoteStrategy = "uniswap_v4" | "phantom_snapshot";
|
|
5131
|
+
type IntentQuoteStrategy = "indexed_rates" | "uniswap_v4" | "phantom_snapshot";
|
|
5132
5132
|
type IntentQuoteTradeType = "EXACT_INPUT" | "EXACT_OUTPUT";
|
|
5133
|
+
type IndexedRateSide = "buy" | "sell";
|
|
5133
5134
|
/**
|
|
5134
5135
|
* Full Uniswap V4 PoolKey. V4 pools cannot be discovered from a token pair alone.
|
|
5135
5136
|
*/
|
|
@@ -5157,10 +5158,10 @@ interface UniswapV4IntentQuoteOptions {
|
|
|
5157
5158
|
* Parameters for `IntentGateway.quoteIntent`. The source and destination
|
|
5158
5159
|
* chains come from the gateway instance itself.
|
|
5159
5160
|
*
|
|
5160
|
-
* Quotes default to
|
|
5161
|
-
*
|
|
5162
|
-
* addresses; the SDK resolves configured token
|
|
5163
|
-
*
|
|
5161
|
+
* Quotes default to the aggregate pool's `indexed_rates`. Legacy Phantom
|
|
5162
|
+
* snapshots and Uniswap V4 remain available as explicit strategies. `tokenIn`
|
|
5163
|
+
* and `tokenOut` are token addresses; the SDK resolves configured token
|
|
5164
|
+
* metadata and decimals internally. Provide exactly one amount.
|
|
5164
5165
|
*/
|
|
5165
5166
|
interface QuoteIntentParams {
|
|
5166
5167
|
strategy?: IntentQuoteStrategy;
|
|
@@ -5202,6 +5203,19 @@ interface PhantomSnapshotIntentQuoteMetadata {
|
|
|
5202
5203
|
/** Source gateway protocol fee already reflected in the returned quote amounts. */
|
|
5203
5204
|
protocolFeeBps: bigint;
|
|
5204
5205
|
}
|
|
5206
|
+
interface IndexedRateIntentQuoteMetadata {
|
|
5207
|
+
sourceChain: Chains;
|
|
5208
|
+
destinationChain: Chains;
|
|
5209
|
+
baseTokenSymbol: ConfiguredAssetSymbol;
|
|
5210
|
+
quoteTokenSymbol: ConfiguredAssetSymbol;
|
|
5211
|
+
/** Directional pool rate used for this order. */
|
|
5212
|
+
rateSide: IndexedRateSide;
|
|
5213
|
+
/** Quote-token units per one base token. */
|
|
5214
|
+
rate: string;
|
|
5215
|
+
rateUpdatedAt: Date;
|
|
5216
|
+
/** Source gateway protocol fee already reflected in the returned quote amounts. */
|
|
5217
|
+
protocolFeeBps: bigint;
|
|
5218
|
+
}
|
|
5205
5219
|
/**
|
|
5206
5220
|
* Quote data partners need before constructing an IntentGateway V2 order.
|
|
5207
5221
|
*
|
|
@@ -5223,7 +5237,14 @@ interface PhantomSnapshotQuoteIntentResult {
|
|
|
5223
5237
|
amountOut: bigint;
|
|
5224
5238
|
quoteMetadata: PhantomSnapshotIntentQuoteMetadata;
|
|
5225
5239
|
}
|
|
5226
|
-
|
|
5240
|
+
interface IndexedRateQuoteIntentResult {
|
|
5241
|
+
strategy: "indexed_rates";
|
|
5242
|
+
tradeType: IntentQuoteTradeType;
|
|
5243
|
+
amountIn: bigint;
|
|
5244
|
+
amountOut: bigint;
|
|
5245
|
+
quoteMetadata: IndexedRateIntentQuoteMetadata;
|
|
5246
|
+
}
|
|
5247
|
+
type QuoteIntentResult = IndexedRateQuoteIntentResult | UniswapV4QuoteIntentResult | PhantomSnapshotQuoteIntentResult;
|
|
5227
5248
|
declare class UnsupportedIntentQuoteStrategyError extends Error {
|
|
5228
5249
|
constructor(strategy: string);
|
|
5229
5250
|
}
|
|
@@ -5242,14 +5263,26 @@ declare class PhantomSnapshotUnavailableError extends Error {
|
|
|
5242
5263
|
declare class InvalidPhantomSnapshotError extends Error {
|
|
5243
5264
|
constructor(commitment: HexString$1, reason: string);
|
|
5244
5265
|
}
|
|
5266
|
+
declare class IndexedRateUnavailableError extends Error {
|
|
5267
|
+
constructor(params: {
|
|
5268
|
+
source?: string;
|
|
5269
|
+
destination?: string;
|
|
5270
|
+
tokenIn?: string;
|
|
5271
|
+
tokenOut?: string;
|
|
5272
|
+
side?: IndexedRateSide;
|
|
5273
|
+
});
|
|
5274
|
+
}
|
|
5275
|
+
declare class InvalidIndexedRateError extends Error {
|
|
5276
|
+
constructor(reason: string);
|
|
5277
|
+
}
|
|
5245
5278
|
|
|
5246
5279
|
/**
|
|
5247
5280
|
* High-level facade for the IntentGatewayV2 protocol.
|
|
5248
5281
|
*
|
|
5249
5282
|
* `IntentGateway` orchestrates the complete lifecycle of an intent-based
|
|
5250
5283
|
* cross-chain swap:
|
|
5251
|
-
* - **Quoting** — prices the order's input/output amounts
|
|
5252
|
-
*
|
|
5284
|
+
* - **Quoting** — prices the order's input/output amounts from aggregate
|
|
5285
|
+
* indexed pool rates by default, with legacy quote strategies available explicitly.
|
|
5253
5286
|
* - **Order placement** — encodes and yields `placeOrder` calldata; caller
|
|
5254
5287
|
* signs and submits the transaction.
|
|
5255
5288
|
* - **Order execution** — polls the Hyperbridge coprocessor for solver bids,
|
|
@@ -5330,21 +5363,21 @@ declare class IntentGateway {
|
|
|
5330
5363
|
/**
|
|
5331
5364
|
* Quotes an intent between this gateway's source and destination chains.
|
|
5332
5365
|
*
|
|
5333
|
-
* Uses the latest directional
|
|
5334
|
-
*
|
|
5335
|
-
* requesting a
|
|
5366
|
+
* Uses the indexer's latest aggregate directional pool rate by default. Pass
|
|
5367
|
+
* `strategy: "phantom_snapshot"` or `strategy: "uniswap_v4"` only when
|
|
5368
|
+
* explicitly requesting a legacy quote source. Provide exactly one of
|
|
5369
|
+
* `amountIn` or `amountOut`.
|
|
5336
5370
|
*
|
|
5337
|
-
*
|
|
5338
|
-
*
|
|
5371
|
+
* The gateway's source and destination chains resolve the configured order
|
|
5372
|
+
* tokens; the indexer supplies the depth-weighted pool rate. Returned
|
|
5339
5373
|
* `amountIn`/`amountOut` already account for the gateway's protocol fee
|
|
5340
|
-
* (`quoteMetadata.protocolFeeBps`), which the gateway deducts from order
|
|
5341
|
-
* inputs; use the returned amounts directly when placing the order.
|
|
5374
|
+
* (`quoteMetadata.protocolFeeBps`), which the gateway deducts from order inputs.
|
|
5342
5375
|
*
|
|
5343
5376
|
* @param params - Token pair, amount, and optional strategy/pool overrides.
|
|
5344
5377
|
* @returns The quoted amounts plus strategy-specific metadata.
|
|
5345
5378
|
* @throws {UnsupportedIntentQuoteStrategyError} For unknown strategies.
|
|
5346
5379
|
* @throws {UnsupportedIntentQuotePairError} When the selected strategy does not support the pair.
|
|
5347
|
-
* @throws {
|
|
5380
|
+
* @throws {IndexedRateUnavailableError} When the requested direction has no indexed rate.
|
|
5348
5381
|
*/
|
|
5349
5382
|
quoteIntent(params: QuoteIntentParams): Promise<QuoteIntentResult>;
|
|
5350
5383
|
/**
|
|
@@ -5359,9 +5392,9 @@ declare class IntentGateway {
|
|
|
5359
5392
|
*/
|
|
5360
5393
|
queryAvailableLiquidity(params: Pick<QuoteIntentParams, "tokenIn" | "tokenOut">): Promise<AvailableLiquidity | undefined>;
|
|
5361
5394
|
/**
|
|
5362
|
-
* Returns
|
|
5363
|
-
* without requiring token addresses. Symbols are matched
|
|
5364
|
-
* chain IDs
|
|
5395
|
+
* Returns aggregate indexed pool buy and sell rates in less-valued quote-token
|
|
5396
|
+
* units without requiring token addresses. Symbols are matched
|
|
5397
|
+
* case-insensitively; chain IDs resolve configured token deployments.
|
|
5365
5398
|
*/
|
|
5366
5399
|
queryBuyAndSellRates(params: QueryBuyAndSellRatesParams): Promise<BuyAndSellRates | undefined>;
|
|
5367
5400
|
/**
|
|
@@ -6126,6 +6159,18 @@ declare function decodePhantomBidDeclaration(paymasterAndData: string | undefine
|
|
|
6126
6159
|
declare function encodeAcceptedSourceChains(chains: string[]): HexString;
|
|
6127
6160
|
/** Back-compat wrapper: the source-chain half of {@link decodePhantomBidDeclaration}. */
|
|
6128
6161
|
declare function decodeAcceptedSourceChains(paymasterAndData: string | undefined | null): string[] | null;
|
|
6162
|
+
/**
|
|
6163
|
+
* Haircut applied to a quote that is priced off a Uniswap V4 pool, in basis points.
|
|
6164
|
+
*
|
|
6165
|
+
* A bid that declares V4 positions is quoting off those pools, and a pool price is what a trade
|
|
6166
|
+
* gets BEFORE the pool takes its fee — so the amount such a bid names is more than the solver
|
|
6167
|
+
* would actually be left holding once the swap that sources it clears. 30bps is the fee tier the
|
|
6168
|
+
* pools these positions sit in charge, so netting it out here is what makes a pool-priced quote
|
|
6169
|
+
* comparable to a wallet-funded one, whose inventory has already paid its cost of goods.
|
|
6170
|
+
*/
|
|
6171
|
+
declare const UNISWAP_QUOTE_HAIRCUT_BPS = 30n;
|
|
6172
|
+
/** Applies {@link UNISWAP_QUOTE_HAIRCUT_BPS} to a quoted output amount, rounding down. */
|
|
6173
|
+
declare function applyUniswapQuoteHaircut(amount: bigint): bigint;
|
|
6129
6174
|
|
|
6130
6175
|
declare const ABI$1: readonly [{
|
|
6131
6176
|
readonly type: "constructor";
|
|
@@ -11010,4 +11055,4 @@ declare function teleport(teleport_param: {
|
|
|
11010
11055
|
extrinsics?: Array<SubmittableExtrinsic<"promise", ISubmittableResult>>;
|
|
11011
11056
|
}): Promise<ReadableStream<HyperbridgeTxEvents>>;
|
|
11012
11057
|
|
|
11013
|
-
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, 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, type FillOptions, 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 IndexerQueryClient, IntentGateway, ABI$1 as IntentGatewayABI, type IntentGatewayContext, type IntentGatewayParams, IntentOrderStatus, type IntentOrderStatusKey, type IntentOrderStatusUpdate, type IntentQuoteStrategy, type IntentQuoteTradeType, IntentsCoprocessor, InvalidLiquidityIndexerResponseError, InvalidPhantomSnapshotError, IsmpClient, type IsmpRequest, 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, 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, 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, bytes20ToBytes32, bytes32ToBytes20, calculateAllowanceMappingLocation, calculateBalanceMappingLocation, chainConfigs, constructRedeemEscrowRequestBody, constructRefundEscrowRequestBody, convertCodecToIGetRequest, convertCodecToIProof, convertIGetRequestToCodec, convertIProofToCodec, convertStateIdToStateMachineId, convertStateMachineEnumToString, convertStateMachineIdToEnum, createEvmChain, createQueryClient, decodeAcceptedSourceChains, decodeERC7821ExecuteBatch, decodePhantomBidDeclaration, decodeUserOpScale, deriveHttpUrl, encodeAcceptedSourceChains, encodeERC7821ExecuteBatch, encodeISMPMessage, encodePhantomBidDeclaration, 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, poolSlug, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, quoteUniswap, requestCommitmentKey, responseCommitmentKey, retryPromise, sortPoolSymbols, teleport, teleportDot, transformOrderForContract, tronChainIds, tronNile };
|
|
11058
|
+
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, 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, type FillOptions, 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, 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, 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, applyUniswapQuoteHaircut, bytes20ToBytes32, bytes32ToBytes20, calculateAllowanceMappingLocation, calculateBalanceMappingLocation, chainConfigs, constructRedeemEscrowRequestBody, constructRefundEscrowRequestBody, convertCodecToIGetRequest, convertCodecToIProof, convertIGetRequestToCodec, convertIProofToCodec, convertStateIdToStateMachineId, convertStateMachineEnumToString, convertStateMachineIdToEnum, createEvmChain, createQueryClient, decodeAcceptedSourceChains, decodeERC7821ExecuteBatch, decodePhantomBidDeclaration, decodeUserOpScale, deriveHttpUrl, encodeAcceptedSourceChains, encodeERC7821ExecuteBatch, encodeISMPMessage, encodePhantomBidDeclaration, 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, poolSlug, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, quoteUniswap, requestCommitmentKey, responseCommitmentKey, retryPromise, sortPoolSymbols, teleport, teleportDot, transformOrderForContract, tronChainIds, tronNile };
|
package/dist/browser/index.js
CHANGED
|
@@ -2847,7 +2847,7 @@ var chainConfigs = {
|
|
|
2847
2847
|
// "Usdt0Oft": Not available on BSC
|
|
2848
2848
|
},
|
|
2849
2849
|
rpcEnvKey: "BSC_MAINNET",
|
|
2850
|
-
defaultRpcUrl: "https://
|
|
2850
|
+
defaultRpcUrl: "https://bsc-rpc.publicnode.com",
|
|
2851
2851
|
consensusStateId: "BSC0",
|
|
2852
2852
|
coingeckoId: "binance-smart-chain",
|
|
2853
2853
|
erc4626Vaults: [
|
|
@@ -8041,7 +8041,15 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
|
|
|
8041
8041
|
if (!this.httpApi) {
|
|
8042
8042
|
const httpUrl = deriveHttpUrl(this.wsEndpoint());
|
|
8043
8043
|
const api = new ApiPromise({
|
|
8044
|
-
|
|
8044
|
+
// Response cache off (third argument, capacity 0). polkadot-js caches every request that
|
|
8045
|
+
// names a block hash — `chain_getHeader(hash)`, `state_getRuntimeVersion(hash)`, storage
|
|
8046
|
+
// reads at a hash — by storing the request promise itself, a rejected one included, for a
|
|
8047
|
+
// 30s TTL that every hit refreshes. The phantom poll retries the block it failed on with
|
|
8048
|
+
// identical parameters every tick, so one reset connection became the same rejection
|
|
8049
|
+
// replayed from memory on every tick, faster than the TTL could lapse, and the node never
|
|
8050
|
+
// saw a second request. The cache bought nothing here anyway: the poll reads each block
|
|
8051
|
+
// once, and `api.at(hash)` reuses registries at the api layer regardless.
|
|
8052
|
+
provider: new HttpProvider(httpUrl, {}, 0),
|
|
8045
8053
|
typesBundle: HYPERBRIDGE_TYPES_BUNDLE,
|
|
8046
8054
|
// A second connection to the node the ws api already reported on; its init warnings
|
|
8047
8055
|
// would just be duplicates.
|
|
@@ -12132,40 +12140,17 @@ query AvailableLiquidity(
|
|
|
12132
12140
|
}
|
|
12133
12141
|
}`;
|
|
12134
12142
|
var BUY_AND_SELL_RATES = `
|
|
12135
|
-
query
|
|
12136
|
-
|
|
12137
|
-
$directChain: String!
|
|
12138
|
-
$directDirection: String!
|
|
12139
|
-
$reverseChain: String!
|
|
12140
|
-
$reverseDirection: String!
|
|
12141
|
-
) {
|
|
12142
|
-
direct: poolChainLiquidities(
|
|
12143
|
-
filter: {
|
|
12144
|
-
and: [
|
|
12145
|
-
{ poolId: { equalToInsensitive: $poolId } }
|
|
12146
|
-
{ chain: { equalTo: $directChain } }
|
|
12147
|
-
{ direction: { equalTo: $directDirection } }
|
|
12148
|
-
]
|
|
12149
|
-
}
|
|
12150
|
-
first: 1
|
|
12151
|
-
) {
|
|
12152
|
-
nodes {
|
|
12153
|
-
rate
|
|
12154
|
-
lastUpdatedAt
|
|
12155
|
-
}
|
|
12156
|
-
}
|
|
12157
|
-
reverse: poolChainLiquidities(
|
|
12158
|
-
filter: {
|
|
12159
|
-
and: [
|
|
12160
|
-
{ poolId: { equalToInsensitive: $poolId } }
|
|
12161
|
-
{ chain: { equalTo: $reverseChain } }
|
|
12162
|
-
{ direction: { equalTo: $reverseDirection } }
|
|
12163
|
-
]
|
|
12164
|
-
}
|
|
12143
|
+
query GetLiquidityPoolRate($poolId: String!) {
|
|
12144
|
+
liquidityPools(
|
|
12165
12145
|
first: 1
|
|
12146
|
+
filter: { id: { equalToInsensitive: $poolId } }
|
|
12166
12147
|
) {
|
|
12167
12148
|
nodes {
|
|
12168
|
-
|
|
12149
|
+
id
|
|
12150
|
+
token0Symbol
|
|
12151
|
+
token1Symbol
|
|
12152
|
+
sellRate
|
|
12153
|
+
buyRate
|
|
12169
12154
|
lastUpdatedAt
|
|
12170
12155
|
}
|
|
12171
12156
|
}
|
|
@@ -18387,29 +18372,29 @@ var LiquidityEngine = class {
|
|
|
18387
18372
|
};
|
|
18388
18373
|
}
|
|
18389
18374
|
/**
|
|
18390
|
-
* Returns
|
|
18391
|
-
* per one base token.
|
|
18375
|
+
* Returns the indexed pool's aggregate buy and sell rates in less-valued
|
|
18376
|
+
* quote-token units per one base token.
|
|
18392
18377
|
*
|
|
18393
|
-
* The
|
|
18394
|
-
*
|
|
18395
|
-
*
|
|
18378
|
+
* The indexer depth-weights fresh per-chain samples into the pool rates. The
|
|
18379
|
+
* source and destination chains remain part of the result because they define
|
|
18380
|
+
* the cross-chain route whose configured token symbols were resolved.
|
|
18396
18381
|
*/
|
|
18397
18382
|
async getBuyAndSellRates(params) {
|
|
18398
18383
|
const pool = resolveLiquidityPool(params.tokenInSymbol, params.tokenOutSymbol);
|
|
18399
|
-
const directDirection = params.tokenInSymbol.toLowerCase() === pool.token0Symbol.toLowerCase() ? SELL : BUY;
|
|
18400
|
-
const reverseDirection = directDirection === SELL ? BUY : SELL;
|
|
18401
18384
|
const response = await this.queryClient.request(BUY_AND_SELL_RATES, {
|
|
18402
|
-
poolId: pool.poolId
|
|
18403
|
-
directChain: params.destinationChain,
|
|
18404
|
-
directDirection,
|
|
18405
|
-
reverseChain: params.sourceChain,
|
|
18406
|
-
reverseDirection
|
|
18385
|
+
poolId: pool.poolId
|
|
18407
18386
|
});
|
|
18408
|
-
if (!response?.
|
|
18409
|
-
throw new InvalidLiquidityIndexerResponseError("
|
|
18410
|
-
}
|
|
18411
|
-
const
|
|
18412
|
-
|
|
18387
|
+
if (!response?.liquidityPools?.nodes) {
|
|
18388
|
+
throw new InvalidLiquidityIndexerResponseError("liquidity pool connection is missing");
|
|
18389
|
+
}
|
|
18390
|
+
const indexedPool = response.liquidityPools.nodes[0];
|
|
18391
|
+
if (!indexedPool) return void 0;
|
|
18392
|
+
validateIndexedPool(indexedPool, pool);
|
|
18393
|
+
const sell = readIndexedRate(indexedPool.sellRate, indexedPool.lastUpdatedAt, "pool sell rate");
|
|
18394
|
+
const buy = readIndexedRate(indexedPool.buyRate, indexedPool.lastUpdatedAt, "pool buy rate");
|
|
18395
|
+
const inputIsToken0 = params.tokenInSymbol.toLowerCase() === pool.token0Symbol.toLowerCase();
|
|
18396
|
+
const direct = inputIsToken0 ? sell : buy;
|
|
18397
|
+
const reverse = inputIsToken0 ? buy : sell;
|
|
18413
18398
|
if (!direct && !reverse) return void 0;
|
|
18414
18399
|
const quoteTokenSymbol = resolveQuoteTokenSymbol(
|
|
18415
18400
|
params.tokenInSymbol,
|
|
@@ -18418,17 +18403,17 @@ var LiquidityEngine = class {
|
|
|
18418
18403
|
reverse?.scaledRate
|
|
18419
18404
|
);
|
|
18420
18405
|
const quoteIsTokenOut = quoteTokenSymbol === params.tokenOutSymbol;
|
|
18421
|
-
const
|
|
18422
|
-
const
|
|
18406
|
+
const orientedBuy = quoteIsTokenOut ? direct : reverse;
|
|
18407
|
+
const orientedSell = quoteIsTokenOut ? reverse : direct;
|
|
18423
18408
|
return {
|
|
18424
18409
|
baseTokenSymbol: quoteIsTokenOut ? params.tokenInSymbol : params.tokenOutSymbol,
|
|
18425
18410
|
quoteTokenSymbol,
|
|
18426
18411
|
sourceChain: params.sourceChain,
|
|
18427
18412
|
destinationChain: params.destinationChain,
|
|
18428
|
-
buyRate:
|
|
18429
|
-
sellRate:
|
|
18430
|
-
buyRateUpdatedAt:
|
|
18431
|
-
sellRateUpdatedAt:
|
|
18413
|
+
buyRate: orientedBuy ? formatUnits(orientedBuy.scaledRate, INDEXER_FIXED_POINT_DECIMALS) : null,
|
|
18414
|
+
sellRate: orientedSell ? formatUnits(reciprocalRate(orientedSell.scaledRate, "sell rate"), INDEXER_FIXED_POINT_DECIMALS) : null,
|
|
18415
|
+
buyRateUpdatedAt: orientedBuy?.updatedAt ?? null,
|
|
18416
|
+
sellRateUpdatedAt: orientedSell?.updatedAt ?? null
|
|
18432
18417
|
};
|
|
18433
18418
|
}
|
|
18434
18419
|
};
|
|
@@ -18470,20 +18455,25 @@ function readIndexerDate(value, label) {
|
|
|
18470
18455
|
if (Number.isNaN(date.getTime())) throw new InvalidLiquidityIndexerResponseError(`${label} is invalid`);
|
|
18471
18456
|
return date;
|
|
18472
18457
|
}
|
|
18473
|
-
function readIndexedRate(
|
|
18474
|
-
if (
|
|
18458
|
+
function readIndexedRate(value, lastUpdatedAt, label) {
|
|
18459
|
+
if (value === null) return void 0;
|
|
18475
18460
|
try {
|
|
18476
|
-
const scaledRate = BigInt(
|
|
18461
|
+
const scaledRate = BigInt(value);
|
|
18477
18462
|
if (scaledRate <= 0n) throw new Error();
|
|
18478
18463
|
return {
|
|
18479
18464
|
scaledRate,
|
|
18480
|
-
updatedAt: readIndexerDate(
|
|
18465
|
+
updatedAt: readIndexerDate(lastUpdatedAt, `${label} lastUpdatedAt`)
|
|
18481
18466
|
};
|
|
18482
18467
|
} catch (error) {
|
|
18483
18468
|
if (error instanceof InvalidLiquidityIndexerResponseError) throw error;
|
|
18484
18469
|
throw new InvalidLiquidityIndexerResponseError(`${label} is not a positive integer`);
|
|
18485
18470
|
}
|
|
18486
18471
|
}
|
|
18472
|
+
function validateIndexedPool(indexedPool, expected) {
|
|
18473
|
+
if (indexedPool.id.toLowerCase() !== expected.poolId.toLowerCase() || indexedPool.token0Symbol.toLowerCase() !== expected.token0Symbol.toLowerCase() || indexedPool.token1Symbol.toLowerCase() !== expected.token1Symbol.toLowerCase()) {
|
|
18474
|
+
throw new InvalidLiquidityIndexerResponseError(`pool identity does not match ${expected.poolId}`);
|
|
18475
|
+
}
|
|
18476
|
+
}
|
|
18487
18477
|
function resolveQuoteTokenSymbol(tokenInSymbol, tokenOutSymbol, directRate, reverseRate) {
|
|
18488
18478
|
const inputIsUsdStable = USD_STABLE_SYMBOLS.has(tokenInSymbol);
|
|
18489
18479
|
const outputIsUsdStable = USD_STABLE_SYMBOLS.has(tokenOutSymbol);
|
|
@@ -18493,7 +18483,8 @@ function resolveQuoteTokenSymbol(tokenInSymbol, tokenOutSymbol, directRate, reve
|
|
|
18493
18483
|
throw new InvalidLiquidityIndexerResponseError("cannot orient an empty rate pair");
|
|
18494
18484
|
}
|
|
18495
18485
|
function reciprocalRate(rate, label) {
|
|
18496
|
-
const
|
|
18486
|
+
const numerator = POOL_RATE_SCALE * POOL_RATE_SCALE;
|
|
18487
|
+
const reciprocal = (numerator + rate - 1n) / rate;
|
|
18497
18488
|
if (reciprocal <= 0n) throw new InvalidLiquidityIndexerResponseError(`${label} reciprocal underflowed`);
|
|
18498
18489
|
return reciprocal;
|
|
18499
18490
|
}
|
|
@@ -18525,6 +18516,20 @@ var InvalidPhantomSnapshotError = class extends Error {
|
|
|
18525
18516
|
this.name = "InvalidPhantomSnapshotError";
|
|
18526
18517
|
}
|
|
18527
18518
|
};
|
|
18519
|
+
var IndexedRateUnavailableError = class extends Error {
|
|
18520
|
+
constructor(params) {
|
|
18521
|
+
const route = params.source && params.destination && params.tokenIn && params.tokenOut ? ` for ${params.tokenIn} -> ${params.tokenOut} on ${params.source} -> ${params.destination}` : "";
|
|
18522
|
+
const side = params.side ? ` ${params.side}` : "";
|
|
18523
|
+
super(`No indexed${side} rate available${route}`);
|
|
18524
|
+
this.name = "IndexedRateUnavailableError";
|
|
18525
|
+
}
|
|
18526
|
+
};
|
|
18527
|
+
var InvalidIndexedRateError = class extends Error {
|
|
18528
|
+
constructor(reason) {
|
|
18529
|
+
super(`Invalid indexed intent rate: ${reason}`);
|
|
18530
|
+
this.name = "InvalidIndexedRateError";
|
|
18531
|
+
}
|
|
18532
|
+
};
|
|
18528
18533
|
var BPS_DENOMINATOR = 10000n;
|
|
18529
18534
|
function validateQuoteParams(params) {
|
|
18530
18535
|
const hasAmountIn = params.amountIn !== void 0;
|
|
@@ -18891,6 +18896,128 @@ function isSupportedSnapshotPair(tokenA, tokenB) {
|
|
|
18891
18896
|
function isConfiguredAddress(address) {
|
|
18892
18897
|
return Boolean(address && address !== "0x" && !/^0x0{40}$/i.test(address));
|
|
18893
18898
|
}
|
|
18899
|
+
var INDEXED_RATE_DECIMALS = 18;
|
|
18900
|
+
var INDEXED_RATE_SCALE = 10n ** BigInt(INDEXED_RATE_DECIMALS);
|
|
18901
|
+
var IndexedRateIntentQuoteStrategy = class {
|
|
18902
|
+
constructor(chainConfigService, getQueryClient) {
|
|
18903
|
+
this.chainConfigService = chainConfigService;
|
|
18904
|
+
this.getQueryClient = getQueryClient;
|
|
18905
|
+
}
|
|
18906
|
+
chainConfigService;
|
|
18907
|
+
getQueryClient;
|
|
18908
|
+
async quote(params, source, destination) {
|
|
18909
|
+
validateQuoteParams(params);
|
|
18910
|
+
const sourceConfig = getConfigByStateMachineId(source.stateMachineId);
|
|
18911
|
+
const destinationConfig = getConfigByStateMachineId(destination.stateMachineId);
|
|
18912
|
+
if (!sourceConfig) throw new UnsupportedLiquidityChainError(source.stateMachineId);
|
|
18913
|
+
if (!destinationConfig) throw new UnsupportedLiquidityChainError(destination.stateMachineId);
|
|
18914
|
+
const tokenIn = this.resolveAsset(sourceConfig.stateMachineId, params.tokenIn);
|
|
18915
|
+
const tokenOut = this.resolveAsset(destinationConfig.stateMachineId, params.tokenOut);
|
|
18916
|
+
const [protocolFeeBps, rates] = await Promise.all([
|
|
18917
|
+
readProtocolFeeBps(this.chainConfigService, source),
|
|
18918
|
+
new LiquidityEngine(this.getQueryClient()).getBuyAndSellRates({
|
|
18919
|
+
sourceChain: sourceConfig.stateMachineId,
|
|
18920
|
+
destinationChain: destinationConfig.stateMachineId,
|
|
18921
|
+
tokenInSymbol: tokenIn.symbol,
|
|
18922
|
+
tokenOutSymbol: tokenOut.symbol
|
|
18923
|
+
})
|
|
18924
|
+
]);
|
|
18925
|
+
if (!rates) {
|
|
18926
|
+
throw new IndexedRateUnavailableError({
|
|
18927
|
+
source: sourceConfig.stateMachineId,
|
|
18928
|
+
destination: destinationConfig.stateMachineId,
|
|
18929
|
+
tokenIn: tokenIn.symbol,
|
|
18930
|
+
tokenOut: tokenOut.symbol
|
|
18931
|
+
});
|
|
18932
|
+
}
|
|
18933
|
+
const selectedRate = selectIndexedRate(rates, tokenIn.symbol, tokenOut.symbol);
|
|
18934
|
+
return quoteWithIndexedRate(params, tokenIn, tokenOut, selectedRate, rates, protocolFeeBps);
|
|
18935
|
+
}
|
|
18936
|
+
resolveAsset(chain, address) {
|
|
18937
|
+
const asset = this.chainConfigService.getAssetMetadataByAddress(chain, address);
|
|
18938
|
+
if (!asset) throw new UnsupportedLiquidityAssetError(chain, address);
|
|
18939
|
+
const { decimals } = asset;
|
|
18940
|
+
if (decimals === void 0 || !Number.isSafeInteger(decimals) || decimals < 0) {
|
|
18941
|
+
throw new InvalidIndexedRateError(`decimals are not configured for ${asset.symbol} on ${chain}`);
|
|
18942
|
+
}
|
|
18943
|
+
return { ...asset, decimals };
|
|
18944
|
+
}
|
|
18945
|
+
};
|
|
18946
|
+
function selectIndexedRate(rates, tokenInSymbol, tokenOutSymbol) {
|
|
18947
|
+
if (tokenInSymbol === rates.baseTokenSymbol && tokenOutSymbol === rates.quoteTokenSymbol) {
|
|
18948
|
+
return readIndexedRate2(
|
|
18949
|
+
"buy",
|
|
18950
|
+
rates.buyRate,
|
|
18951
|
+
rates.buyRateUpdatedAt,
|
|
18952
|
+
rates,
|
|
18953
|
+
tokenInSymbol,
|
|
18954
|
+
tokenOutSymbol
|
|
18955
|
+
);
|
|
18956
|
+
}
|
|
18957
|
+
if (tokenInSymbol === rates.quoteTokenSymbol && tokenOutSymbol === rates.baseTokenSymbol) {
|
|
18958
|
+
return readIndexedRate2(
|
|
18959
|
+
"sell",
|
|
18960
|
+
rates.sellRate,
|
|
18961
|
+
rates.sellRateUpdatedAt,
|
|
18962
|
+
rates,
|
|
18963
|
+
tokenInSymbol,
|
|
18964
|
+
tokenOutSymbol
|
|
18965
|
+
);
|
|
18966
|
+
}
|
|
18967
|
+
throw new InvalidIndexedRateError(
|
|
18968
|
+
`indexed pair ${rates.baseTokenSymbol}/${rates.quoteTokenSymbol} does not match ${tokenInSymbol}/${tokenOutSymbol}`
|
|
18969
|
+
);
|
|
18970
|
+
}
|
|
18971
|
+
function readIndexedRate2(side, rate, updatedAt, rates, tokenInSymbol, tokenOutSymbol) {
|
|
18972
|
+
if (!rate || !updatedAt) {
|
|
18973
|
+
throw new IndexedRateUnavailableError({
|
|
18974
|
+
source: rates.sourceChain,
|
|
18975
|
+
destination: rates.destinationChain,
|
|
18976
|
+
tokenIn: tokenInSymbol,
|
|
18977
|
+
tokenOut: tokenOutSymbol,
|
|
18978
|
+
side
|
|
18979
|
+
});
|
|
18980
|
+
}
|
|
18981
|
+
try {
|
|
18982
|
+
const scaledRate = parseUnits(rate, INDEXED_RATE_DECIMALS);
|
|
18983
|
+
if (scaledRate <= 0n || Number.isNaN(updatedAt.getTime())) throw new Error();
|
|
18984
|
+
return { side, rate, scaledRate, updatedAt };
|
|
18985
|
+
} catch {
|
|
18986
|
+
throw new InvalidIndexedRateError(`${side} rate or timestamp is invalid`);
|
|
18987
|
+
}
|
|
18988
|
+
}
|
|
18989
|
+
function quoteWithIndexedRate(params, tokenIn, tokenOut, selectedRate, rates, protocolFeeBps) {
|
|
18990
|
+
const inputUnit = 10n ** BigInt(tokenIn.decimals);
|
|
18991
|
+
const outputUnit = 10n ** BigInt(tokenOut.decimals);
|
|
18992
|
+
if (params.amountIn !== void 0) {
|
|
18993
|
+
const netAmountIn2 = deductProtocolFee(params.amountIn, protocolFeeBps);
|
|
18994
|
+
const amountOut = selectedRate.side === "buy" ? netAmountIn2 * selectedRate.scaledRate * outputUnit / (inputUnit * INDEXED_RATE_SCALE) : netAmountIn2 * outputUnit * INDEXED_RATE_SCALE / (inputUnit * selectedRate.scaledRate);
|
|
18995
|
+
if (amountOut <= 0n) throw new InvalidIndexedRateError("quote rounds down to zero output");
|
|
18996
|
+
return buildResult("EXACT_INPUT", params.amountIn, amountOut, selectedRate, rates, protocolFeeBps);
|
|
18997
|
+
}
|
|
18998
|
+
if (params.amountOut === void 0) throw new Error("Quote amount is missing after validation");
|
|
18999
|
+
const netAmountIn = selectedRate.side === "buy" ? divCeil(params.amountOut * inputUnit * INDEXED_RATE_SCALE, selectedRate.scaledRate * outputUnit) : divCeil(params.amountOut * inputUnit * selectedRate.scaledRate, outputUnit * INDEXED_RATE_SCALE);
|
|
19000
|
+
const amountIn = grossUpForProtocolFee(netAmountIn, protocolFeeBps);
|
|
19001
|
+
return buildResult("EXACT_OUTPUT", amountIn, params.amountOut, selectedRate, rates, protocolFeeBps);
|
|
19002
|
+
}
|
|
19003
|
+
function buildResult(tradeType, amountIn, amountOut, selectedRate, rates, protocolFeeBps) {
|
|
19004
|
+
return {
|
|
19005
|
+
strategy: "indexed_rates",
|
|
19006
|
+
tradeType,
|
|
19007
|
+
amountIn,
|
|
19008
|
+
amountOut,
|
|
19009
|
+
quoteMetadata: {
|
|
19010
|
+
sourceChain: rates.sourceChain,
|
|
19011
|
+
destinationChain: rates.destinationChain,
|
|
19012
|
+
baseTokenSymbol: rates.baseTokenSymbol,
|
|
19013
|
+
quoteTokenSymbol: rates.quoteTokenSymbol,
|
|
19014
|
+
rateSide: selectedRate.side,
|
|
19015
|
+
rate: selectedRate.rate,
|
|
19016
|
+
rateUpdatedAt: selectedRate.updatedAt,
|
|
19017
|
+
protocolFeeBps
|
|
19018
|
+
}
|
|
19019
|
+
};
|
|
19020
|
+
}
|
|
18894
19021
|
|
|
18895
19022
|
// src/protocols/intents/IntentGateway.ts
|
|
18896
19023
|
var CROSS_CHAIN_ORDER_FEE_GAS_PRICE_BUMP_PERCENT = 10n;
|
|
@@ -18965,6 +19092,10 @@ var IntentGateway = class _IntentGateway {
|
|
|
18965
19092
|
this.gasEstimator = gasEstimator;
|
|
18966
19093
|
this._crypto = crypto;
|
|
18967
19094
|
this.quoteStrategies = {
|
|
19095
|
+
indexed_rates: new IndexedRateIntentQuoteStrategy(
|
|
19096
|
+
dest.configService,
|
|
19097
|
+
() => this.requireIndexer().queryClient
|
|
19098
|
+
),
|
|
18968
19099
|
phantom_snapshot: new PhantomSnapshotIntentQuoteStrategy(
|
|
18969
19100
|
dest.configService,
|
|
18970
19101
|
() => this.requireIndexer().queryClient
|
|
@@ -19018,26 +19149,26 @@ var IntentGateway = class _IntentGateway {
|
|
|
19018
19149
|
/**
|
|
19019
19150
|
* Quotes an intent between this gateway's source and destination chains.
|
|
19020
19151
|
*
|
|
19021
|
-
* Uses the latest directional
|
|
19022
|
-
*
|
|
19023
|
-
* requesting a
|
|
19152
|
+
* Uses the indexer's latest aggregate directional pool rate by default. Pass
|
|
19153
|
+
* `strategy: "phantom_snapshot"` or `strategy: "uniswap_v4"` only when
|
|
19154
|
+
* explicitly requesting a legacy quote source. Provide exactly one of
|
|
19155
|
+
* `amountIn` or `amountOut`.
|
|
19024
19156
|
*
|
|
19025
|
-
*
|
|
19026
|
-
*
|
|
19157
|
+
* The gateway's source and destination chains resolve the configured order
|
|
19158
|
+
* tokens; the indexer supplies the depth-weighted pool rate. Returned
|
|
19027
19159
|
* `amountIn`/`amountOut` already account for the gateway's protocol fee
|
|
19028
|
-
* (`quoteMetadata.protocolFeeBps`), which the gateway deducts from order
|
|
19029
|
-
* inputs; use the returned amounts directly when placing the order.
|
|
19160
|
+
* (`quoteMetadata.protocolFeeBps`), which the gateway deducts from order inputs.
|
|
19030
19161
|
*
|
|
19031
19162
|
* @param params - Token pair, amount, and optional strategy/pool overrides.
|
|
19032
19163
|
* @returns The quoted amounts plus strategy-specific metadata.
|
|
19033
19164
|
* @throws {UnsupportedIntentQuoteStrategyError} For unknown strategies.
|
|
19034
19165
|
* @throws {UnsupportedIntentQuotePairError} When the selected strategy does not support the pair.
|
|
19035
|
-
* @throws {
|
|
19166
|
+
* @throws {IndexedRateUnavailableError} When the requested direction has no indexed rate.
|
|
19036
19167
|
*/
|
|
19037
19168
|
async quoteIntent(params) {
|
|
19038
19169
|
const source = { stateMachineId: this.source.config.stateMachineId, client: this.source.client };
|
|
19039
19170
|
const destination = { stateMachineId: this.dest.config.stateMachineId, client: this.dest.client };
|
|
19040
|
-
const strategy = params.strategy ?? "
|
|
19171
|
+
const strategy = params.strategy ?? "indexed_rates";
|
|
19041
19172
|
const handler = this.quoteStrategies[strategy];
|
|
19042
19173
|
if (!handler) throw new UnsupportedIntentQuoteStrategyError(strategy);
|
|
19043
19174
|
return handler.quote({ ...params, strategy }, source, destination);
|
|
@@ -19077,9 +19208,9 @@ var IntentGateway = class _IntentGateway {
|
|
|
19077
19208
|
});
|
|
19078
19209
|
}
|
|
19079
19210
|
/**
|
|
19080
|
-
* Returns
|
|
19081
|
-
* without requiring token addresses. Symbols are matched
|
|
19082
|
-
* chain IDs
|
|
19211
|
+
* Returns aggregate indexed pool buy and sell rates in less-valued quote-token
|
|
19212
|
+
* units without requiring token addresses. Symbols are matched
|
|
19213
|
+
* case-insensitively; chain IDs resolve configured token deployments.
|
|
19083
19214
|
*/
|
|
19084
19215
|
async queryBuyAndSellRates(params) {
|
|
19085
19216
|
const { queryClient } = this.requireIndexer();
|
|
@@ -19727,6 +19858,10 @@ function encodeAcceptedSourceChains(chains2) {
|
|
|
19727
19858
|
function decodeAcceptedSourceChains(paymasterAndData) {
|
|
19728
19859
|
return decodePhantomBidDeclaration(paymasterAndData).acceptedSources;
|
|
19729
19860
|
}
|
|
19861
|
+
var UNISWAP_QUOTE_HAIRCUT_BPS = 30n;
|
|
19862
|
+
function applyUniswapQuoteHaircut(amount) {
|
|
19863
|
+
return amount * (10000n - UNISWAP_QUOTE_HAIRCUT_BPS) / 10000n;
|
|
19864
|
+
}
|
|
19730
19865
|
FILL_ORDER_ABI.find(
|
|
19731
19866
|
(item) => item?.type === "function" && item?.name === "fillOrder"
|
|
19732
19867
|
)?.inputs?.[0];
|
|
@@ -24200,6 +24335,6 @@ async function teleportDot(param_) {
|
|
|
24200
24335
|
return stream;
|
|
24201
24336
|
}
|
|
24202
24337
|
|
|
24203
|
-
export { ADDRESS_ZERO2 as ADDRESS_ZERO, BundlerMethod, ChainConfigService, Chains, CryptoUtils, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DOMAIN_TYPEHASH, DUMMY_PRIVATE_KEY, ERC20Method, ERC7821_BATCH_MODE, EvmChain, ABI as EvmHostABI, EvmLanguage, HyperClientStatus, HyperFungibleToken, HyperFungibleTokenABI, INCLUSION_TIMEOUT_MS, IntentGateway, ABI3 as IntentGatewayABI, IntentOrderStatus, IntentsCoprocessor, InvalidLiquidityIndexerResponseError, InvalidPhantomSnapshotError, IsmpClient, 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, USE_ETHERSCAN_CHAINS, UnsupportedIntentQuotePairError, UnsupportedIntentQuoteStrategyError, UnsupportedLiquidityAssetError, UnsupportedLiquidityChainError, WrappedHyperFungibleTokenABI, __test, adjustDecimals, bytes20ToBytes32, bytes32ToBytes20, calculateAllowanceMappingLocation, calculateBalanceMappingLocation, chainConfigs, constructRedeemEscrowRequestBody, constructRefundEscrowRequestBody, convertCodecToIGetRequest, convertCodecToIProof, convertIGetRequestToCodec, convertIProofToCodec, convertStateIdToStateMachineId, convertStateMachineEnumToString, convertStateMachineIdToEnum, createEvmChain, createQueryClient, decodeAcceptedSourceChains, decodeERC7821ExecuteBatch, decodePhantomBidDeclaration, decodeUserOpScale, deriveHttpUrl, encodeAcceptedSourceChains, encodeERC7821ExecuteBatch, encodeISMPMessage, encodePhantomBidDeclaration, 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, poolSlug, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, quoteUniswap, requestCommitmentKey, responseCommitmentKey, retryPromise, sortPoolSymbols, teleport, teleportDot, transformOrderForContract, tronChainIds, tronNile };
|
|
24338
|
+
export { ADDRESS_ZERO2 as ADDRESS_ZERO, BundlerMethod, ChainConfigService, Chains, CryptoUtils, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DOMAIN_TYPEHASH, DUMMY_PRIVATE_KEY, ERC20Method, ERC7821_BATCH_MODE, EvmChain, ABI as EvmHostABI, EvmLanguage, HyperClientStatus, HyperFungibleToken, HyperFungibleTokenABI, INCLUSION_TIMEOUT_MS, IndexedRateUnavailableError, IntentGateway, ABI3 as IntentGatewayABI, IntentOrderStatus, IntentsCoprocessor, InvalidIndexedRateError, InvalidLiquidityIndexerResponseError, InvalidPhantomSnapshotError, IsmpClient, 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, applyUniswapQuoteHaircut, bytes20ToBytes32, bytes32ToBytes20, calculateAllowanceMappingLocation, calculateBalanceMappingLocation, chainConfigs, constructRedeemEscrowRequestBody, constructRefundEscrowRequestBody, convertCodecToIGetRequest, convertCodecToIProof, convertIGetRequestToCodec, convertIProofToCodec, convertStateIdToStateMachineId, convertStateMachineEnumToString, convertStateMachineIdToEnum, createEvmChain, createQueryClient, decodeAcceptedSourceChains, decodeERC7821ExecuteBatch, decodePhantomBidDeclaration, decodeUserOpScale, deriveHttpUrl, encodeAcceptedSourceChains, encodeERC7821ExecuteBatch, encodeISMPMessage, encodePhantomBidDeclaration, 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, poolSlug, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, quoteUniswap, requestCommitmentKey, responseCommitmentKey, retryPromise, sortPoolSymbols, teleport, teleportDot, transformOrderForContract, tronChainIds, tronNile };
|
|
24204
24339
|
//# sourceMappingURL=index.js.map
|
|
24205
24340
|
//# sourceMappingURL=index.js.map
|