# Calculating the stochastic integral of $\exp(-rt)S_t$

I am currently reading lecture notes which aim to show that if $$S_t = S_0 \exp (\mu t + \sigma W_t)$$ then, under the probability measure $\tilde{\mathbb{P}}$ with density $$\gamma_T = \exp (c W_T - \frac{c^2 T}{2})$$ $e^{-rt} S_t$ ($0 \leq t \leq T$) is a martingale under $\tilde{\mathbb{P}}$ if $$c = - \frac{\mu - r - \frac{\sigma^2}{2}}{\sigma}$$

To prove this, they start by stating that

$$d \left( e^{-rt} S_t \right) = S_t \left[ (\mu + \sigma c - r + \frac{\sigma^2}{2}) dt + \sigma d \tilde{W}_t \right]$$

This is where my confusion arises, since I have tried using Ito's formula to deduce the above differential, but have instead arrived at the following result: $$d \left( e^{-rt} S_t \right) = S_t e^{-rt} \cdot \left[ (\mu + \sigma c - r + \frac{\sigma^2}{2}) dt + \sigma d \tilde{W}_t \right]$$ (I can add my explicit workings for this if neccessary).

Can anyone help me to understand how they have derived their stochastic differential?

Also, what would the definition of a martingale be in this specific context? My understanding of a martingale currently stands as being a stochastic process $X$ for which $\mathbb{E} [X_{t+\delta} | \mathcal{F}_t] = X_t$. I ask because they conclude their proof by saying

... Therefore, since $d \left( e^{-rt} S_t \right) = S_t \sigma d \tilde{W}_t$, we deduce that $e^{-rt} S_t$ is a martingale under the implied measure $\tilde{\mathbb{P}}$.

And I don't see how this conclusion proves the desired result.

$Y_{t}=e^{-rt}S_{t}$

$dY_{t}=d(e^{-rt}S_{t})=-re^{-rt}S_{t}dt+e^{-rt}dS_{t}=(\mu-r)e^{-rt}S_{t}dt+\sigma e^{-rt}S_{t}dW_{t}=(\mu-r)Y_{t}dt+\sigma Y_{t}dW_{t}$

Now we have: $\hat{W}_{t}=\frac{\mu-r}{\sigma}+W_{t}$

so

$dY_{t}=\sigma Y_{t}d\hat{W}_{t}$

and

$Y_{t}=Y_{0}+\int_{0}^{t}\sigma Y_{s}d\hat{W}_{s}$

Since $\sigma Y_{t}$ is $F_{t}$-adapted and $E\big (\int_{0}^{t}\sigma Y_{s}d\hat{W}_{s}\big )^{2}<+\infty$ for every $t>0$ (use Ito isometry to prove that), then stochastic integral with respect to Wiener process of the form:
$\int_{0}^{t}\sigma Y_{s}d\hat{W}_{s}$
Since $Y_{0}$ is constant, stochastic process given by:
$Y_{t}=Y_{0}+\int_{0}^{t}\sigma Y_{s}d\hat{W}_{s}$