code-423n4 / 2021-09-defiprotocol-findings

1 stars 0 forks source link

Mint fees can be simplified #214

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

Handle

pauliax

Vulnerability details

Impact

This can be refactored to improve precision and gas usage: _mint(publisher, fee (BASE - factory.ownerSplit()) / BASE); _mint(Ownable(address(factory)).owner(), fee factory.ownerSplit() / BASE);

Recommended Mitigation Steps

Proposed solution: uint256 factoryOwnerFee = fee * factory.ownerSplit() / BASE; uint256 publisherFee = fee - factoryOwnerFee; _mint(Ownable(address(factory)).owner(), factoryOwnerFee); _mint(publisher, publisherFee); This will result in fewer math operations and better precision cuz multiplication and division are replaced with subtraction.

GalloDaSballo commented 2 years ago

Clever little optimization