Why are double-swap THOR.RUNE outbound events emitted?
https://gitlab.com/thorchain/thornode/-/blob/v1.120.2/x/thorchain/swap_current.go#L83-94
if isDoubleSwap {
[...]
tx.Coins = common.Coins{common.NewCoin(common.RuneAsset(), amt)}
tx.Gas = nil
swapEvt.OutTxs = common.NewTx(common.BlankTxID, tx.FromAddress, tx.ToAddress, tx.Coins, tx.Gas, tx.Memo)
https://gitlab.com/thorchain/thornode/-/blob/v1.120.2/x/thorchain/swap_current.go#L137-139
if !evt.OutTxs.IsEmpty() {
outboundEvt := NewEventOutbound(evt.InTx.ID, evt.OutTxs)
if err := mgr.EventMgr().EmitEvent(ctx, outboundEvt); err != nil {
ctx.Logger().Error("fail to emit an outbound event for double swap", "error", err)
As an example, during a streaming swap
https://thornode-v1.ninerealms.com/thorchain/block?height=12552547
the DAC21EC796C91F30BA35470727C50BF82A315288F57260508B8697676FE416D4
"outbound" event between the two "swap" events repeats the "48816764400 THOR.RUNE" amount from the first swap event's emit_asset
.
In Flipside, \
SELECT block_id, reftable.*
FROM (thorchain.defi.fact_outbound_events AS reftable INNER JOIN thorchain.core.dim_block
ON reftable.dim_block_id = dim_block.dim_block_id)
WHERE in_tx = 'DAC21EC796C91F30BA35470727C50BF82A315288F57260508B8697676FE416D4'
ORDER BY block_id DESC
returns 1 ETH/USDC outbound event and 141 THOR.RUNE outbound events, while
https://thornode-v1.ninerealms.com/thorchain/tx/status/DAC21EC796C91F30BA35470727C50BF82A315288F57260508B8697676FE416D4
shows only a single ETH/USDC out_txs
.
(For other analytics, double-swap intermediate THOR.RUNE outbound events can obscure actual affiliate fee THOR.RUNE outbound events, for example.)
For context I note that while !2438 (merged) 'Outbound events as they happen' rearranged the code's position,
the OutTxs code appears to originate from these MRs:
!1745 (merged) '[bugfix] strict target asset swap references'
#484 (closed) '[fix] emit an outbound event for double swap'
!963 (merged) '484-issue emit an outbound event for double swap'.
Why was a THOR.RUNE outbound desired for a double-swap, and are they still desirable now?
If not of benefit, I propose removing the swapEvt.OutTxs lines from swap_current.go
.
(Though keeping for instance the tx.Coins line above as it's relevant for the second half of the double-swap.)
Specifically: !3136 (merged)
'Remove double-swap intermediate outbound event'.