Giveth / vaultcontroller

Vault Architecture
GNU General Public License v3.0
0 stars 3 forks source link

Too much automation within the smart contract; move it up a level #49

Open GriffGreen opened 7 years ago

GriffGreen commented 7 years ago

The automation is the scariest feature of this contract. It might be a smarter design choice to put automation into a deployment script outside of the smart contract whenever possible.

For instance in setVaultLimits()

It is probably unnecessary to include:

 if (address(parentVaultController) != 0) {
            parentVaultController.topUpVault();
            sendBackOverflow();
        }

This could easily be done as a script run when a user uses the UI to set the limits as a second function call, it might even save gas by moving some calculations outside of the smart contract.

But the main issue is security; topUpVault() is called way too many times all over this contract. The example above is just the most obvious one that seemed out of place. It is a relatively dangerous function to call so liberally.

I do appreciate that this could impact user experience (multiple function calls could mean, having to click metamask's accept button multiple times) but that is why we can debate the merits of this idea below :-D