The S&P 500 and the Nasdaq have surged to record-high closes, buoyed by signs of a resolution in the Middle East conflict.