& A dynamic-constraint optimization model that incorporates the accumulated nutrient load from farm discharges to the sea is applied to derive an optimal corrective tax for Thai shrimp farming. The model internalizes the environmental costs of the cumulated stock of nutrients discharged, mangrove conversion and abandoned farms. It suggests imposing a tax on the stock externality that is equal to the increasing shadow cost of the stock of nutrient accumulated before damage occurs. However, the simulation results show very small shadow costs at the beginning of the paths and indicate that the nutrient load has a negligible impact on the Andaman Sea but a significant effect on the Gulf of Thailand. A socially efficient level of production for Thailand would be around 70-80% of private optimal production. The tax ensures a higher net gain from trade. On the other hand, its effect on net social welfare is ambiguous.