When the U.S. transferred the canal to Panama in 1999, the waterway’s original locks from 1914 were almost obsolete as they were too narrow for many U.S. Navy ships. Panama embarked on an overhaul to expand canal capacity and boost profitability. It invested more than $5 billion to build larger locks that boosted revenue and the number of ship passages to as many as 36 a day. That sparked its transformation into a vital link for global trade that also triggered investment at U.S. ports to handle the larger tankers going from one coast to the other with oil and liquefied natural gas. The canal now generates some $5 billion in annual revenue. The government keeps about half and the rest covers operating costs and investments.

https://www.wsj.com/world/americas/panama-canal-us-american-history-e79a34f0

It cost about the same to renovate the canal in 1999 as it brings in today in income. Taking inflation into account it cost about $9.47 billion back then in todays dollars. Not a bad return on investment

I guess the moral of the story is you can’t just build something once and assume it’ll be there forever, you have to keep reinvesting over and over to keep up with the times or else people will find other ways around it.