Skip to content

Commit

Permalink
changes after final review
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaurello committed Jan 16, 2025
1 parent a65265d commit 24b9db9
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 25 deletions.
2 changes: 1 addition & 1 deletion mkdocs/docs/contribute/mrl.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ Assuming that all of the required pallets and methods are already supported, you

3. As seen in the above example, a `routes` array contains the chain's routes. The route configuration defines the asset being transferred, the destination chain, the moonchain, information associated with fees, and the builder functions. The builder functions must be used to build the queries or calls as if they were being executed from this chain.

You'll need to create an Route for each asset, for example:
You'll need to create a [Route](../reference/mrl.md#the-mrl-asset-route-object) for each asset, for example:

```ts
{
Expand Down
4 changes: 2 additions & 2 deletions mkdocs/docs/contribute/xcm.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ Assuming that all of the required pallets and methods are already supported, you

3. As seen in the above example, a `routes` array contains the chain's routes. The route configuration defines the asset being transferred, the destination chain, information associated with fees, and the builder functions. The builder functions must be used to build the queries or calls as if they were being executed from this chain.

You'll need to create an Route for each asset, for example:
You'll need to create a [Route](../reference/xcm.md#the-asset-route-object) for each asset, for example:

```ts
{
Expand Down Expand Up @@ -410,4 +410,4 @@ You can use the following queries to ensure that the new configurations have bee
100000000000;
```

Most cases are considered already, but for newly integrated chains, this data might be queried by a different pallet or function. You can check if the pallet is supported in the [Polkadot Service file](https://github.com/moonbeam-foundation/xcm-sdk/blob/main/packages/sdk/src/polkadot/PolkadotService.ts).
Most cases are considered already, but for newly integrated chains, this data might be queried by a different pallet or function.
2 changes: 1 addition & 1 deletion mkdocs/docs/example-usage/mrl.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ npm install viem@2

## Create Signers {: #create-signers }

Similar to the XCM SDK, you'll need to create signers to interact with the SDK. You can refer to the [Create Signers](./example-usage.md#create-signers) section in the XCM SDK guide for more information.
Similar to the XCM SDK, you'll need to create signers to interact with the SDK. You can refer to the [Create Signers](./xcm.md#create-signers) section in the XCM SDK guide for more information.

## Get Chain Data {: #get-chain-data }

Expand Down
17 changes: 7 additions & 10 deletions mkdocs/docs/example-usage/xcm.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ template: tutorial.html

The Moonbeam XCM SDK enables developers to easily transfer assets between chains, either between parachains or between a parachain and the relay chain, within the Polkadot/Kusama ecosystem. With the SDK, you don't need to worry about determining the multilocation of the origin or destination assets or which extrinsics are used on which networks to send XCM transfers.

The XCM SDK offers helper functions that provide a very simple interface for executing XCM transfers between chains in the Polkadot/Kusama ecosystem. In addition, the XCM config package allows any parachain project to [add their information](./contribute.md) in a standard way, so the XCM SDK can immediately support them.
The XCM SDK offers helper functions that provide a very simple interface for executing XCM transfers between chains in the Polkadot/Kusama ecosystem. In addition, the XCM config package allows any parachain project to [add their information](../contribute/xcm.md){target=\_blank} in a standard way, so the XCM SDK can immediately support them.

For an overview of the available methods and interfaces in the Moonbeam XCM SDK, please refer to the [Reference](./reference/interfaces.md){target=\_blank} page.
For an overview of the available methods and interfaces in the Moonbeam XCM SDK, please refer to the [Reference](../reference/xcm.md){target=\_blank} page.

This guide shows how to transfer DOT from Polkadot to Moonbeam.

Expand Down Expand Up @@ -814,12 +814,12 @@ The same output will be generated regardless of which example you used to build

As you may have noticed in the example response, the transfer data contains information on the asset, source, and destination chain. In addition, a couple of functions have been exposed:

- [`transfer`](./reference/methods.md#the-transfer-method) - transfers a given amount of the asset from the source chain to the destination chain
- [`getEstimate`](./reference/methods.md#the-get-estimate-method) - returns an estimated amount of the asset that will be received on the destination chain, less any destination fees
- [`transfer`](../reference/xcm.md#the-transfer-method) - transfers a given amount of the asset from the source chain to the destination chain
- [`getEstimate`](../reference/xcm.md#the-transfer-data-object) - returns an estimated amount of the asset that will be received on the destination chain, less any destination fees

## Transfer an Asset {: #transfer-an-asset }

Now that you've built the transfer data, you can transfer the asset from the source chain to the destination chain. To do so, you can use the [`transfer`](./reference/methods.md#the-transfer-method) function, but first, you'll need to specify an amount to send. You can specify the amount in integer or decimal format. For example, if you wanted to send 0.1 DOT, you could use `1000000000n` or `'0.1'`. You can use [asset conversion methods](../reference/xcm.md#asset-utility-methods){target=\_blank}, like `toDecimal` to convert the asset to decimal format.
Now that you've built the transfer data, you can transfer the asset from the source chain to the destination chain. To do so, you can use the [`transfer`](../reference/xcm.md#the-transfer-method) function, but first, you'll need to specify an amount to send. You can specify the amount in integer or decimal format. For example, if you wanted to send 0.1 DOT, you could use `1000000000n` or `'0.1'`. You can use [asset conversion methods](../reference/xcm.md#asset-utility-methods){target=\_blank}, like `toDecimal` to convert the asset to decimal format.
You'll also need to specify the signer you're using for the transfer.

For this example, you can transfer twice the minimum amount required of DOT:
Expand All @@ -840,11 +840,11 @@ console.log(`${transferData.source.chain.name} tx hash: ${hash}`);
As the above snippet shows, the `transfer` function returns a transaction hash on the source chain.

!!! note
For more information on the parameters and returned data for `transfer`, please refer to the [XCM SDK Reference](./reference/methods.md#the-transfer-method){target=\_blank}.
For more information on the parameters and returned data for `transfer`, please refer to the [XCM SDK Reference](../reference/xcm.md#the-transfer-method){target=\_blank}.

## Get an Estimate of the Asset to Be Received on the Destination Chain {: #get-estimate }

When you send an XCM message, you typically pay fees on the destination chain to execute the XCM instructions. Before you transfer the asset, you can use the [`getEstimate`](./reference/methods.md#the-get-estimate-method) function to calculate an estimated amount of the asset that will be received on the destination chain minus any fees.
When you send an XCM message, you typically pay fees on the destination chain to execute the XCM instructions. Before you transfer the asset, you can use the `getEstimate` function to calculate an estimated amount of the asset that will be received on the destination chain minus any fees.

The `getEstimate` function is tied to a specific transfer request as it is based on the asset being transferred and the destination chain fees, so you'll need to create the [transfer data](#build-xcm-transfer-data) first.

Expand Down Expand Up @@ -897,9 +897,6 @@ The `getEstimate` function returns the estimated amount along with information o
}
```

!!! note
For more information on the parameters and returned data for `getEstimate`, please refer to the [XCM SDK Reference](./reference/methods.md#the-get-estimate-method){target=\_blank}.

## Get Transfer Minimum and Maximum Amounts {: #transfer-min-max-amounts }

You can use [transfer data](#build-xcm-transfer-data) to retrieve the minimum and maximum amount of an asset that can be transferred. To do so, you'll access the `min` and `max` properties of the asset being transferred:
Expand Down
20 changes: 10 additions & 10 deletions mkdocs/docs/reference/mrl.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ description: A reference for the types and interfaces in the Moonbeam MRL SDK th

# Moonbeam MRL SDK Reference

A new module, `@moonbeam-foundation/mrl-sdk`, has been added to the Moonbeam SDK to support transfers between chains from the Polkadot ecosystem and external chains from outside the Polkadot ecosystem.
A new module, `@moonbeam-foundation/mrl`, has been added to the Moonbeam SDK to support transfers between chains from the Polkadot ecosystem and external chains from outside the Polkadot ecosystem.

For more details, refer to the [MRL Documentation](https://docs.moonbeam.network/builders/interoperability/mrl/){target=\_blank}.
For more details about Moonbeam Routed Liquidity (MRL) itself, refer to the [MRL Documentation](https://docs.moonbeam.network/builders/interoperability/mrl/){target=\_blank}.

The MRL SDK simplifies the process of routing liquidity from various blockchains into the Polkadot ecosystem by providing a set of tools and functions that abstract away the complexities of cross-chain communication, by leveraging GMP, XCM, and XC-20s.

Expand All @@ -25,7 +25,7 @@ Always refer to the [MRL Documentation](https://docs.moonbeam.network/builders/i
---

### From EVM chains to parachains. {: #from-evm-chains-to-parachains }
Here the source chain is an [EVM chain](../reference/xcm.md#the-evm-chain-object) and the destination chain either a [Parachain](../reference/xcm.md#the-parachain-object) or an [EVMParachain](../reference/xcm.md#the-evm-parachain-object).
Here the source chain is an [EVM chain](../reference/xcm.md#the-evm-chain-object) and the destination chain either a [Parachain](../reference/xcm.md#the-parachain-object) or an [EVM Parachain](../reference/xcm.md#the-evm-parachain-object).

1. A contract call is made in the source chain, which triggers the assets to be sent to Moonbeam ([moon chain](#the-moon-chain)). This process is done in this sdk by leveraging a [GMP provider](https://docs.moonbeam.network/builders/interoperability/protocols/){target=\_blank}. Currently the only one supported is [Wormhole](https://docs.moonbeam.network/builders/interoperability/protocols/wormhole/){target=\_blank}.
2. Next, to complete the transfer in Moonbeam, it must be executed, either manually or automatically by a relayer from the GMP provider. This execution consists of calling the [GMP precompile](https://docs.moonbeam.network/builders/ethereum/precompiles/interoperability/gmp/){target=\_blank}, which triggers the next step.
Expand All @@ -35,13 +35,13 @@ Here the source chain is an [EVM chain](../reference/xcm.md#the-evm-chain-object

### From parachains to EVM chains. {: #from-parachains-to-evm-chains }

Here the source chain is a [Parachain](../reference/xcm.md#the-parachain-object) or an [EVMParachain](../reference/xcm.md#the-evm-parachain-object) and the destination chain an [EVM chain](../reference/xcm.md#the-evm-chain-object).
Here the source chain is a [Parachain](../reference/xcm.md#the-parachain-object) or an [EVM Parachain](../reference/xcm.md#the-evm-parachain-object) and the destination chain an [EVM chain](../reference/xcm.md#the-evm-chain-object).

1. An XCM message is sent from the source chain to Moonbeam, this message is a batch call containing the following information:
- A 'transfer assets' message, containing the asset that the user wants to transfer, plus the fees necessary to complete the transfer in Moonbeam, if any.
- A 'remote execution' message, which will be executed in Moonbeam.
- The assets are sent to the [computed origin account](https://docs.moonbeam.network/builders/interoperability/mrl/#calculate-computed-origin-account){target=\_blank}, which is an account that can only be manipulated remotely by the source address.
- *Note*: It is possible to only send the remote execution message, in cases where the computed origin account already has the assets necessary to complete the transfer. Refer to the [transfer method](#the-transfer-method) for more information.
- *Note*: It is possible to only send the remote execution message, in cases where the computed origin account already has the assets necessary to complete the transfer. Refer to the [transfer method](#the-transfer-method) for information on how to do this.

2. Now that the computed origin account has the assets, the remote execution message is executed in Moonbeam, which will send the assets to the destination chain through a GMP provider. It is the same first step described in the [From EVM chains to parachains](#from-evm-chains-to-parachains) section, but in reverse.

Expand Down Expand Up @@ -128,7 +128,7 @@ This object contains the routes for a specific chain.
**Attributes**

- `chain` ++"Chain"++ [:material-link-variant:](./reference/xcm.md#the-chain-object) - The chain the routes are for
- `routes` ++"MrlAssetRoute[]"++ [:material-link-variant:](#mrl-asset-route) - The list of asset routes for the chain
- `routes` ++"MrlAssetRoute[]"++ [:material-link-variant:](#the-mrl-asset-route-object) - The list of asset routes for the chain

Chain routes are defined in the [MRL Config](https://github.com/moonbeam-foundation/xcm-sdk/blob/main/packages/config/src/mrl-configs/){target=\_blank} files.

Expand All @@ -143,7 +143,7 @@ In the process of transferring the assets, you must get the transfer data first
<div class="grid" markdown>
<div markdown>

Defines the complete transfer data for transferring an asset, including asset balances, source and destination chain information, and a new concept exlusive to MRL which is the [moon chain](#moonchain)
Defines the complete transfer data for transferring an asset, including asset balances, source and destination chain information, and a new concept exlusive to MRL which is the [moon chain](#the-moon-chain)

**Attributes**

Expand Down Expand Up @@ -738,7 +738,7 @@ We call Moon Chain to the intermediary chain that is used to transfer the assets

- `amount` ++"bigint | number | string"++ - The amount of the asset to transfer
- `isAutomatic` ++"boolean"++ - Whether or not the transfer should be automatic
- `signers` ++"Signers"++ [:material-link-variant:](#the-signers-object) - The signers of the transaction
- `signers` ++"Signers"++ - The signers of the transaction
- `statusCallback` ++"function"++ (optional) - Comes from the polkadot api. A callback function that can be passed to the signAndSend method, and will be called with the status of the transaction. Only applicable for polkadot signers, when the source chain is a parachain.
- `sendOnlyRemoteExecution` ++"boolean"++ (optional) - When this flag is set to true, instead of sending a transfer assets message plus a remote execution message from the parachain to the moon chain, only the remote execution message is sent. Applicable only when the source chain is a parachain. This is useful when some assets are stuck in the moon chain in the [computed origin account](https://docs.moonbeam.network/builders/interoperability/mrl/#calculate-computed-origin-account){target=\_blank} of the sender, in which case sending the assets would not be necessary from the source chain.

Expand Down Expand Up @@ -789,7 +789,7 @@ await transferData.transfer(

This is a concept that is not present in XCM, it represents the fee that the relayer charges for executing the transfer automatically. Note that if the transfer is not automatic, the relayer fee will be 0.

In the [transfer data](#transfer-data-object) you can find the relayer fee in the `relayerFee` attribute in the `source` object, and it is represented as an [AssetAmount](#the-assetamount-object) object.
In the [transfer data](#transfer-data-object) you can find the relayer fee in the `relayerFee` attribute in the `source` object, and it is represented as an [Asset Amount](./xcm.md#the-asset-amount-object) object.

## Execute Transfer Data

Expand All @@ -805,7 +805,7 @@ Defines the data needed to execute the transfer in the destination chain. Usuall

- `vaa` ++"VAA"++ - The [VAA](https://wormhole.com/docs/learn/infrastructure/vaas/) of the transfer. Related to Wormhole
- `tokenTransfer` ++"TokenTransfer"++ - The token transfer of the transfer. Related to Wormhole
- `executeTransfer` ++"function"++ - The function to execute the transfer
- `executeTransfer` ++"function"++ [:material-link-variant:](#the-execute-transfer-method) - The function to execute the transfer


### The Execute Transfer Method
Expand Down
2 changes: 1 addition & 1 deletion mkdocs/docs/reference/xcm.md
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ console.log(bigintValue);
<div class="grid" markdown>
<div markdown>

`convertDecimals()` - Converts an asset amount to a different number of decimals. Useful when chains have different decimals for the same asset, for example when [usesOwnDecimals](../reference/xcm.md#the-parachain-object) is set to `true` in a chain.
`convertDecimals()` - Converts an asset amount to a different number of decimals. Useful when chains have different decimals for the same asset, for example when [usesChainDecimals](../reference/xcm.md#the-parachain-object) is set to `true` in a chain.

**Parameters**

Expand Down

0 comments on commit 24b9db9

Please sign in to comment.