Spanish Miser

There once lived in a small town in New Castile a noted miser named Don Manuel Rodriguez. 
His love of money was only equalled by a strong passion for arithmetical problems. 
These puzzles usually dealt in some way or other with his accumulated treasure, and were propounded by him solely in order that he might have the pleasure of solving them himself. 
Unfortunately very few of them have survived, and when travelling through Spain, collecting material for a proposed work on "The Spanish Onion as a Cause of National Decadence," I only discovered a very few. 
One of these concerns the three boxes that appear in the accompanying authentic portrait.

Each box contained a different number of golden doubloons. 
The difference between the number of doubloons in the upper box and the number in the middle box was the same as the difference between the number in the middle box and the number in the bottom box. 
And if the contents of any two of the boxes were united they would form a square number. 

What is the smallest number of doubloons that there could have been in any one of the boxes?

See answer

Math Genius