Rigging a simple mechanical/extending/telescopic arm with Control Rig?

Ok I think I’ve found a workaround, I’ve made the whole rig with the same hierarchy and then weight painted everything on UE, then I’ve build the control rig with this two-chain IK.
Is not too elegant, as I had to multiply the scaling of each IK bone with some eye-balled value, and lock each bone axis in order to get the correct compression without any bending or overlapping of meshes.

Here’s the 2 IKs with some wonky multiplication…

If anybody can suggest a more elegant and clean solution would be awesome.