Skip to content

Order ​

FieldTypeNotes
idString
userIdStringThe maker
typeOrderTypeSELL = maker sells XLM; BUY = maker buys XLM
xlmAmountDecimal(20,7)Whole order is traded at once
ngnRateDecimal(14,2)Naira per XLM
paymentMethodsPaymentMethod[]Postgres enum array
termsVarChar(500)?
statusOrderStatusDefault ACTIVE
expiresAtDateTimenow + ORDER_TTL_MINUTES
createdAt / updatedAtDateTime

Lifecycle ​

ACTIVE ──(trade opened)──▶ FILLED ──(trade cancelled, not expired)──▶ ACTIVE
   │
   ├──(maker cancels)────▶ CANCELLED
   ├──(expiresAt passes)─▶ EXPIRED
   └──(maker restricted)─▶ CANCELLED

Concurrency ​

Opening a trade claims the order with:

js
prisma.order.updateMany({ where: { id, status: 'ACTIVE' }, data: { status: 'FILLED' } })

If count is 0, another taker won the race and the request fails with 409.

Nexlm is a peer-to-peer facilitator and never holds customer Naira.