---
# System prepended metadata

title: Asset conversion

---

An example of how to use the Asset Conversion pallet on the asset-hub-westend parachain.
(The asset with id 1977 has been created and minted previously.)

# 1. Create a pool:

For foreign assets creating a pool seems pretty natural. For local assets we can refer to them via a multilocation. The assets pallet is pallet index 50 on all the asset hub runtimes and then the asset id is specified using `GeneralIndex`:

![](https://hackmd.io/_uploads/ry8Fx9dOh.png)

Call data: 0x380000000002043205e51e

Result:

https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fwestend-asset-hub-rpc.polkadot.io#/explorer/query/0xc7a96f2401ad6328dc10269fb43bfa7ce055b11c8c903cd275fd1213d5d9c19d

![](https://hackmd.io/_uploads/Skcaxq__3.png)

(We could have had an enum that allowed you to choose from local or remote assets but if we had done that you would still have been able to express the local assets as multilocations. It's better if there's only one way to specify something.)

# 2. Add liquidity:

Next someone needs to add funds to a pool. This could be anyone and doesn't need to be the creater of the pool. Remember though that the ratio of the assets at this point will dictate the initial price. (Ideally this should be near the market price else you will be quickly arbitraged.)

![](https://hackmd.io/_uploads/S1_Gmc_uh.png)

Call data: 0x380100000002043205e51e009435770000000000000000000000000000c2d33f944497000000000000000000ca9a3b0000000000000000000000000000da493b717d0c0000000000000000ccdce2bc61518838d34314c620b7c88040c38c784e0eabe838c17192be7ed91c

## Result:

https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fwestend-asset-hub-rpc.polkadot.io#/explorer/query/0x6d585e607b7b8c9ccd28dcc8be029430861b9b354c6a285a9e13431f655af386

![](https://hackmd.io/_uploads/BkgKX9ddh.png)

# 3. Convert asset:

The first two steps only have to be done once by someone. Then everyone can convert assets. Remember `amountOutMin` dictates how much slippage you are willing to put up with. (This also dictates how much you can be MEVed.) 

![](https://hackmd.io/_uploads/Bk-Vrqu_h.png)

Call data:
0x38030800000002043205e51e00ca9a3b0000000000000000000000000100000000000000000000000000000040a61308e181f0681a1311984d70c415eebe80bef618bfd42a724dd6f9cdb26e01

## Result:

![](https://hackmd.io/_uploads/B1_uBquOh.png)

https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fwestend-asset-hub-rpc.polkadot.io#/explorer/query/0x03ad702a9bfe4f8a231fef2579b77353149e3e4c76e4da6cd99d33cbceb029b2


