Denver chooses after the lottery is completed, as far as I know. In fact, it could be one of those screwy "only in the NBA" draft situations where each of the 3 teams goes into the draft nominally having their own picks, and then the trades are only made official after each team makes a pick at the behest of the team that "really owns" a given pick.
Like, for example, if the lottery and post-season results end up slotting New York 3rd, Denver 5th, and Toronto 20th, then the Nuggets will tell New York who to take at 3, that player will get a Knicks cap for going on stage and being announced. The Raptors will then tell the Nuggets who to take at 5, and that player will get a Nuggets cap. Then like 20 minutes later the trade will be announced and player 3 will trade their Knicks cap for a Nuggets one, and player 5 will give up the Nuggets cap for a Raptors one. And then the Knicks cap will just go into the garbage next to an unused Nets one
And then Toronto would select again at 20 for themselves, and I don't know why I even mentioned it at all since it has zero bearing on the trades/pick swap setup.
The NBA's draft trade rules are stupid and confusing and kinda arbitrary.