There are many factors to have detonation. And it’s always a balancing act between many factors. Air temp, fuel octane, static compression, boost, throttle position, ignition map, cam profile, coolant temp and the list goes on, you can change any one or combination of them above to help.
increase octane, lower boost, lower static compression, pull timing, take your foot off the gas. etc. but one thing you don’t see that I listed is air’fuel ratio. There are ranges for optimum hp air/fuel rations and regardless of the other items mentioned above it should stay in those ranges. Using that as detonation suppression is the wrong method. On any engine!