Market Makers

Execute Market-Making for Limit Orders

To fill a user’s limit order x, market-makers must perform two actions:

  1. Place an equal and opposite limit order x*.

  2. Call the function make_order(x, x*).

Step 1: Placing the User's Limit Order

A user places a limit order with the following parameters:

  • swap: The source chain, source token, and source quantity.

  • to: The destination chain and destination token.

  • at: The price in wei.

  • with fee: The fee in basis points.

The quantity of the destination token (dst_token) that the user will receive on the destination chain is calculated as:

Example

A user wants to place a limit order on the Avalanche chain. The example parameters are as follows:

  • Source Chain: Avalanche

  • Source Token: 0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E

  • Source Quantity: 106106106106 (1,000,000 units)

The function call to place this limit order would look like this:

Step 2: Making the Order

After placing the limit order, the market-maker must place an equal and opposite limit order and then call the function make_order(x, x*) to complete the process.

Example function call:

How to Call placeTrade() as a Maker

Setting the Fee

  • Do not set the fee to 0.

  • Set the fee to be the same amount that the user pays.

Receiving the Fee

  • As the guarantor in the smart contract, you will receive this fee once the transaction is executed.

Example

By setting the fee correctly, you ensure proper fee handling and consistency in the Mach protocol.

For more detailed information, refer to the specific line of code on GitHubarrow-up-right (line 298).

Last updated