WITH the price of oil at record highs over the past few years, oil-exporting countries have enjoyed a bonanza. So the last thing you might expect to be scarce in Venezuela is foreign exchange. But for mysterious reasons, dollars are in short supply—and that threatens slowly to strangle the economy.

Hugo Chávez, the country's left-wing president, imposed exchange controls back in 2003, during a crippling strike by the management and workers of Petróleos de Venezuela (PDVSA), the state oil company. But he also fixed the exchange rate, from 2005 at 2.15 to the dollar even though inflation has since ranged from 14% to 31% a year. This triggered an import boom.

The exchange-control board, known as Cadivi, never supplied all the hard currency the economy required (of the $38.4 billion spent on imports in 2009, only $22.3 billion came from Cadivi, for example). But until recently, the government tolerated a parallel foreign-exchange market known as the permuta, which involved trading government bonds. These could be bought in bolívars and sold for dollars, or vice versa, through brokerage houses. The relation between the two prices became the free-market exchange rate.

When the oil price plummeted in late 2008 Venezuela's economy slumped. The price recovered swiftly, but Venezuela did not: the economy shrank by 3.3% last year and has not yet returned to growth. In January Mr Chávez ordered a surprise devaluation. His officials predicted that the parallel exchange rate would fall, and inflation with it. But even at the new official rate of 4.3 to the dollar (except for priority imports, such as food and medicines, at 2.6), there were not enough dollars to satisfy the market. The parallel dollar rate shot up by around a third.

Blaming “speculators”, the government closed down the permuta market in May. About a third of the country's brokerage houses were raided and accused of acting illegally. The directors of the biggest, Econoinvest, are in jail, pending trial on fraud charges. Declaring that the country had no need of brokers, Mr Chávez announced the creation of a government-run bourse to put an end to capitalist speculation.

In place of the permuta, the government set up a bond-trading system run by the Central Bank and called SITME. The new system sells dollars at 5.3 bolívars, but is providing less than a third of the amount formerly bought in the parallel market and less than half that required last year by importers. On the black market, a dollar now costs around nine bolívars.

The underlying problem seems to be falling, or at least stagnant, oil production and the depletion of Venezuela's foreign-currency reserves. The government periodically siphons off reserves into an opaque “development fund”. At the end of 2009 the Central Bank's reserves officially stood at almost $36 billion, but by mid-August they had fallen to just over $28 billion. This still represents more than eight months of imports, even at last year's rate. But some of the reserves may not be held in liquid form. The government recently issued $3 billion in debt to provide resources for SITME.

The dollar squeeze is hurting the economy. Movistar, a mobile phone company owned by Spain's Telefónica, last month said it had been forced to suspend roaming agreements in 13 countries, after accumulating months of arrears in payments to operators abroad. Importers of goods regarded as non-priority, such as domestic appliances, vehicle parts and clothing, face an uncertain future. Sales of whisky have fallen by 85%. Grupo Soluciones, a consultancy, reckons that half of all import businesses could be forced to close down.

By squeezing businesses it regards as superfluous, the government has managed to maintain food imports and avoid the shortages in staples that caused it to lose a constitutional referendum in 2007. This may help it to win the legislative election due on September 26th. As recently as the 1960s Venezuela was the richest economy in Latin America. It has been reduced to a hand-to-mouth existence.