Wastewater treatment plants (WWTPs) are an example of available but underutilized waste-to-resource processes. Economic benefit opportunities can be generated through the design and operation of WWTPs following a circular economy policy. At the same time, the environmental performance is also enhanced, since water scarcity is counteracted by replacing freshwater usage with reclaimed water. In this work, we develop a MILP mathematical model representing the main characteristics of multi-contaminant wastewater exchange networks and validate it through a case study that is inspired of a WWTP located in Barcelona, Spain. As a result, we find an optimal network that can reduce the water treatment cost from 0.404 €/m³ to 0.312 €/m³. Moreover, the model allows considering the possibility of retrofitting the existing WWTP by constructing an additional treatment line and drawing the barriers for this line to achieve the targeted wastewater treatment cost. These results demonstrate that changing the role of WWTPs from an "end-of-the-pipe" solution towards a waste-to-resource route bears an unexplored potential that should be considered by all actors in the water market.