Question: When was the peace treaty signed based on which Teutonic Knights suffered only minimal territorial losses?

 It was signed on 1 February 1411 in Thorn (Toruń), one of the southernmost cities of the Monastic State of the Teutonic Knights.  In historiography, the treaty is often portrayed as a diplomatic failure of Poland–Lithuania as they failed to capitalize on the decisive defeat of the Knights in the Battle of Grunwald in June 1410. The (First) Peace of Thorn was a peace treaty formally ending the Polish–Lithuanian–Teutonic War between allied Kingdom of Poland and Grand Duchy of Lithuania on one side, and the Teutonic Knights on the other.  The Knights returned Dobrzyń Land which they captured from Poland during the war and made only temporary territorial concessions in Samogitia, which returned to Lithuania only for the lifetimes of Polish King Władysław Jagiełło and Lithuanian Grand Duke Vytautas.  The Peace of Thorn was not stable.  It took two other brief wars, the Hunger War in 1414 and Gollub War in 1422, to sign the Treaty of Melno that solved the territorial disputes.  However, large war reparations were a significant financial burden on the Knights, causing internal unrest and economic decline.  The Teutonic Knights never recovered their former might. <SEP> The Battle of Grunwald, First Battle of Tannenberg or Battle of Žalgiris, was fought on 15 July 1410 during the Polish–Lithuanian–Teutonic War.  The alliance of the Kingdom of Poland and the Grand Duchy of Lithuania, led respectively by King Władysław II Jagiełło (Jogaila) and Grand Duke Vytautas, decisively defeated the German–Prussian Teutonic Knights, led by Grand Master Ulrich von Jungingen.  Most of the Teutonic Knights' leadership were killed or taken prisoner.  Although defeated, the Teutonic Knights withstood the siege of their fortress in Marienburg (Malbork) and suffered minimal territorial losses at the Peace of Thorn (1411) (Toruń), with other territorial disputes continuing until the Peace of Melno in 1422.  The knights, however, would never recover their former power, and the financial burden of war reparations caused internal conflicts and an economic downturn in the lands under their control.  The battle shifted the balance of power in Central and Eastern Europe and marked the rise of the Polish–Lithuanian union as the dominant political and military force in the region. <SEP> The Polish–Lithuanian–Teutonic War or Great War occurred between 1409 and 1411, pitting the allied Kingdom of Poland and Grand Duchy of Lithuania against the Teutonic Knights.  Inspired by the local Samogitian uprising, the war began by Teutonic invasion of Poland in August 1409.  As neither side was ready for a full-scale war, Wenceslaus IV of Bohemia brokered a nine-month truce.  While defeated, the Teutonic Knights withstood the siege on their capital in Marienburg (Malbork) and suffered only minimal territorial losses in the Peace of Thorn (1411).  After the truce expired in June 1410, the military-religious monks were decisively defeated in the Battle of Grunwald (Tannenberg), one of the largest battles in medieval Europe.  Most of the Teutonic leadership was killed or taken prisoner.  Territorial disputes lasted until the Peace of Melno of 1422.  However, the Knights never recovered their former power and the financial burden of war reparations caused internal conflicts and economic decline in their lands.  The war shifted the balance of power in Eastern Europe and marked the rise of the Polish–Lithuanian union as the dominant power in the region. <SEP> The Treaty of Melno (Lithuanian: "Melno taika" ; Polish: "Pokój melneński" ) or Treaty of Lake Melno (German: "Friede von Melnosee" ) was a peace treaty ending the Gollub War.  It was signed on 27 September 1422, between the Teutonic Knights and an alliance of the Kingdom of Poland and the Grand Duchy of Lithuania at Lake Melno (German: "Melnosee", "Meldensee"; Polish: "Jezioro Mełno"), east of Graudenz (Grudziądz).  The treaty resolved territorial disputes between the Knights and Lithuania regarding Samogitia, which had dragged on since 1382, and determined the Prussian–Lithuanian border, which afterwards remained unchanged for about 500 years.  A portion of the original border partially survives as the border between the Republic of Lithuania and Kaliningrad Oblast, Russia, making it one of the most stable borders in Europe.