lightninglabs / lightning-terminal

Lightning Terminal: Your Home for Lightning Liquidity
MIT License
501 stars 88 forks source link

Terminal Web counts Loop In as Profit #614

Closed eliotcougar closed 2 months ago

eliotcougar commented 1 year ago

After performing a Loop In, the Terminal Web summary shows obviously wrong data. CSV export table also shows the Looped In amount in the Fee column. It appeared as profit only after the swap server swiped the funds from the address yesterday… image

7/26/2023, 11:20:35 AM | 1899024 | Loop In 1,900,000 sats (swap server) | swap_id=06ddda4c1d2658813739d7f6b00945114faa389ea947edb4da3ed72b946c6fba

Swap address: bc1ptrz6ktle0uk56eq2v3jv9yhq6a6sdr2tdg6ta4d0vfjqswmjkhvqcy6vpp

Expected behavior

Loop In shouldn't be counted as profit.

To reproduce

Do a Loop In, wait for it to complete.

System information litd 0.10.4, with external LND on Windows 10...

levmi commented 1 year ago

Thanks for the report Eliot! Looking into this on our end, will let you know if we need more details.

jamaljsr commented 1 year ago

I have tried to reproduce this and was not able to. I tested on regtest and testnet and the fees were calculated correctly.

Since the fee is pulled directly from loopd, can you check the CLI output of loop listswaps for this swap to see what value is returned for cost_server?

eliotcougar commented 1 year ago

Since the fee is pulled directly from loopd, can you check the CLI output of loop listswaps for this swap to see what value is returned for cost_server?

cost_server for that swap shows as -1899024

PS: Can it be related to taproot?.. It's my first swap using taproot…

jamaljsr commented 1 year ago

Ah ok, that explains where this value is coming from in the UI. I'm not sure if this is related to taproot swaps but that may be a hint. I'll ping the Loop team to see if someone can assist further.

eliotcougar commented 1 year ago

Just wanted to say that I've just updated to 0.10.5... There was a database migration... Then I deleted all cookies and site data for the Terminal Web, reconnected with a new pairing phrase, and let it repopulate the data...

The 1900000 sat profit is still there, and there's the same -1899024 cost_server in the listswaps output...

jamaljsr commented 1 year ago

Thanks for the update. I have spoken with the Loop team and it appears that the cost_server value shouldn't be used in profit calculations. We'll need to implement a fix on the Terminal side to use a different method to determine the cost of a swap. It'll use the amount sent minus the amount received instead.

levmi commented 1 year ago

Hey Eliot, really appreciate the feedback here. We're going to work on getting a fix in for this over the course of the next week or so. Just wanted to let you know that we ack the issue and are prioing a fix, but that's the timeline that we're looking at so that you have full vis and know what to expect next :)

levmi commented 2 months ago

I believe this was fixed on the Loop backend via the following changes. https://github.com/lightninglabs/loop/pull/751 https://github.com/lightninglabs/loop/pull/764 But, let me know if you're still seeing it.