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

[RFC] Add finance withdraw function for both link and non-link #12352

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ abstract contract AutomationRegistryBase2_3 is ConfirmedOwner {
error UpkeepNotNeeded();
error ValueNotChanged();
error ZeroAddressNotAllowed();
error TransferFailed();

enum MigrationPermission {
NONE,
Expand Down Expand Up @@ -499,6 +500,7 @@ abstract contract AutomationRegistryBase2_3 is ConfirmedOwner {
event Unpaused(address account);
// Event to emit when a billing configuration is set
event BillingConfigSet(IERC20 indexed token, BillingConfig config);
event FeesWithdrawn(address indexed recipient, address indexed assetAddress, uint256 amount);

/**
* @param link address of the LINK Token
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,33 @@ contract AutomationRegistryLogicB2_3 is AutomationRegistryBase2_3 {
emit FundsWithdrawn(id, amountToWithdraw, to);
}

function withdrawNonLinkFees(address assetAddress, address to, uint256 amount) external nonReentrant onlyOwner {
if (to == ZERO_ADDRESS) revert InvalidRecipient();

// withdraw the requested asset
// TODO: Q: this is where we withdraw ERC20 from our contract, where do we get ERC20 deposit, another ticket?
bool transferStatus = IERC20(assetAddress).transfer(to, amount);
shileiwill marked this conversation as resolved.
Show resolved Hide resolved
if (!transferStatus) {
revert TransferFailed();
}

// emit event when funds are withdrawn
emit FeesWithdrawn(to, assetAddress, amount);
}

function linkAvailableForPayment() public view returns (uint256) {
return i_link.balanceOf(address(this)) - s_expectedLinkBalance;
}

function withdrawLinkFees(address to, uint256 amount) external nonReentrant onlyOwner {
if (to == ZERO_ADDRESS) revert InvalidRecipient();
uint256 amount = linkAvailableForPayment();
shileiwill marked this conversation as resolved.
Show resolved Hide resolved

// TODO Q: besides this LINK transfer from current contract to recepient, any other accounting needed?
i_link.transfer(to, amount);
emit FeesWithdrawn(to, address(i_link), amount);
}

// ================================================================
// | NODE MANAGEMENT |
// ================================================================
Expand Down Expand Up @@ -194,14 +221,6 @@ contract AutomationRegistryLogicB2_3 is AutomationRegistryBase2_3 {
i_link.transfer(msg.sender, amount);
}

/**
* @notice allows the owner to withdraw any LINK accidentally sent to the contract
*/
function recoverFunds() external onlyOwner {
uint256 total = i_link.balanceOf(address(this));
i_link.transfer(msg.sender, total - s_expectedLinkBalance);
}

/**
* @notice sets the payees for the transmitters
*/
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ automation_forwarder_logic: ../../contracts/solc/v0.8.16/AutomationForwarderLogi
automation_registrar_wrapper2_1: ../../contracts/solc/v0.8.16/AutomationRegistrar2_1/AutomationRegistrar2_1.abi ../../contracts/solc/v0.8.16/AutomationRegistrar2_1/AutomationRegistrar2_1.bin eb06d853aab39d3196c593b03e555851cbe8386e0fe54a74c2479f62d14b3c42
automation_registrar_wrapper2_3: ../../contracts/solc/v0.8.19/AutomationRegistrar2_3/AutomationRegistrar2_3.abi ../../contracts/solc/v0.8.19/AutomationRegistrar2_3/AutomationRegistrar2_3.bin 8e18d447009546ac8ad15d0d516ad4d663d0e1ca5f723300acb604b5571b63bf
automation_registry_logic_a_wrapper_2_2: ../../contracts/solc/v0.8.19/AutomationRegistryLogicA2_2/AutomationRegistryLogicA2_2.abi ../../contracts/solc/v0.8.19/AutomationRegistryLogicA2_2/AutomationRegistryLogicA2_2.bin 58d09c16be20a6d3f70be6d06299ed61415b7796c71f176d87ce015e1294e029
automation_registry_logic_a_wrapper_2_3: ../../contracts/solc/v0.8.19/AutomationRegistryLogicA2_3/AutomationRegistryLogicA2_3.abi ../../contracts/solc/v0.8.19/AutomationRegistryLogicA2_3/AutomationRegistryLogicA2_3.bin b1de1fdd01fd07ff07c8da4065b14ee4e50a9fd618b595d5221f952c6ed0038d
automation_registry_logic_a_wrapper_2_3: ../../contracts/solc/v0.8.19/AutomationRegistryLogicA2_3/AutomationRegistryLogicA2_3.abi ../../contracts/solc/v0.8.19/AutomationRegistryLogicA2_3/AutomationRegistryLogicA2_3.bin 398cf1c7a3cc8ae83faa47aa870421f0b2101f4c75c7fe41a6383d737f85e8d9
automation_registry_logic_b_wrapper_2_2: ../../contracts/solc/v0.8.19/AutomationRegistryLogicB2_2/AutomationRegistryLogicB2_2.abi ../../contracts/solc/v0.8.19/AutomationRegistryLogicB2_2/AutomationRegistryLogicB2_2.bin e5669214a6b747b17331ebbf8f2d13cf7100d3313d652c6f1304ccf158441fc6
automation_registry_logic_b_wrapper_2_3: ../../contracts/solc/v0.8.19/AutomationRegistryLogicB2_3/AutomationRegistryLogicB2_3.abi ../../contracts/solc/v0.8.19/AutomationRegistryLogicB2_3/AutomationRegistryLogicB2_3.bin d7e8cf91e66b4944d9787e43f3ef24251d211191c52bce832f3de6d48686e603
automation_registry_logic_b_wrapper_2_3: ../../contracts/solc/v0.8.19/AutomationRegistryLogicB2_3/AutomationRegistryLogicB2_3.abi ../../contracts/solc/v0.8.19/AutomationRegistryLogicB2_3/AutomationRegistryLogicB2_3.bin 02d27c2e03e5c4ad800b4aca3a2893782a81525d776529db25b5c2a9c23017ea
automation_registry_wrapper_2_2: ../../contracts/solc/v0.8.19/AutomationRegistry2_2/AutomationRegistry2_2.abi ../../contracts/solc/v0.8.19/AutomationRegistry2_2/AutomationRegistry2_2.bin eca1187a878b622ef3fced041a28a4229d45dd797d95630838ff6351b6afc437
automation_registry_wrapper_2_3: ../../contracts/solc/v0.8.19/AutomationRegistry2_3/AutomationRegistry2_3.abi ../../contracts/solc/v0.8.19/AutomationRegistry2_3/AutomationRegistry2_3.bin e7cf589400feb11b4ccae0a3cbba4d1ef38aa9ae6bdf17f9e81a8a47f999cf3b
automation_registry_wrapper_2_3: ../../contracts/solc/v0.8.19/AutomationRegistry2_3/AutomationRegistry2_3.abi ../../contracts/solc/v0.8.19/AutomationRegistry2_3/AutomationRegistry2_3.bin eb4dbb038e615c014dabde25d5666299fde746755ac1ce1e9303785e5ab798aa
automation_utils_2_1: ../../contracts/solc/v0.8.16/AutomationUtils2_1/AutomationUtils2_1.abi ../../contracts/solc/v0.8.16/AutomationUtils2_1/AutomationUtils2_1.bin 331bfa79685aee6ddf63b64c0747abee556c454cae3fb8175edff425b615d8aa
automation_utils_2_2: ../../contracts/solc/v0.8.19/AutomationUtils2_2/AutomationUtils2_2.abi ../../contracts/solc/v0.8.19/AutomationUtils2_2/AutomationUtils2_2.bin 6fe2e41b1d3b74bee4013a48c10d84da25e559f28e22749aa13efabbf2cc2ee8
automation_utils_2_3: ../../contracts/solc/v0.8.19/AutomationUtils2_3/AutomationUtils2_3.abi ../../contracts/solc/v0.8.19/AutomationUtils2_3/AutomationUtils2_3.bin 47548ad54dd6d69ca238b92cb0fa6b2db9436f13c1eba11b01916fbf20802d57
Expand All @@ -33,7 +33,7 @@ flux_aggregator_wrapper: ../../contracts/solc/v0.6/FluxAggregator/FluxAggregator
gas_wrapper: ../../contracts/solc/v0.8.6/KeeperRegistryCheckUpkeepGasUsageWrapper1_2/KeeperRegistryCheckUpkeepGasUsageWrapper1_2.abi ../../contracts/solc/v0.8.6/KeeperRegistryCheckUpkeepGasUsageWrapper1_2/KeeperRegistryCheckUpkeepGasUsageWrapper1_2.bin 4a5dcdac486d18fcd58e3488c15c1710ae76b977556a3f3191bd269a4bc75723
gas_wrapper_mock: ../../contracts/solc/v0.8.6/KeeperRegistryCheckUpkeepGasUsageWrapper1_2Mock/KeeperRegistryCheckUpkeepGasUsageWrapper1_2Mock.abi ../../contracts/solc/v0.8.6/KeeperRegistryCheckUpkeepGasUsageWrapper1_2Mock/KeeperRegistryCheckUpkeepGasUsageWrapper1_2Mock.bin a9b08f18da59125c6fc305855710241f3d35161b8b9f3e3f635a7b1d5c6da9c8
i_automation_registry_master_wrapper_2_2: ../../contracts/solc/v0.8.19/IAutomationRegistryMaster/IAutomationRegistryMaster.abi ../../contracts/solc/v0.8.19/IAutomationRegistryMaster/IAutomationRegistryMaster.bin 0886dd1df1f4dcf5b08012f8adcf30fd96caab28999610e70ce02beb2170c92f
i_automation_registry_master_wrapper_2_3: ../../contracts/solc/v0.8.19/IAutomationRegistryMaster2_3/IAutomationRegistryMaster2_3.abi ../../contracts/solc/v0.8.19/IAutomationRegistryMaster2_3/IAutomationRegistryMaster2_3.bin a8fe2f4e334043b221e07ce356ed3fa49fa17abcdac8c3d531abf24ecfab0389
i_automation_registry_master_wrapper_2_3: ../../contracts/solc/v0.8.19/IAutomationRegistryMaster2_3/IAutomationRegistryMaster2_3.abi ../../contracts/solc/v0.8.19/IAutomationRegistryMaster2_3/IAutomationRegistryMaster2_3.bin 4fa8e66031413e821a0ebe05c35f2b172030b0dd4a51731b7c91fa61da89f950
i_chain_module: ../../contracts/solc/v0.8.19/IChainModule/IChainModule.abi ../../contracts/solc/v0.8.19/IChainModule/IChainModule.bin 383611981c86c70522f41b8750719faacc7d7933a22849d5004799ebef3371fa
i_keeper_registry_master_wrapper_2_1: ../../contracts/solc/v0.8.16/IKeeperRegistryMaster/IKeeperRegistryMaster.abi ../../contracts/solc/v0.8.16/IKeeperRegistryMaster/IKeeperRegistryMaster.bin 6501bb9bcf5048bab2737b00685c6984a24867e234ddf5b60a65904eee9a4ebc
i_log_automation: ../../contracts/solc/v0.8.16/ILogAutomation/ILogAutomation.abi ../../contracts/solc/v0.8.16/ILogAutomation/ILogAutomation.bin 296beccb6af655d6fc3a6e676b244831cce2da6688d3afc4f21f8738ae59e03e
Expand Down
Loading