-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
LinkBalMonV2(minPerform) and CCIPWatchlist AutoUpdate Contract #13605
Closed
Closed
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
35b3a47
Add files via upload
poke1994 57ac523
Update LinkAvailableBalanceMonitor.sol
poke1994 85fcb70
Update LinkAvailableBalanceMonitor.sol
poke1994 0b034e3
Update LinkAvailableBalanceMonitor.sol
poke1994 d2f2a63
Update CCIPAutoWatchlist.sol
poke1994 95f46c9
Update CCIPAutoWatchlist.sol
poke1994 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
contracts/src/v0.8/automation/upkeeps/CCIPAutoWatchlist.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity 0.8.19; | ||
|
||
import "../../shared/access/ConfirmedOwner.sol"; | ||
import {AutomationCompatibleInterface} from "../interfaces/AutomationCompatibleInterface.sol"; | ||
import {AccessControl} from "../../vendor/openzeppelin-solidity/v4.8.3/contracts/access/AccessControl.sol"; | ||
import {LinkAvailableBalanceMonitor} from "../upkeeps/LinkAvailableBalanceMonitor.sol"; | ||
import "../interfaces/ILogAutomation.sol"; | ||
|
||
contract CCIPOnRampAutoWatchlist is ILogAutomation, ConfirmedOwner { | ||
event setWatchlistOnMonitor(uint64 indexed _dstChainSelector, address indexed _onRamp); | ||
|
||
LinkAvailableBalanceMonitor public linkAvailableBalanceMonitorAddress; | ||
address public routerAddress; | ||
|
||
// keccak256 signature for OnRampSet event set as constant | ||
bytes32 private constant EVENT_SIGNATURE = 0x1f7d0ec248b80e5c0dde0ee531c4fc8fdb6ce9a2b3d90f560c74acd6a7202f23; | ||
|
||
constructor(address contractaddress, address _routerAddress) ConfirmedOwner(msg.sender) { | ||
linkAvailableBalanceMonitorAddress = LinkAvailableBalanceMonitor(contractaddress); | ||
routerAddress = _routerAddress; | ||
} | ||
|
||
// Option to change the Balance Monitor Address | ||
function setBalanceMonitorAddress(address _newBalMonAddress) external onlyOwner { | ||
linkAvailableBalanceMonitorAddress = LinkAvailableBalanceMonitor(_newBalMonAddress); | ||
} | ||
|
||
// Option to change the Router Address | ||
// Changing Router Address would also require setting up new Upkeep as Upkeep is linked with the Router and cannot be changed | ||
function setRouterAddress(address _newRouterAddress) external onlyOwner { | ||
routerAddress = _newRouterAddress; | ||
} | ||
|
||
function updateWatchList(address _targetAddress, uint64 _dstChainSelector) internal { | ||
linkAvailableBalanceMonitorAddress.addToWatchListOrDecommission(_targetAddress, _dstChainSelector); | ||
} | ||
|
||
function checkLog( | ||
poke1994 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Log calldata log, | ||
bytes memory checkData | ||
) external view override returns (bool upkeepNeeded, bytes memory performData) { | ||
// Ensure Router address is set | ||
require(routerAddress != address(0), "Router address not set"); | ||
|
||
// Define the event signature for OnRampSet(uint64,address) | ||
//bytes32 eventSignature = keccak256(abi.encodePacked("OnRampSet(uint64,address)")); | ||
|
||
// Check if the log source matches router contract and topics contain the event signature | ||
if (log.source == routerAddress && log.topics.length > 0 && log.topics[0] == EVENT_SIGNATURE) { | ||
// Extract the indexed parameter from the log | ||
uint64 destChainSelector = uint64(uint256(log.topics[1])); // cast to uint64 | ||
address onRamp = address(uint160(uint256(bytes32(log.data)))); // extract from log.data | ||
|
||
// No sanity checks necessary as the would on to relay information to LinkAvailableBalanceMonitor as it is | ||
// Checking is enabled in LinkAvailableBalanceMonitor contract | ||
return (true, abi.encode(destChainSelector, onRamp)); | ||
} | ||
|
||
// If the event signature doesn't match or log source is not Router contract, no upkeep is needed | ||
return (false, ""); | ||
} | ||
|
||
function performUpkeep(bytes memory performData) external override { | ||
// Decode the data received from checkLog | ||
(uint64 destChainSelector, address onRamp) = abi.decode(performData, (uint64, address)); | ||
// Perform the necessary upkeep actions based on the decoded data | ||
updateWatchList(onRamp, destChainSelector); | ||
emit setWatchlistOnMonitor(destChainSelector, onRamp); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
let's import specific struct / interface