Consider the case where we are interested in decomposing a continuous and piece-wise linear European payoff function $V \left( S_T \right)$ over $n$ intervals with $n + 1$ node points $S_i$ for $i = 0, 1, \ldots, n$. Without loss of generality, we assume that $S_0 = 0$ and write $V_i$ as short-hand for $V \left( S_i \right)$. We assume that the slope of the payoff function for $S > S_n$ is $x_{n + 1}$.
Take the following steps in order to replicate this payoff:
- Buy zero-coupon bonds with a notional value of $V_0$.
- For each $i \in 1, \ldots n$, buy $x_i = \left( V_i - V_{i - 1} \right) / \left( S_i - S_{i - 1} \right)$ European call options with a strike of $S_{i - 1}$ and sell the same amount withe a strike of $S_i$.
- Buy $x_{n + 1}$ European call options with a strike of $S_n$.
All contracts mature at time $T$.
Applying this to your example, we have $n = 2$ and obtain the following portfolio:
- Buy zero-coupon bonds with a notional value of 30 USD.
- Buy 2 call options with a strike of 0 USD and sell 2 call options with a strike of 10 USD.
- Sell 3 call options with a strike of 10 USD and buy 3 call options with a strike of 30 USD.
- Buy one call option with a strike of 30 USD.
Our net positions are thus:
- Long a zero-coupon bond with with a notional value of 30 USD.
- Long 2 zero-strike call options.
- Short 5 call options with a strike of 10 USD.
- Long 4 call options with a strike of 30 USD.
Note that this decomposition is not unique as you can always apply put/call parity to any of the positions.