Omniscia Redacted Cartel Audit

TokenMigrator Code Style Findings

TokenMigrator Code Style Findings

TMR-01C: First-Time Assignment Optimization

Description:

The linked statements increment the burnAmount and mintAmount variables, however, it is known that in the first if clause they will always be zero thus permitting a direct assignment to be made instead.

Example:

contracts/core/TokenMigrator.sol
145uint256 burnAmount;
146uint256 mintAmount;
147
148if (wxAmount != 0) {
149 burnAmount += wxBtrfly.xBTRFLYValue(wxAmount);
150 mintAmount += _migrateWxBtrfly(wxAmount);
151}

Recommendation:

We advise this to be done so optimizing the gas cost of those statements.

Alleviation:

Both assignment operations were adjusted to simple assignments optimizing the codebase.

TMR-02C: wxBTRFLY Integration Optimization

Description:

The unwrapToBTRFLY function of wxBTRFLY yields the amount of BTRFLY that was ultimately unwrapped. In the TokenMigrator contract, this is measured in a separate call to xBTRFLYValue which is inefficient.

Example:

contracts/core/TokenMigrator.sol
85function _migrateWxBtrfly(uint256 amount)
86 internal
87 returns (uint256 mintAmount)
88{
89 // Unwrap wxBTRFLY
90 wxBtrfly.transferFrom(msg.sender, address(this), amount);
91 wxBtrfly.unwrapToBTRFLY(amount);
92
93 return amount;
94}

Recommendation:

We advise the _migrateWxBtrfly function to yield the burnAmount instead and be assigned to it whilst the mintAmount is directly assigned to the wxAmount, optimizing the code's execution cost.

Alleviation:

The codebase was adjusted as advised optimizing the execution cost of the wxBTRFLY conversion path.