Lilian Tintori, center, wife of jailed opposition leader Leopoldo Lopez greets supporters during a campaign rally in Caracas, Venezuela. (AP /Fernando Llano)

After 15 years dominated by crushing electoral defeats, the Venezuelan opposition is set to win the popular vote in this Sunday’s congressional elections. The causes of this reversal are obvious: widespread food shortages, high inflation, rising poverty — in short, the worst recession in Venezuela on record.

What’s less obvious is why, after a long and lucrative oil boom, Venezuela finds itself so deep in crisis. Certainly, the oil bust is partly responsible. Since 2012, Venezuela’s oil export earnings have fallen by more than half, from $94 billion to $41 billion —the largest three-year drop in Venezuela’s oil-producing history.

But that isn’t the whole story. A crisis of this magnitude was avoidable, and not just avoidable in the far-fetched, if-Venezuela-were-Norway, if-the-oil-windfall-had-been-better-managed-all-along sense. President Nicolás Maduro could have headed off much of the crisis eight or twelve or twenty-four months ago, even as the downturn began, with the congressional election in sight.

So why didn’t he?

To see why, consider the needed policy change. Venezuela has long subsidized imports by allowing importers to buy dollars on the cheap. This meant that, for years, Venezuelan importers could purchase $10 from the government for about $7 worth of Bolivars (the Venezuelan currency). The importers then had to spend their bargain-basement $10 on foreign goods, bring the goods to Venezuela, and sell them to Venezuelan consumers for, say, $9 — the maximum price allowed by the government. This was probably not the most efficient way for the government to hand $2 to importing firms and $1 to consumers. But under former Venezuelan president Hugo Chávez, the system was at least minimally functional.

Under Maduro, Chávez’s successor and the current president of Venezuela, that minimal functionality broke down. Instead of selling $10 for $7, Maduro’s government now sells $10 for about a dime’s worth of Bolivars — and then caps the retail price of a $10 import at fifteen cents. This gives an importer two options. If she follows the rules, she spends a dime for a product she can sell for 15 cents. Great. If she cheats, she spends a dime to buy $10, never imports anything and keeps the $9.90. Sure, some people cheated under the old system: that same importer could have bought $10 for $7 and never imported anything, pocketing the $3 profit instead of the $2 she’d make by following the rules. But cheating is costly and, as it turns out, many more importers will break the rules for an extra 9,850 percent profit than for an extra 14 percent. Economist Francisco Rodríguez estimates that, of approximately $40 billion dollars Maduro sold to importers over the past year, only $20 billion translated into goods sold domestically. The rest was stolen.

These extreme price and currency exchange controls contribute not only to shortages but also to runaway inflation. Between the oil-price free-fall and the import subsidy, Maduro’s government found itself running out of money. To deal with this, it printed more. Printing money helped for a while. But at some point, printing money pushes up prices faster than it boosts the government’s spending power. This rarely happens; normally, if the government prints a dollar, prices go up by less than a dollar, and that’s good for the government budget. The Maduro government, in contrast, has printed money so fast that real government spending has actually been declining for most of 2015.

The Venezuelan public senses that Maduro’s program of import subsidies and price controls isn’t working. In a recent poll, only 13 percent of respondents said that the import subsidy benefits society, and the majority — (57 percent) said they’d be as well off or better off if the government were to double prices and eliminate shortages. Hugo Chávez understood this, too, which is why he was always careful to limit the gap between controlled prices and market prices. Maduro’s party would almost certainly have won more seats in this Sunday’s election if he had followed Chávez’s lead. Instead, Maduro broke with el comandante against the ruling party’s electoral interests.

Experts on Venezuelan politics sometimes chalk this up to ignorance, citing “a breakdown of rationality” and “magical thinking.” But following the money points elsewhere: to the business people, military officers, and other “importers” making billions by buying $10 for a dime. These powerful elites have a big stake in Maduro’s dysfunctional exchange and price controls.

One might ask why the arbitrage lobby would double down on a policy that leads to a loss at the polls; surely they understood that an opposition victory would likely shut down the arbitrage party. Maybe rents were so astronomical over the last couple of years that they were worth more than moderate gains over a longer period. Maybe the arbitrageurs faced a coordination problem; together they would have preferred a more sensible policy, but no single rentista wanted to advocate for change on her own. Or maybe they didn’t think anything they could do would save the government’s majority in the National Assembly once oil prices tanked, in which case their best strategy was to get while the getting was good.

In any case, the arbitrage lobby’s gains will be Maduro’s loss this Sunday.