BRAZIL’S economic weather tends towards extremes. During the 1980s and early 1990s hyperinflation raged. From late 2014 to late 2016 GDP shrank by 7.7%, its longest contraction ever. Conditions are now enervatingly calm. GDP grew by just 1% last year, and in June the central bank cut its growth forecast for 2018 from 2.6% to 1.6%. A truckers’ strike in May and uncertainty about the outcome of elections in October have curbed economic activity, weakened the currency and pushed up government-bond yields.

Yet the country’s big private-sector banks have prospered regardless. In the recession, neither Itaú Unibanco nor Bradesco, the two biggest, saw their return on equity (RoE, a measure of profitability) fall below 15.9%. On July 30th Itaú reported net income for the first half of 2018 of 12.5bn reais ($3.3bn), and an RoE of 20.1%. A few days earlier Bradesco and Santander, the local arm of a Spanish lender, reported RoEs in the high teens. Most European banks are stuck in single digits. As the central bank slashed its interest-rate target, the Selic, from 14.25% in October 2016 to a record low of 6.5% in March this year, some analysts predicted a squeeze on profits. It hasn’t happened yet.

The resilience of Brazil’s banks reveals much about the way the economy functions, not all of it good. Back when inflation was “1½% a day”, says Candido Bracher, Itaú’s chief executive, banks were forced to become efficient at transferring and managing money. Now they operate in a financial market riddled with other distortions. Some hurt their profits; others puff them up. Public-sector banks have a big and privileged role, which both constrains their private-sector competitors and shields them from risks, like some lending to the government’s favoured sectors.

All of this means that lending, especially to consumers and small firms, is lower and more expensive than it should be. Although voters are worrying mainly about corruption, crime and unemployment, the winner of the presidential election will have to consider how to make banking a more normal business. Indeed, that is already quietly happening.

The market’s most striking features are the dominance of a few banks—strengthened in the past two years by the retreat of America’s Citigroup, which sold its consumer business to Itaú, and Britain’s HSBC, which sold to Bradesco—and the state’s importance as both supplier and regulator of credit. Three private-sector lenders and three public ones—Banco do Brasil, of which the government owns 59%, Caixa Econômica Federal, a savings bank, and BNDES, a development bank—account for 82% of banking assets and 86% of loans. Regulations steer almost half of loans to favoured purposes, funded by private savings and the state. Interest rates on earmarked lending average 8.9%, according to the central bank. On the unrestricted remainder, they can be sky-high. They average 20.5% for companies and 45.8% for households. On personal loans, credit cards and overdrafts they run well into three figures.

The banks insist that wide spreads reflect not a cosy oligopoly but the high risk of default and the difficulty of pursuing debtors through slow, unsympathetic courts. Regulation also plays a part: a ban on overdraft fees inflates interest rates.

A recent study by the central bank suggests that the banks have a case. It ascribes 37% of spreads to the cost of default, 25% to administrative costs, 23% to taxes and only 15% to banks’ margins. Spreads have narrowed as the Selic has declined. Yet the critics have a point, too. Tony Volpon, an economist at UBS and a former central banker, estimates that consumers pay around 20 percentage points more than they should, given the low Selic, declining defaults and banks’ RoEs. Big companies’ borrowing costs, by contrast, seem “about right”.

That may be because corporations can shop around more easily than individuals. Years of high inflation have accustomed Brazilian consumers, by contrast, to buying goods in instalments, with hefty borrowing costs in effect built into prices.

Buying on credit is so dicey

Market forces and government actions are making banking more competitive. Entrants fired by digital technology and unencumbered by the costs of branch networks (including tight security) are trying to upset the incumbents. Banco Inter may clock up 1m customers for its fee-free account by September. Nubank has pushed on from credit cards into savings. Creditas is offering loans secured on houses and cars at far lower rates than on unsecured credit. (Most Brazilian homeowners, explains Creditas’s boss, Sergio Furio, have no mortgage, giving them room to borrow.) Valor Econômico, a newspaper, has reported that the central bank will restrict Itaú to a minority stake in XP Investimentos, a broker that has been a thorn in banks’ sides which Itaú wants to buy.

The central bank is also trying to nudge down borrowing costs. Last year it obliged banks to switch customers who repeatedly roll over credit-card debt to cheaper loans. It recently eased some reserve requirements on banks.

The expansion of lending by state banks at ruinous, subsidised rates under Dilma Rousseff, president for five years until her impeachment in 2016, has been reversed under her successor, Michel Temer. BNDES has cut disbursements from 188bn reais in 2014 to just 71bn reais, and has introduced higher fixed and floating rates linked to the market. Dyogo Oliveira, its head, says it has switched lending from big companies to infrastructure and smaller firms. Banco do Brasil has cut 10,000 jobs and raised its RoE from a paltry 4% in late 2016 into double figures.

Removing subsidised lending and other distortions, argues Arthur Carvalho of Morgan Stanley, should have an extra, macroeconomic benefit. It should enable the Selic to be lower, other things being equal. The link between monetary policy and the interest rates paid by businesses and households would also be tighter. And if the next president is serious about getting Brazil’s public finances under control, and long-term interest rates fall, investment and growth should at last pick up. A narrower gap between long- and short-term rates would squeeze banks’ margins. But demand for credit would rise—and a stronger economy would mean faster sailing for all.