@paraspell/sdk-core 11.8.3 → 11.8.5

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.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { blake2b } from '@noble/hashes/blake2';
2
- import { isChainEvm, getAssetsObject, InvalidCurrencyError, isForeignAsset, extractAssetLocation, findAssetInfoOrThrow, getNativeAssetSymbol, getOtherAssets, isAssetEqual, findAssetInfo, isTAsset, getExistentialDeposit, getExistentialDepositOrThrow, isSymbolMatch, hasDryRunSupport, isOverrideLocationSpecifier, findAssetInfoByLoc, findAssetOnDestOrThrow, findNativeAssetInfoOrThrow, Native, hasXcmPaymentApiSupport, getRelayChainSymbol, getNativeAssets, findNativeAssetInfo, isAssetXcEqual, hasSupportForAsset, isSymbolSpecifier, normalizeLocation, getEdFromAssetOrThrow, normalizeSymbol } from '@paraspell/assets';
2
+ import { isChainEvm, getAssetsObject, InvalidCurrencyError, isForeignAsset, extractAssetLocation, findAssetInfoOrThrow, getNativeAssetSymbol, getOtherAssets, isAssetEqual, findNativeAssetInfoOrThrow, findAssetInfo, isTAsset, getExistentialDeposit, getExistentialDepositOrThrow, isSymbolMatch, hasDryRunSupport, isOverrideLocationSpecifier, findAssetInfoByLoc, findAssetOnDestOrThrow, Native, hasXcmPaymentApiSupport, getRelayChainSymbol, findNativeAssetInfo, isAssetXcEqual, hasSupportForAsset, isSymbolSpecifier, normalizeLocation, getEdFromAssetOrThrow, normalizeSymbol } from '@paraspell/assets';
3
3
  export * from '@paraspell/assets';
4
4
  import { base58 } from '@scure/base';
5
5
  import { isAddress, parseUnits, createPublicClient, http, getContract, pad, toHex, getAddress, concat, keccak256 } from 'viem';
@@ -3696,6 +3696,44 @@ var handleExecuteTransfer = /*#__PURE__*/function () {
3696
3696
  };
3697
3697
  }();
3698
3698
 
3699
+ var getMythosOriginFee = /*#__PURE__*/function () {
3700
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api) {
3701
+ var ahApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee, ahExecutionFee, nativeAsset, feeConverted;
3702
+ return _regenerator().w(function (_context) {
3703
+ while (1) switch (_context.n) {
3704
+ case 0:
3705
+ ahApi = api.clone();
3706
+ _context.n = 1;
3707
+ return ahApi.init('AssetHubPolkadot');
3708
+ case 1:
3709
+ _context.n = 2;
3710
+ return getParaEthTransferFees(ahApi);
3711
+ case 2:
3712
+ _yield$getParaEthTran = _context.v;
3713
+ _yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 2);
3714
+ bridgeFee = _yield$getParaEthTran2[0];
3715
+ ahExecutionFee = _yield$getParaEthTran2[1];
3716
+ nativeAsset = findNativeAssetInfoOrThrow('Mythos');
3717
+ assertHasLocation(nativeAsset);
3718
+ _context.n = 3;
3719
+ return ahApi.quoteAhPrice(DOT_LOCATION, nativeAsset.location, bridgeFee + ahExecutionFee);
3720
+ case 3:
3721
+ feeConverted = _context.v;
3722
+ if (feeConverted) {
3723
+ _context.n = 4;
3724
+ break;
3725
+ }
3726
+ throw new InvalidParameterError("Pool DOT -> ".concat(nativeAsset.symbol, " not found."));
3727
+ case 4:
3728
+ return _context.a(2, padFeeBy(feeConverted, 10));
3729
+ }
3730
+ }, _callee);
3731
+ }));
3732
+ return function getMythosOriginFee(_x) {
3733
+ return _ref.apply(this, arguments);
3734
+ };
3735
+ }();
3736
+
3699
3737
  var resolveFeeAsset = function resolveFeeAsset(feeAsset, origin, destination, currency) {
3700
3738
  var asset = findAssetInfo(origin, feeAsset, !isTLocation(destination) ? destination : null);
3701
3739
  var usesRawOverriddenMultiAssets = Array.isArray(currency) && currency.every(isTAsset);
@@ -4488,7 +4526,9 @@ var getDestXcmFee = /*#__PURE__*/function () {
4488
4526
  return _context3.a(2, {
4489
4527
  fee: _fee,
4490
4528
  feeType: 'paymentInfo',
4491
- sufficient: sufficient
4529
+ sufficient: sufficient,
4530
+ asset: asset,
4531
+ currency: asset.symbol
4492
4532
  });
4493
4533
  case 3:
4494
4534
  _context3.n = 4;
@@ -4525,7 +4565,9 @@ var getDestXcmFee = /*#__PURE__*/function () {
4525
4565
  fee: _fee2,
4526
4566
  feeType: 'paymentInfo',
4527
4567
  dryRunError: dryRunResult.failureReason,
4528
- sufficient: false
4568
+ sufficient: false,
4569
+ asset: asset,
4570
+ currency: asset.symbol
4529
4571
  });
4530
4572
  case 7:
4531
4573
  fee = dryRunResult.fee, newForwardedXcms = dryRunResult.forwardedXcms, destParaId = dryRunResult.destParaId;
@@ -4534,7 +4576,9 @@ var getDestXcmFee = /*#__PURE__*/function () {
4534
4576
  feeType: 'dryRun',
4535
4577
  sufficient: true,
4536
4578
  forwardedXcms: newForwardedXcms,
4537
- destParaId: destParaId
4579
+ destParaId: destParaId,
4580
+ asset: asset,
4581
+ currency: asset.symbol
4538
4582
  });
4539
4583
  }
4540
4584
  }, _callee3);
@@ -5126,14 +5170,11 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
5126
5170
  };
5127
5171
  }();
5128
5172
 
5129
- function traverseXcmHops(_x) {
5130
- return _traverseXcmHops.apply(this, arguments);
5131
- }
5132
- function _traverseXcmHops() {
5133
- _traverseXcmHops = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(config) {
5173
+ var traverseXcmHops = /*#__PURE__*/function () {
5174
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(config) {
5134
5175
  var api, origin, destination, currency, initialForwardedXcms, initialDestParaId, swapConfig, processHop, shouldContinue, extractNextHopData, assetHubChain, bridgeHubChain, currentOrigin, forwardedXcms, nextParaId, asset, currentAsset, hasPassedExchange, hops, intermediateResults, destinationResult, nextChain, hopApi, isDestination, isAssetHub, isBridgeHub, hopResult, _extractNextHopData, newXcms, destParaId;
5135
- return _regenerator().w(function (_context2) {
5136
- while (1) switch (_context2.p = _context2.n) {
5176
+ return _regenerator().w(function (_context) {
5177
+ while (1) switch (_context.p = _context.n) {
5137
5178
  case 0:
5138
5179
  api = config.api, origin = config.origin, destination = config.destination, currency = config.currency, initialForwardedXcms = config.initialForwardedXcms, initialDestParaId = config.initialDestParaId, swapConfig = config.swapConfig, processHop = config.processHop, shouldContinue = config.shouldContinue, extractNextHopData = config.extractNextHopData;
5139
5180
  assetHubChain = "AssetHub".concat(getRelayChainOf(origin));
@@ -5148,19 +5189,19 @@ function _traverseXcmHops() {
5148
5189
  intermediateResults = {};
5149
5190
  case 1:
5150
5191
  if (!(Array.isArray(forwardedXcms) && forwardedXcms.length > 0 && forwardedXcms[1].length > 0 && ('disconnect' in api.getApi() ? Object.values(forwardedXcms[1][0]).length : forwardedXcms[1][0].value.length) > 0 && nextParaId !== undefined)) {
5151
- _context2.n = 10;
5192
+ _context.n = 10;
5152
5193
  break;
5153
5194
  }
5154
5195
  nextChain = getTChain(nextParaId, getRelayChainOf(origin));
5155
5196
  if (nextChain) {
5156
- _context2.n = 2;
5197
+ _context.n = 2;
5157
5198
  break;
5158
5199
  }
5159
5200
  throw new InvalidParameterError("Unable to find TChain for paraId ".concat(nextParaId));
5160
5201
  case 2:
5161
5202
  hopApi = api.clone();
5162
- _context2.p = 3;
5163
- _context2.n = 4;
5203
+ _context.p = 3;
5204
+ _context.n = 4;
5164
5205
  return hopApi.init(nextChain, DRY_RUN_CLIENT_TIMEOUT_MS);
5165
5206
  case 4:
5166
5207
  // true if this hop should be treated as the destination
@@ -5169,7 +5210,7 @@ function _traverseXcmHops() {
5169
5210
  isDestination = nextChain === destination && (!swapConfig || hasPassedExchange || nextChain === swapConfig.exchangeChain);
5170
5211
  isAssetHub = nextChain === assetHubChain;
5171
5212
  isBridgeHub = nextChain === bridgeHubChain;
5172
- _context2.n = 5;
5213
+ _context.n = 5;
5173
5214
  return processHop({
5174
5215
  api: hopApi,
5175
5216
  currentChain: nextChain,
@@ -5182,7 +5223,7 @@ function _traverseXcmHops() {
5182
5223
  isBridgeHub: isBridgeHub
5183
5224
  });
5184
5225
  case 5:
5185
- hopResult = _context2.v;
5226
+ hopResult = _context.v;
5186
5227
  if (!isDestination) {
5187
5228
  hops.push({
5188
5229
  chain: nextChain,
@@ -5197,10 +5238,10 @@ function _traverseXcmHops() {
5197
5238
  intermediateResults.bridgeHub = hopResult;
5198
5239
  }
5199
5240
  if (shouldContinue(hopResult)) {
5200
- _context2.n = 6;
5241
+ _context.n = 6;
5201
5242
  break;
5202
5243
  }
5203
- return _context2.a(3, 10);
5244
+ return _context.a(3, 10);
5204
5245
  case 6:
5205
5246
  // Update state for next iteration
5206
5247
  if (swapConfig && nextChain === swapConfig.exchangeChain) {
@@ -5212,16 +5253,16 @@ function _traverseXcmHops() {
5212
5253
  nextParaId = destParaId;
5213
5254
  currentOrigin = nextChain;
5214
5255
  case 7:
5215
- _context2.p = 7;
5216
- _context2.n = 8;
5256
+ _context.p = 7;
5257
+ _context.n = 8;
5217
5258
  return hopApi.disconnect();
5218
5259
  case 8:
5219
- return _context2.f(7);
5260
+ return _context.f(7);
5220
5261
  case 9:
5221
- _context2.n = 1;
5262
+ _context.n = 1;
5222
5263
  break;
5223
5264
  case 10:
5224
- return _context2.a(2, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
5265
+ return _context.a(2, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
5225
5266
  hops: hops
5226
5267
  }, intermediateResults.assetHub && {
5227
5268
  assetHub: intermediateResults.assetHub
@@ -5233,40 +5274,42 @@ function _traverseXcmHops() {
5233
5274
  lastProcessedChain: currentOrigin
5234
5275
  }));
5235
5276
  }
5236
- }, _callee2, null, [[3,, 7, 9]]);
5277
+ }, _callee, null, [[3,, 7, 9]]);
5237
5278
  }));
5238
- return _traverseXcmHops.apply(this, arguments);
5239
- }
5279
+ return function traverseXcmHops(_x) {
5280
+ return _ref.apply(this, arguments);
5281
+ };
5282
+ }();
5240
5283
  var addEthereumBridgeFees = /*#__PURE__*/function () {
5241
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, bridgeHubResult, destination, assetHubChain) {
5284
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(api, bridgeHubResult, destination, assetHubChain) {
5242
5285
  var ahApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee;
5243
- return _regenerator().w(function (_context) {
5244
- while (1) switch (_context.n) {
5286
+ return _regenerator().w(function (_context2) {
5287
+ while (1) switch (_context2.n) {
5245
5288
  case 0:
5246
5289
  if (!(!bridgeHubResult || !('fee' in bridgeHubResult) || destination !== 'Ethereum')) {
5247
- _context.n = 1;
5290
+ _context2.n = 1;
5248
5291
  break;
5249
5292
  }
5250
- return _context.a(2, bridgeHubResult);
5293
+ return _context2.a(2, bridgeHubResult);
5251
5294
  case 1:
5252
5295
  ahApi = api.clone();
5253
- _context.n = 2;
5296
+ _context2.n = 2;
5254
5297
  return ahApi.init(assetHubChain, DRY_RUN_CLIENT_TIMEOUT_MS);
5255
5298
  case 2:
5256
- _context.n = 3;
5299
+ _context2.n = 3;
5257
5300
  return getParaEthTransferFees(ahApi);
5258
5301
  case 3:
5259
- _yield$getParaEthTran = _context.v;
5302
+ _yield$getParaEthTran = _context2.v;
5260
5303
  _yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 1);
5261
5304
  bridgeFee = _yield$getParaEthTran2[0];
5262
- return _context.a(2, _objectSpread2(_objectSpread2({}, bridgeHubResult), {}, {
5305
+ return _context2.a(2, _objectSpread2(_objectSpread2({}, bridgeHubResult), {}, {
5263
5306
  fee: bridgeHubResult.fee + bridgeFee
5264
5307
  }));
5265
5308
  }
5266
- }, _callee);
5309
+ }, _callee2);
5267
5310
  }));
5268
5311
  return function addEthereumBridgeFees(_x2, _x3, _x4, _x5) {
5269
- return _ref.apply(this, arguments);
5312
+ return _ref2.apply(this, arguments);
5270
5313
  };
5271
5314
  }();
5272
5315
 
@@ -5304,7 +5347,7 @@ var getFailureInfo$1 = function getFailureInfo(results, hops) {
5304
5347
  var dryRunInternal = /*#__PURE__*/function () {
5305
5348
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
5306
5349
  var _traversalResult$brid;
5307
- var api, origin, destination, currency, tx, senderAddress, feeAsset, swapConfig, bypassOptions, _options$useRootOrigi, useRootOrigin, resolvedFeeAsset, asset, amount, originDryRun, initialForwardedXcms, initialDestParaId, processHop, traversalResult, assetHubChain, bridgeHubChain, processedBridgeHub, bridgeHubHopIndex, bridgeHubWithCurrency, _getFailureInfo, failureReason, failureChain, _t;
5350
+ var api, origin, destination, currency, tx, senderAddress, feeAsset, swapConfig, bypassOptions, _options$useRootOrigi, useRootOrigin, resolvedFeeAsset, asset, amount, originDryRun, isMythosToEthereum, originDryModified, initialForwardedXcms, initialDestParaId, processHop, traversalResult, assetHubChain, bridgeHubChain, processedBridgeHub, bridgeHubHopIndex, bridgeHubWithCurrency, _getFailureInfo, failureReason, failureChain, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9;
5308
5351
  return _regenerator().w(function (_context2) {
5309
5352
  while (1) switch (_context2.n) {
5310
5353
  case 0:
@@ -5316,6 +5359,7 @@ var dryRunInternal = /*#__PURE__*/function () {
5316
5359
  return api.getDryRunCall({
5317
5360
  tx: tx,
5318
5361
  chain: origin,
5362
+ destination: destination,
5319
5363
  address: senderAddress,
5320
5364
  asset: _objectSpread2(_objectSpread2({}, asset), {}, {
5321
5365
  amount: amount
@@ -5337,7 +5381,30 @@ var dryRunInternal = /*#__PURE__*/function () {
5337
5381
  hops: []
5338
5382
  });
5339
5383
  case 2:
5340
- initialForwardedXcms = originDryRun.forwardedXcms, initialDestParaId = originDryRun.destParaId;
5384
+ isMythosToEthereum = origin === 'Mythos' && destination === 'Ethereum';
5385
+ if (!isMythosToEthereum) {
5386
+ _context2.n = 4;
5387
+ break;
5388
+ }
5389
+ _t2 = _objectSpread2;
5390
+ _t3 = _objectSpread2({}, originDryRun);
5391
+ _t4 = {};
5392
+ _t5 = originDryRun.fee;
5393
+ _context2.n = 3;
5394
+ return getMythosOriginFee(api);
5395
+ case 3:
5396
+ _t6 = _context2.v;
5397
+ _t7 = _t5 + _t6;
5398
+ _t = _t2(_t3, _t4, {
5399
+ fee: _t7
5400
+ });
5401
+ _context2.n = 5;
5402
+ break;
5403
+ case 4:
5404
+ _t = originDryRun;
5405
+ case 5:
5406
+ originDryModified = _t;
5407
+ initialForwardedXcms = originDryModified.forwardedXcms, initialDestParaId = originDryModified.destParaId;
5341
5408
  processHop = /*#__PURE__*/function () {
5342
5409
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(params) {
5343
5410
  var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange, isDestination, hopAsset, hopDryRun;
@@ -5345,8 +5412,8 @@ var dryRunInternal = /*#__PURE__*/function () {
5345
5412
  while (1) switch (_context.n) {
5346
5413
  case 0:
5347
5414
  hopApi = params.api, currentChain = params.currentChain, currentOrigin = params.currentOrigin, currentAsset = params.currentAsset, forwardedXcms = params.forwardedXcms, hasPassedExchange = params.hasPassedExchange, isDestination = params.isDestination;
5348
- if (destination === 'Ethereum' && (currentChain.includes('AssetHub') || currentChain.includes('BridgeHub'))) {
5349
- hopAsset = findNativeAssetInfoOrThrow(currentChain);
5415
+ if (asset.location && asset.location.parents === Parents.TWO) {
5416
+ hopAsset = findNativeAssetInfoOrThrow(getRelayChainOf(currentChain));
5350
5417
  } else if (hasPassedExchange && swapConfig && currentChain !== swapConfig.exchangeChain) {
5351
5418
  hopAsset = findAssetOnDestOrThrow(swapConfig.exchangeChain, currentChain, swapConfig.currencyTo);
5352
5419
  } else if (isDestination) {
@@ -5372,9 +5439,9 @@ var dryRunInternal = /*#__PURE__*/function () {
5372
5439
  xcm: forwardedXcms[1][0],
5373
5440
  chain: currentChain,
5374
5441
  origin: currentOrigin,
5375
- asset: currentAsset,
5442
+ asset: hopAsset,
5376
5443
  feeAsset: resolvedFeeAsset,
5377
- originFee: originDryRun.fee,
5444
+ originFee: originDryModified.fee,
5378
5445
  amount: amount
5379
5446
  });
5380
5447
  case 2:
@@ -5390,7 +5457,7 @@ var dryRunInternal = /*#__PURE__*/function () {
5390
5457
  return _ref2.apply(this, arguments);
5391
5458
  };
5392
5459
  }();
5393
- _context2.n = 3;
5460
+ _context2.n = 6;
5394
5461
  return traverseXcmHops({
5395
5462
  api: api,
5396
5463
  origin: origin,
@@ -5410,25 +5477,35 @@ var dryRunInternal = /*#__PURE__*/function () {
5410
5477
  };
5411
5478
  }
5412
5479
  });
5413
- case 3:
5480
+ case 6:
5414
5481
  traversalResult = _context2.v;
5415
5482
  // Process Ethereum bridge fees
5416
5483
  assetHubChain = "AssetHub".concat(getRelayChainOf(origin));
5417
- bridgeHubChain = "BridgeHub".concat(getRelayChainOf(origin));
5484
+ bridgeHubChain = "BridgeHub".concat(getRelayChainOf(origin)); // For Mythos → Ethereum, we skip additional Ethereum bridge fees (aligns with getXcmFeeInternal)
5485
+ if (!isMythosToEthereum) {
5486
+ _context2.n = 7;
5487
+ break;
5488
+ }
5489
+ _t8 = traversalResult.bridgeHub;
5490
+ _context2.n = 11;
5491
+ break;
5492
+ case 7:
5418
5493
  if (!((_traversalResult$brid = traversalResult.bridgeHub) !== null && _traversalResult$brid !== void 0 && _traversalResult$brid.success)) {
5419
- _context2.n = 5;
5494
+ _context2.n = 9;
5420
5495
  break;
5421
5496
  }
5422
- _context2.n = 4;
5497
+ _context2.n = 8;
5423
5498
  return addEthereumBridgeFees(api, traversalResult.bridgeHub, destination, assetHubChain);
5424
- case 4:
5425
- _t = _context2.v;
5426
- _context2.n = 6;
5499
+ case 8:
5500
+ _t9 = _context2.v;
5501
+ _context2.n = 10;
5427
5502
  break;
5428
- case 5:
5429
- _t = traversalResult.bridgeHub;
5430
- case 6:
5431
- processedBridgeHub = _t;
5503
+ case 9:
5504
+ _t9 = traversalResult.bridgeHub;
5505
+ case 10:
5506
+ _t8 = _t9;
5507
+ case 11:
5508
+ processedBridgeHub = _t8;
5432
5509
  // Update bridge hub in hops if needed
5433
5510
  if (processedBridgeHub && processedBridgeHub.success && traversalResult.bridgeHub && traversalResult.bridgeHub.success && processedBridgeHub.fee !== traversalResult.bridgeHub.fee) {
5434
5511
  bridgeHubHopIndex = traversalResult.hops.findIndex(function (hop) {
@@ -5452,7 +5529,7 @@ var dryRunInternal = /*#__PURE__*/function () {
5452
5529
  return _context2.a(2, {
5453
5530
  failureReason: failureReason,
5454
5531
  failureChain: failureChain,
5455
- origin: originDryRun,
5532
+ origin: originDryModified,
5456
5533
  assetHub: traversalResult.assetHub,
5457
5534
  bridgeHub: bridgeHubWithCurrency,
5458
5535
  destination: traversalResult.destination,
@@ -8879,7 +8956,7 @@ var Moonriver = /*#__PURE__*/function (_Parachain) {
8879
8956
 
8880
8957
  var createTypeAndThenTransfer = /*#__PURE__*/function () {
8881
8958
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, chain, version) {
8882
- var api, asset, senderAddress, address, destination, messageId, ahApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee, ahExecutionFee, feeConverted, nativeMythAmount;
8959
+ var api, asset, senderAddress, address, destination, messageId, nativeMythAmount;
8883
8960
  return _regenerator().w(function (_context) {
8884
8961
  while (1) switch (_context.n) {
8885
8962
  case 0:
@@ -8897,28 +8974,10 @@ var createTypeAndThenTransfer = /*#__PURE__*/function () {
8897
8974
  return generateMessageId(api, senderAddress, getParaId(chain), asset.assetId, address, asset.amount);
8898
8975
  case 2:
8899
8976
  messageId = _context.v;
8900
- ahApi = api.clone();
8901
8977
  _context.n = 3;
8902
- return ahApi.init('AssetHubPolkadot');
8978
+ return getMythosOriginFee(api);
8903
8979
  case 3:
8904
- _context.n = 4;
8905
- return getParaEthTransferFees(ahApi);
8906
- case 4:
8907
- _yield$getParaEthTran = _context.v;
8908
- _yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 2);
8909
- bridgeFee = _yield$getParaEthTran2[0];
8910
- ahExecutionFee = _yield$getParaEthTran2[1];
8911
- _context.n = 5;
8912
- return ahApi.quoteAhPrice(DOT_LOCATION, getNativeAssets(chain)[0].location, bridgeFee + ahExecutionFee);
8913
- case 5:
8914
- feeConverted = _context.v;
8915
- if (feeConverted) {
8916
- _context.n = 6;
8917
- break;
8918
- }
8919
- throw new InvalidParameterError("Pool DOT -> ".concat(asset.symbol, " not found."));
8920
- case 6:
8921
- nativeMythAmount = padFeeBy(feeConverted, 10);
8980
+ nativeMythAmount = _context.v;
8922
8981
  return _context.a(2, {
8923
8982
  module: 'PolkadotXcm',
8924
8983
  method: 'transfer_assets_using_type_and_then',
@@ -10105,7 +10164,7 @@ var createMintTxs = function createMintTxs(chain, asset, balance, address, api)
10105
10164
  var nativePallet = getNativeAssetsPallet(chain);
10106
10165
  var otherPallets = getOtherAssetsPallets(chain);
10107
10166
  var isMainNativeAsset = isSymbolMatch(asset.symbol, getNativeAssetSymbol(chain));
10108
- var pallet = isForeignAsset(asset) || !isMainNativeAsset ? pickOtherPallet(asset, otherPallets) : nativePallet;
10167
+ var pallet = isForeignAsset(asset) && chain !== 'Mythos' || !isMainNativeAsset ? pickOtherPallet(asset, otherPallets) : nativePallet;
10109
10168
  var palletInstance = getPalletInstance(pallet);
10110
10169
  return palletInstance.mint(address, asset, balance, chain, api);
10111
10170
  };
@@ -10466,6 +10525,7 @@ var getOriginXcmFeeInternal = /*#__PURE__*/function () {
10466
10525
  return api.getDryRunCall({
10467
10526
  tx: tx,
10468
10527
  chain: origin,
10528
+ destination: destination,
10469
10529
  address: senderAddress,
10470
10530
  asset: _objectSpread2(_objectSpread2({}, asset), {}, {
10471
10531
  amount: amount
@@ -10797,7 +10857,7 @@ var getFailureInfo = function getFailureInfo(chains, hops) {
10797
10857
  };
10798
10858
  var getXcmFeeInternal = /*#__PURE__*/function () {
10799
10859
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref) {
10800
- var api, tx, origin, destination, senderAddress, address, currency, feeAsset, disableFallback, swapConfig, useRootOrigin, asset, amount, _yield$getOriginXcmFe, originFee, originCurrency, originAsset, originFeeType, originDryRunError, initialForwardedXcm, initialDestParaId, originWeight, sufficientOriginFee, destApi, destFeeRes, _result, _getFailureInfo, _failureChain, _failureReason, processHop, traversalResult, destFee, destCurrency, destAsset, destFeeType, destDryRunError, destSufficient, destResult, _destApi, destFallback, assetHubChain, processedBridgeHub, bridgeHubChain, bridgeHubHopIndex, convertToFeeDetail, result, _getFailureInfo2, failureChain, failureReason;
10860
+ var api, tx, origin, destination, senderAddress, address, currency, feeAsset, disableFallback, swapConfig, useRootOrigin, asset, amount, _yield$getOriginXcmFe, originFeeRaw, originCurrency, originAsset, originFeeType, originDryRunError, initialForwardedXcm, initialDestParaId, originWeight, sufficientOriginFee, isMythosToEthereum, originFee, destApi, destFeeRes, _result, _getFailureInfo, _failureChain, _failureReason, processHop, traversalResult, destFee, destCurrency, destAsset, destFeeType, destDryRunError, destSufficient, destResult, _destApi, destFallback, assetHubChain, processedBridgeHub, bridgeHubChain, bridgeHubHopIndex, convertToFeeDetail, result, _getFailureInfo2, failureChain, failureReason, _t, _t2, _t3, _t4;
10801
10861
  return _regenerator().w(function (_context2) {
10802
10862
  while (1) switch (_context2.p = _context2.n) {
10803
10863
  case 0:
@@ -10818,7 +10878,7 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
10818
10878
  });
10819
10879
  case 1:
10820
10880
  _yield$getOriginXcmFe = _context2.v;
10821
- originFee = _yield$getOriginXcmFe.fee;
10881
+ originFeeRaw = _yield$getOriginXcmFe.fee;
10822
10882
  originCurrency = _yield$getOriginXcmFe.currency;
10823
10883
  originAsset = _yield$getOriginXcmFe.asset;
10824
10884
  originFeeType = _yield$getOriginXcmFe.feeType;
@@ -10827,17 +10887,34 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
10827
10887
  initialDestParaId = _yield$getOriginXcmFe.destParaId;
10828
10888
  originWeight = _yield$getOriginXcmFe.weight;
10829
10889
  sufficientOriginFee = _yield$getOriginXcmFe.sufficient;
10890
+ isMythosToEthereum = origin === 'Mythos' && destination === 'Ethereum';
10891
+ if (!isMythosToEthereum) {
10892
+ _context2.n = 3;
10893
+ break;
10894
+ }
10895
+ _context2.n = 2;
10896
+ return getMythosOriginFee(api);
10897
+ case 2:
10898
+ _t2 = _context2.v;
10899
+ _t3 = originFeeRaw !== null && originFeeRaw !== void 0 ? originFeeRaw : 0n;
10900
+ _t = _t2 + _t3;
10901
+ _context2.n = 4;
10902
+ break;
10903
+ case 3:
10904
+ _t = originFeeRaw;
10905
+ case 4:
10906
+ originFee = _t;
10830
10907
  if (!(originDryRunError || originFeeType === 'paymentInfo')) {
10831
- _context2.n = 7;
10908
+ _context2.n = 10;
10832
10909
  break;
10833
10910
  }
10834
10911
  destApi = api.clone();
10835
- _context2.p = 2;
10836
- _context2.n = 3;
10912
+ _context2.p = 5;
10913
+ _context2.n = 6;
10837
10914
  return destApi.init(destination, DRY_RUN_CLIENT_TIMEOUT_MS);
10838
- case 3:
10915
+ case 6:
10839
10916
  destApi.setDisconnectAllowed(false);
10840
- _context2.n = 4;
10917
+ _context2.n = 7;
10841
10918
  return getDestXcmFee({
10842
10919
  api: destApi,
10843
10920
  forwardedXcms: undefined,
@@ -10856,7 +10933,7 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
10856
10933
  disableFallback: disableFallback,
10857
10934
  swapConfig: swapConfig
10858
10935
  });
10859
- case 4:
10936
+ case 7:
10860
10937
  destFeeRes = _context2.v;
10861
10938
  _result = {
10862
10939
  origin: _objectSpread2(_objectSpread2(_objectSpread2({}, originFee && {
@@ -10892,21 +10969,32 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
10892
10969
  failureChain: _failureChain,
10893
10970
  failureReason: _failureReason
10894
10971
  }));
10895
- case 5:
10896
- _context2.p = 5;
10972
+ case 8:
10973
+ _context2.p = 8;
10897
10974
  destApi.setDisconnectAllowed(true);
10898
- _context2.n = 6;
10975
+ _context2.n = 9;
10899
10976
  return destApi.disconnect();
10900
- case 6:
10901
- return _context2.f(5);
10902
- case 7:
10977
+ case 9:
10978
+ return _context2.f(8);
10979
+ case 10:
10903
10980
  processHop = /*#__PURE__*/function () {
10904
10981
  var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(params) {
10905
- var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange, hopResult, hopAsset;
10982
+ var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange, hopAsset, hopResult;
10906
10983
  return _regenerator().w(function (_context) {
10907
10984
  while (1) switch (_context.n) {
10908
10985
  case 0:
10909
10986
  hopApi = params.api, currentChain = params.currentChain, currentOrigin = params.currentOrigin, currentAsset = params.currentAsset, forwardedXcms = params.forwardedXcms, hasPassedExchange = params.hasPassedExchange;
10987
+ if (!(currentAsset.location && currentAsset.location.parents === Parents.TWO)) {
10988
+ if (hasPassedExchange && swapConfig && currentChain !== swapConfig.exchangeChain) {
10989
+ hopAsset = findAssetOnDestOrThrow(swapConfig.exchangeChain, currentChain, swapConfig.currencyTo);
10990
+ } else if (destination === currentChain) {
10991
+ hopAsset = findAssetOnDestOrThrow(origin, currentChain, currency);
10992
+ } else {
10993
+ hopAsset = currentAsset;
10994
+ }
10995
+ } else {
10996
+ hopAsset = findNativeAssetInfoOrThrow(getRelayChainOf(currentChain));
10997
+ }
10910
10998
  _context.n = 1;
10911
10999
  return getDestXcmFee({
10912
11000
  api: hopApi,
@@ -10919,7 +11007,7 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
10919
11007
  }),
10920
11008
  address: address,
10921
11009
  senderAddress: senderAddress,
10922
- asset: currentAsset,
11010
+ asset: hopAsset,
10923
11011
  feeAsset: feeAsset,
10924
11012
  tx: tx,
10925
11013
  originFee: originFee !== null && originFee !== void 0 ? originFee : 0n,
@@ -10929,21 +11017,7 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
10929
11017
  });
10930
11018
  case 1:
10931
11019
  hopResult = _context.v;
10932
- if (hopResult.feeType === 'dryRun' && !(destination === 'Ethereum' && (currentChain.includes('AssetHub') || currentChain.includes('BridgeHub')))) {
10933
- if (hasPassedExchange && swapConfig && currentChain !== swapConfig.exchangeChain) {
10934
- hopAsset = findAssetOnDestOrThrow(swapConfig.exchangeChain, currentChain, swapConfig.currencyTo);
10935
- } else if (destination === currentChain) {
10936
- hopAsset = findAssetOnDestOrThrow(origin, currentChain, currency);
10937
- } else {
10938
- hopAsset = asset;
10939
- }
10940
- } else {
10941
- hopAsset = findNativeAssetInfoOrThrow(currentChain);
10942
- }
10943
- return _context.a(2, _objectSpread2(_objectSpread2({}, hopResult), {}, {
10944
- currency: hopAsset.symbol,
10945
- asset: hopAsset
10946
- }));
11020
+ return _context.a(2, hopResult);
10947
11021
  }
10948
11022
  }, _callee);
10949
11023
  }));
@@ -10951,7 +11025,7 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
10951
11025
  return _ref3.apply(this, arguments);
10952
11026
  };
10953
11027
  }();
10954
- _context2.n = 8;
11028
+ _context2.n = 11;
10955
11029
  return traverseXcmHops({
10956
11030
  api: api,
10957
11031
  origin: origin,
@@ -10971,14 +11045,14 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
10971
11045
  };
10972
11046
  }
10973
11047
  });
10974
- case 8:
11048
+ case 11:
10975
11049
  traversalResult = _context2.v;
10976
11050
  // Handle case where we failed before reaching destination
10977
11051
  destFee = 0n;
10978
11052
  destFeeType = destination === 'Ethereum' ? 'noFeeRequired' : 'paymentInfo';
10979
11053
  destSufficient = undefined;
10980
11054
  if (!traversalResult.destination) {
10981
- _context2.n = 9;
11055
+ _context2.n = 12;
10982
11056
  break;
10983
11057
  }
10984
11058
  destResult = traversalResult.destination;
@@ -10988,23 +11062,19 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
10988
11062
  destSufficient = destResult.sufficient;
10989
11063
  destCurrency = destResult.currency;
10990
11064
  destAsset = destResult.asset;
10991
- _context2.n = 13;
11065
+ _context2.n = 16;
10992
11066
  break;
10993
- case 9:
11067
+ case 12:
10994
11068
  if (!(traversalResult.hops.length > 0 && traversalResult.hops[traversalResult.hops.length - 1].result.dryRunError)) {
10995
- _context2.n = 12;
11069
+ _context2.n = 15;
10996
11070
  break;
10997
11071
  }
10998
11072
  // We failed before reaching destination, use fallback
10999
11073
  _destApi = api.clone();
11000
- if (!(destination !== 'Ethereum')) {
11001
- _context2.n = 10;
11002
- break;
11003
- }
11004
- _context2.n = 10;
11074
+ _context2.n = 13;
11005
11075
  return _destApi.init(destination, DRY_RUN_CLIENT_TIMEOUT_MS);
11006
- case 10:
11007
- _context2.n = 11;
11076
+ case 13:
11077
+ _context2.n = 14;
11008
11078
  return getDestXcmFee({
11009
11079
  api: _destApi,
11010
11080
  forwardedXcms: undefined,
@@ -11022,28 +11092,38 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
11022
11092
  disableFallback: disableFallback,
11023
11093
  swapConfig: swapConfig
11024
11094
  });
11025
- case 11:
11095
+ case 14:
11026
11096
  destFallback = _context2.v;
11027
11097
  destFee = destFallback.fee;
11028
11098
  destFeeType = destFallback.feeType;
11029
11099
  destSufficient = destFallback.sufficient;
11030
11100
  destCurrency = getNativeAssetSymbol(destination);
11031
11101
  destAsset = findNativeAssetInfoOrThrow(destination);
11032
- _context2.n = 13;
11102
+ _context2.n = 16;
11033
11103
  break;
11034
- case 12:
11104
+ case 15:
11035
11105
  destFee = 0n;
11036
11106
  destFeeType = 'noFeeRequired';
11037
11107
  destSufficient = true;
11038
11108
  destCurrency = getNativeAssetSymbol(destination);
11039
11109
  destAsset = findNativeAssetInfoOrThrow(destination);
11040
- case 13:
11110
+ case 16:
11041
11111
  // Process Ethereum bridge fees
11042
11112
  assetHubChain = "AssetHub".concat(getRelayChainOf(origin));
11043
- _context2.n = 14;
11113
+ if (!isMythosToEthereum) {
11114
+ _context2.n = 17;
11115
+ break;
11116
+ }
11117
+ _t4 = traversalResult.bridgeHub;
11118
+ _context2.n = 19;
11119
+ break;
11120
+ case 17:
11121
+ _context2.n = 18;
11044
11122
  return addEthereumBridgeFees(api, traversalResult.bridgeHub, destination, assetHubChain);
11045
- case 14:
11046
- processedBridgeHub = _context2.v;
11123
+ case 18:
11124
+ _t4 = _context2.v;
11125
+ case 19:
11126
+ processedBridgeHub = _t4;
11047
11127
  // Update bridge hub fee in hops if needed
11048
11128
  if (processedBridgeHub && traversalResult.bridgeHub && processedBridgeHub.fee !== traversalResult.bridgeHub.fee) {
11049
11129
  bridgeHubChain = "BridgeHub".concat(getRelayChainOf(origin));
@@ -11119,7 +11199,7 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
11119
11199
  failureReason: failureReason
11120
11200
  }));
11121
11201
  }
11122
- }, _callee2, null, [[2,, 5, 7]]);
11202
+ }, _callee2, null, [[5,, 8, 10]]);
11123
11203
  }));
11124
11204
  return function getXcmFeeInternal(_x) {
11125
11205
  return _ref2.apply(this, arguments);
@@ -12357,12 +12437,14 @@ var createCustomXcm = function createCustomXcm(_ref, isDotAsset) {
12357
12437
  return depositInstruction;
12358
12438
  };
12359
12439
 
12360
- var createRefundInstruction = function createRefundInstruction(api, senderAddress, version) {
12440
+ var createRefundInstruction = function createRefundInstruction(api, senderAddress, version, assetCount) {
12361
12441
  return {
12362
12442
  SetAppendix: [{
12363
12443
  DepositAsset: {
12364
12444
  assets: {
12365
- Wild: 'All'
12445
+ Wild: {
12446
+ AllCounted: assetCount
12447
+ }
12366
12448
  },
12367
12449
  beneficiary: createBeneficiaryLocation({
12368
12450
  api: api,
@@ -12387,7 +12469,7 @@ var buildAssets = function buildAssets(chain, asset, feeAmount, isDotAsset, vers
12387
12469
  */
12388
12470
  var createTypeAndThenCall = /*#__PURE__*/function () {
12389
12471
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, options) {
12390
- var api, senderAddress, version, context, assetInfo, isDotAsset, customXcm, refundInstruction, fees, finalCustomXcm, totalFee, assets;
12472
+ var api, senderAddress, version, context, assetInfo, isDotAsset, customXcm, assetCount, refundInstruction, fees, finalCustomXcm, totalFee, assets;
12391
12473
  return _regenerator().w(function (_context) {
12392
12474
  while (1) switch (_context.n) {
12393
12475
  case 0:
@@ -12408,7 +12490,8 @@ var createTypeAndThenCall = /*#__PURE__*/function () {
12408
12490
  }
12409
12491
  });
12410
12492
  customXcm = createCustomXcm(context, isDotAsset);
12411
- refundInstruction = senderAddress ? createRefundInstruction(api, senderAddress, version) : null;
12493
+ assetCount = isDotAsset ? 1 : 2;
12494
+ refundInstruction = senderAddress ? createRefundInstruction(api, senderAddress, version, assetCount) : null;
12412
12495
  _context.n = 2;
12413
12496
  return computeAllFees(context, customXcm, isDotAsset, refundInstruction);
12414
12497
  case 2: