The formula
profit = (exit − entry) × units for a long profit = (entry − exit) × units for a short fees = fee rate × units × (entry + exit) return on margin = (profit − fees) ÷ margin
Worked example: $500 of margin at 10x is a $5,000 position, about 0.0653 BTC at 76,600. Exit at 79,800 makes about $208.88 before fees and $203.77 after 0.05% a side, a 40.8% return on the $500 margin from a 4.2% move.
Leverage multiplies the return on margin, not the profit
The profit depends on the size of the position and the move. Leverage only decides how much margin backs it. The same $5,000 position makes the same $208.88 at 2x or at 50x; at 50x the margin is smaller, so the return on margin looks bigger, and the liquidation price is far closer. Check it with the liquidation price calculator.
Fees are on the whole position
Exchange fees are charged on the notional value, not the margin, on the way in and the way out. At 10x a 0.05% fee per side costs about 1% of the margin for the round trip, which is why frequent high-leverage trading leaks money even when the trades break even.