I had something like this come up as a question. I traded in my old car, bought a new one. I was heading out on vacation, abck in 2 weeks. The dealer wanted to close the deal, get it on the books before month end. So I signed and paid for a car with the intent to pick it up on return from holidays, so why bother registering it until then?
My father-in-law, the insurance salesman, says “who pays if it’s damaged on the lot?” God question. It’s my (brand new, exensive) car and the dealer’s insurance would only kick in if they were negligent. If a hailstorm came along, or a plane fell out of the sky onto it, or some kids broke into it and hotwired it, well, that’s me parking my new car at the dealer’s lot. My problem, my insurance. So I insured it right away.
In the OP’s case, the answer is logical. You contracted to deliver a car in X condition, or X value. You can’t deliver, you make it right. The dealer can be a dick about it, or more likely try to accomodate you; but you agreed on a price of $Y worth of trade-in you meet that price.
Two contracting parties can re-arrange the contract to meet circumstances however they want, provided they both agreee. If they don’t, that’s what courts are for.
They might be happy to take cash of $Z<$Y since cash simplifies their life, but they don’t have to. In a lawsuit, no judge is going to make you find an identcal car. There likely will be no penalties if there is not deliberate intent to ruin the contract. However, he will fix a dollar amount that is fair to both parties.