How are the BKM risk-neutral moments derived?

I've been doing a lot of research on implied volatility skewness, and one of the most commonly cited papers I've come across is "Stock Return Characteristics, Skew Laws, and the Differential Pricing of Individual Equity Options" by G. Bakshi, N. Kapadia, and D. Madan. In it, they price volatility, cubic, and quartic contracts on page 107. They explain their derivation on page 137, but they're very brief about it, and I don't follow it at all. I know it has something to do with equations 2 and 3 on page 106, but it isn't coming together for me. Would someone be able to derive just one of those equations for me explicitly or provide a reference to a site/paper that does?

Thank You

Let's focus on the volatility contract price. Generalisation to cubic and quartic contracts is straightforward.

Following the paper's notations, the evaluation date is $t$ and the (European) contracts all expire at $T = t+\tau$. A volatility contract is specifically associated to the payoff function

$$H[S] = R(t,\tau;S)^2 = \left(\ln S(t+\tau) - \ln S(t) \right)^2 = \left[ \ln \left(\frac{S}{S(t)}\right) \right]^2$$ where we've used the paper's notation $$S(t+\tau) := S$$

According to arbitrage-free pricing theory, the price of a volatility contract should be calculated as $$V(t,\tau) = \mathcal{E}_t^*\left\{ e^{-r \tau} H[S] \right\}$$ where $\mathcal{E}^*_t\{ \cdot \}$ figures an expectation taken under the (risk-neutral) measure $\Bbb{Q}$ associated to the risk-free money market account numéraire, conditional on the information available at $t$.

The key result to conclude is the Carr-Madan formula (see references mentioned in the paper or here), which tells you that - for a sufficiently regular payout function - one can write out the conditional expectation above as $$\mathcal{E}_t^*\left\{ e^{-r \tau} H[S] \right\} = H[\bar{S}] + (S - \bar{S}) H_S[\bar{S}] + \int_{\bar{S}}^\infty H_{SS}[K] C(t,\tau;K) dK + \int_{0}^\bar{S} H_{SS}[K] P(t,\tau;K) dK \tag{3}$$ for any $\bar{S}$.

From the definition of $H[S]$, by differentiating we get \begin{align} H_S[S] &= 2 R(t,\tau;S) \frac{1}{S} \\ H_{SS}[S] &= \frac{2}{S^2}(1-R(t,\tau;S)) \end{align}

Now let's further simplify equation $(3)$ by picking $\bar{S} = S(t)$. This is a convenient choice since it means that terms involving $H[\bar{S}]$ and $H_S[\bar{S}]$ will disappear (because $R(t,\tau;\bar{S})=0$). We are then left with

\begin{align} \mathcal{E}_t^*\left\{ e^{-r \tau} H[S] \right\} &= \int_{S(t)}^\infty \frac{2 \left(1-\ln\left(\frac{K}{S(t)}\right)\right)}{K^2} C(t,\tau;K) dK + \int_{0}^{S(t)} \frac{2\left(1-\ln\left(\frac{K}{S(t)}\right)\right)}{K^2} P(t,\tau;K) dK \\ &= \int_{S(t)}^\infty \frac{2 \left(1-\ln\left(\frac{K}{S(t)}\right)\right)}{K^2} C(t,\tau;K) dK + \int_{0}^{S(t)} \frac{2\left(1+\ln\left(\frac{S(t)}{K}\right)\right)}{K^2} P(t,\tau;K) dK \tag{7} \\ &= V(t,\tau) \end{align}

That's it!