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

Cross-chain: Reserve transfer #51

Merged
merged 47 commits into from
Aug 20, 2023
Merged

Cross-chain: Reserve transfer #51

merged 47 commits into from
Aug 20, 2023

Conversation

Szegoo
Copy link
Member

@Szegoo Szegoo commented Jul 26, 2023

There are three types of reserve transfers and we support all of them:

  1. The simplest one, transferring assets from the reserve chain itself. For this, we utilize the existing limitedReserveTransfer extrinsic that is part of the XCM pallet.
  2. The second type is transferring an asset which is a reserve asset on the receiver chain. There isn't an existing extrinsic for this so we have to construct our own XCM program that will execute the following instructions:
    1. WithdrawAsset, withdraw the amount the user wants to transfer from the sending chain and put it into the holding register
    2. InitiateReserveWithdraw, this will take all the assets in the holding register and burn them on the origin chain. This will put the appropriate amount into the holding register on the reserve chain.
    3. On the reserve chain execute BuyExecution
    4. DepositAsset into the receiver account
  3. The most complex one, the two-hop reserve transfer. This will burn the asset on the sender chain, move the asset to the receivers chain sovereign account on the reserve chain and tell the receiver chain to deposit the newly received assets into an account.
    The instructions are essentially the same as in the previous case, the only difference being that instead of using DepositAsset instruction on the reserve chain directly we first call DepositReserveAsset to deposit into the parachain sovereign account, and send a DepositAsset instruction to the receiver chain that will actually place the newly received tokens into the receiver account.

NOTE: This PR only allows fee payment with the asset that is being transferred. A separate PR will be opened that will allow fee payment with the relay chain's native currency.

Closes: #30

@Szegoo Szegoo marked this pull request as ready for review August 19, 2023 09:55
@Szegoo Szegoo requested a review from cuteolaf August 19, 2023 10:10
@cuteolaf cuteolaf merged commit 86e7742 into main Aug 20, 2023
7 checks passed
@cuteolaf cuteolaf deleted the reserve-transfer branch August 20, 2023 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Routing tokens
2 participants