Description
Users frequently make the mistake of sending tokens directly to the smart contract address instead of using the proper swap function.
Because our contract doesn't have a way to access un-tracked balances, those tokens are permanently locked.
We need a sweep_tokens function that allows the Admin to rescue these accidentally transferred funds and return them to the users.
This function must explicitly calculate the difference between the pool's mathematical reserves and the actual contract balance.
Requirements
Description
Users frequently make the mistake of sending tokens directly to the smart contract address instead of using the proper
swapfunction.Because our contract doesn't have a way to access un-tracked balances, those tokens are permanently locked.
We need a
sweep_tokensfunction that allows the Admin to rescue these accidentally transferred funds and return them to the users.This function must explicitly calculate the difference between the pool's mathematical reserves and the actual contract balance.
Requirements
sweep_tokens(token: Address, to: Address)function restricted to the Admin.reserveof the requested token from the pool state.token.balance()of the contract.actual_balance - reserve) to the specified recovery address.