diff --git a/packages/config/src/xcm-configs/moonriver.ts b/packages/config/src/xcm-configs/moonriver.ts index 2c58b14f..7b9cb064 100644 --- a/packages/config/src/xcm-configs/moonriver.ts +++ b/packages/config/src/xcm-configs/moonriver.ts @@ -83,7 +83,7 @@ export const moonriverRoutes = new ChainRoutes({ destination: { asset: movr, chain: calamari, - balance: BalanceBuilder().substrate().system().account(), + balance: BalanceBuilder().substrate().assets().account(), fee: { amount: 0.001, asset: movr, @@ -144,7 +144,7 @@ export const moonriverRoutes = new ChainRoutes({ chain: khala, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: 0.0002, + amount: 0.001, asset: movr, }, }, @@ -683,7 +683,7 @@ export const moonriverRoutes = new ChainRoutes({ chain: bifrostKusama, balance: BalanceBuilder().substrate().tokens().accounts(), fee: { - amount: 0.0001, + amount: 0.1, asset: vbnc, }, min: AssetMinBuilder().assetRegistry().currencyMetadatas(), @@ -707,7 +707,7 @@ export const moonriverRoutes = new ChainRoutes({ chain: bifrostKusama, balance: BalanceBuilder().substrate().tokens().accounts(), fee: { - amount: 0.0001, + amount: 0.001, asset: vksm, }, min: AssetMinBuilder().assetRegistry().currencyMetadatas(), @@ -731,7 +731,7 @@ export const moonriverRoutes = new ChainRoutes({ chain: bifrostKusama, balance: BalanceBuilder().substrate().tokens().accounts(), fee: { - amount: 0.00000001, + amount: 0.1, asset: vmovr, }, min: AssetMinBuilder().assetRegistry().currencyMetadatas(), diff --git a/packages/mrl/src/getTransferData/getSourceData.ts b/packages/mrl/src/getTransferData/getSourceData.ts index 9c9c79bc..ec111dca 100644 --- a/packages/mrl/src/getTransferData/getSourceData.ts +++ b/packages/mrl/src/getTransferData/getSourceData.ts @@ -63,6 +63,7 @@ export async function getSourceData({ builder: route.source.balance, chain: source, }); + const feeBalance = route.source.fee ? await getBalance({ address: sourceAddress, @@ -87,6 +88,7 @@ export async function getSourceData({ }); const existentialDeposit = await getExistentialDeposit(source); + const min = await getAssetMin({ asset, builder: route.source.min, @@ -185,6 +187,7 @@ async function getFee({ if (ContractConfig.is(transfer)) { return getContractFee({ address: sourceAddress, + balance, chain: chain as EvmChain | EvmParachain, contract: transfer, destinationFee, @@ -248,7 +251,7 @@ async function getWormholeFee({ const fee = await wh.getFee(config); return AssetAmount.fromChainAsset(chain.getChainAsset(asset), { - amount: fee.relayFee ? fee.relayFee.amount + safetyAmount : 0n, + amount: fee?.relayFee ? fee.relayFee.amount + safetyAmount : 0n, }); } diff --git a/packages/mrl/src/services/wormhole/WormholeService.ts b/packages/mrl/src/services/wormhole/WormholeService.ts index 3eaac618..d9eac2e9 100644 --- a/packages/mrl/src/services/wormhole/WormholeService.ts +++ b/packages/mrl/src/services/wormhole/WormholeService.ts @@ -26,7 +26,12 @@ export class WormholeService { this.#wh = wormholeFactory(chain); } - async getFee(transfer: WormholeConfig): Promise { + async getFee(transfer: WormholeConfig): Promise { + const amount = transfer.args[1]; + if (amount === 0n) { + return undefined; + } + const xfer = await this.#wh[transfer.func](...transfer.args); return TokenTransfer.quoteTransfer( diff --git a/packages/sdk/src/getTransferData/getSourceData.ts b/packages/sdk/src/getTransferData/getSourceData.ts index f9b9647e..70acdfae 100644 --- a/packages/sdk/src/getTransferData/getSourceData.ts +++ b/packages/sdk/src/getTransferData/getSourceData.ts @@ -152,6 +152,7 @@ export async function getFee({ if (contract) { return getContractFee({ address: sourceAddress, + balance, chain: chain as EvmChain | EvmParachain, contract, destinationFee, diff --git a/packages/sdk/src/getTransferData/getTransferData.utils.ts b/packages/sdk/src/getTransferData/getTransferData.utils.ts index 12660347..b40fa118 100644 --- a/packages/sdk/src/getTransferData/getTransferData.utils.ts +++ b/packages/sdk/src/getTransferData/getTransferData.utils.ts @@ -307,6 +307,7 @@ export async function getExtrinsicFee({ export interface GetContractFeeParams { address: string; + balance: AssetAmount; chain: EvmChain | EvmParachain; contract: ContractConfig; destinationFee: AssetAmount; @@ -316,6 +317,7 @@ export interface GetContractFeeParams { export async function getContractFee({ address, + balance, chain, contract, destinationFee, @@ -323,6 +325,9 @@ export async function getContractFee({ feeConfig, }: GetContractFeeParams): Promise { try { + if (balance.amount === 0n) { + return feeBalance.copyWith({ amount: 0n }); + } const evm = EvmService.create(chain); const fee = await evm.getFee(address, contract); const extra = feeConfig?.extra