Problem
Active traders need to manually recreate their buy/sell orders every day. This is tedious and time-consuming, especially for users who consistently offer the same trading conditions.
Proposed Solution
Add a /scheduleorder command that creates orders which automatically republish when they expire (not taken).
Command Syntax
/scheduleorder <buy|sell> <amount> <fiat_amount> <fiat_code> <payment_method> [premium]
Example:
/scheduleorder sell 0 10 eur f2f 1
This creates a sell order for 10 EUR via face-to-face with 1% premium, which will auto-republish if not taken.
Implementation Details
1. New Order Field
Add republish_count field to the Order model:
republish_count: { type: Number, default: 0 }
2. New Environment Variable
Maximum number of days an order can be republished. Prevents abandoned orders from republishing forever.
3. Modify jobs/delete_published_orders.js
When processing expired orders:
if (order.republish_count > 0) {
// Republish the order
order.republish_count -= 1;
order.status = "PENDING";
order.expires_at = new Date(Date.now() + EXPIRATION_TIME);
await order.save();
// Publish to channel
} else {
// Normal expiration flow
}
4. Reset Counter on Take
When an order is taken, reset republish_count to REPUBLISH_ORDER_DAYS:
// In takeorder/takebuy/takesell handler
if (order.republish_count !== undefined) {
order.republish_count = parseInt(process.env.REPUBLISH_ORDER_DAYS || "10");
}
This ensures that after a successful trade, the order continues auto-republishing.
User Flow
- User creates:
/scheduleorder sell 0 100 usd bank 2
- Order is published with
republish_count = 10
- Order expires (not taken) → job republishes it,
republish_count = 9
- ... repeats ...
- If
republish_count = 0 and expires → order is deleted normally
- If order is taken at any point →
republish_count resets to 10
Edge Cases
- User wants to stop auto-republish: Add
/cancelschedule <order_id> command to set republish_count = 0
- Order in dispute: Should NOT auto-republish (check status before republishing)
- User changes trading conditions: They cancel and create a new scheduled order
Benefits
- Saves time for active traders
- Increases liquidity in channels (more consistent order availability)
- Self-cleaning: abandoned orders stop after N days
Based on discussion #462
Problem
Active traders need to manually recreate their buy/sell orders every day. This is tedious and time-consuming, especially for users who consistently offer the same trading conditions.
Proposed Solution
Add a
/scheduleordercommand that creates orders which automatically republish when they expire (not taken).Command Syntax
Example:
This creates a sell order for 10 EUR via face-to-face with 1% premium, which will auto-republish if not taken.
Implementation Details
1. New Order Field
Add
republish_countfield to the Order model:2. New Environment Variable
Maximum number of days an order can be republished. Prevents abandoned orders from republishing forever.
3. Modify
jobs/delete_published_orders.jsWhen processing expired orders:
4. Reset Counter on Take
When an order is taken, reset
republish_counttoREPUBLISH_ORDER_DAYS:This ensures that after a successful trade, the order continues auto-republishing.
User Flow
/scheduleorder sell 0 100 usd bank 2republish_count = 10republish_count = 9republish_count = 0and expires → order is deleted normallyrepublish_countresets to 10Edge Cases
/cancelschedule <order_id>command to setrepublish_count = 0Benefits
Based on discussion #462