Here’s a look at what markets are expecting and planning for, and how a default might happen.The United States is inching closer to calamity, as lawmakers continue to spar over what it will take to raise the country’s $31.4 trillion debt limit.That has raised questions about what will happen if the United States does not raise its borrowing cap in time to avoid defaulting on its debt, along with how key players are preparing for that scenario and what would actually happen should the Treasury Department fail to repay its lenders.Such a situation would be unprecedented, so it’s difficult to say with certainty how it would play out. But it’s not the first time investors and policymakers have had to contemplate “what if?” and they’ve been busy updating their plans for how they think things may play out this time.While negotiators appear to be moving toward an agreement, time is short. There is no certainty that the debt limit will be lifted before June 5, when the Treasury now estimates the government will run out of cash to pay all of its bills on time, a moment known as the “X-date.”“We’ve got to be in the closing hours because of the timeline,” said Representative Patrick McHenry, a North Carolina Republican who is involved in the talks. “I don’t know if it’s in the next day or two or three, but it’s got to come together.”Big questions remain, including what could happen in the markets, how the government is planning for default and what happens if the United States runs out of cash. Here’s a look at how things could unfold.Before the X-DateFinancial markets have become more jittery as the United States moves closer to the X-date. While exuberance over the profit-boosting expectations of artificial intelligence has helped the stock market recover, fears about the debt limit persist. On Friday, the S&P 500 rose 1.3 percent, a modest gain of 0.3 percent for the week.This week, Fitch Ratings said it was placing the nation’s top AAA credit rating on review for a possible downgrade. DBRS Morningstar, another rating firm, did the same on Thursday.For now, the Treasury is still selling debt and making payments to its lenders.That has helped mollify some concerns that the Treasury won’t be able to repay debt coming due in full, as opposed to just an interest payment. That’s because the government has a regular schedule of new Treasury auctions where it sells bonds to raise fresh cash. The auctions are scheduled in a way so that the Treasury receives its new borrowed cash at the same time that it pays off its old debts.That allows the Treasury to avoid adding much to its outstanding $31.4 trillion debt load — something it can’t do right now since it enacted extraordinary measures after coming within a whisker of the debt limit on Jan. 19. And it should give the Treasury the cash it needs to avoid any disruption to payments, at least for now.This week, for example, the government sold two-year, five-year and seven-year bonds. However, that debt doesn’t “settle” — meaning the cash is delivered to the Treasury and the securities delivered to the buyers at the auction — until May 31, coinciding with three other securities coming due.More precisely, the new cash being borrowed is slightly larger than the amount coming due, with the tricky act of balancing all of the money coming in and out pointing to the Treasury’s challenge in the days and weeks ahead.When all the payments are tallied, the government ends up with a little over $20 billion of extra cash, according TD Securities.Some of that could go to the $12 billion of interest payments that the Treasury also has to pay that day. But as time goes on, and the debt limit becomes harder to avoid, the Treasury may have to postpone any incremental fund-raising, as it did during the debt limit standoff in 2015.After the X-Date, Before DefaultThe U.S. Treasury pays its debts through a federal payments system called Fedwire. Big banks hold accounts at Fedwire, and the Treasury credits those accounts with payments on its debt. These banks then pass the payments through the market’s plumbing and via clearing houses, like the Fixed Income Clearing Corporation, with the cash eventually landing in the accounts of holders from domestic retirees to foreign central banks.The Treasury could try to push off default by extending the maturity of debt coming due. Because of the way Fedwire is set up, in the unlikely event that the Treasury chooses to push out the maturity of its debt it will need to do so before 10 p.m. at the latest on the day before the debt matures, according to contingency plans laid out by the trade group Securities Industry and Financial Markets Association, or SIFMA. The group expects that if this is done, the maturity will be extended for only one day at a time.Investors are more nervous that should the government exhaust its available cash, it could miss an interest payment on its other debt. The first big test of that will come on June 15, when interest payments on notes and bonds with an original maturity of more than a year come due.Moody’s, the rating agency, has said it is most concerned about June 15 as the possible day the government could default. However, it may be helped by corporate taxes flowing into its coffers next month.The Treasury can’t delay an interest payment without default, according to SIFMA, but it could notify Fedwire by 7:30 a.m. that the payment will not be ready for the morning. It would then have until 4:30 p.m. to make the payment and avoid default.If a default is feared, SIFMA — alongside representatives from Fedwire, the banks and other industry players — has plans in place to convene up to two calls the day before a default could occur and three further calls on the day a payment is due, with each call following a similar script to update, assess and plan for what could unfold.“On the settlement, infrastructure and plumbing, I think we have a good idea of what could happen,” said Rob Toomey, head of capital markets at SIFMA. “It’s about the best we can do. When it comes to the long-term consequences, we don’t know. What we are trying to do is minimize disruption in what will be a disruptive situation.”Default and BeyondOne big question is how the United States will determine if it has actually defaulted on its debt.There are two main ways the Treasury could default: missing an interest payment on its debt, or not repaying its borrowings when the full amount becomes due.That has prompted speculation that the Treasury Department could prioritize payments to bondholders ahead of other bills. If bondholders are paid but others are not, ratings agencies are likely to rule that the United States has dodged default.But Treasury Secretary Janet L. Yellen has suggested that any missed payment will essentially amount to a default.Shai Akabas, director of economic policy at the Bipartisan Policy Center, said an early warning sign that a default was coming could arrive in the form of a failed Treasury auction. The Treasury Department will also be closely tracking its expenditures and incoming tax revenue to forecast when a missed payment could happen.At that point, Mr. Akabas said, Ms. Yellen is likely to issue a warning with the specific timing of when she predicts the United States will not be able to make all of its payments on time and announce the contingency plans she intends to pursue.For investors, they will also receive updates through industry groups tracking the key deadlines for the Treasury to notify Fedwire that it will not make a scheduled payment.A default would then set off a cascade of potential problems.Rating firms have said a missed payment would merit a downgrade of America’s debt — and Moody’s has said it will not restore its Aaa rating until the debt ceiling was no longer subject to political brinkmanship.International leaders have questioned whether the world should continue to tolerate repeated debt-ceiling crises given the integral role the United States plays in the global economy. Central bankers, politicians and economists have warned that a default would most likely tip America into a recession, leading to waves of second order effects from corporate bankruptcies to rising unemployment.But those are just some of the risks known to be lurking.“All of this is uncharted waters,” Mr. Akabas said. “There’s no playbook to go by.”Luke Broadwater More