Commit dd366772 authored by smartcontracts's avatar smartcontracts Committed by GitHub

fix(ct): various small Drippie management fixes (#10762)

Fixes a number of small bugs in the Drippie management script.

- Fixes a bug that caused Gelato tasks to be created with the
wrong time interval.
- Improves the Drippie script to correctly pause tasks that are
no longer present in the config file.
- Adds config file prefixing so that the management script can
be used with a number of different config files without those
other tasks being paused by accident.
parent 26e7d370
...@@ -2,10 +2,13 @@ ...@@ -2,10 +2,13 @@
"drippie": "0xd6F935Bd272BEE05bD64096D82970482EF16D64b", "drippie": "0xd6F935Bd272BEE05bD64096D82970482EF16D64b",
"gelato": "0x859E31b3848Ec384012EECc72C5c49821008296C", "gelato": "0x859E31b3848Ec384012EECc72C5c49821008296C",
"note": "Object attributes below are prefixed with numbers because of how foundry parses JSON into structs in alphabetical order", "__comment": "Prefix is used to namespace drips so that drip management can be handled modularly",
"prefix": "faucetbridged",
"__comment": "Object attributes below are prefixed with numbers because of how foundry parses JSON into structs in alphabetical order",
"drips": [ "drips": [
{ {
"00__name": "FaucetBridgedDrip_opmainnet_V1", "00__name": "opmainnet_v1",
"01__dripcheck": "CheckTrue", "01__dripcheck": "CheckTrue",
"02__checkparams": {}, "02__checkparams": {},
"03__recipient": "0xFBb0621E0B23b5478B630BD55a5f21f67730B0F1", "03__recipient": "0xFBb0621E0B23b5478B630BD55a5f21f67730B0F1",
...@@ -14,7 +17,7 @@ ...@@ -14,7 +17,7 @@
"06__data": "0x000000000000000000000000f21d42203af9af1c86e1e8ac501b41f5bc004a0a0000000000000000000000000000000000000000000000000000000000030d4000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000" "06__data": "0x000000000000000000000000f21d42203af9af1c86e1e8ac501b41f5bc004a0a0000000000000000000000000000000000000000000000000000000000030d4000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000"
}, },
{ {
"00__name": "FaucetBridgedDrip_base_V1", "00__name": "base_v1",
"01__dripcheck": "CheckTrue", "01__dripcheck": "CheckTrue",
"02__checkparams": {}, "02__checkparams": {},
"03__recipient": "0xfd0Bf71F60660E2f608ed56e1659C450eB113120", "03__recipient": "0xfd0Bf71F60660E2f608ed56e1659C450eB113120",
...@@ -23,7 +26,7 @@ ...@@ -23,7 +26,7 @@
"06__data": "0x000000000000000000000000f21d42203af9af1c86e1e8ac501b41f5bc004a0a0000000000000000000000000000000000000000000000000000000000030d4000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000" "06__data": "0x000000000000000000000000f21d42203af9af1c86e1e8ac501b41f5bc004a0a0000000000000000000000000000000000000000000000000000000000030d4000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000"
}, },
{ {
"00__name": "FaucetBridgedDrip_zora_V1", "00__name": "zora_v1",
"01__dripcheck": "CheckTrue", "01__dripcheck": "CheckTrue",
"02__checkparams": {}, "02__checkparams": {},
"03__recipient": "0x5376f1D543dcbB5BD416c56C189e4cB7399fCcCB", "03__recipient": "0x5376f1D543dcbB5BD416c56C189e4cB7399fCcCB",
...@@ -32,7 +35,7 @@ ...@@ -32,7 +35,7 @@
"06__data": "0x000000000000000000000000f21d42203af9af1c86e1e8ac501b41f5bc004a0a0000000000000000000000000000000000000000000000000000000000030d4000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000" "06__data": "0x000000000000000000000000f21d42203af9af1c86e1e8ac501b41f5bc004a0a0000000000000000000000000000000000000000000000000000000000030d4000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000"
}, },
{ {
"00__name": "FaucetBridgedDrip_pgn_V1", "00__name": "pgn_v1",
"01__dripcheck": "CheckTrue", "01__dripcheck": "CheckTrue",
"02__checkparams": {}, "02__checkparams": {},
"03__recipient": "0xFaE6abCAF30D23e233AC7faF747F2fC3a5a6Bfa3", "03__recipient": "0xFaE6abCAF30D23e233AC7faF747F2fC3a5a6Bfa3",
...@@ -41,7 +44,7 @@ ...@@ -41,7 +44,7 @@
"06__data": "0x000000000000000000000000f21d42203af9af1c86e1e8ac501b41f5bc004a0a0000000000000000000000000000000000000000000000000000000000030d4000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000" "06__data": "0x000000000000000000000000f21d42203af9af1c86e1e8ac501b41f5bc004a0a0000000000000000000000000000000000000000000000000000000000030d4000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000"
}, },
{ {
"00__name": "FaucetBridgedDrip_orderly_V1", "00__name": "orderly_v1",
"01__dripcheck": "CheckTrue", "01__dripcheck": "CheckTrue",
"02__checkparams": {}, "02__checkparams": {},
"03__recipient": "0x1Af0494040d6904A9F3EE21921de4b359C736333", "03__recipient": "0x1Af0494040d6904A9F3EE21921de4b359C736333",
...@@ -50,7 +53,7 @@ ...@@ -50,7 +53,7 @@
"06__data": "0x000000000000000000000000f21d42203af9af1c86e1e8ac501b41f5bc004a0a0000000000000000000000000000000000000000000000000000000000030d4000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000" "06__data": "0x000000000000000000000000f21d42203af9af1c86e1e8ac501b41f5bc004a0a0000000000000000000000000000000000000000000000000000000000030d4000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000"
}, },
{ {
"00__name": "FaucetBridgedDrip_mode_V1", "00__name": "mode_v1",
"01__dripcheck": "CheckTrue", "01__dripcheck": "CheckTrue",
"02__checkparams": {}, "02__checkparams": {},
"03__recipient": "0xbC5C679879B2965296756CD959C3C739769995E2", "03__recipient": "0xbC5C679879B2965296756CD959C3C739769995E2",
...@@ -59,7 +62,7 @@ ...@@ -59,7 +62,7 @@
"06__data": "0x000000000000000000000000f21d42203af9af1c86e1e8ac501b41f5bc004a0a0000000000000000000000000000000000000000000000000000000000030d4000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000" "06__data": "0x000000000000000000000000f21d42203af9af1c86e1e8ac501b41f5bc004a0a0000000000000000000000000000000000000000000000000000000000030d4000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000"
}, },
{ {
"00__name": "FaucetBridgedDrip_lyra_V1", "00__name": "lyra_v1",
"01__dripcheck": "CheckTrue", "01__dripcheck": "CheckTrue",
"02__checkparams": {}, "02__checkparams": {},
"03__recipient": "0x915f179A77FB2e1AeA8b56Ebc0D75A7e1A8a7A17", "03__recipient": "0x915f179A77FB2e1AeA8b56Ebc0D75A7e1A8a7A17",
...@@ -68,7 +71,7 @@ ...@@ -68,7 +71,7 @@
"06__data": "0x000000000000000000000000f21d42203af9af1c86e1e8ac501b41f5bc004a0a0000000000000000000000000000000000000000000000000000000000030d4000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000" "06__data": "0x000000000000000000000000f21d42203af9af1c86e1e8ac501b41f5bc004a0a0000000000000000000000000000000000000000000000000000000000030d4000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000"
}, },
{ {
"00__name": "FaucetBridgedDrip_lisk_V1", "00__name": "lisk_v1",
"01__dripcheck": "CheckTrue", "01__dripcheck": "CheckTrue",
"02__checkparams": {}, "02__checkparams": {},
"03__recipient": "0x1Fb30e446eA791cd1f011675E5F3f5311b70faF5", "03__recipient": "0x1Fb30e446eA791cd1f011675E5F3f5311b70faF5",
......
...@@ -2,10 +2,13 @@ ...@@ -2,10 +2,13 @@
"drippie": "0xd6F935Bd272BEE05bD64096D82970482EF16D64b", "drippie": "0xd6F935Bd272BEE05bD64096D82970482EF16D64b",
"gelato": "0x859E31b3848Ec384012EECc72C5c49821008296C", "gelato": "0x859E31b3848Ec384012EECc72C5c49821008296C",
"note": "Object attributes below are prefixed with numbers because of how foundry parses JSON into structs in alphabetical order", "__comment": "Prefix is used to namespace drips so that drip management can be handled modularly",
"prefix": "faucetcore",
"__comment": "Object attributes below are prefixed with numbers because of how foundry parses JSON into structs in alphabetical order",
"drips": [ "drips": [
{ {
"00__name": "FaucetDrip_V1", "00__name": "balance_v1",
"01__dripcheck": "CheckBalanceLow", "01__dripcheck": "CheckBalanceLow",
"02__checkparams": { "02__checkparams": {
"01__target": "0xF21d42203AF9af1C86E1e8ac501B41f5bc004A0a", "01__target": "0xF21d42203AF9af1C86E1e8ac501B41f5bc004A0a",
...@@ -17,7 +20,7 @@ ...@@ -17,7 +20,7 @@
"06__data": "" "06__data": ""
}, },
{ {
"00__name": "FaucetDrip_V2", "00__name": "balance_v2",
"01__dripcheck": "CheckBalanceLow", "01__dripcheck": "CheckBalanceLow",
"02__checkparams": { "02__checkparams": {
"01__target": "0xF21d42203AF9af1C86E1e8ac501B41f5bc004A0a", "01__target": "0xF21d42203AF9af1C86E1e8ac501B41f5bc004A0a",
...@@ -29,7 +32,7 @@ ...@@ -29,7 +32,7 @@
"06__data": "" "06__data": ""
}, },
{ {
"00__name": "FaucetAdminDrip_V1", "00__name": "admin_v1",
"01__dripcheck": "CheckBalanceLow", "01__dripcheck": "CheckBalanceLow",
"02__checkparams": { "02__checkparams": {
"01__target": "0x212E789D4523D4BAF464f8Fb2A9B9dff2B36e5A6", "01__target": "0x212E789D4523D4BAF464f8Fb2A9B9dff2B36e5A6",
...@@ -41,7 +44,7 @@ ...@@ -41,7 +44,7 @@
"06__data": "" "06__data": ""
}, },
{ {
"00__name": "FaucetGelatoDrip_V1", "00__name": "gelato_v1",
"01__dripcheck": "CheckGelatoLow", "01__dripcheck": "CheckGelatoLow",
"02__checkparams": { "02__checkparams": {
"00__treasury": "0x7506C12a824d73D9b08564d5Afc22c949434755e", "00__treasury": "0x7506C12a824d73D9b08564d5Afc22c949434755e",
......
{ {
"drippie": "0xd6F935Bd272BEE05bD64096D82970482EF16D64b", "drippie": "0xa0fF2a54AdC3fB33c44a141E67d194CF249258cb",
"gelato": "0x2A6C106ae13B558BB9E2Ec64Bd2f1f7BEFF3A5E0", "gelato": "0x2A6C106ae13B558BB9E2Ec64Bd2f1f7BEFF3A5E0",
"note": "Object attributes below are prefixed with numbers because of how foundry parses JSON into structs in alphabetical order", "__comment": "Prefix is used to namespace drips so that drip management can be handled modularly",
"prefix": "operations",
"__comment": "Object attributes below are prefixed with numbers because of how foundry parses JSON into structs in alphabetical order",
"drips": [ "drips": [
{ {
"00__name": "OperationsSequencerDrip_V1", "00__name": "sequencer_v2",
"01__dripcheck": "CheckBalanceLow", "01__dripcheck": "CheckBalanceLow",
"02__checkparams": { "02__checkparams": {
"01__target": "0x8F23BB38F531600e5d8FDDaAEC41F13FaB46E98c", "01__target": "0x8F23BB38F531600e5d8FDDaAEC41F13FaB46E98c",
"02__threshold": 100000000000000000000 "02__threshold": 1000000000000000000000
}, },
"03__recipient": "0x8F23BB38F531600e5d8FDDaAEC41F13FaB46E98c", "03__recipient": "0x8F23BB38F531600e5d8FDDaAEC41F13FaB46E98c",
"04__value": 20000000000000000000, "04__value": 100000000000000000000,
"05__interval": 86400, "05__interval": 3600,
"06__data": "" "06__data": ""
}, },
{ {
"00__name": "OperationsProposerDrip_V1", "00__name": "proposer_v2",
"01__dripcheck": "CheckBalanceLow", "01__dripcheck": "CheckBalanceLow",
"02__checkparams": { "02__checkparams": {
"01__target": "0x49277EE36A024120Ee218127354c4a3591dc90A9", "01__target": "0x49277EE36A024120Ee218127354c4a3591dc90A9",
...@@ -29,27 +32,27 @@ ...@@ -29,27 +32,27 @@
"06__data": "" "06__data": ""
}, },
{ {
"00__name": "OperationsGelatoDrip_V1", "00__name": "gelato_v2",
"01__dripcheck": "CheckGelatoLow", "01__dripcheck": "CheckGelatoLow",
"02__checkparams": { "02__checkparams": {
"00__treasury": "0x7506C12a824d73D9b08564d5Afc22c949434755e", "00__treasury": "0x7506C12a824d73D9b08564d5Afc22c949434755e",
"01__threshold": 1000000000000000000, "01__threshold": 1000000000000000000,
"02__recipient": "0x03C256F7Ae7518D0fe489F257ab4b928D37CBE16" "02__recipient": "0xCd438409d5Cac9D2E076Ac7Bd0Bf2377E99BB6e4"
}, },
"03__recipient": "0x7506C12a824d73D9b08564d5Afc22c949434755e", "03__recipient": "0x7506C12a824d73D9b08564d5Afc22c949434755e",
"04__value": 1000000000000000000, "04__value": 1000000000000000000,
"05__interval": 86400, "05__interval": 86400,
"06__data": "0x00000000000000000000000003c256f7ae7518d0fe489f257ab4b928d37cbe16" "06__data": "0x0000000000000000000000000Cd438409d5Cac9D2E076Ac7Bd0Bf2377E99BB6e4"
}, },
{ {
"00__name": "OperationsSecretsDrip_V1", "00__name": "secrets_v2",
"01__dripcheck": "CheckSecrets", "01__dripcheck": "CheckSecrets",
"02__checkparams": { "02__checkparams": {
"00__delay": 43200, "00__delay": 43200,
"01__secretHashMustExist": "0x565fa8c7daa859353b5b328b97b12c7d66c5832b2a24d4e0f739a65ad266a46f", "01__secretHashMustExist": "0x565fa8c7daa859353b5b328b97b12c7d66c5832b2a24d4e0f739a65ad266a46f",
"02__secretHashMustNotExist": "0xbc362b01d69a85dff1793803dde67df1f338f37a36fdc73dddf27283d215e614" "02__secretHashMustNotExist": "0xbc362b01d69a85dff1793803dde67df1f338f37a36fdc73dddf27283d215e614"
}, },
"03__recipient": "0x03C256F7Ae7518D0fe489F257ab4b928D37CBE16", "03__recipient": "0xCd438409d5Cac9D2E076Ac7Bd0Bf2377E99BB6e4",
"04__value": 1000000000000000000, "04__value": 1000000000000000000,
"05__interval": 3600, "05__interval": 3600,
"06__data": "" "06__data": ""
......
{ {
"create2DeploymentSalt": "0.0.3", "create2DeploymentSalt": "0.0.7",
"gelatoAutomateContract": "0x2A6C106ae13B558BB9E2Ec64Bd2f1f7BEFF3A5E0", "gelatoAutomateContract": "0x2A6C106ae13B558BB9E2Ec64Bd2f1f7BEFF3A5E0",
"operationsDrippieOwner": "0x03C256F7Ae7518D0fe489F257ab4b928D37CBE16", "operationsDrippieOwner": "0xCd438409d5Cac9D2E076Ac7Bd0Bf2377E99BB6e4",
"faucetDrippieOwner": "0x10ab157483dd308f8B38aCF2ad823dfD255F56b5", "faucetDrippieOwner": "0x10ab157483dd308f8B38aCF2ad823dfD255F56b5",
"opChainAdminWalletDripValue": 1000000000000000000, "opChainAdminWalletDripValue": 1000000000000000000,
......
...@@ -46,9 +46,15 @@ contract DrippieConfig is Script, Artifacts { ...@@ -46,9 +46,15 @@ contract DrippieConfig is Script, Artifacts {
/// @notice Gelato automation contract. /// @notice Gelato automation contract.
IGelato public gelato; IGelato public gelato;
/// @notice Prefix for the configuration file.
string public prefix;
/// @notice Drip configuration array. /// @notice Drip configuration array.
FullDripConfig[] public drips; FullDripConfig[] public drips;
/// @notice Mapping of drip names in the config.
mapping(string => bool) public names;
/// @param _path Path to the configuration file. /// @param _path Path to the configuration file.
constructor(string memory _path) { constructor(string memory _path) {
// Make sure artifacts are set up. // Make sure artifacts are set up.
...@@ -69,6 +75,9 @@ contract DrippieConfig is Script, Artifacts { ...@@ -69,6 +75,9 @@ contract DrippieConfig is Script, Artifacts {
// Load the Gelato contract address. // Load the Gelato contract address.
gelato = IGelato(stdJson.readAddress(_json, "$.gelato")); gelato = IGelato(stdJson.readAddress(_json, "$.gelato"));
// Load the prefix.
prefix = stdJson.readString(_json, "$.prefix");
// Determine the number of drips. // Determine the number of drips.
// In an ideal world we'd be able to load this array in one go by parsing it as an array // In an ideal world we'd be able to load this array in one go by parsing it as an array
// of structs that include the checkparams as bytes. Unfortunately, Foundry parses the // of structs that include the checkparams as bytes. Unfortunately, Foundry parses the
...@@ -83,7 +92,8 @@ contract DrippieConfig is Script, Artifacts { ...@@ -83,7 +92,8 @@ contract DrippieConfig is Script, Artifacts {
for (uint256 i = 0; i < corecfg.length; i++) { for (uint256 i = 0; i < corecfg.length; i++) {
// Log so we know what's being loaded. // Log so we know what's being loaded.
string memory name = corecfg[i].name; string memory name = corecfg[i].name;
console.log("DrippieConfig: attempting to load config for %s", name); string memory fullname = string.concat(prefix, "_", name);
console.log("DrippieConfig: attempting to load config for %s", fullname);
// Make sure the dripcheck is deployed. // Make sure the dripcheck is deployed.
string memory dripcheck = corecfg[i].dripcheck; string memory dripcheck = corecfg[i].dripcheck;
...@@ -97,7 +107,7 @@ contract DrippieConfig is Script, Artifacts { ...@@ -97,7 +107,7 @@ contract DrippieConfig is Script, Artifacts {
bytes memory checkparams = stdJson.parseRaw(_json, string.concat(p, ".02__checkparams")); bytes memory checkparams = stdJson.parseRaw(_json, string.concat(p, ".02__checkparams"));
// Determine if the parameters are decodable. // Determine if the parameters are decodable.
console.log("DrippieConfig: attempting to decode check parameters for %s", name); console.log("DrippieConfig: attempting to decode check parameters for %s", fullname);
if (strcmp(dripcheck, "CheckBalanceLow")) { if (strcmp(dripcheck, "CheckBalanceLow")) {
abi.decode(checkparams, (CheckBalanceLow.Params)); abi.decode(checkparams, (CheckBalanceLow.Params));
} else if (strcmp(dripcheck, "CheckGelatoLow")) { } else if (strcmp(dripcheck, "CheckGelatoLow")) {
...@@ -114,7 +124,7 @@ contract DrippieConfig is Script, Artifacts { ...@@ -114,7 +124,7 @@ contract DrippieConfig is Script, Artifacts {
// Parse all the easy stuff first. // Parse all the easy stuff first.
console.log("DrippieConfig: attempting to load core configuration for %s", name); console.log("DrippieConfig: attempting to load core configuration for %s", name);
FullDripConfig memory dripcfg = FullDripConfig({ FullDripConfig memory dripcfg = FullDripConfig({
name: name, name: fullname,
dripcheck: dripcheck, dripcheck: dripcheck,
checkparams: checkparams, checkparams: checkparams,
recipient: stdJson.readAddress(_json, string.concat(p, ".03__recipient")), recipient: stdJson.readAddress(_json, string.concat(p, ".03__recipient")),
...@@ -125,6 +135,7 @@ contract DrippieConfig is Script, Artifacts { ...@@ -125,6 +135,7 @@ contract DrippieConfig is Script, Artifacts {
// Ok we're good to go. // Ok we're good to go.
drips.push(dripcfg); drips.push(dripcfg);
names[fullname] = true;
} }
} }
......
...@@ -4,6 +4,8 @@ pragma solidity ^0.8.0; ...@@ -4,6 +4,8 @@ pragma solidity ^0.8.0;
import { console2 as console } from "forge-std/console2.sol"; import { console2 as console } from "forge-std/console2.sol";
import { Script } from "forge-std/Script.sol"; import { Script } from "forge-std/Script.sol";
import { LibString } from "solady/src/utils/LibString.sol";
import { IAutomate as IGelato } from "gelato/interfaces/IAutomate.sol"; import { IAutomate as IGelato } from "gelato/interfaces/IAutomate.sol";
import { LibDataTypes as GelatoDataTypes } from "gelato/libraries/LibDataTypes.sol"; import { LibDataTypes as GelatoDataTypes } from "gelato/libraries/LibDataTypes.sol";
import { LibTaskId as GelatoTaskId } from "gelato/libraries/LibTaskId.sol"; import { LibTaskId as GelatoTaskId } from "gelato/libraries/LibTaskId.sol";
...@@ -47,13 +49,40 @@ contract ManageDrippie is Script, Artifacts { ...@@ -47,13 +49,40 @@ contract ManageDrippie is Script, Artifacts {
/// @notice Runs the management script. /// @notice Runs the management script.
function run() public { function run() public {
console.log("ManageDrippie: running"); pauseDrips();
installDrips(); installDrips();
} }
/// @notice Pauses drips that have been removed from config.
function pauseDrips() public broadcast {
console.log("ManageDrippie: pausing removed drips");
for (uint256 i = 0; i < cfg.drippie().getDripCount(); i++) {
// Skip drips that aren't prefixed for this config file.
string memory name = cfg.drippie().created(i);
if (!LibString.startsWith(name, cfg.prefix())) {
continue;
}
// Pause drips that are no longer in the config if not already paused.
if (!cfg.names(name)) {
// Pause the drip if it's active.
if (cfg.drippie().getDripStatus(name) == Drippie.DripStatus.ACTIVE) {
console.log("ManageDrippie: pausing drip for %s", name);
cfg.drippie().status(name, Drippie.DripStatus.PAUSED);
}
// Cancel the Gelato task if it's active.
if (_isGelatoDripTaskActive(cfg.gelato(), cfg.drippie(), name)) {
console.log("ManageDrippie: pausing Gelato task for %s", name);
_pauseGelatoDripTask(cfg.gelato(), cfg.drippie(), name);
}
}
}
}
/// @notice Installs drips in the drippie contract. /// @notice Installs drips in the drippie contract.
function installDrips() public broadcast { function installDrips() public broadcast {
console.log("ManageDrippie: installing Drippie config"); console.log("ManageDrippie: installing Drippie config for %s drips", cfg.dripsLength());
for (uint256 i = 0; i < cfg.dripsLength(); i++) { for (uint256 i = 0; i < cfg.dripsLength(); i++) {
DrippieConfig.FullDripConfig memory drip = abi.decode(cfg.drip(i), (DrippieConfig.FullDripConfig)); DrippieConfig.FullDripConfig memory drip = abi.decode(cfg.drip(i), (DrippieConfig.FullDripConfig));
Drippie.DripAction[] memory actions = new Drippie.DripAction[](1); Drippie.DripAction[] memory actions = new Drippie.DripAction[](1);
...@@ -93,15 +122,15 @@ contract ManageDrippie is Script, Artifacts { ...@@ -93,15 +122,15 @@ contract ManageDrippie is Script, Artifacts {
modules[0] = GelatoDataTypes.Module.PROXY; modules[0] = GelatoDataTypes.Module.PROXY;
modules[1] = GelatoDataTypes.Module.TRIGGER; modules[1] = GelatoDataTypes.Module.TRIGGER;
// Interval is in milliseconds, so we should be multiplying by 1000.
// We then want to attempt to trigger the drip 10x per interval, so we divide by 10.
// Total multiplier is then 1000 / 10 = 100.
uint128 interval = uint128(dripInterval) * 100;
// Create arguments for the PROXY and TRIGGER modules. // Create arguments for the PROXY and TRIGGER modules.
bytes[] memory args = new bytes[](2); bytes[] memory args = new bytes[](2);
args[0] = abi.encode(_name); args[0] = abi.encode(_name);
args[1] = abi.encode( args[1] = abi.encode(uint128(GelatoDataTypes.TriggerType.TIME), abi.encode(uint128(0), interval));
GelatoDataTypes.TriggerModuleData({
triggerType: GelatoDataTypes.TriggerType.TIME,
triggerConfig: abi.encode(GelatoDataTypes.Time({ nextExec: 0, interval: uint128(dripInterval) }))
})
);
// Create the task data. // Create the task data.
_taskData = GelatoTaskData({ _taskData = GelatoTaskData({
...@@ -127,6 +156,38 @@ contract ManageDrippie is Script, Artifacts { ...@@ -127,6 +156,38 @@ contract ManageDrippie is Script, Artifacts {
}); });
} }
/// @notice Determines if a gelato drip task is active or not.
/// @param _gelato The gelato contract.
/// @param _drippie The drippie contract.
/// @param _name The name of the drip being triggered.
/// @return _active True if the task is active, false otherwise.
function _isGelatoDripTaskActive(
IGelato _gelato,
Drippie _drippie,
string memory _name
)
internal
view
returns (bool _active)
{
GelatoTaskData memory taskData = _makeGelatoDripTaskData({ _drippie: _drippie, _name: _name });
bytes32 taskId = GelatoTaskId.getTaskId({
taskCreator: taskData.taskCreator,
execAddress: taskData.execAddress,
execSelector: GelatoBytes.memorySliceSelector(taskData.execData),
moduleData: taskData.moduleData,
feeToken: taskData.feeToken
});
// Iterate over the task IDs to see if the task is active.
bytes32[] memory taskIds = _gelato.getTaskIdsByUser(taskData.taskCreator);
for (uint256 i = 0; i < taskIds.length; i++) {
if (taskIds[i] == taskId) {
_active = true;
}
}
}
/// @notice Pauses a gelato drip task. /// @notice Pauses a gelato drip task.
/// @param _gelato The gelato contract. /// @param _gelato The gelato contract.
/// @param _drippie The drippie contract. /// @param _drippie The drippie contract.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment