atomicDEX-API icon indicating copy to clipboard operation
atomicDEX-API copied to clipboard

fix(legacy-swap): taker failed spend maker payment marked as failed

Open laruh opened this issue 1 year ago • 5 comments

related to https://github.com/KomodoPlatform/komodo-defi-framework/issues/2175#issuecomment-2292075372

laruh avatar Aug 26 '24 12:08 laruh

Second problem solving approach

If we wouldn't like to do changes in legacy taker swap events/logic and increase backward incompatibility risks, there is an alternative. We can add maker payment spend confirmation right after send_taker_spends_maker_payment in spend_maker_payment taker swap operation.

https://github.com/KomodoPlatform/komodo-defi-framework/blob/5c47ef0f53fce5eb83afc727a5b685a663279f40/mm2src/mm2_main/src/lp_swap/taker_swap.rs#L1787-L1812

If confirmation failed, then also return swap finish command and MakerPaymentSpendFailed event

                return Ok((Some(TakerSwapCommand::Finish), vec![
                    TakerSwapEvent::MakerPaymentSpendFailed(ERRL!("{}", err.get_plain_text_format()).into()),
                ]));

MakerPaymentSpendFailed is not actually correct event in the case of failed maker payment spend confirmation, but in this way we dont do changes in Taker commands and events logic.

In comparison, Maker has taker payment spend confirmation events in MakerSwapEvent: https://github.com/KomodoPlatform/komodo-defi-framework/blob/5c47ef0f53fce5eb83afc727a5b685a663279f40/mm2src/mm2_main/src/lp_swap/maker_swap.rs#L1646-L1648

laruh avatar Aug 28 '24 03:08 laruh

Solved with second approach in this pr https://github.com/KomodoPlatform/komodo-defi-framework/pull/2206

UPD: opened again as we decided to test both approaches https://github.com/KomodoPlatform/komodo-defi-framework/pull/2206#issuecomment-2330539627

one problem with adding confirmation to SpendMakerPayment step is that GUI will not have the tx hash to show to user until tx is confirmed, users like to check tx on chain while it's awaiting confirmations

This pr approach could be preferable

laruh avatar Aug 30 '24 05:08 laruh

@laruh this is still draft, should I review it? I want to check it so that I can close the other PR if there are no problems with the approach here.

shamardy avatar Sep 06 '24 17:09 shamardy

@laruh this is still draft, should I review it? I want to check it so that I can close the other PR if there are no problems with the approach here.

Its almost r2r, I just wanted to fix these notes https://github.com/KomodoPlatform/komodo-defi-framework/pull/2206#pullrequestreview-2281653170 in other approach and cherry pick commit to this branch, as both branches would have the same review notes. (already fixed this https://github.com/KomodoPlatform/komodo-defi-framework/pull/2199/commits/b2446b9432d484996a0c083d3ea0a033f1b8f2d4, just confirmation number is left)

laruh avatar Sep 08 '24 02:09 laruh

@shamardy its r2r. added confirmations here https://github.com/KomodoPlatform/komodo-defi-framework/pull/2199/commits/2c119be42cfc1024fa4e3b8bdf403d988b32dc6f

laruh avatar Sep 08 '24 02:09 laruh

@cipig you tested this https://github.com/KomodoPlatform/komodo-defi-framework/pull/2206 but we opted for a new event instead and implemented in this PR. Can you please check if the issue is resolved here?

shamardy avatar Oct 04 '24 08:10 shamardy

Please open docs issue and add To Test comment to the PR opening comment.

https://github.com/KomodoPlatform/komodo-docs-mdx/issues/351

laruh avatar Oct 04 '24 09:10 laruh