LzProxyOFTV2

The LzProxyOFTV2.sol contract is a pivotal component in Abracadabra's cross-chain beaming system. This contract is deployed on the Ethereum mainnet and plays a key role in the secure transfer of Magic Internet Money (MIM) tokens across different networks.

Here's a detailed developer's overview of this contract:

Contract Structure

This contract inherits from the LzBaseOFTV2.sol base contract, which provides foundational functionality for operating with Omnichain Fungible Tokens (OFTs) on the LayerZero network.

The contract has two key state variables:

  1. innerToken: This is an instance of the IERC20 interface and signifies the MIM token on the Ethereum mainnet.

  2. ld2sdRate: This variable holds the conversion rate between the shared decimals of the LayerZero network and the decimals of the MIM token.

Constructor

The constructor for LzProxyOFTV2 takes three parameters: _token, _sharedDecimals, and _lzEndpoint. The _token parameter is the address of the MIM token on Ethereum, _sharedDecimals represents the number of decimals that the LayerZero network uses, and _lzEndpoint is the address of the LayerZero endpoint for this chain.

Public Functions

The contract offers two key public functions:

  1. circulatingSupply(): This function returns the total circulating supply of the MIM token on Ethereum, excluding the balance that the contract itself holds.

  2. token(): This function returns the address of the MIM token.

Internal Functions

Three crucial internal functions are defined in the contract:

  1. _debitFrom(address _from, uint16, bytes32, uint _amount): This function transfers MIM tokens from the user to the contract. It requires that the function caller is the owner of the MIM tokens.

  2. _creditTo(uint16, address _toAddress, uint _amount): This function transfers MIM tokens from the contract to the user.

  3. _ld2sdRate(): An immutable uint that represents the conversion rate from the token's native decimal places to the shared decimal places used in the LayerZero system. LayerZero using 8 decimals.

Interaction with LayerZero

The LzProxyOFTV2 contract is a vital part of Abracadabra's system that integrates with LayerZero. This contract acts as a "proxy" on the Ethereum mainnet, facilitating the beaming of MIM tokens to side chains. By locking MIM tokens into this contract, users can initiate the beaming process, which results in the minting of equivalent MIM tokens on the chosen side chain.

This contract uses the LayerZero network to communicate with other chains, enabling the fast, secure, and reliable transfer of MIM tokens across different chains.

Last updated