polkadot-fellows / xcm-format

Polkadot Cross Consensus-system Message format.
Apache License 2.0
181 stars 43 forks source link

RFC: add complex asset transfers instructions #54

Closed acatangiu closed 5 months ago

acatangiu commented 7 months ago

Summary

This RFC proposes new instructions that provide a way to initiate asset transfers which transfer multiple types (teleports, local-reserve, destination-reserve) of assets, on remote chains using XCM alone.

The currently existing instructions are too opinionated and force each XCM asset transfer to a single transfer type (teleport, local-reserve, destination-reserve). This results in inability to combine different types of transfers in single transfer which results in overall poor UX when trying to move assets across chains.

Example usage

    // XCM to be executed locally
    let xcm = Xcm::<penpal_runtime::RuntimeCall>(vec![
        // Withdraw both ROCs and PENs from origin account
        WithdrawAsset(assets.clone().into()),
        // ROCs are reserve-withdrawn on AHR
        DestinationReserveWithdrawAssets(rocs.into()),
        // PENs are teleported to AHR
        TeleportTransferAssets(pens.into()),
        // Execute the transfers while paying remote fees with ROCs
        ExecuteAssetTransfers {
            dest: local_asset_hub,
            remote_fees: Some(AssetFilter::Wild(AllOf { id: rocs_id.into(), fun })),
            remote_xcm: xcm_on_ahr,
        },
    ]);

Proof-of-Concept

I also have a proof-of-concept implementation and a proof-of-concept asset transfer test, transferring 2 different types of assets across 3 chains.

acatangiu commented 7 months ago

cc @mrshiposha @xlc

acatangiu commented 7 months ago

PS: We could also probably do this in the one big instruction, further coupling concepts that work together. It would always require specifying a vector of AssetTransferType, even if it has only one element. That makes it good UX even when just doing a simple teleport.

enum Instruction {
...
InitiateAssetTransfer {
destination: Location,
assets: Vec<AssetTransferType>,
remote_fees: Option<AssetFilter>,
remote_xcm: Xcm<()>,
},
...
}

Yes, I like this ^

Polkadot-Forum commented 6 months ago

This pull request has been mentioned on Polkadot Forum. There might be relevant details there:

https://forum.polkadot.network/t/xcm-user-and-developer-experience-improvements/4511/21

Polkadot-Forum commented 5 months ago

This pull request has been mentioned on Polkadot Forum. There might be relevant details there:

https://forum.polkadot.network/t/managing-sas-on-multiple-reserve-chains-for-same-asset/7538/7

acatangiu commented 5 months ago

Unfortunately, following the repo migration to the new org, I lost write access to the PR (upstream) branch. I've opened the PR from a fork branch here https://github.com/polkadot-fellows/xcm-format/pull/63

Closing this one.