You can get up to $450 in trade-in value from Apple for your XS Max. (The fact that your friend owned it before you won't matter and no proof of purchase is required. It's the condition of the device and the other factors that Apple (or any company offering a trade-in program) considers that impact the value. As noted in the link, If you’re ready at the time of trade-in to buy a new Apple product online (apple.com or the Apple Store app), you can trade in an old device and get credit toward your purchase, right then and there. If you’re not ready to make a purchase, you can trade in your old device online for an Apple Gift Card by email that you can apply to any future Apple purchase. If you go the Apple gift card route, you can opt to spend that card at Apple however you wish, including on a refurbished iPhone XS Max.
I'm not sure I understood your question about the fee the warranty ended. As far as I am aware, the above-described transactions are unaffected by whether the warranty is still in place or not.
Happy transacting!
JDee