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

failed swaps are marked as successful on maker and not refunded

Open cipig opened this issue 1 year ago • 3 comments

I found failed swaps that are shown as successful on maker and not refunded while taker see them as failed and refunds.

example: 722becac-4773-424f-84dc-43981a1c1d98

TakerPaymentSpend (USDT-PLG20) was reverted: https://polygonscan.com/tx/0x8074aa40823c937cde14e6f911c2165c71a9ce58855eaaedf31fb5c8f1f1da1c (idk why and it actually doesn't matter), but maker shows the swap as successful, the relevant part is

      {
         "event" : {
            "data" : {
               "tx_hash" : "8074aa40823c937cde14e6f911c2165c71a9ce58855eaaedf31fb5c8f1f1da1c",
               "tx_hex" : "f9010e8205c38523c3310102830249f0949130b257d37a52e52f21054c4da3450c72f595ce80b8a402ed292bef2789546257ace4a0bc8ee144e23760c31af06cbc48ba382cfcd8e5cab74a4600000000000000000000000000000000000000000000000000000000003dcc505920575ee2a800fdf898eb81c019e218b77645b3455c2dc0870816d66bb2dae9000000000000000000000000c2132d05d31c914a87c6611c10748aeb04b58e8f00000000000000000000000094672df0f5397f338e1ed097ac49555561f93791820136a0683caca390bd8822f4c60d88b38f7dcdf52a8c5eff4a3a7a687b0708a6a7d321a00f967fa5df6560dc34336eaa7c53cef9f3a62c85830cd7fcbdd8f5d29951db73"
            },
            "type" : "TakerPaymentSpent"
         },

this tx was reverted though, so this event should actually be "failed"

the taker shows swap as failed and refunds his takerpayment... the entire swap JSON on taker:

{
   "error_events" : [
      "StartFailed",
      "NegotiateFailed",
      "TakerFeeSendFailed",
      "MakerPaymentValidateFailed",
      "MakerPaymentWaitConfirmFailed",
      "TakerPaymentTransactionFailed",
      "TakerPaymentWaitConfirmFailed",
      "TakerPaymentDataSendFailed",
      "TakerPaymentWaitForSpendFailed",
      "MakerPaymentSpendFailed",
      "TakerPaymentWaitRefundStarted",
      "TakerPaymentRefundStarted",
      "TakerPaymentRefunded",
      "TakerPaymentRefundedByWatcher",
      "TakerPaymentRefundFailed",
      "TakerPaymentRefundFinished"
   ],
   "events" : [
      {
         "event" : {
            "data" : {
               "fee_to_send_taker_fee" : {
                  "amount" : "0.0064774822551744",
                  "coin" : "MATIC",
                  "paid_from_trading_vol" : false
               },
               "lock_duration" : 7800,
               "maker" : "1bb83b58ec130e28e0a6d5d2acf2eb01b0d3f1670e021d47d31db8a858219da8",
               "maker_amount" : "135.1939672913384596660315109431338121848019415055427189903594350267473753509952512534817453761493407",
               "maker_coin" : "BSTY",
               "maker_coin_htlc_pubkey" : "02bc0520be83e8d9d69ac001df8b314d74741b518c4a6f390ac27164595f26b4ca",
               "maker_coin_start_block" : 478850,
               "maker_payment_confirmations" : 1,
               "maker_payment_requires_nota" : false,
               "maker_payment_spend_trade_fee" : {
                  "amount" : "0.002",
                  "coin" : "BSTY",
                  "paid_from_trading_vol" : true
               },
               "maker_payment_wait" : 1712947952,
               "my_persistent_pub" : "02bc0520be83e8d9d69ac001df8b314d74741b518c4a6f390ac27164595f26b4ca",
               "p2p_privkey" : null,
               "started_at" : 1712944832,
               "taker_amount" : "4.05",
               "taker_coin" : "USDT-PLG20",
               "taker_coin_htlc_pubkey" : "02bc0520be83e8d9d69ac001df8b314d74741b518c4a6f390ac27164595f26b4ca",
               "taker_coin_start_block" : 55745831,
               "taker_coin_swap_contract_address" : "9130b257d37a52e52f21054c4da3450c72f595ce",
               "taker_payment_confirmations" : 20,
               "taker_payment_lock" : 1712952632,
               "taker_payment_requires_nota" : false,
               "taker_payment_trade_fee" : {
                  "amount" : "0.048939508067726592",
                  "coin" : "MATIC",
                  "paid_from_trading_vol" : false
               },
               "uuid" : "722becac-4773-424f-84dc-43981a1c1d98"
            },
            "type" : "Started"
         },
         "timestamp" : 1712944832844
      },
      {
         "event" : {
            "data" : {
               "maker_coin_htlc_pubkey" : "031bb83b58ec130e28e0a6d5d2acf2eb01b0d3f1670e021d47d31db8a858219da8",
               "maker_coin_swap_contract_addr" : null,
               "maker_payment_locktime" : 1712960431,
               "maker_pubkey" : "000000000000000000000000000000000000000000000000000000000000000000",
               "secret_hash" : "6dfabe0ac57ab37e578d39d7bfe073d6e447152b",
               "taker_coin_htlc_pubkey" : "031bb83b58ec130e28e0a6d5d2acf2eb01b0d3f1670e021d47d31db8a858219da8",
               "taker_coin_swap_contract_addr" : "9130b257d37a52e52f21054c4da3450c72f595ce"
            },
            "type" : "Negotiated"
         },
         "timestamp" : 1712944834854
      },
      {
         "event" : {
            "data" : {
               "tx_hash" : "c39afa8ef454c94843708fbb73fc7efdc3fa96a8550b27239ab7e3a609cfd6a7",
               "tx_hex" : "f8ac1a852659ef2a258303345094c2132d05d31c914a87c6611c10748aeb04b58e8f80b844a9059cbb000000000000000000000000d8997941dd1346e9231118d5685d866294f59e5b000000000000000000000000000000000000000000000000000000000000145c820136a01d4f3401f068e9f32c18a42e5729a3d396c4a54438b4dcbc8646cdc460a25fdfa03e773d600398122cb2b27e23512251a619970880e450acec4d87d35859d394e4"
            },
            "type" : "TakerFeeSent"
         },
         "timestamp" : 1712944836959
      },
      {
         "event" : {
            "data" : null,
            "type" : "TakerPaymentInstructionsReceived"
         },
         "timestamp" : 1712944837961
      },
      {
         "event" : {
            "data" : {
               "tx_hash" : "1724070e610fff726fa371e8347ff412cafadae33492f0824639ba825d344291",
               "tx_hex" : "0100000005b4e068335ba1370c7b905679fc5b4bbf0aaeda4a4a251eb9c5147dfbb82ffe85000000006a47304402202be657b896144f448b988606db32c8fb84ce44e365aedea196cfe29e7b3754a5022009bc1a4f7ccb365de9ecbd28ce65ec6f9f628d02ae157c27f106a0641772ac150121031bb83b58ec130e28e0a6d5d2acf2eb01b0d3f1670e021d47d31db8a858219da8ffffffff6d6ca1c3c0ccfed0983b893f7d0a6461a99baf4b0196ee7bfc884be3555eea20000000006a4730440220268dfd46fea05c48406c2fa820d9a66c5e214da8a2db8e0de5be4676f2dbc2fb02206eddf23f36b76326bec88d95101c5ae48fc1f3a833b82941db9b9844016aeb110121031bb83b58ec130e28e0a6d5d2acf2eb01b0d3f1670e021d47d31db8a858219da8fffffffff5bd02c71e2a747727bf1bc2582526610157d98158f5c99c7fc8cc79989e21d3020000006a4730440220040d013daf922a4cab4fd4ffd331fe4b4729044cd42fbfecab5736dfae4a159302206da03c455fb42cd8752ba4fe6f8e799f8e2f2f99fac65ae5d3de286f073739020121031bb83b58ec130e28e0a6d5d2acf2eb01b0d3f1670e021d47d31db8a858219da8ffffffffeacf733c2b1abc067b2b280e65e6c0c4509bc53ee3408fba3233ac1eee631015000000006a47304402201c9f228caefafe2a1e34cfc20f0adfa0f635a8a6dc01015b96155468204c28c802205b48ec7a87d218fbcf79e86a11efcde17b3d1e9137ac7f5d5441aaf2bd3b77100121031bb83b58ec130e28e0a6d5d2acf2eb01b0d3f1670e021d47d31db8a858219da8ffffffffe761b071c232d8e54c309ef8cd42b545ea9ab8c3b0c3cfb749059f79a50b353b000000006b483045022100bda82f5039b97903dd6c79e3a15acae3b39f56173c26e5b9d2d3226f5039cd0002206ac4a885718341ea3d9e13d02914b1820497bcb737537b86b379b0d327fabb8d0121031bb83b58ec130e28e0a6d5d2acf2eb01b0d3f1670e021d47d31db8a858219da8ffffffff03799fd1250300000017a914bd801ba1b8704a194b5a67a43fb462702ea302e0870000000000000000166a146dfabe0ac57ab37e578d39d7bfe073d6e447152ba1119e8d000000001976a914c3f710deb7320b0efa6edb14e3ebeeb9155fa90d88acc6761966"
            },
            "type" : "MakerPaymentReceived"
         },
         "timestamp" : 1712944837962
      },
      {
         "event" : {
            "type" : "MakerPaymentWaitConfirmStarted"
         },
         "timestamp" : 1712944837963
      },
      {
         "event" : {
            "type" : "MakerPaymentValidatedAndConfirmed"
         },
         "timestamp" : 1712945472027
      },
      {
         "event" : {
            "data" : {
               "tx_hash" : "4db0f2855a38c5dadac835225b2fba69fcdd3850d0ee0db35bf45e0e0110336e",
               "tx_hex" : "f9012c1c8525c0c9691f830249f0949130b257d37a52e52f21054c4da3450c72f595ce80b8c49b415b2aef2789546257ace4a0bc8ee144e23760c31af06cbc48ba382cfcd8e5cab74a4600000000000000000000000000000000000000000000000000000000003dcc50000000000000000000000000c2132d05d31c914a87c6611c10748aeb04b58e8f00000000000000000000000098298409c949135eed89233d04c2cfef984baff56dfabe0ac57ab37e578d39d7bfe073d6e447152b0000000000000000000000000000000000000000000000000000000000000000000000000000000066199538820135a087e70811fe2eb8c086e21b0506b3e90dcfcc27bc62a97cf36f335bd7b6ce316da07e044832952eff96b600a16b05376a47b37cc8fef68e308a739082a57626d411"
            },
            "type" : "TakerPaymentSent"
         },
         "timestamp" : 1712945626265
      },
      {
         "event" : {
            "data" : {
               "error" : "taker_swap:1698] !taker_coin.wait_for_confirmations: eth:4631] Timeout: eth:4631] Waited too long until 1712952632 for payment tx: 4db0f2855a38c5dadac835225b2fba69fcdd3850d0ee0db35bf45e0e0110336e, for coin:USDT-PLG20, to be confirmed!"
            },
            "type" : "TakerPaymentWaitConfirmFailed"
         },
         "timestamp" : 1712953089183
      },
      {
         "event" : {
            "data" : {
               "wait_until" : 1712956332
            },
            "type" : "TakerPaymentWaitRefundStarted"
         },
         "timestamp" : 1712953089185
      },
      {
         "event" : {
            "type" : "TakerPaymentRefundStarted"
         },
         "timestamp" : 1712953089187
      },
      {
         "event" : {
            "data" : {
               "tx_hash" : "7f779b72c7141305343ccf786506d297bab40bdefa144cacc567eef412b3ef34",
               "tx_hex" : "f9010c1d8564fe2e00e6830249f0949130b257d37a52e52f21054c4da3450c72f595ce80b8a446fc0294ef2789546257ace4a0bc8ee144e23760c31af06cbc48ba382cfcd8e5cab74a4600000000000000000000000000000000000000000000000000000000003dcc506dfabe0ac57ab37e578d39d7bfe073d6e447152b000000000000000000000000000000000000000000000000c2132d05d31c914a87c6611c10748aeb04b58e8f00000000000000000000000098298409c949135eed89233d04c2cfef984baff5820135a0f22f850b4e2e28c0edd768404e74bb8a18f21f36a66ae23e88c47a680759683ba00ce594eb9f718b5d84d71496c0804d5178483b85bd63e989f981de39e502c7b1"
            },
            "type" : "TakerPaymentRefunded"
         },
         "timestamp" : 1712953091972
      },
      {
         "event" : {
            "type" : "TakerPaymentRefundFinished"
         },
         "timestamp" : 1712953091974
      },
      {
         "event" : {
            "type" : "Finished"
         },
         "timestamp" : 1712953091975
      }
   ],
   "gui" : "Komodo Wallet 0.9.0 Android; BT=1706085862",
   "maker_amount" : "135.1939672913384596660315109431338121848019415055427189903594350267473753509952512534817453761493407",
   "maker_coin" : "BSTY",
   "maker_coin_usd_price" : "0.019787",
   "mm_version" : "2.0.0-beta_b0fd99e",
   "my_order_uuid" : "722becac-4773-424f-84dc-43981a1c1d98",
   "success_events" : [
      "Started",
      "Negotiated",
      "TakerFeeSent",
      "TakerPaymentInstructionsReceived",
      "MakerPaymentReceived",
      "MakerPaymentWaitConfirmStarted",
      "MakerPaymentValidatedAndConfirmed",
      "TakerPaymentSent",
      "TakerPaymentSpent",
      "MakerPaymentSpent",
      "Finished"
   ],
   "taker_amount" : "4.05",
   "taker_coin" : "USDT-PLG20",
   "taker_coin_usd_price" : "1.0002",
   "type" : "Taker",
   "uuid" : "722becac-4773-424f-84dc-43981a1c1d98"
}

main problem is that those swaps are hard to find... i found them by looking at reverted txes of our PLG20 swap contract: https://polygonscan.com/txs?a=0x9130b257d37a52e52f21054c4da3450c72f595ce&f=1 (the ones with receiverSpend), then checked if it's one of my addresses and if so searched all swap JSON files on that node for the txid

refunding is also not trivial, need to edit the swap JSON, remove all events after MakerPaymentSent and call revover_funds manually... for the above swap, it worked fine:

curl -s --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"recover_funds_of_swap\",\"params\":{\"uuid\":\"722becac-4773-424f-84dc-43981a1c1d98\"}}" | json_pp
{
   "result" : {
      "action" : "RefundedMyPayment",
      "coin" : "BSTY",
      "tx_hash" : "40c6136157188fe7c590e76cf7ffe360f8d0fcefdef2cd59786cb19656a9aa04",
      "tx_hex" : "01000000019142345d82ba394682f09234e3dafaca12f47f34e871a36f72ff0f610e07241700000000b647304402205604bed69015ff9b986691c7a277454a0ba7ab1fa65d5314ad633a58c9edb00e02202dc0b22e62dcc227a24b905e810161a7cc85017efcfbeb2698428b036b5060ea01514c6b6304afb31966b17521031bb83b58ec130e28e0a6d5d2acf2eb01b0d3f1670e021d47d31db8a858219da8ac6782012088a9146dfabe0ac57ab37e578d39d7bfe073d6e447152b882102bc0520be83e8d9d69ac001df8b314d74741b518c4a6f390ac27164595f26b4caac68feffffff013992ce25030000001976a914c3f710deb7320b0efa6edb14e3ebeeb9155fa90d88ac06eaa066"
   }
}

cipig avatar Jul 24 '24 12:07 cipig

I think there is something in the code:

here in spend_taker_payment() we create a tx spending the maker payment tx. Then in the same function we create next MakerSwapCommand::ConfirmTakerPaymentSpend command. From the command name we can see that it was supposed we must wait for the spend tx confirmation. However when MakerSwapCommand::ConfirmTakerPaymentSpend runs it calls confirm_taker_payment_spend() and this function always waits only for the payment tx (not for spend tx).

So I believe in fact we do not wait for spend tx confirmation so if it is reverted for any reason we won't know about that and mark MakerSwap as finished

dimxy avatar Jul 24 '24 17:07 dimxy

However when MakerSwapCommand::ConfirmTakerPaymentSpend runs it calls confirm_taker_payment_spend() and this function always waits only for the payment tx (not for spend tx).

Wow, this is bad, It was changed by me in the past here https://github.com/KomodoPlatform/komodo-defi-framework/pull/1724 and has not been catched at all for a long time. Will fix it straight away.

shamardy avatar Jul 25 '24 00:07 shamardy

@cipig this should be fixed here https://github.com/KomodoPlatform/komodo-defi-framework/pull/2176 , please close this issue once this is confirmed as fixed.

shamardy avatar Jul 29 '24 14:07 shamardy

following swap failed on maker on takerpaymentspend it's marked as failed and refund loop started, so this issue is fixed

      {
         "event" : {
            "data" : {
               "tx_hash" : "c122bb3bcac2d600f3de5bd3989e2315ce420479bfef7a181710912e5aab849f",
               "tx_hex" : "01f90203388203b2843b9aca008301adb094edc5b89fe1f0382f9e4316069971d90a0951db3180b8c49b415b2a2ea79882c150c4d88d71c5173b482095edb14e6f60ec9ef31d00ecf4fa6ae42600000000000000000000000000000000000000000000003612229bb655014c4000000000000000000000000043c934a845205f0b514417d757d7235b8f53f1b9000000000000000000000000df38dd108bab50da564092ad0cd739c4634d963cbd3078450e39983da0d64cc658dbdbda62091efc0000000000000000000000000000000000000000000000000000000000000000000000000000000066be3b74f8d5f8bc9443c934a845205f0b514417d757d7235b8f53f1b9f8a5a0360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbca01222b3f0a1c0f03a4db7cfafb70e6e5ad26b7489d340be568f034c0e985d43eda0d7abb519c40da78118c826ff0cf8d78d7ccff62119a8f82182e200e3bfc5cedfa0bf08780af8d1d576d3c7b9d81258bc8db447bf5d943b638dc6bdf34efc316a40a0b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103d694ba5fe23f8a3a24bed3236f05f2fcf35fd0bf0b5cc080a0d2a6525f4291dc8c1ee2378c0424408704ece31030ab5a87b0424afe1e1b9486a0400dde5bca2e3cd973817790dd22a8e70554547f4d736f2d9c883a8081987568"
            },
            "type" : "TakerPaymentReceived"
         },
         "timestamp" : 1723735351515
      },
      {
         "event" : {
            "type" : "TakerPaymentWaitConfirmStarted"
         },
         "timestamp" : 1723735351518
      },
      {
         "event" : {
            "type" : "TakerPaymentValidatedAndConfirmed"
         },
         "timestamp" : 1723735366672
      },
      {
         "event" : {
            "data" : {
               "error" : "maker_swap:1110] !taker_coin.send_maker_spends_taker_payment: Eth transaction type not supported"
            },
            "type" : "TakerPaymentSpendFailed"
         },
         "timestamp" : 1723735366855
      },
      {
         "event" : {
            "data" : {
               "wait_until" : 1723754591
            },
            "type" : "MakerPaymentWaitRefundStarted"
         },
         "timestamp" : 1723735366856
      },
      {
         "event" : {
            "type" : "MakerPaymentRefundStarted"
         },
         "timestamp" : 1723735366857
      }

cipig avatar Aug 15 '24 15:08 cipig

i have to reopen this issue because i found the same problem, now on taker: image but taker couldn't spend makerpayment, tx was reverted: https://polygonscan.com/tx/0x5e8ade242bb51b9312476cce75445a9540b1e50b0099a1d72d89f1fe36821d5f so swap actually failed, but taker shows it as successful with maker payment spend fine

      {
         "event" : {
            "data" : {
               "tx_hash" : "5e8ade242bb51b9312476cce75445a9540b1e50b0099a1d72d89f1fe36821d5f",
               "tx_hex" : "01f901a381898217518506fc23ac2483013880949130b257d37a52e52f21054c4da3450c72f595ce80b8a402ed292bc3030e54fc7144ccb337d246aa21a2b0386e0658db330b507b6620d6e1b8e3b40000000000000000000000000000000000000000000000029ecb7dcd35fca77f23bbe758e95eaeba4df52f70334e6e93e0bf64b16b04e6a81bac942211ded4e30000000000000000000000008f3cf7ad23cd3cadbd9735aff958023239c6a063000000000000000000000000df38dd108bab50da564092ad0cd739c4634d963cf893f87a948f3cf7ad23cd3cadbd9735aff958023239c6a063f863a0baab7dbf64751104133af04abc7d9979f0fda3b059a322a8333f533d3f32bf7fa041587256da2d7733d0860c4b69f4f40974a681485f4398a35b4f3cfff44f9abca0b899ff6e1bfd9838a15242d3f328080cc178c6f40679e41fae6092c1ddeeca55d694490e379c9cff64944be82b849f8fd5972c7999a7c080a0d5cd99813f05b34495c0c846dce9f1b798dc3e6da65e0aab8812de87290d5c91a016680d5139e0a3846d7e5f970bfd9c5159df7fedfd6f89455b678bbbd943be1f"
            },
            "type" : "MakerPaymentSpent"
         },
         "timestamp" : 1723750222682
      },
      {
         "event" : {
            "type" : "Finished"
         },
         "timestamp" : 1723750222683
      }

cipig avatar Aug 15 '24 19:08 cipig

@cipig I will start with this comment https://github.com/KomodoPlatform/komodo-defi-framework/issues/2175#issuecomment-2291580387 as this error Eth transaction type not supported is related to new code changes, I want to know what coin was used by taker / for taker payment to check why send_maker_spends_taker_payment failed.

shamardy avatar Aug 16 '24 01:08 shamardy

c.c. @dimxy https://github.com/KomodoPlatform/komodo-defi-framework/issues/2175#issuecomment-2292583764

shamardy avatar Aug 16 '24 01:08 shamardy

@cipig I will start with this comment #2175 (comment) as this error Eth transaction type not supported is related to new code changes, I want to know what coin was used by taker / for taker payment to check why send_maker_spends_taker_payment failed.

taker coin was MOVR, but that doesn't really matter... the problem is the same that was fixed in https://github.com/KomodoPlatform/komodo-defi-framework/pull/2176, but this time the fix is needed on taker side, the PR fixed it for maker

cipig avatar Aug 16 '24 02:08 cipig

taker coin was MOVR, but that doesn't really matter... the problem is the same that was fixed in https://github.com/KomodoPlatform/komodo-defi-framework/pull/2176, but this time the fix is needed on taker side, the PR fixed it for maker

I understand, Eth transaction types were added in the last release and I wanted to know why Eth transaction type not supported error occurred. Will debug/check it now.

shamardy avatar Aug 16 '24 02:08 shamardy

Were you trying/testing Eip1559 fees for this transaction https://github.com/KomodoPlatform/komodo-defi-framework/issues/2175#issuecomment-2291580387 @cipig ?

shamardy avatar Aug 16 '24 02:08 shamardy

I understand, Eth transaction types were added in the last release and I wanted to know why Eth transaction type not supported error occurred. Will debug/check it now.

It didn't occur here. I tried to swap MOVR for DAI-PLG20 as taker.. makerpayment (DAI-PLG20) was sent by maker, but taker failed to spend it (tx reverted because of too low gas limit) and taker still showed swap as successful... that is the problem... same as in the initial issue, where the error was on maker, now it's on taker, maker side was already fixed

cipig avatar Aug 16 '24 02:08 cipig

It didn't occur here. I tried to swap MOVR for DAI-PLG20 as taker.. makerpayment (DAI-PLG20) was sent by maker, but taker failed to spend it (tx reverted because of too low gas limit) and taker still showed swap as successful... that is the problem... same as in the initial issue, where the error was on maker, now it's on taker, maker side was already fixed

I understand again :), I am trying to debug the first one first then will move to this one https://github.com/KomodoPlatform/komodo-defi-framework/issues/2175#issuecomment-2292075372 . Although this https://github.com/KomodoPlatform/komodo-defi-framework/issues/2175#issuecomment-2291580387 might not be of importance to you as maker payment could be refunded, I want to know why Eth transaction type not supported happened to also make similar swaps to not fail.

shamardy avatar Aug 16 '24 02:08 shamardy

I understand again :), I am trying to debug the first one first then will move to this one #2175 (comment) . Although this #2175 (comment) might not be of importance to you as maker payment could be refunded, I want to know why Eth transaction type not supported happened to also make similar swaps to not fail.

the first one is not important, @dimxy is already at it... it comes from https://github.com/KomodoPlatform/komodo-defi-framework/pull/2170... he will fix that problem

i actually used that comment to confirm that the issue on maker was resolved :-)

but 10 minutes later i detected that the same issue exists on taker too and reopened this issue

cipig avatar Aug 16 '24 02:08 cipig

but 10 minutes later i detected that the same issue exists on taker too and reopened this issue

It's not the same issue even so it appears to be :)

We always made swaps successful on taker side once the spending transaction is broadcasted since it was assumed that it should never fail at this point. I will check why it was reverted, maybe it's a gas estimation issue.

shamardy avatar Aug 16 '24 02:08 shamardy

We always made swaps successful on taker side once the spending transaction is broadcasted since it was assumed that it should never fail at this point. I will check why it was reverted, maybe it's a gas estimation issue.

Yes, the reason why it was reverted is gas limit... i reproduced later... then i increased gas limit and tx was not reverted any more... but the problem is that taker marked the swap as successful even though he was not able to spend makerpayment.. i had to edit the swap json files on taker, remove the makerpaymentspend event (that was wrongfully marked successful), then i could call recover_funds_of_swap on taker and make it to retry spending, which then succeeded:

{
   "result" : {
      "action" : "SpentOtherPayment",
      "coin" : "DAI-PLG20",
      "tx_hash" : "ecedd23d5bc1b71baf1643b2d5854a7d0ae401e9dbf1e2c4c39bf058c4ee70dc",
      "tx_hex" : "01f901a381898217588506fc23ac2083015f90949130b257d37a52e52f21054c4da3450c72f595ce80b8a402ed292bc3030e54fc7144ccb337d246aa21a2b0386e0658db330b507b6620d6e1b8e3b40000000000000000000000000000000000000000000000029ecb7dcd35fca77f23bbe758e95eaeba4df52f70334e6e93e0bf64b16b04e6a81bac942211ded4e30000000000000000000000008f3cf7ad23cd3cadbd9735aff958023239c6a063000000000000000000000000df38dd108bab50da564092ad0cd739c4634d963cf893f87a948f3cf7ad23cd3cadbd9735aff958023239c6a063f863a041587256da2d7733d0860c4b69f4f40974a681485f4398a35b4f3cfff44f9abca0b899ff6e1bfd9838a15242d3f328080cc178c6f40679e41fae6092c1ddeeca55a0baab7dbf64751104133af04abc7d9979f0fda3b059a322a8333f533d3f32bf7fd694490e379c9cff64944be82b849f8fd5972c7999a7c080a06d0d7a61124b92b13debad2f48987d42f64f2b4b4ffa9fbc57b78fc5eddc6e5fa004b10d67c8388e4e98a02682d3520deb8ad922834b24f42651db6287fbfdcfd8"
   }
}

but a normal user will not be able to do this tricks in case it happens to him

cipig avatar Aug 16 '24 02:08 cipig

but a normal user will not be able to do this tricks in case it happens to him

Agreed, we should make sure that execution was successful after broadcasting the spend transaction. @laruh can you please take care of this in the next sprint as it might be needed in v2 swaps as well. Please open a PR that fixes this in legacy swaps independent of the v2 swaps PR.

shamardy avatar Aug 16 '24 03:08 shamardy

It didn't occur here. I tried to swap MOVR for DAI-PLG20 as taker.. makerpayment (DAI-PLG20) was sent by maker, but taker failed to spend it (tx reverted because of too low gas limit) and taker still showed swap as successful... that is the problem... same as in the initial issue, where the error was on maker, now it's on taker, maker side was already fixed

I understand again :), I am trying to debug the first one first then will move to this one #2175 (comment) . Although this #2175 (comment) might not be of importance to you as maker payment could be refunded, I want to know why Eth transaction type not supported happened to also make similar swaps to not fail.

'Eth transaction type not supported' error occurs because of an issue with max_eth_tx_type coin setting. I tried to implement it that it could be obtained from the platform coin config (so no need to set it for each token) but it currently does not work if a token is initialised with "enable_eth_with_tokens".

dimxy avatar Aug 16 '24 06:08 dimxy

https://github.com/KomodoPlatform/komodo-defi-framework/pull/2206 fixes the problem on taker side

cipig avatar Aug 29 '24 13:08 cipig