@paraspell/sdk-core 12.7.0 → 12.7.1

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/index.d.ts CHANGED
@@ -810,7 +810,10 @@ type TCreateBaseTransferXcmOptions<TRes> = {
810
810
  feeAssetInfo?: TAssetInfo;
811
811
  fees: TTransferFeeEstimates;
812
812
  recipientAddress: string;
813
+ senderAddress?: string;
813
814
  version: Version;
815
+ useJitWithdraw?: boolean;
816
+ useFeeAssetOnHops?: boolean;
814
817
  paraIdTo?: number;
815
818
  transactOptions?: TTransactOptions<TRes>;
816
819
  };
@@ -837,6 +840,14 @@ type TCreateSwapXcmInternalOptions<TApi, TRes, TSigner> = WithApi<TCreateBaseSwa
837
840
  fees: TSwapFeeEstimates;
838
841
  paraIdTo?: number;
839
842
  };
843
+ type TCreateEthBridgeInstructionsOptions<TApi, TRes, TSigner> = {
844
+ api: IPolkadotApi<TApi, TRes, TSigner>;
845
+ address: TAddress;
846
+ assetInfo: TAssetInfo;
847
+ senderAddress: string;
848
+ ahAddress?: string;
849
+ version: Version;
850
+ };
840
851
 
841
852
  type TAssetClaimOptionsBase = {
842
853
  chain: TSubstrateChain;
@@ -2363,4 +2374,4 @@ declare const pickCompatibleXcmVersion: (origin: TSubstrateChain, destination: T
2363
2374
  declare const pickRouterCompatibleXcmVersion: (origin: TSubstrateChain | undefined, exchangeChain: TSubstrateChain, destination: TChain | undefined) => Version;
2364
2375
 
2365
2376
  export { AmountTooLowError, AssetClaimBuilder, BaseAssetsPallet, BatchMode, BatchValidationError, BridgeHaltedError, Builder, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETH_MAINNET_CHAIN_ID, ETH_TESTNET_CHAIN_ID, FeatureTemporarilyDisabledError, GeneralBuilder, InvalidAddressError, MissingChainApiError, MissingParameterError, NoXCMSupportImplementedError, NumberFormatError, OverrideConflictError, PolkadotXcmError, PolkadotXcmExecutionError, ProviderUnavailableError, RELAY_LOCATION, RoutingResolutionError, RuntimeApiUnavailableError, ScenarioNotSupportedError, TRANSACT_ORIGINS, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, TypeAndThenUnavailableError, UnableToComputeError, UnsupportedOperationError, ValidationError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, applyDecimalAbstraction, assertAddressIsString, assertHasId, assertSender, assertSenderAddress, assertToIsString, blake2b256, blake2b512, calcPreviewMintAmount, claimAssets, compareAddresses, computeFeeFromDryRun, computeFeeFromDryRunPjs, computeOverridenAmount, constructTypeAndThenCall, convertSs58, createAsset, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createChainClient, createClientCache, createClientPoolHelpers, createDestination, createDirectExecuteXcm, createExecuteCall, createExecuteExchangeXcm, createId, createTx, createTypeAndThenCall, createTypeThenAutoReserve, createVersionedAssets, createVersionedDestination, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, formatAssetIdToERC20, formatUnits, getAssetBalanceInternal, getAssetReserveChain, getBalance, getBalanceInternal, getBridgeStatus, getChain, getChainConfig, getChainLocation, getChainProviders, getChainVersion, getEthErc20Balance, getEvmPrivateKeyHex, getFailureInfo, getLocalTransferAmount, getMinTransferableAmount, getMinTransferableAmountInternal, getMoonbeamErc20Balance, getOriginXcmFee, getOriginXcmFeeEstimate, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getRelayChainOf, getTChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, getXcmFeeInternal, getXcmFeeOnce, handleExecuteTransfer, handleSwapExecuteTransfer, handleToAhTeleport, isConfig, isSenderSigner, keyFromWs, localizeLocation, maybeOverrideAsset, maybeOverrideAssets, normalizeAmount, overrideTxAmount, padFee, padValueBy, parseUnits, pickCompatibleXcmVersion, pickRouterCompatibleXcmVersion, resolveDestChain, resolveModuleError, resolveParaId, resolveSendParams, reverseTransformLocation, selectXcmVersion, send, sortAssets, throwUnsupportedCurrency, transferMoonbeamEvm, transferMoonbeamToEth, traverseXcmHops, validateAddress, validateAssetSpecifiers, validateCurrency, validateDestination, validateDestinationAddress, validateTransact, verifyEdOnDestination, wrapTxBypass };
2366
- export type { BuildHopInfoOptions, ClientCache, HopProcessParams, HopTraversalConfig, HopTraversalResult, IPolkadotApi, IPolkadotXCMTransfer, IXTokensTransfer, OneKey, TAddress, TApiOrUrl, TAssetClaimInternalOptions, TAssetClaimOptions, TAssetClaimOptionsBase, TBatchOptions, TBatchedSendOptions, TBifrostToken, TBridgeStatus, TBuildDestInfoOptions, TBuildInternalRes, TBuilderConfig, TBuilderInternalOptions, TBuilderOptions, TBypassOptions, TCacheItem, TChainConfig, TChainConfigMap, TChainEndpoint, TChainWithApi, TClientEntry, TClientKey, TConditionalXcmFeeDetail, TConditionalXcmFeeHopInfo, TCreateBaseSwapXcmOptions, TCreateBaseTransferXcmOptions, TCreateBeneficiaryOptions, TCreateBeneficiaryXTokensOptions, TCreateSwapXcmInternalOptions, TCreateSwapXcmOptions, TCreateTransferXcmOptions, TCreateTxsOptions, TDestWeight, TDestXcmFeeDetail, TDestination, TDryRunBaseOptions, TDryRunBypassOptions, TDryRunCallBaseOptions, TDryRunCallOptions, TDryRunChainFailure, TDryRunChainResult, TDryRunChainSuccess, TDryRunError, TDryRunOptions, TDryRunPreviewOptions, TDryRunResBase, TDryRunResult, TDryRunXcmBaseOptions, TDryRunXcmOptions, TEvmBuilderOptions, TEvmBuilderOptionsBase, TEvmChainFrom, TFeeType, TForeignAssetId, TForeignOrNativeAsset, TForeignOrTokenAsset, TGetAssetBalanceOptions, TGetAssetBalanceOptionsBase, TGetBalanceCommonOptions, TGetBalanceOptions, TGetBalanceOptionsBase, TGetFeeForDestChainBaseOptions, TGetFeeForDestChainOptions, TGetMinTransferableAmountOptions, TGetOriginXcmFeeBaseOptions, TGetOriginXcmFeeEstimateOptions, TGetOriginXcmFeeInternalOptions, TGetOriginXcmFeeOptions, TGetReverseTxFeeOptions, TGetTransferInfoOptions, TGetTransferInfoOptionsBase, TGetTransferableAmountOptions, TGetTransferableAmountOptionsBase, TGetXcmFeeBaseOptions, TGetXcmFeeBuilderOptions, TGetXcmFeeEstimateDetail, TGetXcmFeeEstimateOptions, TGetXcmFeeEstimateResult, TGetXcmFeeInternalOptions, TGetXcmFeeOptions, TGetXcmFeeResult, THopInfo, THopTransferInfo, TMantaAsset, TModuleError, TNativeTokenAsset, TNodleAsset, TOriginFeeDetails, TOtherReserveAsset, TPaymentInfo, TPolkadotXCMTransferOptions, TPolkadotXcmMethod, TProviderEntry, TReserveAsset, TResolveHopParams, TScenario, TSelfReserveAsset, TSendBaseOptions, TSendBaseOptionsWithSenderAddress, TSendInternalOptions, TSendOptions, TSender, TSerializeEthTransferOptions, TSerializedEthTransfer, TSerializedExtrinsics, TSerializedRuntimeApiQuery, TSerializedStateQuery, TSetBalanceRes, TSwapConfig, TSwapFeeEstimates, TTransactOptions, TTransactOrigin, TTransferFeeEstimates, TTransferInfo, TTransferLocalOptions, TTxFactory, TTypeAndThenCallContext, TTypeAndThenFees, TTypeAndThenOverrides, TUrl, TVerifyEdOnDestinationOptions, TVerifyEdOnDestinationOptionsBase, TWeight, TXTokensCurrencySelection, TXTokensMethod, TXTokensTransferOptions, TXcmAsset, TXcmFeeBase, TXcmFeeDetail, TXcmFeeDetailError, TXcmFeeDetailSuccess, TXcmFeeDetailWithFallback, TXcmFeeHopInfo, TXcmFeeHopResult, TXcmFeeSwapConfig, TXcmForeignAsset, TXcmPalletMethod, TXcmVersioned, TZeitgeistAsset, WithApi, WithRequiredSenderAddress };
2377
+ export type { BuildHopInfoOptions, ClientCache, HopProcessParams, HopTraversalConfig, HopTraversalResult, IPolkadotApi, IPolkadotXCMTransfer, IXTokensTransfer, OneKey, TAddress, TApiOrUrl, TAssetClaimInternalOptions, TAssetClaimOptions, TAssetClaimOptionsBase, TBatchOptions, TBatchedSendOptions, TBifrostToken, TBridgeStatus, TBuildDestInfoOptions, TBuildInternalRes, TBuilderConfig, TBuilderInternalOptions, TBuilderOptions, TBypassOptions, TCacheItem, TChainConfig, TChainConfigMap, TChainEndpoint, TChainWithApi, TClientEntry, TClientKey, TConditionalXcmFeeDetail, TConditionalXcmFeeHopInfo, TCreateBaseSwapXcmOptions, TCreateBaseTransferXcmOptions, TCreateBeneficiaryOptions, TCreateBeneficiaryXTokensOptions, TCreateEthBridgeInstructionsOptions, TCreateSwapXcmInternalOptions, TCreateSwapXcmOptions, TCreateTransferXcmOptions, TCreateTxsOptions, TDestWeight, TDestXcmFeeDetail, TDestination, TDryRunBaseOptions, TDryRunBypassOptions, TDryRunCallBaseOptions, TDryRunCallOptions, TDryRunChainFailure, TDryRunChainResult, TDryRunChainSuccess, TDryRunError, TDryRunOptions, TDryRunPreviewOptions, TDryRunResBase, TDryRunResult, TDryRunXcmBaseOptions, TDryRunXcmOptions, TEvmBuilderOptions, TEvmBuilderOptionsBase, TEvmChainFrom, TFeeType, TForeignAssetId, TForeignOrNativeAsset, TForeignOrTokenAsset, TGetAssetBalanceOptions, TGetAssetBalanceOptionsBase, TGetBalanceCommonOptions, TGetBalanceOptions, TGetBalanceOptionsBase, TGetFeeForDestChainBaseOptions, TGetFeeForDestChainOptions, TGetMinTransferableAmountOptions, TGetOriginXcmFeeBaseOptions, TGetOriginXcmFeeEstimateOptions, TGetOriginXcmFeeInternalOptions, TGetOriginXcmFeeOptions, TGetReverseTxFeeOptions, TGetTransferInfoOptions, TGetTransferInfoOptionsBase, TGetTransferableAmountOptions, TGetTransferableAmountOptionsBase, TGetXcmFeeBaseOptions, TGetXcmFeeBuilderOptions, TGetXcmFeeEstimateDetail, TGetXcmFeeEstimateOptions, TGetXcmFeeEstimateResult, TGetXcmFeeInternalOptions, TGetXcmFeeOptions, TGetXcmFeeResult, THopInfo, THopTransferInfo, TMantaAsset, TModuleError, TNativeTokenAsset, TNodleAsset, TOriginFeeDetails, TOtherReserveAsset, TPaymentInfo, TPolkadotXCMTransferOptions, TPolkadotXcmMethod, TProviderEntry, TReserveAsset, TResolveHopParams, TScenario, TSelfReserveAsset, TSendBaseOptions, TSendBaseOptionsWithSenderAddress, TSendInternalOptions, TSendOptions, TSender, TSerializeEthTransferOptions, TSerializedEthTransfer, TSerializedExtrinsics, TSerializedRuntimeApiQuery, TSerializedStateQuery, TSetBalanceRes, TSwapConfig, TSwapFeeEstimates, TTransactOptions, TTransactOrigin, TTransferFeeEstimates, TTransferInfo, TTransferLocalOptions, TTxFactory, TTypeAndThenCallContext, TTypeAndThenFees, TTypeAndThenOverrides, TUrl, TVerifyEdOnDestinationOptions, TVerifyEdOnDestinationOptionsBase, TWeight, TXTokensCurrencySelection, TXTokensMethod, TXTokensTransferOptions, TXcmAsset, TXcmFeeBase, TXcmFeeDetail, TXcmFeeDetailError, TXcmFeeDetailSuccess, TXcmFeeDetailWithFallback, TXcmFeeHopInfo, TXcmFeeHopResult, TXcmFeeSwapConfig, TXcmForeignAsset, TXcmPalletMethod, TXcmVersioned, TZeitgeistAsset, WithApi, WithRequiredSenderAddress };
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { blake2b } from '@noble/hashes/blake2.js';
2
- import { isChainEvm, getAssetsObject, InvalidCurrencyError, isTAsset, findAssetInfoOrThrow, findNativeAssetInfoOrThrow, findAssetInfo, getExistentialDepositOrThrow, isSymbolMatch, getNativeAssetSymbol, getEdFromAssetOrThrow, hasDryRunSupport, findAssetOnDestOrThrow, findAssetInfoOnDest, isAssetEqual, isStableCoinAsset, isOverrideLocationSpecifier, extractAssetLocation, getRelayChainSymbol, isSymbolSpecifier, findNativeAssetInfo, isAssetXcEqual, normalizeLocation, normalizeSymbol, Native, hasXcmPaymentApiSupport, getOtherAssets } from '@paraspell/assets';
2
+ import { isChainEvm, getAssetsObject, InvalidCurrencyError, isTAsset, findAssetInfoOrThrow, findNativeAssetInfoOrThrow, findAssetInfo, getExistentialDepositOrThrow, isSymbolMatch, getNativeAssetSymbol, getEdFromAssetOrThrow, hasDryRunSupport, findAssetOnDestOrThrow, findAssetInfoOnDest, isAssetEqual, isStableCoinAsset, isBridgedSystemAsset, isOverrideLocationSpecifier, extractAssetLocation, getRelayChainSymbol, isSymbolSpecifier, findNativeAssetInfo, isAssetXcEqual, normalizeLocation, normalizeSymbol, Native, hasXcmPaymentApiSupport, getOtherAssets } from '@paraspell/assets';
3
3
  export * from '@paraspell/assets';
4
4
  import { base58 } from '@scure/base';
5
5
  import { isAddress, isHex, getContract, createPublicClient, http, parseUnits as parseUnits$1, formatUnits as formatUnits$1, pad, toHex, getAddress, concat, keccak256 } from 'viem';
@@ -4710,10 +4710,8 @@ var validateBridgeAsset = function validateBridgeAsset(origin, destination, asse
4710
4710
  }
4711
4711
  var nativeAsset = findNativeAssetInfoOrThrow(origin);
4712
4712
  var isNativeAsset = isAssetEqual(asset, nativeAsset);
4713
- var ecosystem = getRelayChainOf(destination).toLowerCase();
4714
- var isBridgedSystemAsset = asset.location.parents === Parents.TWO && deepEqual(getJunctionValue(asset.location, 'GlobalConsensus'), _defineProperty({}, ecosystem, null));
4715
4713
  var isBridgedStablecoin = isStableCoinAsset(asset);
4716
- if (!(isNativeAsset || isBridgedSystemAsset || isBridgedStablecoin)) {
4714
+ if (!(isNativeAsset || isBridgedSystemAsset(asset, [getRelayChainOf(destination)]) || isBridgedStablecoin)) {
4717
4715
  throw new InvalidCurrencyError("Substrate bridge does not support currency ".concat(JSON.stringify(currency, replaceBigInt), "."));
4718
4716
  }
4719
4717
  };
@@ -5573,7 +5571,7 @@ var createMainInstruction = function createMainInstruction(origin, asset, ethAss
5573
5571
  }
5574
5572
  };
5575
5573
  };
5576
- var createCustomXcmOnDest = function createCustomXcmOnDest(_ref, origin, messageId, ethAsset) {
5574
+ var createEthereumBridgeInstructions = function createEthereumBridgeInstructions(_ref, origin, messageId, ethAsset) {
5577
5575
  var api = _ref.api,
5578
5576
  address = _ref.address,
5579
5577
  assetInfo = _ref.assetInfo,
@@ -5584,7 +5582,7 @@ var createCustomXcmOnDest = function createCustomXcmOnDest(_ref, origin, message
5584
5582
  if (isChainEvm(origin) && !ahAddress) {
5585
5583
  throw new MissingParameterError('ahAddress');
5586
5584
  }
5587
- return _defineProperty({}, version, [{
5585
+ return [{
5588
5586
  SetAppendix: origin === 'Mythos' ? [] : [{
5589
5587
  DepositAsset: {
5590
5588
  assets: {
@@ -5599,7 +5597,24 @@ var createCustomXcmOnDest = function createCustomXcmOnDest(_ref, origin, message
5599
5597
  }]
5600
5598
  }, createMainInstruction(origin, assetInfo, ethAsset, address, messageId), {
5601
5599
  SetTopic: messageId
5602
- }]);
5600
+ }];
5601
+ };
5602
+ var createCustomXcmOnDest = function createCustomXcmOnDest(options, origin, messageId, ethAsset) {
5603
+ var api = options.api,
5604
+ address = options.address,
5605
+ assetInfo = options.assetInfo,
5606
+ senderAddress = options.senderAddress,
5607
+ ahAddress = options.ahAddress,
5608
+ version = options.version;
5609
+ var instructions = createEthereumBridgeInstructions({
5610
+ api: api,
5611
+ address: address,
5612
+ assetInfo: assetInfo,
5613
+ senderAddress: senderAddress,
5614
+ ahAddress: ahAddress,
5615
+ version: version
5616
+ }, origin, messageId, ethAsset);
5617
+ return _defineProperty({}, version, instructions);
5603
5618
  };
5604
5619
 
5605
5620
  var generateMessageId = /*#__PURE__*/function () {
@@ -8975,6 +8990,8 @@ var prepareExecuteContext = function prepareExecuteContext(_ref) {
8975
8990
  var assetLocalizedToReserve = createAsset(version, amount, localizeLocation(reserveChain !== null && reserveChain !== void 0 ? reserveChain : chain, assetInfo.location));
8976
8991
  var feeAsset = feeAssetInfo && !isAssetEqual(assetInfo, feeAssetInfo) ? createAsset(version, originFee, feeAssetInfo.location) : undefined;
8977
8992
  var feeAssetLocalized = feeAssetInfo && !isAssetEqual(assetInfo, feeAssetInfo) ? createAsset(version, originFee, localizeLocation(chain, feeAssetInfo.location)) : undefined;
8993
+ var feeAssetLocalizedToDest = feeAssetInfo && !isAssetEqual(assetInfo, feeAssetInfo) ? createAsset(version, originFee, localizeLocation(destChain, feeAssetInfo.location)) : undefined;
8994
+ var feeAssetLocalizedToReserve = feeAssetInfo && !isAssetEqual(assetInfo, feeAssetInfo) ? createAsset(version, originFee, localizeLocation(reserveChain !== null && reserveChain !== void 0 ? reserveChain : chain, feeAssetInfo.location)) : undefined;
8978
8995
  return {
8979
8996
  amount: amount,
8980
8997
  asset: asset,
@@ -8983,6 +9000,8 @@ var prepareExecuteContext = function prepareExecuteContext(_ref) {
8983
9000
  assetLocalizedToReserve: assetLocalizedToReserve,
8984
9001
  feeAsset: feeAsset,
8985
9002
  feeAssetLocalized: feeAssetLocalized,
9003
+ feeAssetLocalizedToDest: feeAssetLocalizedToDest,
9004
+ feeAssetLocalizedToReserve: feeAssetLocalizedToReserve,
8986
9005
  reserveChain: reserveChain
8987
9006
  };
8988
9007
  };
@@ -9028,6 +9047,7 @@ var createBaseExecuteXcm = function createBaseExecuteXcm(options) {
9028
9047
  version = options.version,
9029
9048
  paraIdTo = options.paraIdTo,
9030
9049
  transactOptions = options.transactOptions,
9050
+ useFeeAssetOnHops = options.useFeeAssetOnHops,
9031
9051
  _options$suffixXcm = options.suffixXcm,
9032
9052
  suffixXcm = _options$suffixXcm === void 0 ? [] : _options$suffixXcm;
9033
9053
  var _prepareExecuteContex = prepareExecuteContext(options),
@@ -9036,18 +9056,27 @@ var createBaseExecuteXcm = function createBaseExecuteXcm(options) {
9036
9056
  assetLocalizedToReserve = _prepareExecuteContex.assetLocalizedToReserve,
9037
9057
  assetLocalizedToDest = _prepareExecuteContex.assetLocalizedToDest,
9038
9058
  feeAsset = _prepareExecuteContex.feeAsset,
9059
+ feeAssetLocalizedToReserve = _prepareExecuteContex.feeAssetLocalizedToReserve,
9060
+ feeAssetLocalizedToDest = _prepareExecuteContex.feeAssetLocalizedToDest,
9039
9061
  reserveChain = _prepareExecuteContex.reserveChain;
9062
+ var hopFeeAssetToReserve = useFeeAssetOnHops ? feeAssetLocalizedToReserve : undefined;
9063
+ var hopFeeAssetToDest = useFeeAssetOnHops ? feeAssetLocalizedToDest : undefined;
9040
9064
  var destLocation = createDestination(version, chain, destChain, paraIdTo);
9041
9065
  if (chain !== 'AssetHubPolkadot' && reserveChain === undefined) {
9042
9066
  throw new UnsupportedOperationError('Sending local reserve assets with custom fee asset is not yet supported for this chain.');
9043
9067
  }
9044
9068
  var transferType = getInstructionType(version, chain, destChain, reserveChain, transactOptions);
9069
+ var routingAssetsFilter = feeAsset ? {
9070
+ Wild: {
9071
+ AllCounted: 2
9072
+ }
9073
+ } : createAssetsFilter(assetLocalized, version);
9045
9074
  var isReserveDest = reserveChain === destChain;
9046
9075
  var resolvedDepositInstruction = isReserveDest ? suffixXcm : [{
9047
9076
  DepositReserveAsset: {
9048
9077
  assets: createAssetsFilter(assetLocalizedToReserve, version),
9049
9078
  dest: createDestination(version, reserveChain !== null && reserveChain !== void 0 ? reserveChain : chain, destChain, paraIdTo),
9050
- xcm: [].concat(_toConsumableArray(createPayFees(version, updateAsset(assetLocalizedToDest, reserveFee === 1000n ? amount / 2n : amount - (feeAsset ? reserveFee : originFee + reserveFee)))), _toConsumableArray(suffixXcm))
9079
+ xcm: [].concat(_toConsumableArray(createPayFees(version, hopFeeAssetToDest !== null && hopFeeAssetToDest !== void 0 ? hopFeeAssetToDest : updateAsset(assetLocalizedToDest, reserveFee === 1000n ? amount / 2n : amount - originFee - reserveFee))), _toConsumableArray(suffixXcm))
9051
9080
  }
9052
9081
  }];
9053
9082
  var mainInstructions;
@@ -9058,9 +9087,9 @@ var createBaseExecuteXcm = function createBaseExecuteXcm(options) {
9058
9087
  mainInstructions = [{
9059
9088
  InitiateTransfer: {
9060
9089
  destination: destLocation,
9061
- remote_fees: _defineProperty({}, transferFilter, createAssetsFilter(assetLocalized, version)),
9090
+ remote_fees: _defineProperty({}, transferFilter, routingAssetsFilter),
9062
9091
  preserve_origin: true,
9063
- assets: [_defineProperty({}, transferFilter, createAssetsFilter(assetLocalized, version))],
9092
+ assets: [_defineProperty({}, transferFilter, routingAssetsFilter)],
9064
9093
  remote_xcm: [{
9065
9094
  RefundSurplus: undefined
9066
9095
  }].concat(_toConsumableArray(suffixXcm))
@@ -9072,9 +9101,9 @@ var createBaseExecuteXcm = function createBaseExecuteXcm(options) {
9072
9101
  // Use teleport for trusted chains
9073
9102
  mainInstructions = [{
9074
9103
  InitiateTeleport: {
9075
- assets: createAssetsFilter(assetLocalized, version),
9104
+ assets: routingAssetsFilter,
9076
9105
  dest: destLocation,
9077
- xcm: [].concat(_toConsumableArray(createPayFees(version, updateAsset(assetLocalizedToDest, feeAsset ? amount : amount - originFee))), _toConsumableArray(suffixXcm))
9106
+ xcm: [].concat(_toConsumableArray(createPayFees(version, hopFeeAssetToDest !== null && hopFeeAssetToDest !== void 0 ? hopFeeAssetToDest : updateAsset(assetLocalizedToDest, amount - originFee))), _toConsumableArray(suffixXcm))
9078
9107
  }
9079
9108
  }];
9080
9109
  break;
@@ -9082,9 +9111,9 @@ var createBaseExecuteXcm = function createBaseExecuteXcm(options) {
9082
9111
  // Teleport to reserve chain first
9083
9112
  mainInstructions = [{
9084
9113
  InitiateTeleport: {
9085
- assets: createAssetsFilter(assetLocalized, version),
9114
+ assets: routingAssetsFilter,
9086
9115
  dest: getChainLocation(chain, reserveChain),
9087
- xcm: [].concat(_toConsumableArray(createPayFees(version, updateAsset(assetLocalizedToReserve, feeAsset ? amount : amount - originFee))), _toConsumableArray(resolvedDepositInstruction))
9116
+ xcm: [].concat(_toConsumableArray(createPayFees(version, hopFeeAssetToReserve !== null && hopFeeAssetToReserve !== void 0 ? hopFeeAssetToReserve : updateAsset(assetLocalizedToReserve, amount - originFee))), _toConsumableArray(resolvedDepositInstruction))
9088
9117
  }
9089
9118
  }];
9090
9119
  break;
@@ -9092,12 +9121,11 @@ var createBaseExecuteXcm = function createBaseExecuteXcm(options) {
9092
9121
  // For non-trusted chains
9093
9122
  mainInstructions = [{
9094
9123
  InitiateReserveWithdraw: {
9095
- assets: createAssetsFilter(assetLocalized, version),
9124
+ assets: routingAssetsFilter,
9096
9125
  reserve: getChainLocation(chain, reserveChain),
9097
- xcm: [].concat(_toConsumableArray(createPayFees(version,
9098
- // Decrease amount by 2 units becuase for some reason polkadot withdraws 2 units less
9126
+ xcm: [].concat(_toConsumableArray(createPayFees(version, // Decrease amount by 2 units because for some reason polkadot withdraws 2 units less
9099
9127
  // than requested, so we need to account for that
9100
- updateAsset(assetLocalizedToReserve, amount - 2n))), _toConsumableArray(resolvedDepositInstruction))
9128
+ hopFeeAssetToReserve !== null && hopFeeAssetToReserve !== void 0 ? hopFeeAssetToReserve : updateAsset(assetLocalizedToReserve, amount - 2n))), _toConsumableArray(resolvedDepositInstruction))
9101
9129
  }
9102
9130
  }];
9103
9131
  break;
@@ -9215,6 +9243,7 @@ var createExecuteExchangeXcm = function createExecuteExchangeXcm(input, origin,
9215
9243
  var prepareCommonExecuteXcm = function prepareCommonExecuteXcm(options, assetToDeposit) {
9216
9244
  var api = options.api,
9217
9245
  feeAsset = options.feeAssetInfo,
9246
+ useJitWithdraw = options.useJitWithdraw,
9218
9247
  recipientAddress = options.recipientAddress,
9219
9248
  version = options.version;
9220
9249
  var context = prepareExecuteContext(options);
@@ -9226,7 +9255,7 @@ var prepareCommonExecuteXcm = function prepareCommonExecuteXcm(options, assetToD
9226
9255
  prefix.push({
9227
9256
  WithdrawAsset: withdrawAssets
9228
9257
  });
9229
- if (feeAsset) {
9258
+ if (feeAsset && !useJitWithdraw) {
9230
9259
  prefix.push.apply(prefix, _toConsumableArray(createPayFees(version, feeAssetLocalized !== null && feeAssetLocalized !== void 0 ? feeAssetLocalized : assetLocalized, {
9231
9260
  refTime: 450n,
9232
9261
  proofSize: 0n
@@ -9399,7 +9428,7 @@ var isMultiHopSwap = function isMultiHopSwap(exchangeChain, assetFrom, assetTo)
9399
9428
  };
9400
9429
 
9401
9430
  var createExchangeInstructions = /*#__PURE__*/function () {
9402
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, assetFrom, assetTo) {
9431
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, assetFrom, assetTo, hasSeparateFeeAsset) {
9403
9432
  var chain, exchangeChain, assetInfoFrom, assetInfoTo, version, calculateMinAmountOut, _options$fees, originReserveFee, exchangeFee, nativeSymbol, needsMultiHop, nativeAsset, nativeAmountOut, assetNative;
9404
9433
  return _regenerator().w(function (_context) {
9405
9434
  while (1) switch (_context.n) {
@@ -9418,7 +9447,7 @@ var createExchangeInstructions = /*#__PURE__*/function () {
9418
9447
  ExchangeAsset: {
9419
9448
  give: createAssetsFilter(assetFrom, version),
9420
9449
  want: [assetTo],
9421
- maximal: false
9450
+ maximal: hasSeparateFeeAsset
9422
9451
  }
9423
9452
  }]);
9424
9453
  case 1:
@@ -9443,60 +9472,131 @@ var createExchangeInstructions = /*#__PURE__*/function () {
9443
9472
  }
9444
9473
  }, _callee);
9445
9474
  }));
9446
- return function createExchangeInstructions(_x, _x2, _x3) {
9475
+ return function createExchangeInstructions(_x, _x2, _x3, _x4) {
9447
9476
  return _ref.apply(this, arguments);
9448
9477
  };
9449
9478
  }();
9450
9479
  var createSwapExecuteXcm = /*#__PURE__*/function () {
9451
9480
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
9452
- var api, chain, exchangeChain, destChain, assetInfoFrom, assetInfoTo, _options$fees2, originReserveFee, destReserveFee, recipientAddress, version, paraIdTo, assetFrom, amountOut, assetTo, assetToLocalizedToDest, _prepareCommonExecute, prefix, depositInstruction, exchangeInstructions, exchangeToDestXcm, finalXcm, fullXcm;
9481
+ var _ref3, _ref4;
9482
+ var api, chain, exchangeChain, destChain, assetInfoFrom, assetInfoTo, _options$fees2, originReserveFee, destReserveFee, senderAddress, recipientAddress, version, paraIdTo, isEthereumDest, resolvedDestChain, assetFrom, amountOut, assetTo, assetToLocalizedToDest, ethFeeAssetInfo, ethBridgeFee, isMainAssetDot, nativeFeeAssetInfo, ahApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee, executionFee, hasSeparateFeeAsset, _prepareCommonExecute, prefix, depositInstruction, exchangeInstructions, exchangeToDestXcm, ethAsset, messageId, snowbridgeInstructions, finalXcm, fullXcm;
9453
9483
  return _regenerator().w(function (_context2) {
9454
9484
  while (1) switch (_context2.n) {
9455
9485
  case 0:
9456
- api = options.api, chain = options.chain, exchangeChain = options.exchangeChain, destChain = options.destChain, assetInfoFrom = options.assetInfoFrom, assetInfoTo = options.assetInfoTo, _options$fees2 = options.fees, originReserveFee = _options$fees2.originReserveFee, destReserveFee = _options$fees2.destReserveFee, recipientAddress = options.recipientAddress, version = options.version, paraIdTo = options.paraIdTo;
9486
+ api = options.api, chain = options.chain, exchangeChain = options.exchangeChain, destChain = options.destChain, assetInfoFrom = options.assetInfoFrom, assetInfoTo = options.assetInfoTo, _options$fees2 = options.fees, originReserveFee = _options$fees2.originReserveFee, destReserveFee = _options$fees2.destReserveFee, senderAddress = options.senderAddress, recipientAddress = options.recipientAddress, version = options.version, paraIdTo = options.paraIdTo;
9487
+ isEthereumDest = destChain !== undefined && isExternalChain(destChain); // For Ethereum destination, the actual hop target is AssetHub (bridge hub)
9488
+ resolvedDestChain = isEthereumDest ? "AssetHub".concat(getRelayChainOf(chain !== null && chain !== void 0 ? chain : exchangeChain)) : undefined;
9457
9489
  assetFrom = createAsset(version, assetInfoFrom.amount, localizeLocation(exchangeChain, assetInfoFrom.location));
9458
9490
  amountOut = assetInfoTo.amount;
9459
- assetTo = createAsset(version, amountOut, localizeLocation(exchangeChain, assetInfoTo.location));
9460
- assetToLocalizedToDest = createAsset(version, amountOut, localizeLocation(destChain !== null && destChain !== void 0 ? destChain : exchangeChain, assetInfoTo.location));
9491
+ assetTo = createAsset(version, amountOut, localizeLocation(exchangeChain, assetInfoTo.location)); // For Ethereum, localize to AssetHub since that's where instructions execute
9492
+ assetToLocalizedToDest = createAsset(version, amountOut, localizeLocation((_ref3 = resolvedDestChain !== null && resolvedDestChain !== void 0 ? resolvedDestChain : destChain) !== null && _ref3 !== void 0 ? _ref3 : exchangeChain, assetInfoTo.location)); // For Ethereum destination, use DOT as feeAsset for bridge fees
9493
+ ethBridgeFee = 0n; // Whether main asset IS DOT — no separate fee asset needed
9494
+ isMainAssetDot = false;
9495
+ if (!isEthereumDest) {
9496
+ _context2.n = 3;
9497
+ break;
9498
+ }
9499
+ nativeFeeAssetInfo = findNativeAssetInfoOrThrow(getRelayChainOf(chain !== null && chain !== void 0 ? chain : exchangeChain));
9500
+ _context2.n = 1;
9501
+ return api.createApiForChain('AssetHubPolkadot');
9502
+ case 1:
9503
+ ahApi = _context2.v;
9504
+ _context2.n = 2;
9505
+ return getParaEthTransferFees(ahApi);
9506
+ case 2:
9507
+ _yield$getParaEthTran = _context2.v;
9508
+ _yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 2);
9509
+ bridgeFee = _yield$getParaEthTran2[0];
9510
+ executionFee = _yield$getParaEthTran2[1];
9511
+ ethBridgeFee = bridgeFee + executionFee;
9512
+ isMainAssetDot = isAssetEqual(assetInfoFrom, nativeFeeAssetInfo);
9513
+ if (!isMainAssetDot) {
9514
+ ethFeeAssetInfo = nativeFeeAssetInfo;
9515
+ }
9516
+ case 3:
9517
+ hasSeparateFeeAsset = isEthereumDest && !isMainAssetDot;
9461
9518
  _prepareCommonExecute = prepareCommonExecuteXcm({
9462
9519
  api: api,
9463
9520
  chain: chain !== null && chain !== void 0 ? chain : exchangeChain,
9464
- destChain: destChain !== null && destChain !== void 0 ? destChain : exchangeChain,
9521
+ destChain: (_ref4 = resolvedDestChain !== null && resolvedDestChain !== void 0 ? resolvedDestChain : destChain) !== null && _ref4 !== void 0 ? _ref4 : exchangeChain,
9465
9522
  assetInfo: assetInfoFrom,
9523
+ feeAssetInfo: ethFeeAssetInfo,
9524
+ useJitWithdraw: isEthereumDest,
9466
9525
  recipientAddress: recipientAddress,
9467
- // Deal with this after feeAsset for swaps is supported
9468
9526
  fees: {
9469
- originFee: 0n,
9527
+ originFee: hasSeparateFeeAsset ? ethBridgeFee : 0n,
9470
9528
  reserveFee: originReserveFee
9471
9529
  },
9472
9530
  version: version
9473
9531
  }, assetToLocalizedToDest), prefix = _prepareCommonExecute.prefix, depositInstruction = _prepareCommonExecute.depositInstruction;
9474
- _context2.n = 1;
9475
- return createExchangeInstructions(options, assetFrom, assetTo);
9476
- case 1:
9532
+ _context2.n = 4;
9533
+ return createExchangeInstructions(options, assetFrom, assetTo, hasSeparateFeeAsset);
9534
+ case 4:
9477
9535
  exchangeInstructions = _context2.v;
9478
- exchangeToDestXcm = destChain ? createBaseExecuteXcm({
9536
+ if (!isEthereumDest) {
9537
+ _context2.n = 6;
9538
+ break;
9539
+ }
9540
+ ethAsset = findAssetInfoOrThrow('Ethereum', {
9541
+ symbol: assetInfoTo.symbol
9542
+ }, null);
9543
+ _context2.n = 5;
9544
+ return generateMessageId(api, senderAddress, getParaId(chain !== null && chain !== void 0 ? chain : exchangeChain), ethAsset.assetId, recipientAddress, amountOut);
9545
+ case 5:
9546
+ messageId = _context2.v;
9547
+ snowbridgeInstructions = createEthereumBridgeInstructions({
9548
+ api: api,
9549
+ address: recipientAddress,
9550
+ assetInfo: assetInfoTo,
9551
+ senderAddress: senderAddress,
9552
+ version: version
9553
+ }, chain !== null && chain !== void 0 ? chain : exchangeChain, messageId, ethAsset); // If exchange chain is already AssetHub, instructions run directly there
9554
+ // Otherwise, route from exchange chain to AssetHub with bridge instructions as suffix
9555
+ exchangeToDestXcm = exchangeChain === resolvedDestChain ? snowbridgeInstructions : createBaseExecuteXcm({
9479
9556
  chain: exchangeChain,
9480
- destChain: destChain,
9557
+ destChain: resolvedDestChain,
9481
9558
  assetInfo: assetInfoTo,
9482
- paraIdTo: paraIdTo,
9559
+ feeAssetInfo: ethFeeAssetInfo,
9560
+ useFeeAssetOnHops: hasSeparateFeeAsset,
9561
+ paraIdTo: getParaId(resolvedDestChain),
9483
9562
  version: version,
9484
- // Deal with this after feeAsset is supported
9485
9563
  fees: {
9486
- originFee: 0n,
9564
+ originFee: hasSeparateFeeAsset ? ethBridgeFee : 0n,
9487
9565
  reserveFee: destReserveFee
9488
9566
  },
9489
- suffixXcm: [depositInstruction]
9490
- }) : [depositInstruction];
9567
+ suffixXcm: snowbridgeInstructions
9568
+ });
9569
+ _context2.n = 7;
9570
+ break;
9571
+ case 6:
9572
+ if (destChain) {
9573
+ exchangeToDestXcm = createBaseExecuteXcm({
9574
+ chain: exchangeChain,
9575
+ destChain: destChain,
9576
+ assetInfo: assetInfoTo,
9577
+ paraIdTo: paraIdTo,
9578
+ version: version,
9579
+ // Deal with this after feeAsset is supported
9580
+ fees: {
9581
+ originFee: 0n,
9582
+ reserveFee: destReserveFee
9583
+ },
9584
+ suffixXcm: [depositInstruction]
9585
+ });
9586
+ } else {
9587
+ exchangeToDestXcm = [depositInstruction];
9588
+ }
9589
+ case 7:
9491
9590
  finalXcm = chain ? createBaseExecuteXcm({
9492
9591
  chain: chain,
9493
9592
  destChain: exchangeChain,
9494
9593
  assetInfo: assetInfoFrom,
9594
+ feeAssetInfo: ethFeeAssetInfo,
9595
+ useFeeAssetOnHops: hasSeparateFeeAsset,
9495
9596
  paraIdTo: getParaId(exchangeChain),
9496
9597
  version: version,
9497
- // Deal with this after feeAsset is supported
9498
9598
  fees: {
9499
- originFee: 0n,
9599
+ originFee: hasSeparateFeeAsset ? ethBridgeFee : 0n,
9500
9600
  reserveFee: originReserveFee
9501
9601
  },
9502
9602
  suffixXcm: [].concat(_toConsumableArray(exchangeInstructions), _toConsumableArray(exchangeToDestXcm))
@@ -9506,7 +9606,7 @@ var createSwapExecuteXcm = /*#__PURE__*/function () {
9506
9606
  }
9507
9607
  }, _callee2);
9508
9608
  }));
9509
- return function createSwapExecuteXcm(_x4) {
9609
+ return function createSwapExecuteXcm(_x5) {
9510
9610
  return _ref2.apply(this, arguments);
9511
9611
  };
9512
9612
  }();
@@ -9670,7 +9770,7 @@ var createXcmAndCall = /*#__PURE__*/function () {
9670
9770
  }();
9671
9771
  var handleSwapExecuteTransfer = /*#__PURE__*/function () {
9672
9772
  var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(options) {
9673
- var api, chain, exchangeChain, destChain, assetFrom, assetTo, currencyTo, senderAddress, recipientAddress, calculateMinAmountOut, version, internalOptions, dryRunParams, fees, totalFeesPre, _yield$createXcmAndCa, initialCall, firstDryRunResult, exchangeHopIndex, extractedFees, totalFees, updatedAssetTo, amountAvailableForSwap, recalculatedMinAmountOut, _yield$createXcmAndCa2, finalCall;
9773
+ var api, chain, exchangeChain, destChain, assetFrom, assetTo, currencyTo, senderAddress, recipientAddress, calculateMinAmountOut, version, isEthereumDest, hasSeparateFeeAsset, internalOptions, dryRunParams, fees, totalFeesPre, _yield$createXcmAndCa, initialCall, firstDryRunResult, exchangeHopIndex, extractedFees, totalFees, updatedAssetTo, amountAvailableForSwap, recalculatedMinAmountOut, _yield$createXcmAndCa2, finalCall;
9674
9774
  return _regenerator().w(function (_context3) {
9675
9775
  while (1) switch (_context3.n) {
9676
9776
  case 0:
@@ -9680,6 +9780,9 @@ var handleSwapExecuteTransfer = /*#__PURE__*/function () {
9680
9780
  case 1:
9681
9781
  validateAmount(assetFrom.amount, MIN_FEE);
9682
9782
  version = pickRouterCompatibleXcmVersion(chain, exchangeChain, destChain);
9783
+ isEthereumDest = destChain !== undefined && isExternalChain(destChain); // When main asset is DOT and dest is Ethereum, fees come from the same asset
9784
+ // (no separate fee asset needed). Only skip fee validation when currencies differ.
9785
+ hasSeparateFeeAsset = isEthereumDest && !isAssetEqual(assetFrom, findNativeAssetInfoOrThrow(getRelayChainOf(chain !== null && chain !== void 0 ? chain : exchangeChain)));
9683
9786
  internalOptions = _objectSpread2(_objectSpread2({}, options), {}, {
9684
9787
  version: version,
9685
9788
  paraIdTo: getParaId(destChain !== null && destChain !== void 0 ? destChain : exchangeChain)
@@ -9708,7 +9811,9 @@ var handleSwapExecuteTransfer = /*#__PURE__*/function () {
9708
9811
  destReserveFee: MIN_FEE
9709
9812
  };
9710
9813
  totalFeesPre = calculateTotalFees(chain, fees);
9711
- validateAmount(assetFrom.amount, totalFeesPre);
9814
+ if (!hasSeparateFeeAsset) {
9815
+ validateAmount(assetFrom.amount, totalFeesPre);
9816
+ }
9712
9817
  // First dry run with dummy fees to extract actual fees
9713
9818
  _context3.n = 2;
9714
9819
  return createXcmAndCall(_objectSpread2(_objectSpread2({}, internalOptions), {}, {
@@ -9740,13 +9845,17 @@ var handleSwapExecuteTransfer = /*#__PURE__*/function () {
9740
9845
  extractedFees.exchangeFee = MIN_FEE;
9741
9846
  }
9742
9847
  totalFees = calculateTotalFees(chain, extractedFees);
9743
- validateAmount(assetFrom.amount, totalFees);
9848
+ if (!hasSeparateFeeAsset) {
9849
+ validateAmount(assetFrom.amount, totalFees);
9850
+ }
9744
9851
  updatedAssetTo = assetTo;
9745
9852
  if (!chain) {
9746
9853
  _context3.n = 6;
9747
9854
  break;
9748
9855
  }
9749
- amountAvailableForSwap = assetFrom.amount - totalFees;
9856
+ // When fees are paid from a separate asset (e.g. DOT for Ethereum),
9857
+ // the full main asset amount is available for the swap
9858
+ amountAvailableForSwap = hasSeparateFeeAsset ? assetFrom.amount : assetFrom.amount - totalFees;
9750
9859
  _context3.n = 5;
9751
9860
  return calculateMinAmountOut(amountAvailableForSwap);
9752
9861
  case 5:
@@ -13862,12 +13971,14 @@ var FungiblesPallet = /*#__PURE__*/function (_AssetsPallet) {
13862
13971
 
13863
13972
  var SIZE = 32;
13864
13973
  var BALANCE_SLOT = 0;
13865
- var calculateMappingSlot = function calculateMappingSlot(key) {
13974
+ var BALANCE_SLOT_WORMHOLE = 5;
13975
+ var calculateMappingSlot = function calculateMappingSlot(key, assetId) {
13866
13976
  var normalizedKey = getAddress(key);
13867
13977
  var keyPadded = pad(normalizedKey, {
13868
13978
  size: SIZE
13869
13979
  });
13870
- var slotHex = pad(toHex(BALANCE_SLOT), {
13980
+ var resolvedSlot = assetId !== null && assetId !== void 0 && assetId.startsWith('0x') ? BALANCE_SLOT_WORMHOLE : BALANCE_SLOT;
13981
+ var slotHex = pad(toHex(resolvedSlot), {
13871
13982
  size: SIZE
13872
13983
  });
13873
13984
  var encoded = concat([keyPadded, slotHex]);
@@ -13889,7 +14000,7 @@ var SystemPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
13889
14000
  case 0:
13890
14001
  assertHasId(assetInfo);
13891
14002
  contractAddr = formatAssetIdToERC20(assetInfo.assetId);
13892
- slot = calculateMappingSlot(address);
14003
+ slot = calculateMappingSlot(address, assetInfo.assetId);
13893
14004
  amountEncoded = pad(toHex(assetInfo.amount + balance), {
13894
14005
  size: SIZE
13895
14006
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk-core",
3
- "version": "12.7.0",
3
+ "version": "12.7.1",
4
4
  "description": "SDK core for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -26,9 +26,9 @@
26
26
  "@noble/hashes": "^2.0.1",
27
27
  "@scure/base": "^2.0.0",
28
28
  "viem": "2.45.0",
29
- "@paraspell/pallets": "12.7.0",
30
- "@paraspell/sdk-common": "12.7.0",
31
- "@paraspell/assets": "12.7.0"
29
+ "@paraspell/pallets": "12.7.1",
30
+ "@paraspell/sdk-common": "12.7.1",
31
+ "@paraspell/assets": "12.7.1"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@babel/plugin-syntax-import-attributes": "^7.28.6",