Sleep Country Canada has agreed to buy online mattress seller Endy for $89 million.

The two companies announced a deal Thursday evening that will see the retail mattress chain buy the Canadian mattress maker for $63.7 million in cash now, plus up to another $25 million in three years if certain growth and profitability targets are achieved.

"The acquisition of Endy will … complement Sleep Country's national store footprint and diverse selection of sleep products," Sleep Country CEO David Friesema said in a statement.

Created in 2015 by Rajen Ruparell and Mike Gettis, who first met as high school students in Calgary, Endy has quickly grown into one of the leading sellers of mattresses online.

Unlike conventional boxspring-based systems, Endy sells mattresses that ship direct to consumers in a cardboard box about the size of a large duffel bag, before being unfurled by users in their homes to fit any standard sized bed frame.

Sleep Country Canada, meanwhile, is the biggest retail mattress chain in the country, with 264 locations across Canada. It already sells its own type of mattress-in-a-box product, Bloom, which comes in four different styles and price levels.

Despite the new ownership structure, both companies say they will continue to operate as separate entities, and the Endy founders will remain in charge, "encouraging the competitive entrepreneurial spirit that has positioned them both as leaders in their respective spaces," they said in a release.