# Omnichain MIM

Abracadabra's Cross-Chain Token Beaming System utilizes the Omnichain Fungible Token (OFT) standard by LayerZero, a decentralized and highly scalable protocol for cross-chain transactions. This system replaces the previous Multichain router for web3 that facilitated arbitrary cross-chain interactions. The system comprises three components:

1. The LzProxyOFTV2 contract used on the Ethereum mainnet
2. The LzIndirectOFTV2 contract used on sidechains
3. The ElevatedMinterBurner contract that authorizes the minting and burning of MIM tokens on sidechains, allowing compatibility with already deployed MIM contract on sidechain

## Beaming flow:

### Mainnet to Sidechain:

This process involves transferring native MIM from the Ethereum mainnet to a sidechain.

1. The user initiates the process by interacting with the `LzProxyOFTV2` contract on the Ethereum mainnet, which transfers MIM from the user's address to the contract's own address.
2. Once the transfer to the `LzProxyOFTV2` mainnet contract is complete, it communicates the transaction details, or "beaming" information, to the `LzIndirectOFTV2` contract on the sidechain through LayerZero
3. The `LzIndirectOFTV2` contract on the sidechain then interacts with the `ElevatedMinterBurner` contract, which mints an equivalent amount of MIM tokens on sidechain, credited to the user's account.

<figure><img src="https://335078740-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAyUNiFaEKoywXDmFsJSp%2Fuploads%2Fgit-blob-a14406556ff2d3e5a67eaec69e1a807271e46da3%2Fdiagram.png?alt=media" alt=""><figcaption></figcaption></figure>

### Sidechain A to sidechain B

This process involves burning MIM tokens on sidechain A and minting them on sidechain B.

1. The user first interacts with the `LzIndirectOFTV2` contract on sidechain A which then calls upon the `ElevatedMinterBurner` contract on the same sidechain, burning the user's MIM tokens.
2. Once the tokens are burnt, the `LzIndirectOFTV2` contract on sidechain A communicates "beaming" information to the `LzIndirectOFTV2` contract on sidechain B through LayerZero.
3. Upon receiving the beaming information, the `LzIndirectOFTV2` contract on sidechain B interacts with its `ElevatedMinterBurner`, which mints an equivalent amount of MIM tokens on sidechain B, assigned to the user's account.

<figure><img src="https://335078740-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAyUNiFaEKoywXDmFsJSp%2Fuploads%2Fgit-blob-97d8471c4573dd594b123f31882641e4f5a42f0a%2Fdiagram.png?alt=media" alt=""><figcaption></figcaption></figure>

### Sidechain to Mainnet

This process involves burning MIM tokens on a sidechain and transferring an equivalent amount from the proxy to the user on the Ethereum mainnet.

1. The user interacts with the `LzIndirectOFTV2` contract on the sidechain, which engages its `ElevatedMinterBurner` contract, burning the user's MIM tokens.
2. Once the tokens are burnt, the `LzIndirectOFTV2` contract communicates the "beaming" information to the `LzProxyOFTV2` contract on the Ethereym mainnet through LayerZero.
3. The `LzProxyOFTV2` contract on mainnet transfers an equivalent amount of MIM tokens from itself to the user's account.

<figure><img src="https://335078740-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAyUNiFaEKoywXDmFsJSp%2Fuploads%2Fgit-blob-69fe5d9e36c531b8e286d324bb2e202ebca384ab%2Fdiagram.png?alt=media" alt=""><figcaption></figcaption></figure>

Note that while these examples use a generic "user" term, Omnichain MIM can be beamed from one user to another or to oneself, with the sender specifying the recipient.
