Yanfly Lunatic Custom State/Buff Formula Help

So I want to go with a FF9 Trance-like system, and decided to use a passive state that checks whether the user's TP is at 100, at which point the state goes active. That's all working fine thanks to the Tips & Tricks videos on Power Up Mode & Trance:

<Custom Passive Condition>
if ($gameParty.inBattle()) {
condition = user.tp = 100;
} else {
condition = false;
}
</Custom Passive Condition>

In those videos the stat bonuses are just flat percentage boosts set with the state's traits options. But I want the stat bonuses to ATK, MAT, etc, to be based on the actor's level, so that as they level up, their stat bonuses go up significantly for achieving the state. There are only five levels per actor in my game, so I thought something like "if state is active then user.atk = (user.atk*((user.level+25)*5))/100" or something to that effect. Or maybe even when state become active, the user gains one buff stack per user level, i.e., if user is level one, they get one buff to atk/mat/def/mdf, but if user is level 5 then they get 5 stacks to atk/mat/def/mdf. How could I go about implementing this kind of thing? Any help is appreciated, thanks ^^

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-lunatic-custom-state-buff-formula-help.119305/