The Web3 Paradigm: Smart Contracts Instead of API Keys
Unlike classic CEXs with a centralized order book, MYX Finance's architecture is built on the Matching Pool Mechanism (MPM). The platform runs fully on-chain, and its flagship network is the fast and inexpensive L2 zkEVM blockchain Linea.
Security: Your Keys, Your Orders
You do not register an account with a login and password. Your account is a standard Web3 wallet (EOA) or a smart contract. Your access key is a private key on the Linea network.
Key security practices:
- Ethers / Viem libraries: Standard Ethereum libraries can be used to work with Linea.
- Key protection: Store `PRIVATE_KEY` exclusively in a secure perimeter (vaults) or `.env` environment files.
- USDC approvals: Control the size of `approve` granted to MYX contracts. Approve only the necessary amount of stablecoins to minimize the attack surface.
MYX Architecture: MPM, Keeper Network and Zero Slippage
For building trading algorithms on MYX Finance, developers get access to the platform's unique advantages:
- Matching Pool Mechanism (MPM): When your bot submits an on-chain order to open a position, the liquidity pool instantly acts as the passive counterparty, locking collateral to cover potential losses. This guarantees zero price slippage.
- Keeper Network: To prevent front-running manipulation and ensure transparent execution, MYX uses a decentralized network of keepers (community nodes). Keepers pick up your requests from the mempool and execute them honestly based on up-to-date oracle prices.
- USDC Collateral and Leverage up to 50x: All perpetual contracts are settled in USDC. The built-in Isolated Margin system protects your entire portfolio from liquidations by isolating losses within a single position.
Use Cases: Algorithmic Derivatives Trading
Slippage-free execution and high capital efficiency (up to 125x for LPs) open new horizons for algo trading. Current MYX volume and open interest metrics are available on the dashboard:
- Macro news trading: Strategies that require precise entries at the exact moment of news releases, without the slippage traditionally inherent in AMM DEXs.
- Funding Rate Arbitrage: Delta-neutral hedging of positions between MYX Finance on Linea and other CEX/DEX venues.
- Copy-Trading: Thanks to the simple `Buy-to-Open` and `Sell-to-Close` logic of the MYX architecture, it is easy to port CEX strategies into a decentralized environment.
Where to Get Data? (RPC, Oracles)
The data infrastructure is split into several layers:
1. Trade Execution (Linea RPC Nodes)
Connect to the Linea network RPC (via Infura, Alchemy or public endpoints) using Ethers.js. This is where your bot sends transactions.
2. Quotes (Tamper-resistant Oracles)
Execution prices are generated by protected decentralized oracles. For your bot to use the same prices in its calculations, request quotes via the API of the chosen oracle (e.g., Pyth Network or Chainlink), adjusted for the Linea blockchain.
3. MYX Indexers
PnL history, trading volumes and historical liquidation data can be obtained from public graphs (The Graph) or the platform's internal indexers (follow the official MYX documentation).
Error Handling (Smart Contract Reverts)
Trading errors are transaction reverts raised by the smart contract on the Linea network. Key errors:
| Revert Reason / Error | Cause | Solution |
|---|---|---|
| InsufficientMargin | The USDC collateral is below the required minimum for the specified leverage. | Increase the margin or reduce the leverage (especially when trading at the maximum 50x). |
| ADL Triggered (Auto-Deleveraging) | The auto-deleveraging system has kicked in to protect the pool from systemic risk. | The system may force-close the most profitable positions. Monitor the long/short ratio in the MPM pool. |
| Keeper Execution Delayed | Order validation delayed by the keeper network. Often due to unpredictable volatility or oracle issues. | Implement retry logic in your bot, or cancel the order if the waiting time has expired. |
Code Examples: Connecting to Linea and MYX
Example 1: Basic Ethers.js Initialization
To interact with MYX smart contracts you need a standard Web3 provider setup:
const { ethers } = require("ethers");
require('dotenv').config();
async function initLineaAndMYX() {
// Подключение к RPC сети Linea
const provider = new ethers.JsonRpcProvider("https://rpc.linea.build");
// Инициализация кошелька
const privateKey = process.env.PRIVATE_KEY;
const wallet = new ethers.Wallet(privateKey, provider);
const address = await wallet.getAddress();
const balance = await provider.getBalance(address);
console.log(`Адрес трейдера: ${address}`);
console.log(`Баланс газа (ETH): ${ethers.formatEther(balance)} ETH`);
// Пример адреса контракта MYX Router (укажите актуальный из документации)
const MYX_ROUTER_ADDRESS = "0x...";
// const myxContract = new ethers.Contract(MYX_ROUTER_ADDRESS, ABI, wallet);
}
initLineaAndMYX();
Frequently Asked Questions (FAQ) about the MYX Finance API
Where do I get an API key for trading on MYX Finance?
As with any true DeFi application, there are no centralized servers issuing API keys here. You build transactions locally, sign them with your EVM wallet's private key and submit them to the Linea network through an RPC provider. Keepers process your on-chain requests.
How do I pay gas in a MYX trading bot?
Since the platform is deployed on the Linea network, paying transaction fees (gas) requires ETH on the Linea network in your wallet balance. The margin collateral itself for opening derivatives positions is deposited in USDC stablecoins.