BUG: [TX HISTORY] Transactions history page not handling DOUBLE swap correctly
When doing a double swap eg. LOK --> BNB, on success and when visiting the transactions history page, we can see the internal swap because the system in the background for those swaps will do LOK --> RUNE && RUNE --> BNB. We create 2 distinct events, and Midgard send both of those events, the INBOUND txid will be the same and a way for Bepswap to discover that this was a double swap. UX wise, I think for the end user having only one transaction in the history makes more sense LOK --> BNB. I wouldn't display both event in 2 separate lines as it might confuse the end user that doesn't necesseraly know that we have a swap in RUNE in the middle.
Events from midgard for those:
{
"count":2,
"txs":[
{
"date":1591598720,
"events":{
"fee":"5643660344",
"slip":"2.8364",
"stakeUnits":"0"
},
"height":"41939",
"in":{
"address":"tbnb1tl26hrxlvgmt0atyykxq7920jhfnw0lar2vdvl",
"coins":[
{
"amount":"5887001918",
"asset":"BNB.RUNE-A1F"
},
{
"amount":"22584700000",
"asset":"BNB.LOK-3C0"
}
],
"memo":"SWAP:BNB.BNB::",
"txID":"535F0C1D172EC743E87B0BD65DD986EAA36CCE36A4FFB19D9F5DAB43F8E601AC"
},
"options":{
"asymmetry":"0",
"priceTarget":"0",
"withdrawBasisPoints":"0"
},
"out":[
],
"pool":"BNB.LOK-3C0",
"status":"",
"type":"swap"
},
{
"date":1591598720,
"events":{
"fee":"59155",
"slip":"0.0017",
"stakeUnits":"0"
},
"height":"41939",
"in":{
"address":"tbnb1tl26hrxlvgmt0atyykxq7920jhfnw0lar2vdvl",
"coins":[
{
"amount":"5887001918",
"asset":"BNB.RUNE-A1F"
},
{
"amount":"22584700000",
"asset":"BNB.LOK-3C0"
}
],
"memo":"SWAP:BNB.BNB::",
"txID":"535F0C1D172EC743E87B0BD65DD986EAA36CCE36A4FFB19D9F5DAB43F8E601AC"
},
"options":{
"asymmetry":"0",
"priceTarget":"0",
"withdrawBasisPoints":"0"
},
"out":[
{
"address":"tbnb1vnl4sv4vjn2xw7su88jqdyf2fe2hz2rdd5v437",
"coins":[
{
"amount":"67477918",
"asset":"BNB.BNB"
}
],
"memo":"OUTBOUND:535F0C1D172EC743E87B0BD65DD986EAA36CCE36A4FFB19D9F5DAB43F8E601AC",
"txID":"E81D27AAC7EA77E0A7C784EB763892A692815BFD830351FA55EE027AFA6D6243"
}
],
"pool":"BNB.BNB",
"status":"",
"type":"swap"
}
]
}
Reproduce:
View of the transaction history page when the swap is NOT completed yet, WRONG: we can see depending on the order return by midgard, we display different information, sometimes RUNE as IN and sometimes LOK as IN.
Result when swap is complete: same thing if you refresh the page multiple times, you can get different IN either LOK or RUNE: