To make the curry paste, place the red onion, garlic, ginger, lemongrass and chili in a mortar and pestle and mash until it becomes a paste, stir in spices and oil. Or add all ingredients to a small food processor, blend until it becomes a paste.
Marinate the chicken in the paste for at least 30 minutes, or overnight in fridge.
Remove chicken from marinade, take excess paste off and reserve. Turn on Instant Pot to Sauté to brown chicken. Add oil to pot and then chicken, skin side down, working in batches, do not overcrowd the pot. Brown 2 to 3 minutes then flip and repeat on other side. Remove from pot and side aside until all chicken has been browned. Add onions to pot along with water, sauté for 5 minutes, deglazing bottom of pot, scraping up any browned bits. Next add reserved paste, sauté for 2 minutes then add the tomatoes, stir to combine, pour in the coconut milk, mixing well, scraping bottom to release any brown bits. Add the sweet potatoes and place chicken on top, along with any juices. Turn off sauté function.
Lock the lid and turn valve to Seal position, set to Poultry setting for 15 minutes, or Manual, High pressure, 15 minutes. Allow a natural release for 10 minutes. Press cancel, open lid carefully, remove and strain out chicken and potatoes and any large chunks. Thicken remaining sauce, set pot to sauté, remove about a ¼ cup of sauce, mix well with cornstarch, once sauce is bubbling pour cornstarch mixture into pot and stir for about one minute, turn off pot, stir in lime juice.
Serve with jasmine rice and fresh chopped cilantro, if desired.