Case Scenario

Scenario 1: Basic Buy Levels

Description: The market maker is buying the baseToken (ETH), and the trader is selling it. The market maker provides multiple buy levels with increasing quantities and prices.

Data Structure:

{
  "baseToken": {
    "chain": { "chainType": "evm", "chainId": 1 },
    "address": "0x0000000000000000000000000000000000000000"
  },
  "quoteToken": {
    "chain": { "chainType": "evm", "chainId": 1 },
    "address": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
  },
  "buyLevels": [
    { "quantity": "0.1", "price": "1600.00" },
    { "quantity": "1", "price": "1600.00" },
    { "quantity": "0.5", "price": "1599.00" }
  ],
  "sellLevels": []
}

Result:

  • Trader sells 1.6 ETH.

    • Level 1: Fully filled (0.1 ETH at $1600.00).

    • Level 2: Fully filled (1 ETH at $1600.00).

    • Level 3: Partially filled (0.5 ETH at $1599.00).

  • Total traded: 1.6 ETH at an average price of $1599.375.

Scenario 2: Basic Sell Levels

Description: The market maker is selling the baseToken (ETH), and the trader is buying it. The market maker provides multiple sell levels with increasing quantities and prices.

Data Structure:

{
  "baseToken": {
    "chain": { "chainType": "evm", "chainId": 1 },
    "address": "0x0000000000000000000000000000000000000000"
  },
  "quoteToken": {
    "chain": { "chainType": "evm", "chainId": 1 },
    "address": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
  },
  "buyLevels": [],
  "sellLevels": [
    { "quantity": "0", "price": "1601.00" },
    { "quantity": "1", "price": "1601.00" },
    { "quantity": "1", "price": "1602.00" }
  ]
}

Result:

  • Trader buys 1.24906367 ETH.

    • Level 1: Fully filled (0 ETH at $1601.00).

    • Level 2: Fully filled (1 ETH at $1601.00).

    • Level 3: Partially filled (0.24906367 ETH at $1602.00).

  • Total traded: 1.24906367 ETH at an average price of $1601.30.

Scenario 3: Buy Levels with Arbitrarily Small Orders and Non-Zero First Level

Description: The market maker is buying the baseToken (ETH), allowing arbitrarily small orders with a non-zero first level quantity.

Data Structure:

{
  "baseToken": {
    "chain": { "chainType": "evm", "chainId": 1 },
    "address": "0x0000000000000000000000000000000000000000"
  },
  "quoteToken": {
    "chain": { "chainType": "evm", "chainId": 1 },
    "address": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
  },
  "buyLevels": [
    { "quantity": "1", "price": "90.00" },
    { "quantity": "2", "price": "91.00" },
    { "quantity": "3", "price": "92.00" },
    { "quantity": "4", "price": "93.00" }
  ],
  "sellLevels": []
}

Result:

  • Trader sells 7 ETH.

    • Level 1: Fully filled (1 ETH at $90.00).

    • Level 2: Fully filled (2 ETH at $91.00).

    • Level 3: Fully filled (3 ETH at $92.00).

    • Level 4: Partially filled (1 out of 4 ETH at $93.00).

  • Total traded: 7 ETH at an average price of $91.57.

Scenario 4: Sell Levels with Non-Zero First Level Quantity

Description: The market maker is selling the baseToken (ETH), and the trader is buying it. The first level has a non-zero quantity.

Data Structure:

{
  "baseToken": {
    "chain": { "chainType": "evm", "chainId": 1 },
    "address": "0x0000000000000000000000000000000000000000"
  },
  "quoteToken": {
    "chain": { "chainType": "evm", "chainId": 1 },
    "address": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
  },
  "buyLevels": [],
  "sellLevels": [
    { "quantity": "10", "price": "150.00" },
    { "quantity": "20", "price": "151.00" },
    { "quantity": "30", "price": "152.00" },
    { "quantity": "40", "price": "153.00" }
  ]
}

Result:

  • Trader buys 60 ETH.

    • Level 1: Fully filled (10 ETH at $150.00).

    • Level 2: Fully filled (20 ETH at $151.00).

    • Level 3: Fully filled (30 ETH at $152.00).

  • Total traded: 60 ETH at an average price of $151.33.

Last updated