 He then commanded the establishment of a revolutionary government in Upper Peru (today's Bolivia) with the aim of freeing the indigenous peoples and African slaves.In 1811 Castelli signed a truce with the Spanish in Upper Peru, but they betrayed him and caught the Northern Army unprepared.As a result, the Argentines suffered a major loss in the Battle of Huaqui on June 20, 1811.