Instead, it has become part of a national scandal engulfing the country in corruption, perilous amounts of debt — and a future tethered to China.

Nearly every top Ecuadorean official involved in the dam’s construction is either imprisoned or sentenced on bribery charges. That includes a former vice president, a former electricity minister and even the former anti-corruption official monitoring the project, who was caught on tape talking about Chinese bribes.

Then there is the price tag: around $19 billion in Chinese loans, not only for this dam, known as Coca Codo Sinclair, but also for bridges, highways, irrigation, schools, health clinics and a half dozen other dams the government is scrambling to pay for.

It doesn’t matter whether Ecuador can afford them.

China gets paid either way.

To settle the bill, China gets to keep 80 percent of Ecuador’s most valuable export — oil — because many of the contracts are repaid in petroleum, not dollars. In fact, China gets the oil at a discount, then sells it for an additional profit.

Pumping enough oil to repay China has become such an imperative for Ecuador that it is drilling deeper in the Amazon, threatening more deforestation.