Superform v1
  • Introduction
  • Components
    • Protocol
    • Keepers
    • API
    • App
  • E2E Flows
    • Same-chain Deposit
    • Cross-chain Deposit
    • Same-chain Withdrawal
    • Cross-chain Withdrawal
  • Periphery Contracts
    • SuperformRouter
      • SuperformRouterPlus
      • SuperformRouterPlusAsync
    • PayMaster
    • PaymentHelper
    • EmergencyQueue
    • SuperformFactory
    • Forms
      • ERC4626Form
      • ERC5115Form
      • ERC7540Form
    • SuperPositions
      • ERC1155A
    • RewardsDistributor
  • Core Contracts
    • State Registries
      • CoreStateRegistry
      • AsyncStateRegistry
      • PayloadHelper
    • AMB Implementations
      • LayerzeroImplementation
      • LayerzeroV2Implementation
      • WormholeARImplementation
      • HyperlaneImplementation
      • AxelarImplementation
    • Broadcasting
      • BroadcastRegistry
      • WormholeSRImplementation
    • Bridge Validators
      • LiFiValidator
      • SocketValidator
      • SocketOneInchValidator
      • DebridgeValidator (and forwarder)
      • OneInchValidator
    • DstSwapper
    • Settings
      • SuperRBAC
      • SuperRegistry
  • SuperVaults
    • SuperVaults
  • Resources
    • Deployment Addresses
    • Subgraphs
      • Protocol Level Entities
      • Form Related Entities
      • Deposits and Withdrawals
      • SuperPosition Events
      • External Entities
    • Infrastructure Integrations
    • Security & Audits
    • Protocol License
    • Glossary
    • Protocol Multisig
    • Superform Labs Socials
Powered by GitBook
On this page
  • Introduction
  • Core Concepts
  • Trusted Remotes
  • Receiving payloads
  • Retrying Payloads
  • Configuration Setters

Was this helpful?

  1. Core Contracts
  2. AMB Implementations

LayerzeroImplementation

Last updated 6 months ago

Was this helpful?

Introduction

This contract is used to allow Superform to send messages via .

Core Concepts

LayerzeroImplementation builds upon AMBImplementation to formalize certain methods specific to LayerZero. The application is notably nonblocking, to ensure that Superform's destination LayerZero Endpoint will never be blocked. You can read more on nonblocking applications .

Trusted Remotes

Trusted remotes establish a secure connection between the LayerzeroImplementation on source chain and the LayerzeroImplementation on destination chain. They are configured by the LayerzeroImplementation contract on the LZendpoint which validates it upon sending and receiving payloads. You can read more on Trusted Remotes .

Receiving payloads

LayerZero attempts to call lzReceive function on Superform's LayerzeroImplementation contract after the successful validation of a message at the bridge end. Upon delivery, certain mandatory input validations are made by the lzReceive function.

lzReceive

Receives a payload from the LayerZero endpoint and forwards it to the appropriate state registry by decoding the payload header. The lzReceive function can only be called by the LayerZero endpoint and each nonce_ can only be used once.

function lzReceive(
        uint16 srcChainId_,
        bytes memory srcAddress_,
        uint64 nonce_,
        bytes memory payload_
) public;
name
description

srcChainId_

uint16 identifier of the chain from which the cross-chain message is sent

srcAddress_

trusted remote that sent the message

nonce_

unique identifier used to prevent replay attacks used by the message bridge

payload_

the cross-chain message send by the srcAddress_ from srcChainId_

Retrying Payloads

(uint16 srcChainId, bytes memory srcAddress, bytes memory payload)

Configuration Setters

There are multiple bridge related configurations to be made on the LayerzeroImplementation contract. These configuration functions are gate kept and can only be called by addresses with PROTOCOL_ADMIN_ROLE

setChainId

Each messaging bridge uses their own chain identifiers, different than the blockchain's native chain identifier (a uint256 value). Hence a mapping is introduced to map the chain id of the bridge to Superform protocol's internal chain ids.

function setChainId(uint64 superChainId_, uint16 ambChainId_) external
name
description

superChainId_

internal chain id used by the Superform protocol. block.chainid casted to uint64

ambChainId_

uint16 chain id allocated to each chain by LayerZero

setLzEndpoint

This setter function updates / sets the LayerZero endpoint contract. The LayerZero endpoint is where cross-chain messages are sent/received by LayerzeroImplementation

function setLzEndpoint(address endpoint_) external
name
description

endpoint_

the address of the LayerZero's endpoint contract

setConfig

function setConfig(
    uint16 version_,
    uint16 chainId_,
    uint256 configType_,
    bytes calldata config_
) external override onlyProtocolAdmin
name
description

version_

uint16 version of the configuration

chainId_

uint16 LayerZero chainId to update

configType_

uint256 type of configuration

config_

bytes config data to set

As mentioned in the section, messages can be retried by calling retryPayload with a bytes hash of relevant data. In the case of LayerZero, the data is the following:

LayerZero
here
here
AMB Implementations