Two days before he died, Jeffrey Epstein made sure his affairs were in order -- signing a will that lays out where he's putting $577 million, and who's calling the shots.

Epstein signed his will on August 8 -- 2 days before his body was discovered at Manhattan's Metropolitan Correctional Center -- and the doc was filed last week in the U.S. Virgin Islands ... where the ex-hedge fund manager owned 2 islands worth tens of millions.

The eerie timing aside ... Epstein's will lays out the total amount he's dumping into a trust ... a whopping $577,672,654. Keep in mind, the trust might already have even more cash in there -- we just don't know as the trust docs aren't public.

As for who stands to inherit that massive fortune -- there are no beneficiaries listed. Although, he does list "next of kin" as his brother, Mark Epstein ... but that doesn't guarantee he's inheriting anything. Again, the trust would spell that out.

The docs, first posted by the New York Post, say his executors are Darren Indyke and Richard Kahn ... each of whom will get $250k for carrying out Epstein's final wishes.

Here's a quick breakdown of Epstein's assets, per the will. $56 million-plus in cash, a little over $14 mil in fixed income, nearly $113 mil in equities, about $195 mil in hedge funds and private equity ... not to mention 6 properties/estates worth well over $178 million.