You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Similar to other methods, FeeCollector.setSplitAllocation() can be defined as external instead of public and use calldata for the _allocations parameter
In the FeeCollector contract, the depositTokens state variable is modified to include new elements in two methods: the constructor and registerTokenToDepositList. However, different checks are implemented to validate the new tokens added to the list in these two methods.
In the constructor the following check is provided:
require(_initialDepositTokens[index] !=address(0), "Token cannot be 0 address");
and in registerTokenToDepositList the following ones:
require(depositTokens.length() < MAX_NUM_FEE_TOKENS, "Too many tokens");
require(_tokenAddress != weth, "WETH not supported"); // There is no WETH -> WETH pool in uniswaprequire(depositTokens.contains(_tokenAddress) ==false, "Already exists");
Does it make sense to include the 4 validations in both cases? The logic could be placed in a new internal method called from the constructor and registerTokenToDepositList
Same question from the previous point but for depositTokens from the SmartTreasuryBootstrap contract.
Regarding code styles, all external methods seem to be named without a prefix for public and external methods (example: deposit()) and the internal methods seem to be named with a _ prefix (example: _depositAllTokens()). This applies to both contracts except for some external methods from the SmartTreasuryBootstrap such as _setIDLEPrice, _registerTokenToDepositList, _removeTokenFromDepositList and other view methods. Does it make sense to remove the _ prefix from the mentioned methods for consistency and to avoid confusion when reading the code?
The text was updated successfully, but these errors were encountered:
Hey @patitanor, thank you for the feedback, here's what I've implemented so far
I've added this optimisation, thanks
I've implemented this change
I've added the checks now to the constructor, I cannot use the registerTokenToDepositList function in the constructor at this stage, since the weth state variable is immutable, therefore not read accessible in the constructor.
See previous comment, similar changes implemented
This was an artifact from early development and is now fixed, thanks for raising this.
Besides the already applied fixes mentioned in #8, here are some other improvements I identified from my review.
depositTokens.at
twice inFeeCollector.deposit()
. In order to save some gas, the following code:can be modified to:
Similar to other methods,
FeeCollector.setSplitAllocation()
can be defined asexternal
instead ofpublic
and usecalldata
for the_allocations
parameterIn the
FeeCollector
contract, thedepositTokens
state variable is modified to include new elements in two methods: the constructor andregisterTokenToDepositList
. However, different checks are implemented to validate the new tokens added to the list in these two methods.In the constructor the following check is provided:
and in
registerTokenToDepositList
the following ones:Does it make sense to include the 4 validations in both cases? The logic could be placed in a new internal method called from the constructor and
registerTokenToDepositList
Same question from the previous point but for
depositTokens
from theSmartTreasuryBootstrap
contract.Regarding code styles, all external methods seem to be named without a prefix for
public
andexternal
methods (example:deposit()
) and theinternal
methods seem to be named with a_
prefix (example:_depositAllTokens()
). This applies to both contracts except for someexternal
methods from theSmartTreasuryBootstrap
such as_setIDLEPrice
,_registerTokenToDepositList
,_removeTokenFromDepositList
and other view methods. Does it make sense to remove the_
prefix from the mentioned methods for consistency and to avoid confusion when reading the code?The text was updated successfully, but these errors were encountered: