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

Change vDOT paying asset - fix decimals fetching in destination #153

Merged
merged 2 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions .changeset/orange-trainers-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@moonbeam-network/xcm-config': patch
'@moonbeam-network/xcm-sdk': patch
---

Change how we get decimals from assets in destination and change vDOT transfers paying asset
2 changes: 1 addition & 1 deletion packages/config/src/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ export const bifrostPolkadot = new Parachain({
name: 'Bifrost',
parachainId: 2030,
ss58Format: 6,
ws: 'wss://hk.p.bifrost-rpc.liebi.com/ws',
ws: 'wss://eu.bifrost-polkadot-rpc.liebi.com/ws',
});

export const calamari = new Parachain({
Expand Down
8 changes: 4 additions & 4 deletions packages/config/src/configs/bifrostPolkadot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ export const bifrostPolkadotConfig = new ChainConfig({
balance: BalanceBuilder().substrate().tokens().accounts(),
destination: moonbeam,
destinationFee: {
amount: 0.2,
asset: bnc,
balance: BalanceBuilder().substrate().system().account(),
amount: 0.01,
asset: vdot,
balance: BalanceBuilder().substrate().tokens().accounts(),
},
extrinsic: ExtrinsicBuilder().xTokens().transferMultiCurrencies(),
extrinsic: ExtrinsicBuilder().xTokens().transfer(),
fee: {
asset: bnc,
balance: BalanceBuilder().substrate().system().account(),
Expand Down
19 changes: 17 additions & 2 deletions packages/sdk/src/getTransferData/getDestinationData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ export async function getDestinationData({
const balanceAmount = zeroAmount.copyWith({ amount: balance });
const { existentialDeposit } = polkadot;

const feeAmount = await getFee({ config: transferConfig, polkadot });
const feeAmount = await getFee({
address: destinationAddress,
config: transferConfig,
evmSigner,
polkadot,
});
const minAmount = zeroAmount.copyWith({ amount: min });

return {
Expand All @@ -59,16 +64,26 @@ export async function getDestinationData({
}

export interface GetFeeParams {
address: string;
config: TransferConfig;
evmSigner?: EvmSigner;
polkadot: PolkadotService;
}

export async function getFee({
address,
config,
evmSigner,
polkadot,
}: GetFeeParams): Promise<AssetAmount> {
const { amount, asset } = config.source.config.destinationFee;
const decimals = await polkadot.getAssetDecimals(asset);
const decimals = await getDecimals({
address,
asset,
config: config.destination.config,
evmSigner,
polkadot,
});
const zeroAmount = AssetAmount.fromAsset(asset, {
amount: 0n,
decimals,
Expand Down
Loading