If we view "wealth" as the subjective experience of pleasure, then "wealth" can spring up ex nihilo: if people used to get two dollars' worth of pleasure from having a cup, but now they get ten dollars' worth, then in some sense eight dollars of wealth has come "out of nowhere".
However, it's more likely that at least one party has misvalued the cup. Perhaps the original seller was unaware that there was someone out there who would get ten dollars' worth of pleasure from the cup, or maybe the buyer has miscalculated how much pleasure they will get from the cup. In that case, wealth has not been created, it has simply been transferred to you.
A third possibility is that you have added value to the cup. Perhaps you own a retail store, and 2 dollars is the wholesale price while 10 dollars is the retail price. The person who paid 10 dollars for the cup doesn't want to buy in bulk like you do to get the wholesale price, and they don't want to deal with buying from the manufacturer. Maybe they bought a bunch of stuff from your store, and it would have been a lot of work to arrange purchases from all the different manufacturers. You've added to the end user's convenience, and therefore added wealth to the economy.
The issue of currency is a side matter. Currency is a measure of wealth; it isn't wealth in and of itself. If you had made the cup all by yourself, clearly you would have created wealth, even if no money changed hands. Money enables price signals to let other people know how much you value their activity, but that value exists independent of an explicit monetary figure been ascribed to it. If you create a cup and then sell it for 10 dollars, the wealth creation occurs when you make the cup. When you sell the cup, you are indeed not creating 10 dollars of wealth at that moment; it already has existed since you made the cup (however, depending on how one does the accounting, some of the wealth may be created when you transfer possession, if the person you sell it to has more of a use for it than you do, but it's the transferring possession, not the payment of currency, that causes the increase in wealth).