Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ethereum, moonbeam and Hydration configurations #409

Merged
merged 6 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/config/src/xcm-configs/moonriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const moonriverRoutes = new ChainRoutes({
destination: {
asset: movr,
chain: calamari,
balance: BalanceBuilder().substrate().system().account(),
balance: BalanceBuilder().substrate().assets().account(),
Rihyx marked this conversation as resolved.
Show resolved Hide resolved
fee: {
amount: 0.001,
asset: movr,
Expand Down Expand Up @@ -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,
},
},
Expand Down Expand Up @@ -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(),
Expand All @@ -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(),
Expand All @@ -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(),
Expand Down
5 changes: 4 additions & 1 deletion packages/mrl/src/getTransferData/getSourceData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export async function getSourceData({
builder: route.source.balance,
chain: source,
});

const feeBalance = route.source.fee
? await getBalance({
address: sourceAddress,
Expand All @@ -87,6 +88,7 @@ export async function getSourceData({
});

const existentialDeposit = await getExistentialDeposit(source);

const min = await getAssetMin({
asset,
builder: route.source.min,
Expand Down Expand Up @@ -185,6 +187,7 @@ async function getFee({
if (ContractConfig.is(transfer)) {
return getContractFee({
address: sourceAddress,
balance,
chain: chain as EvmChain | EvmParachain,
contract: transfer,
destinationFee,
Expand Down Expand Up @@ -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,
});
}

Expand Down
7 changes: 6 additions & 1 deletion packages/mrl/src/services/wormhole/WormholeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ export class WormholeService {
this.#wh = wormholeFactory(chain);
}

async getFee(transfer: WormholeConfig): Promise<TransferQuote> {
async getFee(transfer: WormholeConfig): Promise<TransferQuote | undefined> {
const amount = transfer.args[1];
if (amount === 0n) {
return undefined;
}

const xfer = await this.#wh[transfer.func](...transfer.args);

return TokenTransfer.quoteTransfer(
Expand Down
1 change: 1 addition & 0 deletions packages/sdk/src/getTransferData/getSourceData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export async function getFee({
if (contract) {
return getContractFee({
address: sourceAddress,
balance,
chain: chain as EvmChain | EvmParachain,
contract,
destinationFee,
Expand Down
5 changes: 5 additions & 0 deletions packages/sdk/src/getTransferData/getTransferData.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ export async function getExtrinsicFee({

export interface GetContractFeeParams {
address: string;
balance: AssetAmount;
chain: EvmChain | EvmParachain;
contract: ContractConfig;
destinationFee: AssetAmount;
Expand All @@ -316,13 +317,17 @@ export interface GetContractFeeParams {

export async function getContractFee({
address,
balance,
chain,
contract,
destinationFee,
feeBalance,
feeConfig,
}: GetContractFeeParams): Promise<AssetAmount> {
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
Expand Down
Loading