PIP-57 Add migrateTo() in the POL Migration Contract

PIP: 57
Title: Add migrateTo() in the POL Migration Contract
Author: @simonDos
Description: Adds a migrateTo function in the POL migration contract
Type: Core
Date: 2025-01-16

Abstract

This proposal introduces a new migrateTo function in the POL Migration contract. This function allows users to migrate MATIC to POL while specifying a recipient address different from their own, enhancing functionality and improving flexibility and usability. The contract version will be incremented to 1.2.0.

Motivation

The POL Migration contract only supports migrating MATIC to POL for the sender’s address. The current implementation creates a pain point for users or platforms who require the ability to migrate tokens to other designated recipients.

Specification

The following changes will be made to the PolygonMigration.sol contract:
New migrateTo Function:

function migrateTo(address recipient, uint256 amount) external {
    emit Migrated(msg.sender, recipient, amount);

    matic.safeTransferFrom(msg.sender, address(this), amount);
    polygon.safeTransfer(recipient, amount);
}

Updated Migrated Event:

The Migrated event will now include a separate recipient address.

event Migrated(address indexed account, address recipient, uint256 amount);

Security Considerations

The migrateTo function relies on safe transfer methods to mitigate risks associated with token transfers. Only users with sufficient MATIC balances and valid approvals can call migrateTo and the Migrated event ensures traceability for all migrations.

1 Like

Adding this function would provide a small improvement. However, it would require a contract upgrade. All contract upgrades should be viewed as high risk. Does this small additional functionality outweigh the upgrade risk?

2 Likes

Thanks for raising this concern. Of course there is always risk involved when upgrading these contracts. We are not taking it lightly and I will discuss this with leaders to find out if we should rather wait for a bigger update to have this included.
In my opinion, that kind of an update will likely not come for a while, which is why I decided to push for an upgrade regardless :nerd_face:

1 Like