Integrating with the SwapFacility
The SwapFacility
is the central, permissioned router for the M0 ecosystem. It is the only contract that can perform wrap
and unwrap
operations between the core $M
token and any M0 Extension. This ensures all conversions are 1:1, secure, and standardized.
Understanding how to interact with it is a critical step for launching your extension.
The Approval Process: A Two-Step Whitelisting
For your extension to be fully integrated, two components must be approved by M0 Governance: your Extension Contract and your Swapper Contract.
Step 1: Get Your Extension Approved as an M0 Earner
First, your deployed extension contract address must be on the official earners
list in the TTGRegistrar
. This is a prerequisite for any interaction with the SwapFacility
.
This process ensures that only recognized and audited extensions are part of the ecosystem.
For a detailed walkthrough, follow the Gaining Earner Approval guide.
Step 2: Get Your Swapper Contract Whitelisted
Direct calls to swapInM
(wrapping $M
) and swapOutM
(unwrapping to $M
) are restricted. Only addresses with the M_SWAPPER_ROLE
can execute these functions.
This means you cannot have your end-users call the SwapFacility
directly from their wallets. Instead, you must deploy an intermediary contract that will act on their behalf.
-
Deploy an Intermediary Contract: This contract will contain your application's logic for handling user deposits (
$M
) and withdrawals (your extension token). It will be the sole contract from your application that calls theSwapFacility
. -
Submit a Governance Proposal: Create and submit a proposal to M0 Governance to grant the
M_SWAPPER_ROLE
to your intermediary contract's address or EOA. Your proposal should include:- A description of your project.
- The address of your deployed intermediary contract.
- Links to your contract's source code and security audit.
-
Integrate: Once the proposal passes, your contract can successfully call
swapInM
andswapOutM
, enabling your users to move seamlessly between$M
and your extension through your application's interface.
Advanced: Permissioned Extensions
The SwapFacility
also supports a stricter model for institutional or private use cases. An extension can be marked as "permissioned" by the DEFAULT_ADMIN_ROLE
.
- Effect: A permissioned extension blocks all general
swap
calls. - Access: To interact with a permissioned extension, a swapper address must be granted specific approval for that individual extension via
setPermissionedMSwapper()
.
This provides an extra layer of access control for extensions that are not intended for public use.