Open app

Build a swap

Markdown

Split and delayed payouts

A swap into XMR can pay its output to several Monero addresses, each with its share, and it can pay at a random time within a window the user chooses instead of as soon as the swap has run. The two can be combined. Both are offered on swaps from any other asset into XMR; an XMR source and a swap to any other asset pay one address, at once.

The quote says what the route offers right now. Read it before you show either option:

Quote field Meaning
payees.maxCount How many addresses an order on this route may pay now. Absent, or 1, when the route pays one (a quote that sends payeeSharesBps always gets payees, with maxCount: 1 on such a route).
payees.expected With payeeSharesBps in the request: each address's estimated amount, in atomic units of XMR, in the order of the shares. null without payeeSharesBps.
delivery.windowsSeconds The windows, in seconds, a create may choose, shortest first. Absent when the route pays at once.

Both depend on what Wagyu has switched on. Do not hard-code them: offer a split only when payees.maxCount is above 1, and a delay only when delivery is present. A create that asks for an option the route does not offer is refused.

#Split a payout

#1. Quote with the shares

Shares are basis points: 10000 is the whole output. Send the shares you will create with as payeeSharesBps, in the order you will name the addresses:

Shell
curl -X POST 'https://api.wagyu.xyz/v2/swaps/quote' \
  -H 'content-type: application/json' \
  -d '{
    "fromChainId": 1,
    "toChainId": 0,
    "fromToken": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
    "toToken": "XMR",
    "fromAmount": "100000000",
    "payeeSharesBps": [7000, 3000]
  }'

payees.expected splits toAmount exactly as the payout will split what it delivers, and is an estimate like toAmount. minDepositUsd is the split's minimum (below).

#2. Create with payees

Send payees instead of toAddress, never both:

Creates a real order
curl -X POST 'https://api.wagyu.xyz/v2/swaps' \
  -H 'content-type: application/json' \
  -d '{
    "fromChainId": 1,
    "toChainId": 0,
    "fromToken": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
    "toToken": "XMR",
    "fromAmount": "100000000",
    "payees": [
      { "address": "<first Monero address>", "shareBps": 7000 },
      { "address": "<second Monero address>", "shareBps": 3000 }
    ]
  }'

The rules, the same for the quote's payeeSharesBps:

  • At most payees.maxCount addresses.
  • Each shareBps is a whole number, at least 100 (1%), and the shares sum to 10000.
  • The addresses are distinct.
  • An integrated address (one with a payment ID) can only be paid alone: send it as toAddress, or use its standard address.

The answer is the order, as for any swap. toAddress is the first payee, and payees lists every address with its shareBps.

A split order has no coinflip bonus: coinflip: true on a create with several payees is ignored, and the order answers coinflipRequested: false and bonusStage: "none". A delayed order to one address keeps it.

#The minimum of a split

Every payee is held to the source chain's minimum. With two payees or more, the order's minimum is that chain's minimum divided by the smallest share, rounded up to the cent. With a $20 minimum, two halves need $40, three shares of 3334/3333/3333 need $60.01, a 90/10 split needs $200, and ten equal shares need $200. Each chain's minimum is on Chains and tokens.

Unlike a quote to one address, a split quote under its minimum is refused: 400 amount_below_minimum, with the split's minimum in minAmountUsd. The create refuses the same amount the same way.

#Each payee's payment

On the owner's read, each entry of payees carries:

Field Meaning
address Where this payee is paid: the address the order named, or the replacement saved for it.
shareBps Its share of the output.
deliveredAtomic What it was paid, in atomic units of XMR, once its payment settled; null before.
txHash The Monero transaction that paid it, once it did.

Without a delivery window, one Monero transaction pays every payee, so they share one txHash. The order completes when that transaction is sent, as an order to one address does.

If one address turns out not to be payable, the order asks the owner for a new one: customerState is action_required with action payout_address, and payeePosition names which entry of payees needs it. Send it with its position:

Shell
curl -X PUT 'https://api.wagyu.xyz/v2/orders/<orderId>/payout-address' \
  -H 'x-session-id: <sessionId>' \
  -H 'content-type: application/json' \
  -d '{ "payoutAddress": "<new Monero address>", "position": 1 }'

position is optional: the order names the payee it is waiting on, and a different position is refused with 409 conflict. The new address cannot be another payee's address or an integrated address. More on replacements in Deposits and refunds.

#What a payee can read

Each payee can follow its own payment without the owner's session: GET /v2/swaps/{id}?verify=<its own address>. The answer is scoped to that payee:

It reads It does not read
Its own expectedOutput, then actualOutput once it was paid The deposit address, the amount asked or sent (depositAddress, fromAmount, depositAmount are absent), the USD value
Its own status: completed once it was paid, even if another payee is still owed Its share, and every other payee
receivingTxHash and its single payees entry: the transaction that paid it The deposit transaction, confirmations, refund details, fills, routing or TWAP
delivery, on a delayed order; its sendBy only while its own payment is still to come Any action: replacing an address or asking a refund needs the owner session

The execution receipts, GET /v2/swaps/{id}/fills, answer 404 to a payee's proof. A payee's read never shows an action the owner must take: while the order waits on the owner, the payee reads plain processing.

On an order to one address, ?verify= works as it always did: see Order lifecycle.

#Delay the payout

To pay at a random time instead of at once, add delivery with one of the quote's delivery.windowsSeconds:

JSON
{ "delivery": { "windowSeconds": 1800 } }
  • The window starts once the swap has run and the XMR is ready to send. The payout goes at a time drawn uniformly at random within it.
  • The order reads processing, at stage sending, while it waits. Its delivery says when the payout will have gone at the latest:
Field Meaning
delivery.windowSeconds The window the order was created with.
delivery.sendBy While the payout waits for its time: the end of the window. null once it is sent, and on an order that is not waiting.

The drawn time itself is never published. An order created without delivery has no delivery field and pays as soon as it can.

#Split and delay together

A split with a window pays each address by its own Monero transaction, each at its own random time within the window, drawn independently. Two payments can land close together; there is no fixed gap, since a fixed gap would itself mark the payments as one order's.

  • Each entry of payees gets its own txHash and deliveredAtomic as its payment is sent.
  • The owner's order stays processing until the last payment, then completes.
  • A payee reading its own payment reads completed once it was paid, and delivery.sendBy only while its own payment is still to come.
  • A payee that cannot be paid does not hold up the others: they are paid on time, and the order asks the owner for that payee's new address.

Separate transactions add no fee: each payment's network fee is paid by Wagyu, as for one payout.

#Refusals

Answer When
400 amount_below_minimum The amount is under the split's minimum. minAmountUsd is that minimum.
400 invalid_request Both or neither of toAddress and payees; more addresses than the route pays now (This route pays a single address, or at most N addresses); a share under 100 or not a whole number; shares that do not sum to 10000; two payees with the same address; an integrated address in a split; an address that is not payable. The message names the field and its position, such as payees[1].address.
400 invalid_request delivery.windowSeconds is not one of the windows the route offers, or the route offers none (delivery is not offered on this route: omit it).
409 conflict PUT /v2/orders/{id}/payout-address names a position other than the payee the order waits on.
400 invalid_request That replacement address is another payee's address, or an integrated address.
404 GET /v2/swaps/{id}/fills read with a payee's address.

Every code is in Errors, limits and retries.

Tip: every page is also plain Markdown, and /llms.txt indexes them for AI tools.