If not kingexists :
Set kingto “”.
Set recordBuyto 0.
If the event's amountis at least 1and the event's amountis more than recordBuy:
Set kingto the event's wallet.
Set recordBuyto the event's amount.
If not kingexists :
Set kingto “”.
Set recordBuyto 0.
Set kingWalletMatchto .
Append kingto list kingWalletMatch.
Set sellerWalletMatchto .
Append the event's walletto list sellerWalletMatch.
If sellerWalletMatchis kingWalletMatch:
Set kingto “”.
Set recordBuyto 0.
If not kingexists :
Set kingto “”.
Set recordBuyto 0.
If kingexists :
If wallet kingowns token “”:
If the coin's unspent fees in SOLis more than 0:
Send the coin's unspent fees in SOLSOLto king.
Otherwise:
Set kingto “”.
Set recordBuyto 0.