Skip to main content

Energy Market

The energy market is a decentralized order book where players can trade energy for SES. It is powered by the EnergyMarket.sol contract.


Selling Energy (Creating an Order)​

Operation​

createOrder(energyAmount, sesPrice)
  1. Enter the amount of energy you want to sell
  2. Enter the total price in SES you're asking for
  3. Confirm the transaction

Energy Locking​

When you create an order, the contract immediately locks your energy (marked as energyReserved), preventing you from spending it while the order is active.

Canceling an Order​

cancelOrder(orderId)
  • The order must be at least 3 seconds old before cancellation (prevents same-block frontrunning)
  • After cancellation, the energy is unlocked

Buying Energy (Filling an Order)​

Operation​

fillOrder(orderId, energyAmount, maxUnitPrice)
  1. Browse the list of active sell orders
  2. Select an order
  3. Enter the maximum price you're willing to accept
  4. Confirm the transaction

Fees​

A 1% SES protocol fee is deducted from the seller's proceeds:

Buyer pays = order price (exact listing price)
Seller receives = order price × 99%
Protocol fee = order price × 1% (accumulated in contract)

The 1% protocol fee accumulates in the contract and can be withdrawn by the admin.


Market Parameters​

ParameterValue
Protocol Fee1% (deducted from seller)
Minimum Order Age3 seconds (before cancel/fill)
Order Statusactive / inactive (becomes inactive after cancel or fill)

Trade Example​

Alice Sells Energy​

  1. Alice creates a sell order: createOrder(10000, 100 SES) — selling 10,000 energy for a total of 100 SES
  2. The contract locks Alice's 10,000 energy

Bob Buys Energy​

  1. Bob sees Alice's order
  2. Calls fillOrder(orderId, 100, maxUnitPrice) — buys exactly 100 energy
  3. Alice receives 99 SES (100 - 1% fee)
  4. 1 SES is accumulated as protocol fee

Strategy Tips​

ScenarioSuggestion
Need energy urgently for battleAccept the lowest-priced sell orders
Not in a hurryPlace a limit order and wait for the right price
SES price is risingSell energy for SES to profit
Surplus energyList sell orders to earn SES

Recommended next step: Daily Mint →