@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.cjs
CHANGED
|
@@ -2808,7 +2808,7 @@ var chainConfigs = {
|
|
|
2808
2808
|
// "Usdt0Oft": Not available on BSC
|
|
2809
2809
|
},
|
|
2810
2810
|
rpcEnvKey: "BSC_MAINNET",
|
|
2811
|
-
defaultRpcUrl: "https://
|
|
2811
|
+
defaultRpcUrl: "https://bsc-rpc.publicnode.com",
|
|
2812
2812
|
consensusStateId: "BSC0",
|
|
2813
2813
|
coingeckoId: "binance-smart-chain",
|
|
2814
2814
|
erc4626Vaults: [
|
|
@@ -12101,40 +12101,17 @@ query AvailableLiquidity(
|
|
|
12101
12101
|
}
|
|
12102
12102
|
}`;
|
|
12103
12103
|
var BUY_AND_SELL_RATES = `
|
|
12104
|
-
query
|
|
12105
|
-
|
|
12106
|
-
$directChain: String!
|
|
12107
|
-
$directDirection: String!
|
|
12108
|
-
$reverseChain: String!
|
|
12109
|
-
$reverseDirection: String!
|
|
12110
|
-
) {
|
|
12111
|
-
direct: poolChainLiquidities(
|
|
12112
|
-
filter: {
|
|
12113
|
-
and: [
|
|
12114
|
-
{ poolId: { equalToInsensitive: $poolId } }
|
|
12115
|
-
{ chain: { equalTo: $directChain } }
|
|
12116
|
-
{ direction: { equalTo: $directDirection } }
|
|
12117
|
-
]
|
|
12118
|
-
}
|
|
12119
|
-
first: 1
|
|
12120
|
-
) {
|
|
12121
|
-
nodes {
|
|
12122
|
-
rate
|
|
12123
|
-
lastUpdatedAt
|
|
12124
|
-
}
|
|
12125
|
-
}
|
|
12126
|
-
reverse: poolChainLiquidities(
|
|
12127
|
-
filter: {
|
|
12128
|
-
and: [
|
|
12129
|
-
{ poolId: { equalToInsensitive: $poolId } }
|
|
12130
|
-
{ chain: { equalTo: $reverseChain } }
|
|
12131
|
-
{ direction: { equalTo: $reverseDirection } }
|
|
12132
|
-
]
|
|
12133
|
-
}
|
|
12104
|
+
query GetLiquidityPoolRate($poolId: String!) {
|
|
12105
|
+
liquidityPools(
|
|
12134
12106
|
first: 1
|
|
12107
|
+
filter: { id: { equalToInsensitive: $poolId } }
|
|
12135
12108
|
) {
|
|
12136
12109
|
nodes {
|
|
12137
|
-
|
|
12110
|
+
id
|
|
12111
|
+
token0Symbol
|
|
12112
|
+
token1Symbol
|
|
12113
|
+
sellRate
|
|
12114
|
+
buyRate
|
|
12138
12115
|
lastUpdatedAt
|
|
12139
12116
|
}
|
|
12140
12117
|
}
|
|
@@ -18346,29 +18323,29 @@ var LiquidityEngine = class {
|
|
|
18346
18323
|
};
|
|
18347
18324
|
}
|
|
18348
18325
|
/**
|
|
18349
|
-
* Returns
|
|
18350
|
-
* per one base token.
|
|
18326
|
+
* Returns the indexed pool's aggregate buy and sell rates in less-valued
|
|
18327
|
+
* quote-token units per one base token.
|
|
18351
18328
|
*
|
|
18352
|
-
* The
|
|
18353
|
-
*
|
|
18354
|
-
*
|
|
18329
|
+
* The indexer depth-weights fresh per-chain samples into the pool rates. The
|
|
18330
|
+
* source and destination chains remain part of the result because they define
|
|
18331
|
+
* the cross-chain route whose configured token symbols were resolved.
|
|
18355
18332
|
*/
|
|
18356
18333
|
async getBuyAndSellRates(params) {
|
|
18357
18334
|
const pool = resolveLiquidityPool(params.tokenInSymbol, params.tokenOutSymbol);
|
|
18358
|
-
const directDirection = params.tokenInSymbol.toLowerCase() === pool.token0Symbol.toLowerCase() ? SELL : BUY;
|
|
18359
|
-
const reverseDirection = directDirection === SELL ? BUY : SELL;
|
|
18360
18335
|
const response = await this.queryClient.request(BUY_AND_SELL_RATES, {
|
|
18361
|
-
poolId: pool.poolId
|
|
18362
|
-
directChain: params.destinationChain,
|
|
18363
|
-
directDirection,
|
|
18364
|
-
reverseChain: params.sourceChain,
|
|
18365
|
-
reverseDirection
|
|
18336
|
+
poolId: pool.poolId
|
|
18366
18337
|
});
|
|
18367
|
-
if (!response?.
|
|
18368
|
-
throw new InvalidLiquidityIndexerResponseError("
|
|
18369
|
-
}
|
|
18370
|
-
const
|
|
18371
|
-
|
|
18338
|
+
if (!response?.liquidityPools?.nodes) {
|
|
18339
|
+
throw new InvalidLiquidityIndexerResponseError("liquidity pool connection is missing");
|
|
18340
|
+
}
|
|
18341
|
+
const indexedPool = response.liquidityPools.nodes[0];
|
|
18342
|
+
if (!indexedPool) return void 0;
|
|
18343
|
+
validateIndexedPool(indexedPool, pool);
|
|
18344
|
+
const sell = readIndexedRate(indexedPool.sellRate, indexedPool.lastUpdatedAt, "pool sell rate");
|
|
18345
|
+
const buy = readIndexedRate(indexedPool.buyRate, indexedPool.lastUpdatedAt, "pool buy rate");
|
|
18346
|
+
const inputIsToken0 = params.tokenInSymbol.toLowerCase() === pool.token0Symbol.toLowerCase();
|
|
18347
|
+
const direct = inputIsToken0 ? sell : buy;
|
|
18348
|
+
const reverse = inputIsToken0 ? buy : sell;
|
|
18372
18349
|
if (!direct && !reverse) return void 0;
|
|
18373
18350
|
const quoteTokenSymbol = resolveQuoteTokenSymbol(
|
|
18374
18351
|
params.tokenInSymbol,
|
|
@@ -18377,17 +18354,17 @@ var LiquidityEngine = class {
|
|
|
18377
18354
|
reverse?.scaledRate
|
|
18378
18355
|
);
|
|
18379
18356
|
const quoteIsTokenOut = quoteTokenSymbol === params.tokenOutSymbol;
|
|
18380
|
-
const
|
|
18381
|
-
const
|
|
18357
|
+
const orientedBuy = quoteIsTokenOut ? direct : reverse;
|
|
18358
|
+
const orientedSell = quoteIsTokenOut ? reverse : direct;
|
|
18382
18359
|
return {
|
|
18383
18360
|
baseTokenSymbol: quoteIsTokenOut ? params.tokenInSymbol : params.tokenOutSymbol,
|
|
18384
18361
|
quoteTokenSymbol,
|
|
18385
18362
|
sourceChain: params.sourceChain,
|
|
18386
18363
|
destinationChain: params.destinationChain,
|
|
18387
|
-
buyRate:
|
|
18388
|
-
sellRate:
|
|
18389
|
-
buyRateUpdatedAt:
|
|
18390
|
-
sellRateUpdatedAt:
|
|
18364
|
+
buyRate: orientedBuy ? viem.formatUnits(orientedBuy.scaledRate, INDEXER_FIXED_POINT_DECIMALS) : null,
|
|
18365
|
+
sellRate: orientedSell ? viem.formatUnits(reciprocalRate(orientedSell.scaledRate, "sell rate"), INDEXER_FIXED_POINT_DECIMALS) : null,
|
|
18366
|
+
buyRateUpdatedAt: orientedBuy?.updatedAt ?? null,
|
|
18367
|
+
sellRateUpdatedAt: orientedSell?.updatedAt ?? null
|
|
18391
18368
|
};
|
|
18392
18369
|
}
|
|
18393
18370
|
};
|
|
@@ -18429,20 +18406,25 @@ function readIndexerDate(value, label) {
|
|
|
18429
18406
|
if (Number.isNaN(date.getTime())) throw new InvalidLiquidityIndexerResponseError(`${label} is invalid`);
|
|
18430
18407
|
return date;
|
|
18431
18408
|
}
|
|
18432
|
-
function readIndexedRate(
|
|
18433
|
-
if (
|
|
18409
|
+
function readIndexedRate(value, lastUpdatedAt, label) {
|
|
18410
|
+
if (value === null) return void 0;
|
|
18434
18411
|
try {
|
|
18435
|
-
const scaledRate = BigInt(
|
|
18412
|
+
const scaledRate = BigInt(value);
|
|
18436
18413
|
if (scaledRate <= 0n) throw new Error();
|
|
18437
18414
|
return {
|
|
18438
18415
|
scaledRate,
|
|
18439
|
-
updatedAt: readIndexerDate(
|
|
18416
|
+
updatedAt: readIndexerDate(lastUpdatedAt, `${label} lastUpdatedAt`)
|
|
18440
18417
|
};
|
|
18441
18418
|
} catch (error) {
|
|
18442
18419
|
if (error instanceof InvalidLiquidityIndexerResponseError) throw error;
|
|
18443
18420
|
throw new InvalidLiquidityIndexerResponseError(`${label} is not a positive integer`);
|
|
18444
18421
|
}
|
|
18445
18422
|
}
|
|
18423
|
+
function validateIndexedPool(indexedPool, expected) {
|
|
18424
|
+
if (indexedPool.id.toLowerCase() !== expected.poolId.toLowerCase() || indexedPool.token0Symbol.toLowerCase() !== expected.token0Symbol.toLowerCase() || indexedPool.token1Symbol.toLowerCase() !== expected.token1Symbol.toLowerCase()) {
|
|
18425
|
+
throw new InvalidLiquidityIndexerResponseError(`pool identity does not match ${expected.poolId}`);
|
|
18426
|
+
}
|
|
18427
|
+
}
|
|
18446
18428
|
function resolveQuoteTokenSymbol(tokenInSymbol, tokenOutSymbol, directRate, reverseRate) {
|
|
18447
18429
|
const inputIsUsdStable = USD_STABLE_SYMBOLS.has(tokenInSymbol);
|
|
18448
18430
|
const outputIsUsdStable = USD_STABLE_SYMBOLS.has(tokenOutSymbol);
|
|
@@ -18452,7 +18434,8 @@ function resolveQuoteTokenSymbol(tokenInSymbol, tokenOutSymbol, directRate, reve
|
|
|
18452
18434
|
throw new InvalidLiquidityIndexerResponseError("cannot orient an empty rate pair");
|
|
18453
18435
|
}
|
|
18454
18436
|
function reciprocalRate(rate, label) {
|
|
18455
|
-
const
|
|
18437
|
+
const numerator = POOL_RATE_SCALE * POOL_RATE_SCALE;
|
|
18438
|
+
const reciprocal = (numerator + rate - 1n) / rate;
|
|
18456
18439
|
if (reciprocal <= 0n) throw new InvalidLiquidityIndexerResponseError(`${label} reciprocal underflowed`);
|
|
18457
18440
|
return reciprocal;
|
|
18458
18441
|
}
|
|
@@ -18484,6 +18467,20 @@ var InvalidPhantomSnapshotError = class extends Error {
|
|
|
18484
18467
|
this.name = "InvalidPhantomSnapshotError";
|
|
18485
18468
|
}
|
|
18486
18469
|
};
|
|
18470
|
+
var IndexedRateUnavailableError = class extends Error {
|
|
18471
|
+
constructor(params) {
|
|
18472
|
+
const route = params.source && params.destination && params.tokenIn && params.tokenOut ? ` for ${params.tokenIn} -> ${params.tokenOut} on ${params.source} -> ${params.destination}` : "";
|
|
18473
|
+
const side = params.side ? ` ${params.side}` : "";
|
|
18474
|
+
super(`No indexed${side} rate available${route}`);
|
|
18475
|
+
this.name = "IndexedRateUnavailableError";
|
|
18476
|
+
}
|
|
18477
|
+
};
|
|
18478
|
+
var InvalidIndexedRateError = class extends Error {
|
|
18479
|
+
constructor(reason) {
|
|
18480
|
+
super(`Invalid indexed intent rate: ${reason}`);
|
|
18481
|
+
this.name = "InvalidIndexedRateError";
|
|
18482
|
+
}
|
|
18483
|
+
};
|
|
18487
18484
|
var BPS_DENOMINATOR = 10000n;
|
|
18488
18485
|
function validateQuoteParams(params) {
|
|
18489
18486
|
const hasAmountIn = params.amountIn !== void 0;
|
|
@@ -18850,6 +18847,128 @@ function isSupportedSnapshotPair(tokenA, tokenB) {
|
|
|
18850
18847
|
function isConfiguredAddress(address) {
|
|
18851
18848
|
return Boolean(address && address !== "0x" && !/^0x0{40}$/i.test(address));
|
|
18852
18849
|
}
|
|
18850
|
+
var INDEXED_RATE_DECIMALS = 18;
|
|
18851
|
+
var INDEXED_RATE_SCALE = 10n ** BigInt(INDEXED_RATE_DECIMALS);
|
|
18852
|
+
var IndexedRateIntentQuoteStrategy = class {
|
|
18853
|
+
constructor(chainConfigService, getQueryClient) {
|
|
18854
|
+
this.chainConfigService = chainConfigService;
|
|
18855
|
+
this.getQueryClient = getQueryClient;
|
|
18856
|
+
}
|
|
18857
|
+
chainConfigService;
|
|
18858
|
+
getQueryClient;
|
|
18859
|
+
async quote(params, source, destination) {
|
|
18860
|
+
validateQuoteParams(params);
|
|
18861
|
+
const sourceConfig = getConfigByStateMachineId(source.stateMachineId);
|
|
18862
|
+
const destinationConfig = getConfigByStateMachineId(destination.stateMachineId);
|
|
18863
|
+
if (!sourceConfig) throw new UnsupportedLiquidityChainError(source.stateMachineId);
|
|
18864
|
+
if (!destinationConfig) throw new UnsupportedLiquidityChainError(destination.stateMachineId);
|
|
18865
|
+
const tokenIn = this.resolveAsset(sourceConfig.stateMachineId, params.tokenIn);
|
|
18866
|
+
const tokenOut = this.resolveAsset(destinationConfig.stateMachineId, params.tokenOut);
|
|
18867
|
+
const [protocolFeeBps, rates] = await Promise.all([
|
|
18868
|
+
readProtocolFeeBps(this.chainConfigService, source),
|
|
18869
|
+
new LiquidityEngine(this.getQueryClient()).getBuyAndSellRates({
|
|
18870
|
+
sourceChain: sourceConfig.stateMachineId,
|
|
18871
|
+
destinationChain: destinationConfig.stateMachineId,
|
|
18872
|
+
tokenInSymbol: tokenIn.symbol,
|
|
18873
|
+
tokenOutSymbol: tokenOut.symbol
|
|
18874
|
+
})
|
|
18875
|
+
]);
|
|
18876
|
+
if (!rates) {
|
|
18877
|
+
throw new IndexedRateUnavailableError({
|
|
18878
|
+
source: sourceConfig.stateMachineId,
|
|
18879
|
+
destination: destinationConfig.stateMachineId,
|
|
18880
|
+
tokenIn: tokenIn.symbol,
|
|
18881
|
+
tokenOut: tokenOut.symbol
|
|
18882
|
+
});
|
|
18883
|
+
}
|
|
18884
|
+
const selectedRate = selectIndexedRate(rates, tokenIn.symbol, tokenOut.symbol);
|
|
18885
|
+
return quoteWithIndexedRate(params, tokenIn, tokenOut, selectedRate, rates, protocolFeeBps);
|
|
18886
|
+
}
|
|
18887
|
+
resolveAsset(chain, address) {
|
|
18888
|
+
const asset = this.chainConfigService.getAssetMetadataByAddress(chain, address);
|
|
18889
|
+
if (!asset) throw new UnsupportedLiquidityAssetError(chain, address);
|
|
18890
|
+
const { decimals } = asset;
|
|
18891
|
+
if (decimals === void 0 || !Number.isSafeInteger(decimals) || decimals < 0) {
|
|
18892
|
+
throw new InvalidIndexedRateError(`decimals are not configured for ${asset.symbol} on ${chain}`);
|
|
18893
|
+
}
|
|
18894
|
+
return { ...asset, decimals };
|
|
18895
|
+
}
|
|
18896
|
+
};
|
|
18897
|
+
function selectIndexedRate(rates, tokenInSymbol, tokenOutSymbol) {
|
|
18898
|
+
if (tokenInSymbol === rates.baseTokenSymbol && tokenOutSymbol === rates.quoteTokenSymbol) {
|
|
18899
|
+
return readIndexedRate2(
|
|
18900
|
+
"buy",
|
|
18901
|
+
rates.buyRate,
|
|
18902
|
+
rates.buyRateUpdatedAt,
|
|
18903
|
+
rates,
|
|
18904
|
+
tokenInSymbol,
|
|
18905
|
+
tokenOutSymbol
|
|
18906
|
+
);
|
|
18907
|
+
}
|
|
18908
|
+
if (tokenInSymbol === rates.quoteTokenSymbol && tokenOutSymbol === rates.baseTokenSymbol) {
|
|
18909
|
+
return readIndexedRate2(
|
|
18910
|
+
"sell",
|
|
18911
|
+
rates.sellRate,
|
|
18912
|
+
rates.sellRateUpdatedAt,
|
|
18913
|
+
rates,
|
|
18914
|
+
tokenInSymbol,
|
|
18915
|
+
tokenOutSymbol
|
|
18916
|
+
);
|
|
18917
|
+
}
|
|
18918
|
+
throw new InvalidIndexedRateError(
|
|
18919
|
+
`indexed pair ${rates.baseTokenSymbol}/${rates.quoteTokenSymbol} does not match ${tokenInSymbol}/${tokenOutSymbol}`
|
|
18920
|
+
);
|
|
18921
|
+
}
|
|
18922
|
+
function readIndexedRate2(side, rate, updatedAt, rates, tokenInSymbol, tokenOutSymbol) {
|
|
18923
|
+
if (!rate || !updatedAt) {
|
|
18924
|
+
throw new IndexedRateUnavailableError({
|
|
18925
|
+
source: rates.sourceChain,
|
|
18926
|
+
destination: rates.destinationChain,
|
|
18927
|
+
tokenIn: tokenInSymbol,
|
|
18928
|
+
tokenOut: tokenOutSymbol,
|
|
18929
|
+
side
|
|
18930
|
+
});
|
|
18931
|
+
}
|
|
18932
|
+
try {
|
|
18933
|
+
const scaledRate = viem.parseUnits(rate, INDEXED_RATE_DECIMALS);
|
|
18934
|
+
if (scaledRate <= 0n || Number.isNaN(updatedAt.getTime())) throw new Error();
|
|
18935
|
+
return { side, rate, scaledRate, updatedAt };
|
|
18936
|
+
} catch {
|
|
18937
|
+
throw new InvalidIndexedRateError(`${side} rate or timestamp is invalid`);
|
|
18938
|
+
}
|
|
18939
|
+
}
|
|
18940
|
+
function quoteWithIndexedRate(params, tokenIn, tokenOut, selectedRate, rates, protocolFeeBps) {
|
|
18941
|
+
const inputUnit = 10n ** BigInt(tokenIn.decimals);
|
|
18942
|
+
const outputUnit = 10n ** BigInt(tokenOut.decimals);
|
|
18943
|
+
if (params.amountIn !== void 0) {
|
|
18944
|
+
const netAmountIn2 = deductProtocolFee(params.amountIn, protocolFeeBps);
|
|
18945
|
+
const amountOut = selectedRate.side === "buy" ? netAmountIn2 * selectedRate.scaledRate * outputUnit / (inputUnit * INDEXED_RATE_SCALE) : netAmountIn2 * outputUnit * INDEXED_RATE_SCALE / (inputUnit * selectedRate.scaledRate);
|
|
18946
|
+
if (amountOut <= 0n) throw new InvalidIndexedRateError("quote rounds down to zero output");
|
|
18947
|
+
return buildResult("EXACT_INPUT", params.amountIn, amountOut, selectedRate, rates, protocolFeeBps);
|
|
18948
|
+
}
|
|
18949
|
+
if (params.amountOut === void 0) throw new Error("Quote amount is missing after validation");
|
|
18950
|
+
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);
|
|
18951
|
+
const amountIn = grossUpForProtocolFee(netAmountIn, protocolFeeBps);
|
|
18952
|
+
return buildResult("EXACT_OUTPUT", amountIn, params.amountOut, selectedRate, rates, protocolFeeBps);
|
|
18953
|
+
}
|
|
18954
|
+
function buildResult(tradeType, amountIn, amountOut, selectedRate, rates, protocolFeeBps) {
|
|
18955
|
+
return {
|
|
18956
|
+
strategy: "indexed_rates",
|
|
18957
|
+
tradeType,
|
|
18958
|
+
amountIn,
|
|
18959
|
+
amountOut,
|
|
18960
|
+
quoteMetadata: {
|
|
18961
|
+
sourceChain: rates.sourceChain,
|
|
18962
|
+
destinationChain: rates.destinationChain,
|
|
18963
|
+
baseTokenSymbol: rates.baseTokenSymbol,
|
|
18964
|
+
quoteTokenSymbol: rates.quoteTokenSymbol,
|
|
18965
|
+
rateSide: selectedRate.side,
|
|
18966
|
+
rate: selectedRate.rate,
|
|
18967
|
+
rateUpdatedAt: selectedRate.updatedAt,
|
|
18968
|
+
protocolFeeBps
|
|
18969
|
+
}
|
|
18970
|
+
};
|
|
18971
|
+
}
|
|
18853
18972
|
|
|
18854
18973
|
// src/protocols/intents/IntentGateway.ts
|
|
18855
18974
|
var CROSS_CHAIN_ORDER_FEE_GAS_PRICE_BUMP_PERCENT = 10n;
|
|
@@ -18924,6 +19043,10 @@ var IntentGateway = class _IntentGateway {
|
|
|
18924
19043
|
this.gasEstimator = gasEstimator;
|
|
18925
19044
|
this._crypto = crypto;
|
|
18926
19045
|
this.quoteStrategies = {
|
|
19046
|
+
indexed_rates: new IndexedRateIntentQuoteStrategy(
|
|
19047
|
+
dest.configService,
|
|
19048
|
+
() => this.requireIndexer().queryClient
|
|
19049
|
+
),
|
|
18927
19050
|
phantom_snapshot: new PhantomSnapshotIntentQuoteStrategy(
|
|
18928
19051
|
dest.configService,
|
|
18929
19052
|
() => this.requireIndexer().queryClient
|
|
@@ -18977,26 +19100,26 @@ var IntentGateway = class _IntentGateway {
|
|
|
18977
19100
|
/**
|
|
18978
19101
|
* Quotes an intent between this gateway's source and destination chains.
|
|
18979
19102
|
*
|
|
18980
|
-
* Uses the latest directional
|
|
18981
|
-
*
|
|
18982
|
-
* requesting a
|
|
19103
|
+
* Uses the indexer's latest aggregate directional pool rate by default. Pass
|
|
19104
|
+
* `strategy: "phantom_snapshot"` or `strategy: "uniswap_v4"` only when
|
|
19105
|
+
* explicitly requesting a legacy quote source. Provide exactly one of
|
|
19106
|
+
* `amountIn` or `amountOut`.
|
|
18983
19107
|
*
|
|
18984
|
-
*
|
|
18985
|
-
*
|
|
19108
|
+
* The gateway's source and destination chains resolve the configured order
|
|
19109
|
+
* tokens; the indexer supplies the depth-weighted pool rate. Returned
|
|
18986
19110
|
* `amountIn`/`amountOut` already account for the gateway's protocol fee
|
|
18987
|
-
* (`quoteMetadata.protocolFeeBps`), which the gateway deducts from order
|
|
18988
|
-
* inputs; use the returned amounts directly when placing the order.
|
|
19111
|
+
* (`quoteMetadata.protocolFeeBps`), which the gateway deducts from order inputs.
|
|
18989
19112
|
*
|
|
18990
19113
|
* @param params - Token pair, amount, and optional strategy/pool overrides.
|
|
18991
19114
|
* @returns The quoted amounts plus strategy-specific metadata.
|
|
18992
19115
|
* @throws {UnsupportedIntentQuoteStrategyError} For unknown strategies.
|
|
18993
19116
|
* @throws {UnsupportedIntentQuotePairError} When the selected strategy does not support the pair.
|
|
18994
|
-
* @throws {
|
|
19117
|
+
* @throws {IndexedRateUnavailableError} When the requested direction has no indexed rate.
|
|
18995
19118
|
*/
|
|
18996
19119
|
async quoteIntent(params) {
|
|
18997
19120
|
const source = { stateMachineId: this.source.config.stateMachineId, client: this.source.client };
|
|
18998
19121
|
const destination = { stateMachineId: this.dest.config.stateMachineId, client: this.dest.client };
|
|
18999
|
-
const strategy = params.strategy ?? "
|
|
19122
|
+
const strategy = params.strategy ?? "indexed_rates";
|
|
19000
19123
|
const handler = this.quoteStrategies[strategy];
|
|
19001
19124
|
if (!handler) throw new UnsupportedIntentQuoteStrategyError(strategy);
|
|
19002
19125
|
return handler.quote({ ...params, strategy }, source, destination);
|
|
@@ -19036,9 +19159,9 @@ var IntentGateway = class _IntentGateway {
|
|
|
19036
19159
|
});
|
|
19037
19160
|
}
|
|
19038
19161
|
/**
|
|
19039
|
-
* Returns
|
|
19040
|
-
* without requiring token addresses. Symbols are matched
|
|
19041
|
-
* chain IDs
|
|
19162
|
+
* Returns aggregate indexed pool buy and sell rates in less-valued quote-token
|
|
19163
|
+
* units without requiring token addresses. Symbols are matched
|
|
19164
|
+
* case-insensitively; chain IDs resolve configured token deployments.
|
|
19042
19165
|
*/
|
|
19043
19166
|
async queryBuyAndSellRates(params) {
|
|
19044
19167
|
const { queryClient } = this.requireIndexer();
|
|
@@ -19686,6 +19809,10 @@ function encodeAcceptedSourceChains(chains2) {
|
|
|
19686
19809
|
function decodeAcceptedSourceChains(paymasterAndData) {
|
|
19687
19810
|
return decodePhantomBidDeclaration(paymasterAndData).acceptedSources;
|
|
19688
19811
|
}
|
|
19812
|
+
var UNISWAP_QUOTE_HAIRCUT_BPS = 30n;
|
|
19813
|
+
function applyUniswapQuoteHaircut(amount) {
|
|
19814
|
+
return amount * (10000n - UNISWAP_QUOTE_HAIRCUT_BPS) / 10000n;
|
|
19815
|
+
}
|
|
19689
19816
|
FILL_ORDER_ABI.find(
|
|
19690
19817
|
(item) => item?.type === "function" && item?.name === "fillOrder"
|
|
19691
19818
|
)?.inputs?.[0];
|
|
@@ -24177,10 +24304,12 @@ exports.HyperClientStatus = HyperClientStatus;
|
|
|
24177
24304
|
exports.HyperFungibleToken = HyperFungibleToken;
|
|
24178
24305
|
exports.HyperFungibleTokenABI = HyperFungibleTokenABI;
|
|
24179
24306
|
exports.INCLUSION_TIMEOUT_MS = INCLUSION_TIMEOUT_MS;
|
|
24307
|
+
exports.IndexedRateUnavailableError = IndexedRateUnavailableError;
|
|
24180
24308
|
exports.IntentGateway = IntentGateway;
|
|
24181
24309
|
exports.IntentGatewayABI = ABI3;
|
|
24182
24310
|
exports.IntentOrderStatus = IntentOrderStatus;
|
|
24183
24311
|
exports.IntentsCoprocessor = IntentsCoprocessor;
|
|
24312
|
+
exports.InvalidIndexedRateError = InvalidIndexedRateError;
|
|
24184
24313
|
exports.InvalidLiquidityIndexerResponseError = InvalidLiquidityIndexerResponseError;
|
|
24185
24314
|
exports.InvalidPhantomSnapshotError = InvalidPhantomSnapshotError;
|
|
24186
24315
|
exports.IsmpClient = IsmpClient;
|
|
@@ -24208,6 +24337,7 @@ exports.TeleportStatus = TeleportStatus;
|
|
|
24208
24337
|
exports.TimeoutStatus = TimeoutStatus;
|
|
24209
24338
|
exports.TokenGateway = TokenGateway;
|
|
24210
24339
|
exports.TronChain = TronChain;
|
|
24340
|
+
exports.UNISWAP_QUOTE_HAIRCUT_BPS = UNISWAP_QUOTE_HAIRCUT_BPS;
|
|
24211
24341
|
exports.USE_ETHERSCAN_CHAINS = USE_ETHERSCAN_CHAINS;
|
|
24212
24342
|
exports.UnsupportedIntentQuotePairError = UnsupportedIntentQuotePairError;
|
|
24213
24343
|
exports.UnsupportedIntentQuoteStrategyError = UnsupportedIntentQuoteStrategyError;
|
|
@@ -24216,6 +24346,7 @@ exports.UnsupportedLiquidityChainError = UnsupportedLiquidityChainError;
|
|
|
24216
24346
|
exports.WrappedHyperFungibleTokenABI = WrappedHyperFungibleTokenABI;
|
|
24217
24347
|
exports.__test = __test;
|
|
24218
24348
|
exports.adjustDecimals = adjustDecimals;
|
|
24349
|
+
exports.applyUniswapQuoteHaircut = applyUniswapQuoteHaircut;
|
|
24219
24350
|
exports.bytes20ToBytes32 = bytes20ToBytes32;
|
|
24220
24351
|
exports.bytes32ToBytes20 = bytes32ToBytes20;
|
|
24221
24352
|
exports.calculateAllowanceMappingLocation = calculateAllowanceMappingLocation;
|