TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/circlefin/evm-cctp-contracts/llms.txt
Use this file to discover all available pages before exploring further.
Rescuable contract provides emergency functionality to recover ERC20 tokens that are accidentally sent to or locked in CCTP contracts. This is a safety mechanism to prevent permanent loss of funds.
Contract: src/roles/Rescuable.sol
Key Concepts
- Rescuer Role: Authorized address that can rescue locked ERC20 tokens
- Emergency Recovery: Allows withdrawal of tokens that shouldn’t be in the contract
- Owner Control: Only the owner can assign the rescuer role
State Variables
_rescuer
Functions
rescueERC20
tokenContract: Address of the ERC20 token contract to rescueto: Recipient address to receive the rescued tokensamount: Amount of tokens to rescue
- Caller must be the rescuer
- Contract must have sufficient token balance
- Token transfer must succeed
updateRescuer
newRescuer: Address of the new rescuer
- Caller must be the owner
- New rescuer must be non-zero address
RescuerChanged(address indexed newRescuer)
Source: Rescuable.sol:70
rescuer
Internal Functions
_updateRescuer
newRescuer: Address of the new rescuer
- New rescuer must be non-zero address
RescuerChanged(address indexed newRescuer)
Source: Rescuable.sol:78
Modifiers
onlyRescuer
Events
RescuerChanged
newRescuer: Address of the new rescuer
Usage Example
Use Cases
When to Use Rescue
- Accidental Transfers: Users accidentally send tokens directly to the contract address
- Unsupported Tokens: Tokens other than those officially supported by CCTP end up in the contract
- Operational Errors: Tokens become stuck due to failed operations
- Protocol Upgrades: Recovery needed during migration or upgrade scenarios
When NOT to Use Rescue
- Do not rescue tokens that are part of normal protocol operations (e.g., tokens held for pending burns/mints)
- Do not rescue tokens that belong to users as part of legitimate deposits
- The rescue function should only be used for truly locked or mistakenly sent funds
Security Considerations
- The rescuer role is separate from the owner role for operational flexibility
- Only the owner can change the rescuer address
- Uses OpenZeppelin’s SafeERC20 library to handle tokens safely
- The rescuer should be a trusted address (e.g., multisig or DAO)
- Rescuing tokens does not affect the contract’s paused state
- Consider implementing governance or timelock mechanisms for rescue operations
- Log all rescue operations for transparency and auditability
Implementation Details
SafeERC20 Usage
The contract uses OpenZeppelin’sSafeERC20 library, which:
- Handles tokens that don’t return a boolean on transfer
- Reverts on failed transfers instead of returning false
- Provides protection against common ERC20 implementation issues
Origin
Forked from Centre USDC Rescuable with modifications:- Updated Solidity version from 0.6.12 to 0.7.6
- Added internal
_updateRescuerfunction