Skip to content

Instantly share code, notes, and snippets.

@muddlebee
Last active April 10, 2025 21:20
Show Gist options
  • Select an option

  • Save muddlebee/6bbf5d6b3a1f21986bf25fc6e2d3fd6b to your computer and use it in GitHub Desktop.

Select an option

Save muddlebee/6bbf5d6b3a1f21986bf25fc6e2d3fd6b to your computer and use it in GitHub Desktop.
sample xcm message
const message = XcmVersionedXcm.V4([
// 1. Withdraw DOT from Asset Hub
XcmV4Instruction.WithdrawAsset([dotAsset]),
// 2. Deposit to HydraDX with instructions
XcmV4Instruction.DepositReserveAsset({
assets: dotAssetFilter,
dest: hydradxDest,
xcm: [
// 2a. Pay for execution on HydraDX
XcmV4Instruction.BuyExecution({
fees: dotFeeAsset,
weight_limit: XcmV3WeightLimit.Unlimited()
}),
// 2b. Exchange DOT for USDT
XcmV4Instruction.ExchangeAsset({
give: dotAssetSwapFilter,
want: [usdtAsset],
maximal: true
}),
// 2c. Send swapped assets (USDT) back to Asset Hub
XcmV4Instruction.InitiateReserveWithdraw({
assets: XcmV4AssetAssetFilter.Wild(
XcmV4AssetWildAsset.All()
),
reserve: assetHubDest,
xcm: [
XcmV4Instruction.BuyExecution({
fees: dotFeeAsset,
weight_limit: XcmV3WeightLimit.Unlimited()
}),
XcmV4Instruction.DepositAsset({
assets: XcmV4AssetAssetFilter.Wild(
XcmV4AssetWildAsset.All()
),
beneficiary: beneficiary(bobKeyPair)
})
]
}),
]
})
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment