Use Case
I'm building an automated market maker bot for CAT tokens on Dexie. The bot creates 30-60 offers at a time, each sized to specific tiers (e.g. 2.4, 1.2, 0.6, 0.24 XCH). To do this efficiently, I pre-split coins to exact sizes so each offer locks exactly one coin.
The problem is that make_offer doesn't let me specify which coin to use. The wallet's internal coin selector picks automatically, which means:
- I can't control which coin gets locked — the wallet might pick my reserve coin or a coin from the wrong tier
- I have to poll before/after each offer to detect which coin disappeared (adds ~1-5s per offer)
- Coin reuse can occur when creating offers in rapid succession — the wallet picks the same coin twice before it's marked as locked, creating overlapping offers
Current Workaround
Before each offer I snapshot spendable coins via get_xch_coins/get_cat_coins, create the offer, then poll until a coin disappears from the spendable set. This works but is slow and fragile.
Proposed Change
Add an optional coin_ids field to the MakeOffer RPC request:
pub struct MakeOffer {
pub requested_assets: Vec<OfferAmount>,
pub offered_assets: Vec<OfferAmount>,
pub fee: Amount,
#[serde(default)]
pub receive_address: Option<String>,
#[serde(default)]
pub expires_at_second: Option<u64>,
#[serde(default = "yes")]
pub auto_import: bool,
#[serde(default)]
pub coin_ids: Option<Vec<String>>, // <-- NEW: optional specific coins to use
}
When coin_ids is provided, pass them through to select_spends() (or prepare_spends_for_selection()) so the wallet uses exactly those coins instead of auto-selecting. When omitted, behaviour is unchanged.
Why This Should Be Straightforward
The internal plumbing already exists — combine() and split() in coin_management.rs both accept selected_coin_ids: Vec<Bytes32>. The make_offer flow just needs the same pattern: accept optional coin IDs, and if provided, use them instead of calling the auto-selector.
Benefits
- Deterministic offer creation — the caller knows exactly which coin is locked without polling
- Faster batch creation — no need for before/after snapshots between offers
- No coin reuse risk — the caller manages which coins are available
- Enables market maker bots — essential for any automated trading system creating many offers
This would be a huge quality-of-life improvement for anyone building trading bots or automated offer systems on Sage. Happy to help test if a branch is available.
Use Case
I'm building an automated market maker bot for CAT tokens on Dexie. The bot creates 30-60 offers at a time, each sized to specific tiers (e.g. 2.4, 1.2, 0.6, 0.24 XCH). To do this efficiently, I pre-split coins to exact sizes so each offer locks exactly one coin.
The problem is that
make_offerdoesn't let me specify which coin to use. The wallet's internal coin selector picks automatically, which means:Current Workaround
Before each offer I snapshot spendable coins via
get_xch_coins/get_cat_coins, create the offer, then poll until a coin disappears from the spendable set. This works but is slow and fragile.Proposed Change
Add an optional
coin_idsfield to theMakeOfferRPC request:When
coin_idsis provided, pass them through toselect_spends()(orprepare_spends_for_selection()) so the wallet uses exactly those coins instead of auto-selecting. When omitted, behaviour is unchanged.Why This Should Be Straightforward
The internal plumbing already exists —
combine()andsplit()incoin_management.rsboth acceptselected_coin_ids: Vec<Bytes32>. Themake_offerflow just needs the same pattern: accept optional coin IDs, and if provided, use them instead of calling the auto-selector.Benefits
This would be a huge quality-of-life improvement for anyone building trading bots or automated offer systems on Sage. Happy to help test if a branch is available.