Submitted by rbserver, also found by Arz, karanctf, 0xnacho, 0xnev, and zaevlad.
Calling the following V2Migrator.migrate function executes uint256 amountWithdrawn = bathTokenV1.withdraw(bathBalance).
https://github.com/code-423n4/2023-04-rubicon/blob/main/contracts/V2Migrator.sol#L38-L74
Then, calling bathTokenV1.withdraw(bathBalance) further calls the following BathTokenV1._withdraw function, which executes amountWithdrawn = r.sub(_fee) so amountWithdrawn has _fee deducted. When underlyingToken.safeTransfer(receiver, amountWithdrawn) is executed, such amountWithdrawn is transferred to the V2Migrator contract.
https://github.com/code-423n4/2023-04-rubicon/blob/main/contracts/periphery/BathTokenV1.sol#L532-L564
Back in the V2Migrator.migrate function, amountWithdrawn that already has _fee deducted is used to call CErc20Interface(bathTokenV2).mint(amountWithdrawn), and the minted bathTokenV2 tokens are then transferred to the user. The whole migration process basically makes the user send their bathTokenV1 tokens in exchange of the bathTokenV2 tokens accordingly, so the value owned by the user before and after the migration should be the same. However, after deducting _fee from amountWithdrawn, which is used to mint the new bathTokenV2 tokens, has become less than the underlying token value that is equivalent to the users original bathTokenV1 token balance. Although the user should own the same value either holding the bathTokenV1 tokens before the migration or bathTokenV2 tokens after the migration, the user is forced to pay _fee and possess less value than before the V2Migrator.migrate function is called to give up bathTokenV1 tokens and hold bathTokenV2 tokens. Losing value because of the migration is unfair to the user.
The following steps can occur for the described scenario.
VSCode
The BathHouse contract corresponding to bathHouse used in the BathToken V1 proxy contract can be upgraded to allow its BathHouse.setBathTokenFeeBPS function, which its current implementation is shown below, to be additionally callable by the V2Migrator contract. Then, the V2Migrator.migrate function can be updated to call this BathHouse.setBathTokenFeeBPS function to change the BathToken V1 proxy contracts feeBPS to 0 before calling bathTokenV1.withdraw(bathBalance) and restore the BathToken V1 proxy contracts feeBPS to its original value after calling bathTokenV1.withdraw(bathBalance).
https://optimistic.etherscan.io/address/0x29da5213c75a1976452a27c8054e4c65ab0a3c53#code#F1#L337
daoio (Rubicon) acknowledged
