Skip to main content

Overview

MeltFactory handles the full lifecycle of deploying new mAssets: creating the wrapped token, registering it with MeltHub, and linking it to HyperCore. Inherits: Ownable

Constructor

constructor(address _hub, address _owner, address _lzEndpoint, address _oftOwner)
ParameterDescription
_hubMeltHub contract address
_ownerFactory owner
_lzEndpointLayerZero endpoint
_oftOwnerOFT owner for new token deployments

Token Deployment

deployToken

function deployToken(
    address originalToken_,
    uint32 sourceEid_,
    string calldata name_,
    string calldata symbol_,
    uint8 decimals_,
    uint256 feeBps_
) external onlyOwner returns (address wrappedToken, bytes32 configKey)
Deploys a new wrapped token and registers it with MeltHub:
  1. Creates new MeltAsset instance
  2. Grants MINTER_ROLE and BURNER_ROLE to MeltHub
  3. Grants MINTER_ROLE to Factory (for HyperCore preparation)
  4. Registers token with MeltHub
  5. Returns wrapped token address and configKey

HyperCore Integration

Two-step process to link a token to HyperCore for spot trading:

Step 1: prepareForCore

function prepareForCore(
    bytes32 configKey,
    uint64 expectedCoreIndex_,
    int8 decimalDiff_,
    uint256 mintAmount
) external onlyOwner
  • Calculates asset bridge address from expectedCoreIndex_
  • Mints tokens directly to the asset bridge
  • Records pending state

Step 2: completeCoreLinking

function completeCoreLinking(bytes32 configKey) external onlyOwner
  • Calls hub.setCoreConfig() to finalize the link
  • Marks deployment as fully linked

Deployment State

Each deployment tracks its lifecycle:
struct PendingDeployment {
    address originalToken;
    uint32 sourceEid;
    MeltAsset wrappedToken;
    uint256 feeBps;
    uint64 expectedCoreIndex;
    int8 decimalDiff;
    bool registered;      // Registered with MeltHub
    bool corePending;     // Core preparation done
    bool coreLinked;      // Core linking completed
}

View Functions

FunctionReturns
getDeployment(configKey)Full deployment state
getDeployedTokens()Array of all deployed token addresses
deployedTokenCount()Number of deployed tokens
getAssetBridge(coreIndexId)Asset bridge address for a HyperCore index