Safest solution for recovering ERC20 token

Hey, I'm implementing to my staking contract the solution to recover funds.

My own ERC20 token is staked and this token is also used as the rewards.

I didn't implement any recoverERC20() function or recoverMyToken(), so I wonder what is the safest way of doing it?

I imagine two scenarios for recoverMyToken()

  • Function that will approve the owner(me) to transfer tokens. In that situation I will use safeTransferFrom()
  • Function that will use safeTransfer() to send it to me directly

What do you think? What are the pitfalls of these solutions?

1 Like