Loan/Repayment messing up Capital Gains

I know Koinly states loans should be categorized as Deposits and repayments as Withdrawals but I think this is incorrect.

For example, if I borrowed 1 BTC and sat on it for 6 months and then repaid the 1 BTC after it went up $20k, why am I being hit with a 20k capital gain? I didn’t gain anything.

Labelling the loan as a deposit assumes I own the coin, and therefore when I withdraw (repay loan) I’m hit with a capital gain/loss.

Which exchange/wallet is this regarding?

How did you import data into this wallet?

All import history was done via CSV

What have you tried to fix this so far?

Labelling Loans as from Pool, and Repayments to Pool. How would this impact things?

Would having [Loan = Deposit] and [Loan Repayment = Lost] work?

Loan = 1 BTC @ $1000

Sold 1 BTC for $1000

Bought back 1 BTC for $800

Lost = 1 BTC worth $800

Remainder = $200 capital gain (assuming no other BTC holdings)

Essentially disposing of the loan at my average cost base and the remainder being my real capital gain or loss?

After much fiddling around…

Having Loan Received set as ‘Airdrop’ or ‘Fork’ @ 0 Cost base (Settings: Treat airdrops/forks as income Disabled) and Having Loan Repayment tagged as ‘Realized P&L’ seems to do the trick with regards to calculating correct capital gains for margin trading imported via manual CSV.

Same question but for stable coins? Do I need to add manual fiat → stablecoins for “borrow” and stablecoins → fiat for repay or is that handled automatically by Koinly?

e.g. is this enough?

  1. Collateralized 40 SOL (Sent to Pool)
  2. Borrowed 1000 USDC
  3. Some days/months later
  4. Repay 1000 USDC
  5. Add manual transaction for 0.5 SOL “Loan Interest” inside the Pool
  6. Remove collateral 40.5 SOL (Received from Pool)

Or am I doing it wrong?

I’m now thinking

Loan Borrowed = Airdrop @ 0 cost
Loan Repayment = Send ‘tagged as Cost’

Should nullify eachother correctly and produce correct capital gains unless I’m mistaken.

My initial example is incorrect as the Deposit doesn’t trigger a gain nor does the ‘Lost’.

Tagging the Loan as Airdrop @ 0 would trigger capital gain once the loan assets are traded; and when disposed of as ‘Cost’, should also trigger a capital gain/loss on the way out.

I tried switching the deposit from borrow to trade with fiat to stablecoin and there’s no difference in tax disposal. I just thought that I may get taxed upon received if it’s not from fiat. But then I read Tax treatment on deposits.

Tax treatment

By default Koinly treats all deposits as investments or purchases at market price (at the time of the transaction). If your deposit has some special tax consideration ex. it is received as Income then you can tag it as such.

https://help.koinly.io/en/articles/3661665-transactions-in-koinly-explained