[XCM] Transfer Reserve & Non-Reserve Assets in a Single XCM

Thank you for the question! I’m happy to answer.

First of all, the extrinsics for asset teleportation and reserve asset transfers in pallet xcm aim to solve really useful scenarios. However, it’s encouraged to make your own pallets with extrinsics that use XCM in the way that’s most useful to your use case.
That said, this flow is definitely possible.

You can create your own extrinsic in a pallet to send a message with exactly those instructions.

Let’s say we have the following accounts:

let alice = sp_runtime::AccountId32::new([0u8; 32]); // Sender
let bob = sp_runtime::AccountId32::new([1u8; 32]); // Recipient

and the following amounts:

let amount_a = 1 * UNITS; // Amount of asset A to send (via derivative)
let amount_b = 2 * UNITS; // Amount of asset B to send (local transaction)

and let’s assume chains A and B are parachains of a relay chain with ids 1 and 2 respectively.

Then we could send this message:

let message = Xcm(vec![
  ReserveAssetDeposited((ParentThen(X1(Parachain(1))), amount_a).into()),
  WithdrawAsset((Here, amount_b).into()),
  ClearOrigin,
  BuyExecution {
    fees: (Here, amount_b).into(),
    weight_limit: WeightLimit::Unlimited,
  },
  DepositAsset {
    assets: All.into(),
    beneficiary: Junction::AccountId32 {
      id: bob.into(),
      network: None
    }.into(),
  },
]);

Sending this message would work. bob in chain B will have 1 unit of a derivative representing asset A and 2 units of the real asset B in his account.

This XCM is not enough though. When we just send a ReserveAssetDeposited instruction, we need to make sure we move an equal amount of the real asset A to chain B’s sovereign account on chain A. We need to do this ourselves. Instructions like TransferReserveAsset or DepositReserveAsset take care of this in case we want the most common behaviour (it’s expected to want to do custom things and get a little bit in the weeds). If we don’t fix this, derivatives don’t mean anything.

We need to make sure before we send our XCM that we transfer assets locally from alice’s account on chain A to chain B’s sovereign account. You could do this with the balances pallet.

Being allowed by the IsReserve config item of the other system is the only thing you need to make sure they trust that you actually do what’s needed before sending them the instruction to mint derivatives.

I hope that answers your question