Skip to content
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

Link liquidity pool, add withdraw functions for finance team and some refactoring #12375

Merged
merged 5 commits into from
Mar 13, 2024

Conversation

shileiwill
Copy link
Contributor

AUTO-9114

Copy link
Contributor

I see that you haven't updated any README files. Would it make sense to do so?

Copy link
Contributor

Go solidity wrappers are out-of-date, regenerate them via the make wrappers-all command

@shileiwill shileiwill changed the title Some refactoring and Add withdraw functions for finance team Link liquidity pool, add withdraw functions for finance team and some refactoring Mar 11, 2024
@@ -295,7 +298,6 @@ abstract contract AutomationRegistryBase2_3 is ConfirmedOwner {
*/
struct State {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we actually have to keep this struct as-is for backwards compatibility :/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but I'm happy to just return 0 for this field in the getState() function

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, we kept the field name as is in this PR. we use the new s_reserveLinkBalance as the return value in getState() [ref] Does this look good?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we will return 0 once we change the s_reserveLinkBalance to a mapping. very soon, in the next PR!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we revert this change in this PR? sorry to be nit-picky but this essentially breaks our backwards compatibility and I don't want to forget to fix it in a later PR.

Comment on lines 166 to 168
error OnlyFinanceAdmin();
error TransferFailed();
error InsufficientBalance(uint256 available, uint256 requested);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick - can we keep 'em alphabetized :)))

@@ -276,14 +279,14 @@ abstract contract AutomationRegistryBase2_3 is ConfirmedOwner {
address upkeepPrivilegeManager;
IChainModule chainModule;
bool reorgProtectionEnabled;
address financeAdmin;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we add a TODO comment to struct pack this better? We can address in a follow up PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_onlyFinanceAdminAllowed();
if (to == ZERO_ADDRESS) revert InvalidRecipient();

bool transferStatus = IERC20(assetAddress).transfer(to, amount);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here, can we check the reserve amount for the taken being transferred?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to confirm, you meant IERC20(assetAddress).balanceOf(registryMasterAddress) should be smaller? add a require statement here?

Copy link
Contributor Author

@shileiwill shileiwill Mar 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are on the same page, we actually have foundry tests covering the above:

    assertEq(getNonLinkBalance(address(aMockAddress)), 1);
    assertEq(getNonLinkBalance(address(registryMaster)), 1e10 - 1);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can do this in the follow up PR, where we convert the reserve amount to a mapping :)

Comment on lines 205 to 206
//change back to the original address
changePrank(originalAddr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this pattern of pranking is a touch verbose - I think we could simplify like this...

    // set config with the finance admin
    setConfigForWithdraw();

    // try to withdraw 1 link while there is 0 balance
    vm.expectRevert(abi.encodeWithSelector(IAutomationRegistryMaster2_3.InsufficientBalance.selector, 0, 1));
    vm.prank(FINANCE_ADMIN_ADDRESS);
    registryMaster.withdrawLinkFees(aMockAddress, 1);

... or ...

    // set config with the finance admin
    setConfigForWithdraw();

    vm.startPrank(FINANCE_ADMIN_ADDRESS); // better if we have to make more than 1 call

    // try to withdraw 1 link while there is 0 balance
    vm.expectRevert(abi.encodeWithSelector(IAutomationRegistryMaster2_3.InsufficientBalance.selector, 0, 1));
    
    registryMaster.withdrawLinkFees(aMockAddress, 1);
    vm.stopPrank();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also wouldn't be opposed to adding a vm.stopPrank() at the end of setup() - this guarantees us a "clean state" at the beginning of every test

Copy link
Contributor

Go solidity wrappers are out-of-date, regenerate them via the make wrappers-all command

1 similar comment
Copy link
Contributor

Go solidity wrappers are out-of-date, regenerate them via the make wrappers-all command

Copy link
Contributor

@RyanRHall RyanRHall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 super small requests

@@ -295,7 +298,6 @@ abstract contract AutomationRegistryBase2_3 is ConfirmedOwner {
*/
struct State {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we revert this change in this PR? sorry to be nit-picky but this essentially breaks our backwards compatibility and I don't want to forget to fix it in a later PR.

Copy link
Contributor

Go solidity wrappers are out-of-date, regenerate them via the make wrappers-all command

1 similar comment
Copy link
Contributor

Go solidity wrappers are out-of-date, regenerate them via the make wrappers-all command

@cl-sonarqube-production
Copy link

event FundsAdded(uint256 indexed id, address indexed from, uint96 amount);
event FundsWithdrawn(uint256 indexed id, uint256 amount, address to);
event InsufficientFundsUpkeepReport(uint256 indexed id, bytes trigger);
event OwnerFundsWithdrawn(uint96 amount);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we keep this event? if not, it won't be compatible with existing atlas.

@cmalec what do you think?

Copy link
Contributor

@RyanRHall RyanRHall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good from my end - can we confirm with @cmalec that changing / removing that OwnerFundsWithdrawn event isn't important?

@shileiwill shileiwill added this pull request to the merge queue Mar 13, 2024
Merged via the queue into develop with commit 831aea8 Mar 13, 2024
109 checks passed
@shileiwill shileiwill deleted the AUTO-9114-new branch March 13, 2024 15:19
ogtownsend pushed a commit that referenced this pull request Mar 14, 2024
… refactoring (#12375)

* add financeAdmin to onchainConfig

* remove ownerLinkbalance and rename expectedLinkBalance

* add withdraw functions

* add foundry test and generate wrappers
kidambisrinivas pushed a commit that referenced this pull request Mar 27, 2024
… refactoring (#12375)

* add financeAdmin to onchainConfig

* remove ownerLinkbalance and rename expectedLinkBalance

* add withdraw functions

* add foundry test and generate wrappers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants