The mIRC-internal /ban command can resolve a users address for you if the internal address list has not stored it. To remove a type 4 ban on a specific nick:
/ban -r <nick> 4
See /help /ban for more information. For your code you should be using $$2 instead of %nick as I'd assume your bot operators would be using '!unban <nick>' and would not want to be restricted to whatever was (last) in %nick.
Hope that helps.