It is a simple problem if you look at what you have shared, though the solution is not simple.
The challenge of retaining employees
The employees are getting better offers, so they are leaving. How can you retain them? By paying market rate salaries.
Addressing salary issues
If you are saying that the customers are not paying you better rates, then either you are in the wrong market or your operations are inefficient. There is no other reason why others are able to pay good salaries and you are not.
Retaining talent in smaller software companies
For smaller software companies, retaining good people has always been a problem. They take freshers and train them, but as soon as they are able, they switch to better companies paying more. The solution is in business and operations, which should enable you to pay salaries properly. There is nothing else that will matter really.
If you are thinking of some convoluted ways like bonds and the likes, it will not work.