@hyperbridge/sdk 2.8.7 → 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 +200 -73
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +203 -72
- 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 +200 -73
- 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/node/index.js
CHANGED
|
@@ -2797,7 +2797,7 @@ var chainConfigs = {
|
|
|
2797
2797
|
// "Usdt0Oft": Not available on BSC
|
|
2798
2798
|
},
|
|
2799
2799
|
rpcEnvKey: "BSC_MAINNET",
|
|
2800
|
-
defaultRpcUrl: "https://
|
|
2800
|
+
defaultRpcUrl: "https://bsc-rpc.publicnode.com",
|
|
2801
2801
|
consensusStateId: "BSC0",
|
|
2802
2802
|
coingeckoId: "binance-smart-chain",
|
|
2803
2803
|
erc4626Vaults: [
|
|
@@ -12090,40 +12090,17 @@ query AvailableLiquidity(
|
|
|
12090
12090
|
}
|
|
12091
12091
|
}`;
|
|
12092
12092
|
var BUY_AND_SELL_RATES = `
|
|
12093
|
-
query
|
|
12094
|
-
|
|
12095
|
-
$directChain: String!
|
|
12096
|
-
$directDirection: String!
|
|
12097
|
-
$reverseChain: String!
|
|
12098
|
-
$reverseDirection: String!
|
|
12099
|
-
) {
|
|
12100
|
-
direct: poolChainLiquidities(
|
|
12101
|
-
filter: {
|
|
12102
|
-
and: [
|
|
12103
|
-
{ poolId: { equalToInsensitive: $poolId } }
|
|
12104
|
-
{ chain: { equalTo: $directChain } }
|
|
12105
|
-
{ direction: { equalTo: $directDirection } }
|
|
12106
|
-
]
|
|
12107
|
-
}
|
|
12108
|
-
first: 1
|
|
12109
|
-
) {
|
|
12110
|
-
nodes {
|
|
12111
|
-
rate
|
|
12112
|
-
lastUpdatedAt
|
|
12113
|
-
}
|
|
12114
|
-
}
|
|
12115
|
-
reverse: poolChainLiquidities(
|
|
12116
|
-
filter: {
|
|
12117
|
-
and: [
|
|
12118
|
-
{ poolId: { equalToInsensitive: $poolId } }
|
|
12119
|
-
{ chain: { equalTo: $reverseChain } }
|
|
12120
|
-
{ direction: { equalTo: $reverseDirection } }
|
|
12121
|
-
]
|
|
12122
|
-
}
|
|
12093
|
+
query GetLiquidityPoolRate($poolId: String!) {
|
|
12094
|
+
liquidityPools(
|
|
12123
12095
|
first: 1
|
|
12096
|
+
filter: { id: { equalToInsensitive: $poolId } }
|
|
12124
12097
|
) {
|
|
12125
12098
|
nodes {
|
|
12126
|
-
|
|
12099
|
+
id
|
|
12100
|
+
token0Symbol
|
|
12101
|
+
token1Symbol
|
|
12102
|
+
sellRate
|
|
12103
|
+
buyRate
|
|
12127
12104
|
lastUpdatedAt
|
|
12128
12105
|
}
|
|
12129
12106
|
}
|
|
@@ -18335,29 +18312,29 @@ var LiquidityEngine = class {
|
|
|
18335
18312
|
};
|
|
18336
18313
|
}
|
|
18337
18314
|
/**
|
|
18338
|
-
* Returns
|
|
18339
|
-
* per one base token.
|
|
18315
|
+
* Returns the indexed pool's aggregate buy and sell rates in less-valued
|
|
18316
|
+
* quote-token units per one base token.
|
|
18340
18317
|
*
|
|
18341
|
-
* The
|
|
18342
|
-
*
|
|
18343
|
-
*
|
|
18318
|
+
* The indexer depth-weights fresh per-chain samples into the pool rates. The
|
|
18319
|
+
* source and destination chains remain part of the result because they define
|
|
18320
|
+
* the cross-chain route whose configured token symbols were resolved.
|
|
18344
18321
|
*/
|
|
18345
18322
|
async getBuyAndSellRates(params) {
|
|
18346
18323
|
const pool = resolveLiquidityPool(params.tokenInSymbol, params.tokenOutSymbol);
|
|
18347
|
-
const directDirection = params.tokenInSymbol.toLowerCase() === pool.token0Symbol.toLowerCase() ? SELL : BUY;
|
|
18348
|
-
const reverseDirection = directDirection === SELL ? BUY : SELL;
|
|
18349
18324
|
const response = await this.queryClient.request(BUY_AND_SELL_RATES, {
|
|
18350
|
-
poolId: pool.poolId
|
|
18351
|
-
directChain: params.destinationChain,
|
|
18352
|
-
directDirection,
|
|
18353
|
-
reverseChain: params.sourceChain,
|
|
18354
|
-
reverseDirection
|
|
18325
|
+
poolId: pool.poolId
|
|
18355
18326
|
});
|
|
18356
|
-
if (!response?.
|
|
18357
|
-
throw new InvalidLiquidityIndexerResponseError("
|
|
18358
|
-
}
|
|
18359
|
-
const
|
|
18360
|
-
|
|
18327
|
+
if (!response?.liquidityPools?.nodes) {
|
|
18328
|
+
throw new InvalidLiquidityIndexerResponseError("liquidity pool connection is missing");
|
|
18329
|
+
}
|
|
18330
|
+
const indexedPool = response.liquidityPools.nodes[0];
|
|
18331
|
+
if (!indexedPool) return void 0;
|
|
18332
|
+
validateIndexedPool(indexedPool, pool);
|
|
18333
|
+
const sell = readIndexedRate(indexedPool.sellRate, indexedPool.lastUpdatedAt, "pool sell rate");
|
|
18334
|
+
const buy = readIndexedRate(indexedPool.buyRate, indexedPool.lastUpdatedAt, "pool buy rate");
|
|
18335
|
+
const inputIsToken0 = params.tokenInSymbol.toLowerCase() === pool.token0Symbol.toLowerCase();
|
|
18336
|
+
const direct = inputIsToken0 ? sell : buy;
|
|
18337
|
+
const reverse = inputIsToken0 ? buy : sell;
|
|
18361
18338
|
if (!direct && !reverse) return void 0;
|
|
18362
18339
|
const quoteTokenSymbol = resolveQuoteTokenSymbol(
|
|
18363
18340
|
params.tokenInSymbol,
|
|
@@ -18366,17 +18343,17 @@ var LiquidityEngine = class {
|
|
|
18366
18343
|
reverse?.scaledRate
|
|
18367
18344
|
);
|
|
18368
18345
|
const quoteIsTokenOut = quoteTokenSymbol === params.tokenOutSymbol;
|
|
18369
|
-
const
|
|
18370
|
-
const
|
|
18346
|
+
const orientedBuy = quoteIsTokenOut ? direct : reverse;
|
|
18347
|
+
const orientedSell = quoteIsTokenOut ? reverse : direct;
|
|
18371
18348
|
return {
|
|
18372
18349
|
baseTokenSymbol: quoteIsTokenOut ? params.tokenInSymbol : params.tokenOutSymbol,
|
|
18373
18350
|
quoteTokenSymbol,
|
|
18374
18351
|
sourceChain: params.sourceChain,
|
|
18375
18352
|
destinationChain: params.destinationChain,
|
|
18376
|
-
buyRate:
|
|
18377
|
-
sellRate:
|
|
18378
|
-
buyRateUpdatedAt:
|
|
18379
|
-
sellRateUpdatedAt:
|
|
18353
|
+
buyRate: orientedBuy ? formatUnits(orientedBuy.scaledRate, INDEXER_FIXED_POINT_DECIMALS) : null,
|
|
18354
|
+
sellRate: orientedSell ? formatUnits(reciprocalRate(orientedSell.scaledRate, "sell rate"), INDEXER_FIXED_POINT_DECIMALS) : null,
|
|
18355
|
+
buyRateUpdatedAt: orientedBuy?.updatedAt ?? null,
|
|
18356
|
+
sellRateUpdatedAt: orientedSell?.updatedAt ?? null
|
|
18380
18357
|
};
|
|
18381
18358
|
}
|
|
18382
18359
|
};
|
|
@@ -18418,20 +18395,25 @@ function readIndexerDate(value, label) {
|
|
|
18418
18395
|
if (Number.isNaN(date.getTime())) throw new InvalidLiquidityIndexerResponseError(`${label} is invalid`);
|
|
18419
18396
|
return date;
|
|
18420
18397
|
}
|
|
18421
|
-
function readIndexedRate(
|
|
18422
|
-
if (
|
|
18398
|
+
function readIndexedRate(value, lastUpdatedAt, label) {
|
|
18399
|
+
if (value === null) return void 0;
|
|
18423
18400
|
try {
|
|
18424
|
-
const scaledRate = BigInt(
|
|
18401
|
+
const scaledRate = BigInt(value);
|
|
18425
18402
|
if (scaledRate <= 0n) throw new Error();
|
|
18426
18403
|
return {
|
|
18427
18404
|
scaledRate,
|
|
18428
|
-
updatedAt: readIndexerDate(
|
|
18405
|
+
updatedAt: readIndexerDate(lastUpdatedAt, `${label} lastUpdatedAt`)
|
|
18429
18406
|
};
|
|
18430
18407
|
} catch (error) {
|
|
18431
18408
|
if (error instanceof InvalidLiquidityIndexerResponseError) throw error;
|
|
18432
18409
|
throw new InvalidLiquidityIndexerResponseError(`${label} is not a positive integer`);
|
|
18433
18410
|
}
|
|
18434
18411
|
}
|
|
18412
|
+
function validateIndexedPool(indexedPool, expected) {
|
|
18413
|
+
if (indexedPool.id.toLowerCase() !== expected.poolId.toLowerCase() || indexedPool.token0Symbol.toLowerCase() !== expected.token0Symbol.toLowerCase() || indexedPool.token1Symbol.toLowerCase() !== expected.token1Symbol.toLowerCase()) {
|
|
18414
|
+
throw new InvalidLiquidityIndexerResponseError(`pool identity does not match ${expected.poolId}`);
|
|
18415
|
+
}
|
|
18416
|
+
}
|
|
18435
18417
|
function resolveQuoteTokenSymbol(tokenInSymbol, tokenOutSymbol, directRate, reverseRate) {
|
|
18436
18418
|
const inputIsUsdStable = USD_STABLE_SYMBOLS.has(tokenInSymbol);
|
|
18437
18419
|
const outputIsUsdStable = USD_STABLE_SYMBOLS.has(tokenOutSymbol);
|
|
@@ -18441,7 +18423,8 @@ function resolveQuoteTokenSymbol(tokenInSymbol, tokenOutSymbol, directRate, reve
|
|
|
18441
18423
|
throw new InvalidLiquidityIndexerResponseError("cannot orient an empty rate pair");
|
|
18442
18424
|
}
|
|
18443
18425
|
function reciprocalRate(rate, label) {
|
|
18444
|
-
const
|
|
18426
|
+
const numerator = POOL_RATE_SCALE * POOL_RATE_SCALE;
|
|
18427
|
+
const reciprocal = (numerator + rate - 1n) / rate;
|
|
18445
18428
|
if (reciprocal <= 0n) throw new InvalidLiquidityIndexerResponseError(`${label} reciprocal underflowed`);
|
|
18446
18429
|
return reciprocal;
|
|
18447
18430
|
}
|
|
@@ -18473,6 +18456,20 @@ var InvalidPhantomSnapshotError = class extends Error {
|
|
|
18473
18456
|
this.name = "InvalidPhantomSnapshotError";
|
|
18474
18457
|
}
|
|
18475
18458
|
};
|
|
18459
|
+
var IndexedRateUnavailableError = class extends Error {
|
|
18460
|
+
constructor(params) {
|
|
18461
|
+
const route = params.source && params.destination && params.tokenIn && params.tokenOut ? ` for ${params.tokenIn} -> ${params.tokenOut} on ${params.source} -> ${params.destination}` : "";
|
|
18462
|
+
const side = params.side ? ` ${params.side}` : "";
|
|
18463
|
+
super(`No indexed${side} rate available${route}`);
|
|
18464
|
+
this.name = "IndexedRateUnavailableError";
|
|
18465
|
+
}
|
|
18466
|
+
};
|
|
18467
|
+
var InvalidIndexedRateError = class extends Error {
|
|
18468
|
+
constructor(reason) {
|
|
18469
|
+
super(`Invalid indexed intent rate: ${reason}`);
|
|
18470
|
+
this.name = "InvalidIndexedRateError";
|
|
18471
|
+
}
|
|
18472
|
+
};
|
|
18476
18473
|
var BPS_DENOMINATOR = 10000n;
|
|
18477
18474
|
function validateQuoteParams(params) {
|
|
18478
18475
|
const hasAmountIn = params.amountIn !== void 0;
|
|
@@ -18839,6 +18836,128 @@ function isSupportedSnapshotPair(tokenA, tokenB) {
|
|
|
18839
18836
|
function isConfiguredAddress(address) {
|
|
18840
18837
|
return Boolean(address && address !== "0x" && !/^0x0{40}$/i.test(address));
|
|
18841
18838
|
}
|
|
18839
|
+
var INDEXED_RATE_DECIMALS = 18;
|
|
18840
|
+
var INDEXED_RATE_SCALE = 10n ** BigInt(INDEXED_RATE_DECIMALS);
|
|
18841
|
+
var IndexedRateIntentQuoteStrategy = class {
|
|
18842
|
+
constructor(chainConfigService, getQueryClient) {
|
|
18843
|
+
this.chainConfigService = chainConfigService;
|
|
18844
|
+
this.getQueryClient = getQueryClient;
|
|
18845
|
+
}
|
|
18846
|
+
chainConfigService;
|
|
18847
|
+
getQueryClient;
|
|
18848
|
+
async quote(params, source, destination) {
|
|
18849
|
+
validateQuoteParams(params);
|
|
18850
|
+
const sourceConfig = getConfigByStateMachineId(source.stateMachineId);
|
|
18851
|
+
const destinationConfig = getConfigByStateMachineId(destination.stateMachineId);
|
|
18852
|
+
if (!sourceConfig) throw new UnsupportedLiquidityChainError(source.stateMachineId);
|
|
18853
|
+
if (!destinationConfig) throw new UnsupportedLiquidityChainError(destination.stateMachineId);
|
|
18854
|
+
const tokenIn = this.resolveAsset(sourceConfig.stateMachineId, params.tokenIn);
|
|
18855
|
+
const tokenOut = this.resolveAsset(destinationConfig.stateMachineId, params.tokenOut);
|
|
18856
|
+
const [protocolFeeBps, rates] = await Promise.all([
|
|
18857
|
+
readProtocolFeeBps(this.chainConfigService, source),
|
|
18858
|
+
new LiquidityEngine(this.getQueryClient()).getBuyAndSellRates({
|
|
18859
|
+
sourceChain: sourceConfig.stateMachineId,
|
|
18860
|
+
destinationChain: destinationConfig.stateMachineId,
|
|
18861
|
+
tokenInSymbol: tokenIn.symbol,
|
|
18862
|
+
tokenOutSymbol: tokenOut.symbol
|
|
18863
|
+
})
|
|
18864
|
+
]);
|
|
18865
|
+
if (!rates) {
|
|
18866
|
+
throw new IndexedRateUnavailableError({
|
|
18867
|
+
source: sourceConfig.stateMachineId,
|
|
18868
|
+
destination: destinationConfig.stateMachineId,
|
|
18869
|
+
tokenIn: tokenIn.symbol,
|
|
18870
|
+
tokenOut: tokenOut.symbol
|
|
18871
|
+
});
|
|
18872
|
+
}
|
|
18873
|
+
const selectedRate = selectIndexedRate(rates, tokenIn.symbol, tokenOut.symbol);
|
|
18874
|
+
return quoteWithIndexedRate(params, tokenIn, tokenOut, selectedRate, rates, protocolFeeBps);
|
|
18875
|
+
}
|
|
18876
|
+
resolveAsset(chain, address) {
|
|
18877
|
+
const asset = this.chainConfigService.getAssetMetadataByAddress(chain, address);
|
|
18878
|
+
if (!asset) throw new UnsupportedLiquidityAssetError(chain, address);
|
|
18879
|
+
const { decimals } = asset;
|
|
18880
|
+
if (decimals === void 0 || !Number.isSafeInteger(decimals) || decimals < 0) {
|
|
18881
|
+
throw new InvalidIndexedRateError(`decimals are not configured for ${asset.symbol} on ${chain}`);
|
|
18882
|
+
}
|
|
18883
|
+
return { ...asset, decimals };
|
|
18884
|
+
}
|
|
18885
|
+
};
|
|
18886
|
+
function selectIndexedRate(rates, tokenInSymbol, tokenOutSymbol) {
|
|
18887
|
+
if (tokenInSymbol === rates.baseTokenSymbol && tokenOutSymbol === rates.quoteTokenSymbol) {
|
|
18888
|
+
return readIndexedRate2(
|
|
18889
|
+
"buy",
|
|
18890
|
+
rates.buyRate,
|
|
18891
|
+
rates.buyRateUpdatedAt,
|
|
18892
|
+
rates,
|
|
18893
|
+
tokenInSymbol,
|
|
18894
|
+
tokenOutSymbol
|
|
18895
|
+
);
|
|
18896
|
+
}
|
|
18897
|
+
if (tokenInSymbol === rates.quoteTokenSymbol && tokenOutSymbol === rates.baseTokenSymbol) {
|
|
18898
|
+
return readIndexedRate2(
|
|
18899
|
+
"sell",
|
|
18900
|
+
rates.sellRate,
|
|
18901
|
+
rates.sellRateUpdatedAt,
|
|
18902
|
+
rates,
|
|
18903
|
+
tokenInSymbol,
|
|
18904
|
+
tokenOutSymbol
|
|
18905
|
+
);
|
|
18906
|
+
}
|
|
18907
|
+
throw new InvalidIndexedRateError(
|
|
18908
|
+
`indexed pair ${rates.baseTokenSymbol}/${rates.quoteTokenSymbol} does not match ${tokenInSymbol}/${tokenOutSymbol}`
|
|
18909
|
+
);
|
|
18910
|
+
}
|
|
18911
|
+
function readIndexedRate2(side, rate, updatedAt, rates, tokenInSymbol, tokenOutSymbol) {
|
|
18912
|
+
if (!rate || !updatedAt) {
|
|
18913
|
+
throw new IndexedRateUnavailableError({
|
|
18914
|
+
source: rates.sourceChain,
|
|
18915
|
+
destination: rates.destinationChain,
|
|
18916
|
+
tokenIn: tokenInSymbol,
|
|
18917
|
+
tokenOut: tokenOutSymbol,
|
|
18918
|
+
side
|
|
18919
|
+
});
|
|
18920
|
+
}
|
|
18921
|
+
try {
|
|
18922
|
+
const scaledRate = parseUnits(rate, INDEXED_RATE_DECIMALS);
|
|
18923
|
+
if (scaledRate <= 0n || Number.isNaN(updatedAt.getTime())) throw new Error();
|
|
18924
|
+
return { side, rate, scaledRate, updatedAt };
|
|
18925
|
+
} catch {
|
|
18926
|
+
throw new InvalidIndexedRateError(`${side} rate or timestamp is invalid`);
|
|
18927
|
+
}
|
|
18928
|
+
}
|
|
18929
|
+
function quoteWithIndexedRate(params, tokenIn, tokenOut, selectedRate, rates, protocolFeeBps) {
|
|
18930
|
+
const inputUnit = 10n ** BigInt(tokenIn.decimals);
|
|
18931
|
+
const outputUnit = 10n ** BigInt(tokenOut.decimals);
|
|
18932
|
+
if (params.amountIn !== void 0) {
|
|
18933
|
+
const netAmountIn2 = deductProtocolFee(params.amountIn, protocolFeeBps);
|
|
18934
|
+
const amountOut = selectedRate.side === "buy" ? netAmountIn2 * selectedRate.scaledRate * outputUnit / (inputUnit * INDEXED_RATE_SCALE) : netAmountIn2 * outputUnit * INDEXED_RATE_SCALE / (inputUnit * selectedRate.scaledRate);
|
|
18935
|
+
if (amountOut <= 0n) throw new InvalidIndexedRateError("quote rounds down to zero output");
|
|
18936
|
+
return buildResult("EXACT_INPUT", params.amountIn, amountOut, selectedRate, rates, protocolFeeBps);
|
|
18937
|
+
}
|
|
18938
|
+
if (params.amountOut === void 0) throw new Error("Quote amount is missing after validation");
|
|
18939
|
+
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);
|
|
18940
|
+
const amountIn = grossUpForProtocolFee(netAmountIn, protocolFeeBps);
|
|
18941
|
+
return buildResult("EXACT_OUTPUT", amountIn, params.amountOut, selectedRate, rates, protocolFeeBps);
|
|
18942
|
+
}
|
|
18943
|
+
function buildResult(tradeType, amountIn, amountOut, selectedRate, rates, protocolFeeBps) {
|
|
18944
|
+
return {
|
|
18945
|
+
strategy: "indexed_rates",
|
|
18946
|
+
tradeType,
|
|
18947
|
+
amountIn,
|
|
18948
|
+
amountOut,
|
|
18949
|
+
quoteMetadata: {
|
|
18950
|
+
sourceChain: rates.sourceChain,
|
|
18951
|
+
destinationChain: rates.destinationChain,
|
|
18952
|
+
baseTokenSymbol: rates.baseTokenSymbol,
|
|
18953
|
+
quoteTokenSymbol: rates.quoteTokenSymbol,
|
|
18954
|
+
rateSide: selectedRate.side,
|
|
18955
|
+
rate: selectedRate.rate,
|
|
18956
|
+
rateUpdatedAt: selectedRate.updatedAt,
|
|
18957
|
+
protocolFeeBps
|
|
18958
|
+
}
|
|
18959
|
+
};
|
|
18960
|
+
}
|
|
18842
18961
|
|
|
18843
18962
|
// src/protocols/intents/IntentGateway.ts
|
|
18844
18963
|
var CROSS_CHAIN_ORDER_FEE_GAS_PRICE_BUMP_PERCENT = 10n;
|
|
@@ -18913,6 +19032,10 @@ var IntentGateway = class _IntentGateway {
|
|
|
18913
19032
|
this.gasEstimator = gasEstimator;
|
|
18914
19033
|
this._crypto = crypto;
|
|
18915
19034
|
this.quoteStrategies = {
|
|
19035
|
+
indexed_rates: new IndexedRateIntentQuoteStrategy(
|
|
19036
|
+
dest.configService,
|
|
19037
|
+
() => this.requireIndexer().queryClient
|
|
19038
|
+
),
|
|
18916
19039
|
phantom_snapshot: new PhantomSnapshotIntentQuoteStrategy(
|
|
18917
19040
|
dest.configService,
|
|
18918
19041
|
() => this.requireIndexer().queryClient
|
|
@@ -18966,26 +19089,26 @@ var IntentGateway = class _IntentGateway {
|
|
|
18966
19089
|
/**
|
|
18967
19090
|
* Quotes an intent between this gateway's source and destination chains.
|
|
18968
19091
|
*
|
|
18969
|
-
* Uses the latest directional
|
|
18970
|
-
*
|
|
18971
|
-
* requesting a
|
|
19092
|
+
* Uses the indexer's latest aggregate directional pool rate by default. Pass
|
|
19093
|
+
* `strategy: "phantom_snapshot"` or `strategy: "uniswap_v4"` only when
|
|
19094
|
+
* explicitly requesting a legacy quote source. Provide exactly one of
|
|
19095
|
+
* `amountIn` or `amountOut`.
|
|
18972
19096
|
*
|
|
18973
|
-
*
|
|
18974
|
-
*
|
|
19097
|
+
* The gateway's source and destination chains resolve the configured order
|
|
19098
|
+
* tokens; the indexer supplies the depth-weighted pool rate. Returned
|
|
18975
19099
|
* `amountIn`/`amountOut` already account for the gateway's protocol fee
|
|
18976
|
-
* (`quoteMetadata.protocolFeeBps`), which the gateway deducts from order
|
|
18977
|
-
* inputs; use the returned amounts directly when placing the order.
|
|
19100
|
+
* (`quoteMetadata.protocolFeeBps`), which the gateway deducts from order inputs.
|
|
18978
19101
|
*
|
|
18979
19102
|
* @param params - Token pair, amount, and optional strategy/pool overrides.
|
|
18980
19103
|
* @returns The quoted amounts plus strategy-specific metadata.
|
|
18981
19104
|
* @throws {UnsupportedIntentQuoteStrategyError} For unknown strategies.
|
|
18982
19105
|
* @throws {UnsupportedIntentQuotePairError} When the selected strategy does not support the pair.
|
|
18983
|
-
* @throws {
|
|
19106
|
+
* @throws {IndexedRateUnavailableError} When the requested direction has no indexed rate.
|
|
18984
19107
|
*/
|
|
18985
19108
|
async quoteIntent(params) {
|
|
18986
19109
|
const source = { stateMachineId: this.source.config.stateMachineId, client: this.source.client };
|
|
18987
19110
|
const destination = { stateMachineId: this.dest.config.stateMachineId, client: this.dest.client };
|
|
18988
|
-
const strategy = params.strategy ?? "
|
|
19111
|
+
const strategy = params.strategy ?? "indexed_rates";
|
|
18989
19112
|
const handler = this.quoteStrategies[strategy];
|
|
18990
19113
|
if (!handler) throw new UnsupportedIntentQuoteStrategyError(strategy);
|
|
18991
19114
|
return handler.quote({ ...params, strategy }, source, destination);
|
|
@@ -19025,9 +19148,9 @@ var IntentGateway = class _IntentGateway {
|
|
|
19025
19148
|
});
|
|
19026
19149
|
}
|
|
19027
19150
|
/**
|
|
19028
|
-
* Returns
|
|
19029
|
-
* without requiring token addresses. Symbols are matched
|
|
19030
|
-
* chain IDs
|
|
19151
|
+
* Returns aggregate indexed pool buy and sell rates in less-valued quote-token
|
|
19152
|
+
* units without requiring token addresses. Symbols are matched
|
|
19153
|
+
* case-insensitively; chain IDs resolve configured token deployments.
|
|
19031
19154
|
*/
|
|
19032
19155
|
async queryBuyAndSellRates(params) {
|
|
19033
19156
|
const { queryClient } = this.requireIndexer();
|
|
@@ -19675,6 +19798,10 @@ function encodeAcceptedSourceChains(chains2) {
|
|
|
19675
19798
|
function decodeAcceptedSourceChains(paymasterAndData) {
|
|
19676
19799
|
return decodePhantomBidDeclaration(paymasterAndData).acceptedSources;
|
|
19677
19800
|
}
|
|
19801
|
+
var UNISWAP_QUOTE_HAIRCUT_BPS = 30n;
|
|
19802
|
+
function applyUniswapQuoteHaircut(amount) {
|
|
19803
|
+
return amount * (10000n - UNISWAP_QUOTE_HAIRCUT_BPS) / 10000n;
|
|
19804
|
+
}
|
|
19678
19805
|
FILL_ORDER_ABI.find(
|
|
19679
19806
|
(item) => item?.type === "function" && item?.name === "fillOrder"
|
|
19680
19807
|
)?.inputs?.[0];
|
|
@@ -24148,6 +24275,6 @@ async function teleportDot(param_) {
|
|
|
24148
24275
|
return stream;
|
|
24149
24276
|
}
|
|
24150
24277
|
|
|
24151
|
-
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 };
|
|
24278
|
+
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 };
|
|
24152
24279
|
//# sourceMappingURL=index.js.map
|
|
24153
24280
|
//# sourceMappingURL=index.js.map
|