Staring at the possibility of a second government shutdown, and under the watchful eye of a hard-to-predict president, the four members of Congress who are holding the federal purse strings crafted a border security deal Monday night that could pass the House and Senate.

Here is exactly what’s in the compromise struck between the top Republicans and Democrats on the congressional appropriations committees, and how it looks from both sides of Pennsylvania Avenue.

Key highlights

Border barriers: $1.375 billion. That will fund the construction of 55 miles of barriers in the Rio Grande valley. Democrats say this will be “bollard” or steel-slat construction.

$1.375 billion. That will fund the construction of 55 miles of barriers in the Rio Grande valley. Democrats say this will be “bollard” or steel-slat construction. Detention space: Funding for U.S. Immigrations and Customs Enforcement (ICE) to detain an average of 45,274 people a day for the rest of this fiscal year.

Funding for U.S. Immigrations and Customs Enforcement (ICE) to detain an average of 45,274 people a day for the rest of this fiscal year. Unknown amount of funding for new immigration judges: Final terms have not been made public yet.

About that detention space…

A limit on detention space has become a sticking point in funding negotiations. Democrats wanted to reduce the amount of detention space, closer to the level seen under the Obama administration — but Republicans argued that a lower cap would limit the federal government’s ability to detain immigrants with criminal records.

The debate became a proxy fight over Trump’s hardline immigration policies, and whether they should be strengthened or pulled back. It also raised a question about the difference between the number of beds and number of people who are actually detained over the course of a year. The total number of detention beds, as the government defines them, represents the average daily number of people in detention. But because lengths of stay in detention vary, it doesn’t always accurately reflect the number of immigrants who cycle through detention centers over the course of a year.

Democrats and Republicans are both claiming wins. Here’s why.

Currently in ICE detention: an average of 49,057 detainees each day.

Democrats say: To get to an average of 45,274 per day (the figure in the deal), ICE will have to cut daily detentions for the rest of the year to 40,520. That would mean a drop of 9,000 detainees (average, per day) until Oct. 1, when the fiscal year ends. The key here, according to Democrats, is that the average number of detainees per day goes down.

Republicans say: Under the deal, the change to a daily average of 45,274 detainees for the year is a actually an increase of nearly 5,000 over the previous year, when ICE used congressional funding to detain an average of 40,520 people.The key here, according to Republicans, is that funding for detention goes up.

Who is right?

It depends on what timeline you look at. In the end, this border deal increases total ICE detention funding from the total funding the agency had last year. But the cap on the average daily number of people in detention would decrease for the rest of the year.

What it means for Trump

How Trump could spin the deal: The agreement would allow the president to make the case that he got wall funding, after Democrats said for weeks that they would not give him one dollar for his proposed wall on the southern border.

What conservative critics are saying: The funding would be $4.325 billion less than the $5.7 billion Trump demanded during the 35-day government shutdown. Fox News host Sean Hannity called the deal a “garbage compromise,” and other conservatives have slammed it as well. In the past, Trump has buckled to pressure from such voices, the president said Tuesday he wanted to avoid another shutdown.

Will Trump use executive power for more wall funding? Mick Mulvaney, the acting White House chief of staff, has said that Trump will look at using his executive power to find other money for the wall that would supplement the funding approved by the House and Senate. As Mulvaney said Sunday on Meet The Press: “Whether or not he gets $1.6 billion from Congress, whether or not he gets $2.5 or $5.7, he’s going to do whatever he legally can to secure that border.” Mulvaney has not specified exactly where the funds might come from. Trump has also been adamant that he will build the wall no matter what happens in Congress, a promise he repeated Monday at a campaign rally in El Paso, Texas.

What’s next: If Trump maneuvers to get more wall money, it could get held up in court, since it’s likely an attempt to redirect funds for a wall that would face legal challenges.

READ MORE: How Trump has already changed immigration policy