ampleforth/cross-chain-ample

TVT-01: Function Simplification

Closed this issue · 1 comments

https://github.com/ampleforth/ampl-bridge-solidity/blob/954d0d20de14a4a7641f1592a33410dd16059a2c/contracts/base-chain/TokenVault.sol#L56-L82

Description:

The linked functions toggle the bool state of the whitelistedBridgeGateways mapping to adjust whether a particular bridge is whitelisted to withdraw and deposit tokens to the vault.

Recommendation:

As the toggle mechanism can only utilize two states, these two functions can be combined into a single one that accepts a bool variable as input, reducing the bytecode size of the contract and thus the overall gas footprint of its deployment.

Though the recommendation is sound and merging the addBridgeGateway and removeBridgeGateway functions will translate into deployment gas saving, we choose to keep them as separate functions to minimize critical operational errors.