-
Notifications
You must be signed in to change notification settings - Fork 586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make AToken's initialize and _transfer functions virtual so they can be extended #774
Make AToken's initialize and _transfer functions virtual so they can be extended #774
Conversation
Thanks for the suggestion @davidlaprade . It is a bit challenging to identify/pick which functions should be virtual or not. It's a matter to find a golden balance, between having all functions as virtual or not having any. At the end of the day, the conclusion was to have the functions of the How does it sound? If adding this change, we should re-evaluate which other functions of the |
That's good feedback, thanks @miguelmtzinf!
Agreed, and I can totally see why you'd want to follow a principled strategy rather than just making functions virtual at the request of rando's on the internet 😅
As I think about this more, I think it makes sense to not make the With respect to There are 3 core balance-altering ERC20 functions: That said, this PR only changes one of the two |
Hey @miguelmtzinf! Totally agree it can be challenging to figure out which functions should be virtual or not, but I have a few thoughts here so figured I'd chime in. (I'm working with @davidlaprade on the flexible voting AToken implementation). I'll use our flexible voting extension as an example here, but this applies to any AToken market that extends the base
Given those first two assumptions,
There's nothing inherently wrong with the second approach, it's just more costly and leaves more room for errors/mistakes. The first approach is cleaner and feels like the correct approach. Given the first and third assumption,
It seems the 4-arg Curious to hear your thoughts! |
Your feedback is much appreciated @davidlaprade @mds1
As a workaround, you could just call Something like: contract CustomAToken is AToken {
function initialize(
IPool initializingPool,
address treasury,
address underlyingAsset,
IAaveIncentivesController incentivesController,
uint8 aTokenDecimals,
string calldata aTokenName,
string calldata aTokenSymbol,
bytes calldata params
) external override initializer {
super.intialize(
initializingPool,
treasury,
underlyingAsset,
incentivesController,
aTokenDecimals,
aTokenName,
aTokenSymbol,
params
);
(
address myAddress1,
address myAddress2,
uint256 myNumber1
) = abi.decode(params, (address, address, uint256));
// do something
} It also makes sense to have the two Are you keen on tackling the changes please? |
Awesome, thanks a lot @miguelmtzinf. We'll update this PR with the agreed upon changes to |
3afe5e6
to
bd4c6a8
Compare
@@ -59,7 +59,7 @@ contract AToken is VersionedInitializable, ScaledBalanceTokenBase, EIP712Base, I | |||
string calldata aTokenName, | |||
string calldata aTokenSymbol, | |||
bytes calldata params | |||
) external override initializer { | |||
) public virtual override initializer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be public as well as virtual for extensions to be able to call super.initiailize(...)
Thanks @miguelmtzinf @mds1!
Yeah, that's a great point. I agree. Just made the changes, I think this is ready for review |
Thanks @davidlaprade @mds1 ! |
This is a follow up to #726
It does two things:
aToken.intialize
public and virtualaToken._transfer
virtualDoing so will make
AToken
easier to extend, e.g. for grant-funded projects like the one I'm working on.I'd like
initialize()
to be public as well so that the override can just callsuper.initialize(...)
to inherit all the current functionality without having to copy/paste it.