@hyperbridge/sdk 2.8.11 → 2.8.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- export { bR as AggregationLogger, bS as BidNonceKeyFn, bT as BidSignature, bU as ENTRY_POINT_V08_ADDRESS, bV as FILL_ORDER_ABI, ai as FILL_ORDER_V1_ABI, bW as FetchLike, bX as FillData, bY as HexString, bZ as IntentGatewayV2, b_ as LpBalance, b$ as OrderCommitmentFn, aN as PHANTOM_QUOTE_HAIRCUT_BPS, c0 as PhantomAggregation, c1 as PhantomLegAggregation, c2 as PhantomLegBidder, c3 as PoolAndPositionInfo, c4 as RecoverBidSigner, c5 as RpcBidInfo, c6 as SolverBalanceReader, c7 as SolverV4Position, bf as UNISWAP_QUOTE_HAIRCUT_BPS, c8 as UniswapV4Contracts, c9 as V4PositionState, ca as YieldVaultMap, cb as aggregatePhantomBids, bh as applyPhantomQuoteHaircut, bi as applyUniswapQuoteHaircut, br as decodeAcceptedSourceChains, bs as decodeERC7821ExecuteBatch, bu as decodePhantomBidDeclaration, bv as decodeUserOpScale, bx as encodeAcceptedSourceChains, by as encodeERC7821ExecuteBatch, bB as encodePhantomBidDeclaration, bC as encodeUserOpScale, cc as extractFillData, cd as fetchBidsForOrder, ce as getTotalSolverBalance, cf as memoizedSolverBalance, cg as orderCommitmentFromDecoded, bM as poolSlug, ch as positionAmountOfToken, ci as readV4Position, cj as recoverBidSignerViem, ck as setAggregationFetch, bO as sortPoolSymbols, cl as splitBidSignature, cm as weightedMedian, cn as zipFillLegs } from './intents-helpers-BRegx4yZ.cjs';
1
+ export { bR as AggregationLogger, bS as BidNonceKeyFn, bT as BidSignature, bU as ENTRY_POINT_V08_ADDRESS, bV as FILL_ORDER_ABI, ai as FILL_ORDER_V1_ABI, bW as FetchLike, bX as FillData, bY as HexString, bZ as IntentGatewayV2, b_ as LpBalance, b$ as OrderCommitmentFn, c0 as PhantomAggregation, c1 as PhantomLegAggregation, c2 as PhantomLegBidder, c3 as PoolAndPositionInfo, c4 as RecoverBidSigner, c5 as RpcBidInfo, c6 as SolverBalanceReader, c7 as SolverV4Position, be as UNISWAP_QUOTE_HAIRCUT_BPS, c8 as UniswapV4Contracts, c9 as V4PositionState, ca as YieldVaultMap, cb as aggregatePhantomBids, bg as applyProtocolFeeHaircut, bh as applyUniswapQuoteHaircut, bq as decodeAcceptedSourceChains, br as decodeERC7821ExecuteBatch, bt as decodePhantomBidDeclaration, bu as decodeUserOpScale, bw as encodeAcceptedSourceChains, bx as encodeERC7821ExecuteBatch, bA as encodePhantomBidDeclaration, bB as encodeUserOpScale, cc as extractFillData, cd as fetchBidsForOrder, ce as getTotalSolverBalance, cf as memoizedSolverBalance, cg as orderCommitmentFromDecoded, bL as poolSlug, ch as positionAmountOfToken, bM as readProtocolFeeHaircutBps, ci as readV4Position, cj as recoverBidSignerViem, ck as setAggregationFetch, bO as sortPoolSymbols, cl as splitBidSignature, cm as weightedMedian, cn as zipFillLegs } from './intents-helpers-C9PJp8rx.cjs';
2
2
  import 'consola';
3
3
  import 'decimal.js';
4
4
  import 'graphql-request';
@@ -1,4 +1,4 @@
1
- export { bR as AggregationLogger, bS as BidNonceKeyFn, bT as BidSignature, bU as ENTRY_POINT_V08_ADDRESS, bV as FILL_ORDER_ABI, ai as FILL_ORDER_V1_ABI, bW as FetchLike, bX as FillData, bY as HexString, bZ as IntentGatewayV2, b_ as LpBalance, b$ as OrderCommitmentFn, aN as PHANTOM_QUOTE_HAIRCUT_BPS, c0 as PhantomAggregation, c1 as PhantomLegAggregation, c2 as PhantomLegBidder, c3 as PoolAndPositionInfo, c4 as RecoverBidSigner, c5 as RpcBidInfo, c6 as SolverBalanceReader, c7 as SolverV4Position, bf as UNISWAP_QUOTE_HAIRCUT_BPS, c8 as UniswapV4Contracts, c9 as V4PositionState, ca as YieldVaultMap, cb as aggregatePhantomBids, bh as applyPhantomQuoteHaircut, bi as applyUniswapQuoteHaircut, br as decodeAcceptedSourceChains, bs as decodeERC7821ExecuteBatch, bu as decodePhantomBidDeclaration, bv as decodeUserOpScale, bx as encodeAcceptedSourceChains, by as encodeERC7821ExecuteBatch, bB as encodePhantomBidDeclaration, bC as encodeUserOpScale, cc as extractFillData, cd as fetchBidsForOrder, ce as getTotalSolverBalance, cf as memoizedSolverBalance, cg as orderCommitmentFromDecoded, bM as poolSlug, ch as positionAmountOfToken, ci as readV4Position, cj as recoverBidSignerViem, ck as setAggregationFetch, bO as sortPoolSymbols, cl as splitBidSignature, cm as weightedMedian, cn as zipFillLegs } from './intents-helpers-BRegx4yZ.js';
1
+ export { bR as AggregationLogger, bS as BidNonceKeyFn, bT as BidSignature, bU as ENTRY_POINT_V08_ADDRESS, bV as FILL_ORDER_ABI, ai as FILL_ORDER_V1_ABI, bW as FetchLike, bX as FillData, bY as HexString, bZ as IntentGatewayV2, b_ as LpBalance, b$ as OrderCommitmentFn, c0 as PhantomAggregation, c1 as PhantomLegAggregation, c2 as PhantomLegBidder, c3 as PoolAndPositionInfo, c4 as RecoverBidSigner, c5 as RpcBidInfo, c6 as SolverBalanceReader, c7 as SolverV4Position, be as UNISWAP_QUOTE_HAIRCUT_BPS, c8 as UniswapV4Contracts, c9 as V4PositionState, ca as YieldVaultMap, cb as aggregatePhantomBids, bg as applyProtocolFeeHaircut, bh as applyUniswapQuoteHaircut, bq as decodeAcceptedSourceChains, br as decodeERC7821ExecuteBatch, bt as decodePhantomBidDeclaration, bu as decodeUserOpScale, bw as encodeAcceptedSourceChains, bx as encodeERC7821ExecuteBatch, bA as encodePhantomBidDeclaration, bB as encodeUserOpScale, cc as extractFillData, cd as fetchBidsForOrder, ce as getTotalSolverBalance, cf as memoizedSolverBalance, cg as orderCommitmentFromDecoded, bL as poolSlug, ch as positionAmountOfToken, bM as readProtocolFeeHaircutBps, ci as readV4Position, cj as recoverBidSignerViem, ck as setAggregationFetch, bO as sortPoolSymbols, cl as splitBidSignature, cm as weightedMedian, cn as zipFillLegs } from './intents-helpers-C9PJp8rx.js';
2
2
  import 'consola';
3
3
  import 'decimal.js';
4
4
  import 'graphql-request';
@@ -2823,15 +2823,35 @@ function zipFillLegs(assets, outputs) {
2823
2823
  });
2824
2824
  }
2825
2825
  var UNISWAP_QUOTE_HAIRCUT_BPS = 10n;
2826
- var PHANTOM_QUOTE_HAIRCUT_BPS = 5n;
2827
2826
  function haircut(amount, bps) {
2828
2827
  return amount * (10000n - bps) / 10000n;
2829
2828
  }
2830
2829
  function applyUniswapQuoteHaircut(amount) {
2831
2830
  return haircut(amount, UNISWAP_QUOTE_HAIRCUT_BPS);
2832
2831
  }
2833
- function applyPhantomQuoteHaircut(amount) {
2834
- return haircut(amount, PHANTOM_QUOTE_HAIRCUT_BPS);
2832
+ var SELECTOR_GATEWAY_PARAMS = "0xcff0ab96";
2833
+ var GATEWAY_PARAMS_WORDS = 6;
2834
+ var GATEWAY_PARAMS_FEE_WORD = 4;
2835
+ async function readProtocolFeeHaircutBps(evmRpcUrl, gatewayAddress) {
2836
+ const result = await rpcCall(evmRpcUrl, {
2837
+ id: 1,
2838
+ jsonrpc: "2.0",
2839
+ method: "eth_call",
2840
+ params: [{ to: gatewayAddress, data: SELECTOR_GATEWAY_PARAMS }, "latest"]
2841
+ });
2842
+ const hex = result.result;
2843
+ if (typeof hex !== "string" || hex.length < 2 + 64 * GATEWAY_PARAMS_WORDS) {
2844
+ throw new PhantomRpcError(`IntentGateway.params() returned no usable result from ${gatewayAddress} on ${evmRpcUrl}`);
2845
+ }
2846
+ const start = 2 + 64 * GATEWAY_PARAMS_FEE_WORD;
2847
+ const protocolFeeBps = BigInt(`0x${hex.slice(start, start + 64)}`);
2848
+ if (protocolFeeBps >= 10000n) {
2849
+ throw new PhantomRpcError(`IntentGateway ${gatewayAddress} reports an implausible protocol fee: ${protocolFeeBps} bps`);
2850
+ }
2851
+ return protocolFeeBps;
2852
+ }
2853
+ function applyProtocolFeeHaircut(amount, protocolFeeBps) {
2854
+ return haircut(amount, protocolFeeBps);
2835
2855
  }
2836
2856
  function weightedMedian(entries) {
2837
2857
  const sorted = [...entries].sort((a, b) => a.price < b.price ? -1 : a.price > b.price ? 1 : 0);
@@ -3153,6 +3173,7 @@ async function runAggregation(params, isDelegated) {
3153
3173
  }
3154
3174
  const bids = await fetchBidsForOrder(nodeUrl, commitment);
3155
3175
  if (bids.length === 0) return null;
3176
+ const protocolFeeHaircutBps = await readProtocolFeeHaircutBps(destUrl, gatewayAddress);
3156
3177
  const v4Contracts = params.uniswapV4?.[chain];
3157
3178
  const readPosition = memoizedV4Position(params.keccak ?? keccak256, logger);
3158
3179
  const getBalance = params.getBalance ?? memoizedSolverBalance(yieldVaults);
@@ -3199,7 +3220,7 @@ async function runAggregation(params, isDelegated) {
3199
3220
  const declaration = decodePhantomBidDeclaration(decoded.paymasterAndData);
3200
3221
  const acceptedSources = declaration.acceptedSources;
3201
3222
  const poolPriced = declaration.uniswapV4Positions.length > 0;
3202
- const applyHaircut = poolPriced ? applyUniswapQuoteHaircut : applyPhantomQuoteHaircut;
3223
+ const applyHaircut = (amount) => poolPriced ? applyUniswapQuoteHaircut(amount) : applyProtocolFeeHaircut(amount, protocolFeeHaircutBps);
3203
3224
  const quotedLegs = [...fillData.legs.entries()].map(([legIndex, leg]) => [
3204
3225
  legIndex,
3205
3226
  { ...leg, solverAmount: applyHaircut(leg.solverAmount) }
@@ -3287,6 +3308,6 @@ async function runAggregation(params, isDelegated) {
3287
3308
  return { legs, lpBalances, positions: verifiedPositions, solvers: [...countedSolvers] };
3288
3309
  }
3289
3310
 
3290
- export { ENTRY_POINT_V08_ADDRESS, FILL_ORDER_ABI, FILL_ORDER_V1_ABI, IntentGatewayV2_default as IntentGatewayV2, PHANTOM_QUOTE_HAIRCUT_BPS, UNISWAP_QUOTE_HAIRCUT_BPS, aggregatePhantomBids, applyPhantomQuoteHaircut, applyUniswapQuoteHaircut, decodeAcceptedSourceChains, decodeERC7821ExecuteBatch, decodePhantomBidDeclaration, decodeUserOpScale, encodeAcceptedSourceChains, encodeERC7821ExecuteBatch, encodePhantomBidDeclaration, encodeUserOpScale, extractFillData, fetchBidsForOrder, getTotalSolverBalance, memoizedSolverBalance, orderCommitmentFromDecoded, poolSlug, positionAmountOfToken, readV4Position, recoverBidSignerViem, setAggregationFetch, sortPoolSymbols, splitBidSignature, weightedMedian, zipFillLegs };
3311
+ export { ENTRY_POINT_V08_ADDRESS, FILL_ORDER_ABI, FILL_ORDER_V1_ABI, IntentGatewayV2_default as IntentGatewayV2, UNISWAP_QUOTE_HAIRCUT_BPS, aggregatePhantomBids, applyProtocolFeeHaircut, applyUniswapQuoteHaircut, decodeAcceptedSourceChains, decodeERC7821ExecuteBatch, decodePhantomBidDeclaration, decodeUserOpScale, encodeAcceptedSourceChains, encodeERC7821ExecuteBatch, encodePhantomBidDeclaration, encodeUserOpScale, extractFillData, fetchBidsForOrder, getTotalSolverBalance, memoizedSolverBalance, orderCommitmentFromDecoded, poolSlug, positionAmountOfToken, readProtocolFeeHaircutBps, readV4Position, recoverBidSignerViem, setAggregationFetch, sortPoolSymbols, splitBidSignature, weightedMedian, zipFillLegs };
3291
3312
  //# sourceMappingURL=intents-helpers.js.map
3292
3313
  //# sourceMappingURL=intents-helpers.js.map