Meson in Solidity

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 compile and deploy script will automatically set this config file.

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

  • 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

Last updated