Transaction Flow

How Trades are Handled Behind the Scenes

Funding your Account

To begin trading or providing liquidity on Lynx, users must first deposit funds into their Lynx account by submitting a transaction from any origin chain. Upon depositing funds, the user will receive an equivalent amount of chips, minted directly to their wallet on the engine chain.

While funding an account requires a standard on-chain transaction, it allows all subsequent interactions on Lynx to be submitted via intents thereby eliminating the need for the user to pay their gas fees.

How are Chips Minted

The process of minting chips is powered by LayerZero and is similar to the way a standard lock-and-mint asset bridge works:

  1. User Deposits TKN: After submitting the transaction to fund their account, the user's TKN is transferred from their wallet to a secure holding contract on the origin chain.

  2. LayerZero Communicates the Deposit Cross-Chain: The contract triggers a message, sent by LayerZero, from the origin chain to the engine chain.

  3. User Receives TKN Chips in their Wallet: The token minting contract on the engine chain mints chips to the user's wallet, representing their deposited TKN.

With chips now in their wallet on the engine chain, the user is free to begin trading (or supplying liquidity) on Lynx. To do so, the user can begin submitting intents from their origin chain without needing to connect to the engine chain.

Note: Chips are designed for use within Lynx, enabling them to be transferred between contracts on the engine chain without prior approvals. Chips are not meant to have utility outside of Lynx.

Submitting Intents on Lynx

Let's look at an example of a user who wants to open a trade on Lynx. The user first sets up their trade parameters on the Lynx app (eg. traded amount, leverage, stop loss, etc.). When they are ready to open their position, they click "Place Order" on the application UI and the intent signing process begins:

  1. User Submits Intent on Lynx: Instead of being prompted by their wallet provider to confirm a transaction, the user will receive a request to sign a message. By clicking "Sign", the user sends a request (ie. intent) to open their trade.

  2. Intent Published as On-Chain Transaction: Once the intent has been submitted, a solver bot mines the intent, publishing it as a transaction on the engine chain.

  3. Transaction is Triggered, Opening the Trade: A whitelisted bot triggers the now on-chain request, transferring chips from the user's wallet accordingly and opening the requested position.

Withdrawing Funds from your Account

At any point in time, a user can withdraw their funds from their Lynx account. This process burns the appropriate number of chips from the user's wallet on the engine chain and releases their funds to their wallet on the origin chain. The steps are similar to funding your account, with the key difference that withdrawing funds is initiated as an intent, not a transaction:

  1. User Initiates TKN Withdrawal: The user requests to withdraw their TKN using Lynx's intent system. The intent is verified by the intent verifier contract and then published on the engine chain, burning the user's chips and triggering a cross-chain message.

  2. LayerZero Communicates the Deposit Cross-Chain: A cross-chain message is sent by LayerZero on the engine chain to LayerZero on the origin chain.

  3. User Receives TKN Back: Upon receiving the message on the origin chain, the 'release' function on the Lynx contract is triggered and the user's TKN is sent back to their wallet on the origin chain.

Last updated