Meson Fi
  • Meson Docs
  • Introducing Meson
  • Guides
    • Meson App
      • Premium
      • Swap on Mobile
    • Meson Explorer
  • Protocol
    • Background
      • Hash Time Lock Contract (HTLC)
    • The Meson Protocol
      • Swap Process
      • Trusted Verifiers
      • Swap Fee
      • Liquidity Providers
    • System Design
      • Relayer
        • Relayer APIs
      • LP Service
    • Security Precautions
      • Waiting Time
  • Implementation
    • Smart Contracts
      • Meson in Solidity
      • Time
    • Applications
  • References
    • Audits
      • SSLabs at Georgia Tech
      • Trail of Bits : Design Review
      • Trail of Bits : Security Review
      • Trail of Bits : Fix Review
    • Stablecoins supported by Meson
Powered by GitBook
On this page
  • Chain-specific System Invariates
  • Source Code
  1. Implementation
  2. Smart Contracts

Meson in Solidity

PreviousSmart ContractsNextTime

Last updated 2 years ago

We have implemented the Meson protocol with Solidity smart contracts, and deployed to the following EVM-compatible public chains:

  • Ethereum

  • BNB Chain (formerly BSC)

  • Polygon

  • Evmos Mainnet

  • Arbitrum

  • Optimism

  • Aurora (on NEAR)

  • Conflux eSpace

  • Avalanche C-chain

  • Fantom

  • Tron

  • Harmony

  • Moonriver

  • Moonbeam

Chain-specific System Invariates

The chain-specific invariants are given in the MesonConfig.sol file. The will automatically set this config file.

  • Chain
    Short Coin Type

    Ethereum

    0x003c

    Tron

    0x00c3

    Conflux

    0x01f7

    Optimism

    0x0266

    BNB Chain

    0x02ca

    Polygon

    0x03c6

    Fantom

    0x03ef

    Harmony

    0x03ff

    Moonbeam

    0x0504

    Moonriver

    0x0505

    Aurora

    0x0a0a

    Evmos

    0x11bc

    Avalanche

    0x2328

    Arbitrum

    0x2329

  • MIN_BOND_TIME_PERIOD (uint256) & MAX_BOND_TIME_PERIOD (uint256): The minimal and maximum expire time when bonding a swap, set to 1 hour and 2 hours, respectively. The swap encoding will include a timestamp expireTs before which the user's assets will be locked on the initial chain. The LP should call executeSwap before expireTs to take away the swapping fund. The expireTs needs to satisfy ts_bonded_tx + MIN_BOND_TIME_PERIOD < expireTs < ts_bonded_tx + MAX_BOND_TIME_PERIOD, where ts_bonded_tx is the block time for the executed postSwap transaction.

  • LOCK_TIME_PERIOD (uint256): The time length when an LP locks a swap, sets to 40 minutes. The initiator should sign the release signature to get swapped assets on the target chain before the time ts_locked_tx + LOCK_TIME_PERIOD, where ts_locked_tx is the block time for the executed lock transaction.

  • REQUEST_TYPE_HASH (bytes32): Equals to keccak256(bytes32 "Sign to request a swap on Meson") or keccak256(bytes32 "Sign to request a swap on Meson (Testnet)"). It's used when checking the request signature.

  • RELEASE_TYPE_HASH (bytes32): Equals to keccak256(bytes32 "Sign to release a swap on Meson" + bytes32 [Recipient]) or keccak256(bytes32 "Sign to release a swap on Meson (Testnet)" + bytes32 "[Recipient]"). It's used when checking the release signature.

Source Code

SHORT_COIN_TYPE (uint16): The identifier of the chain. We use the last 2 bytes of as the unique ID of a chain:

compile and deploy script
SLIP-44
https://github.com/MesonFi/meson-contracts-soliditygithub.com
Meson Smart Contracts