Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
0ae1166b
Commit
0ae1166b
authored
Jul 20, 2023
by
Andreas Bigger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port drippie contracts to triple slash natspec styling
parent
1a8f502f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
88 additions
and
153 deletions
+88
-153
Drippie.sol
...contracts-bedrock/contracts/periphery/drippie/Drippie.sol
+56
-93
IDripCheck.sol
...tracts-bedrock/contracts/periphery/drippie/IDripCheck.sol
+4
-8
CheckBalanceHigh.sol
...ntracts/periphery/drippie/dripchecks/CheckBalanceHigh.sol
+7
-14
CheckBalanceLow.sol
...ontracts/periphery/drippie/dripchecks/CheckBalanceLow.sol
+7
-14
CheckGelatoLow.sol
...contracts/periphery/drippie/dripchecks/CheckGelatoLow.sol
+9
-15
CheckTrue.sol
...rock/contracts/periphery/drippie/dripchecks/CheckTrue.sol
+5
-9
No files found.
packages/contracts-bedrock/contracts/periphery/drippie/Drippie.sol
View file @
0ae1166b
...
...
@@ -4,27 +4,22 @@ pragma solidity 0.8.15;
import { AssetReceiver } from "../AssetReceiver.sol";
import { IDripCheck } from "./IDripCheck.sol";
/**
* @title Drippie
* @notice Drippie is a system for managing automated contract interactions. A specific interaction
* is called a "drip" and can be executed according to some condition (called a dripcheck)
* and an execution interval. Drips cannot be executed faster than the execution interval.
* Drips can trigger arbitrary contract calls where the calling contract is this contract
* address. Drips can also send ETH value, which makes them ideal for keeping addresses
* sufficiently funded with ETH. Drippie is designed to be connected with smart contract
* automation services so that drips can be executed automatically. However, Drippie is
* specifically designed to be separated from these services so that trust assumptions are
* better compartmentalized.
*/
/// @title Drippie
/// @notice Drippie is a system for managing automated contract interactions. A specific interaction
/// is called a "drip" and can be executed according to some condition (called a dripcheck)
/// and an execution interval. Drips cannot be executed faster than the execution interval.
/// Drips can trigger arbitrary contract calls where the calling contract is this contract
/// address. Drips can also send ETH value, which makes them ideal for keeping addresses
/// sufficiently funded with ETH. Drippie is designed to be connected with smart contract
/// automation services so that drips can be executed automatically. However, Drippie is
/// specifically designed to be separated from these services so that trust assumptions are
/// better compartmentalized.
contract Drippie is AssetReceiver {
/**
* @notice Enum representing different status options for a given drip.
*
* @custom:value NONE Drip does not exist.
* @custom:value PAUSED Drip is paused and cannot be executed until reactivated.
* @custom:value ACTIVE Drip is active and can be executed.
* @custom:value ARCHIVED Drip is archived and can no longer be executed or reactivated.
*/
/// @notice Enum representing different status options for a given drip.
/// @custom:value NONE Drip does not exist.
/// @custom:value PAUSED Drip is paused and cannot be executed until reactivated.
/// @custom:value ACTIVE Drip is active and can be executed.
/// @custom:value ARCHIVED Drip is archived and can no longer be executed or reactivated.
enum DripStatus {
NONE,
PAUSED,
...
...
@@ -32,18 +27,14 @@ contract Drippie is AssetReceiver {
ARCHIVED
}
/**
* @notice Represents a drip action.
*/
/// @notice Represents a drip action.
struct DripAction {
address payable target;
bytes data;
uint256 value;
}
/**
* @notice Represents the configuration for a given drip.
*/
/// @notice Represents the configuration for a given drip.
struct DripConfig {
bool reentrant;
uint256 interval;
...
...
@@ -52,9 +43,7 @@ contract Drippie is AssetReceiver {
DripAction[] actions;
}
/**
* @notice Represents the state of an active drip.
*/
/// @notice Represents the state of an active drip.
struct DripState {
DripStatus status;
DripConfig config;
...
...
@@ -62,13 +51,10 @@ contract Drippie is AssetReceiver {
uint256 count;
}
/**
* @notice Emitted when a new drip is created.
*
* @param nameref Indexed name parameter (hashed).
* @param name Unindexed name parameter (unhashed).
* @param config Config for the created drip.
*/
/// @notice Emitted when a new drip is created.
/// @param nameref Indexed name parameter (hashed).
/// @param name Unindexed name parameter (unhashed).
/// @param config Config for the created drip.
event DripCreated(
// Emit name twice because indexed version is hashed.
string indexed nameref,
...
...
@@ -76,13 +62,10 @@ contract Drippie is AssetReceiver {
DripConfig config
);
/**
* @notice Emitted when a drip status is updated.
*
* @param nameref Indexed name parameter (hashed).
* @param name Unindexed name parameter (unhashed).
* @param status New drip status.
*/
/// @notice Emitted when a drip status is updated.
/// @param nameref Indexed name parameter (hashed).
/// @param name Unindexed name parameter (unhashed).
/// @param status New drip status.
event DripStatusUpdated(
// Emit name twice because indexed version is hashed.
string indexed nameref,
...
...
@@ -90,14 +73,11 @@ contract Drippie is AssetReceiver {
DripStatus status
);
/**
* @notice Emitted when a drip is executed.
*
* @param nameref Indexed name parameter (hashed).
* @param name Unindexed name parameter (unhashed).
* @param executor Address that executed the drip.
* @param timestamp Time when the drip was executed.
*/
/// @notice Emitted when a drip is executed.
/// @param nameref Indexed name parameter (hashed).
/// @param name Unindexed name parameter (unhashed).
/// @param executor Address that executed the drip.
/// @param timestamp Time when the drip was executed.
event DripExecuted(
// Emit name twice because indexed version is hashed.
string indexed nameref,
...
...
@@ -106,24 +86,17 @@ contract Drippie is AssetReceiver {
uint256 timestamp
);
/**
* @notice Maps from drip names to drip states.
*/
/// @notice Maps from drip names to drip states.
mapping(string => DripState) public drips;
/**
* @param _owner Initial contract owner.
*/
//// @param _owner Initial contract owner.
constructor(address _owner) AssetReceiver(_owner) {}
/**
* @notice Creates a new drip with the given name and configuration. Once created, drips cannot
* be modified in any way (this is a security measure). If you want to update a drip,
* simply pause (and potentially archive) the existing drip and create a new one.
*
* @param _name Name of the drip.
* @param _config Configuration for the drip.
*/
/// @notice Creates a new drip with the given name and configuration. Once created, drips cannot
/// be modified in any way (this is a security measure). If you want to update a drip,
/// simply pause (and potentially archive) the existing drip and create a new one.
/// @param _name Name of the drip.
/// @param _config Configuration for the drip.
function create(string calldata _name, DripConfig calldata _config) external onlyOwner {
// Make sure this drip doesn't already exist. We *must* guarantee that no other function
// will ever set the status of a drip back to NONE after it's been created. This is why
...
...
@@ -165,15 +138,12 @@ contract Drippie is AssetReceiver {
emit DripCreated(_name, _name, _config);
}
/**
* @notice Sets the status for a given drip. The behavior of this function depends on the
* status that the user is trying to set. A drip can always move between ACTIVE and
* PAUSED, but it can never move back to NONE and once ARCHIVED, it can never move back
* to ACTIVE or PAUSED.
*
* @param _name Name of the drip to update.
* @param _status New drip status.
*/
/// @notice Sets the status for a given drip. The behavior of this function depends on the
/// status that the user is trying to set. A drip can always move between ACTIVE and
/// PAUSED, but it can never move back to NONE and once ARCHIVED, it can never move back
/// to ACTIVE or PAUSED.
/// @param _name Name of the drip to update.
/// @param _status New drip status.
function status(string calldata _name, DripStatus _status) external onlyOwner {
// Make sure we can never set drip status back to NONE. A simple security measure to
// prevent accidental overwrites if this code is ever updated down the line.
...
...
@@ -223,13 +193,9 @@ contract Drippie is AssetReceiver {
emit DripStatusUpdated(_name, _name, _status);
}
/**
* @notice Checks if a given drip is executable.
*
* @param _name Drip to check.
*
* @return True if the drip is executable, reverts otherwise.
*/
/// @notice Checks if a given drip is executable.
/// @param _name Drip to check.
/// @return True if the drip is executable, reverts otherwise.
function executable(string calldata _name) public view returns (bool) {
DripState storage state = drips[_name];
...
...
@@ -259,18 +225,15 @@ contract Drippie is AssetReceiver {
return true;
}
/**
* @notice Triggers a drip. This function is deliberately left as a public function because the
* assumption being made here is that setting the drip to ACTIVE is an affirmative
* signal that the drip should be executable according to the drip parameters, drip
* check, and drip interval. Note that drip parameters are read entirely from the state
* and are not supplied as user input, so there should not be any way for a
* non-authorized user to influence the behavior of the drip. Note that the drip check
* is executed only **once** at the beginning of the call to the drip function and will
* not be executed again between the drip actions within this call.
*
* @param _name Name of the drip to trigger.
*/
/// @notice Triggers a drip. This function is deliberately left as a public function because the
/// assumption being made here is that setting the drip to ACTIVE is an affirmative
/// signal that the drip should be executable according to the drip parameters, drip
/// check, and drip interval. Note that drip parameters are read entirely from the state
/// and are not supplied as user input, so there should not be any way for a
/// non-authorized user to influence the behavior of the drip. Note that the drip check
/// is executed only **once** at the beginning of the call to the drip function and will
/// not be executed again between the drip actions within this call.
/// @param _name Name of the drip to trigger.
function drip(string calldata _name) external {
DripState storage state = drips[_name];
...
...
packages/contracts-bedrock/contracts/periphery/drippie/IDripCheck.sol
View file @
0ae1166b
...
...
@@ -7,12 +7,8 @@ interface IDripCheck {
// possible to easily encode parameters on the client side. Solidity does not support generics
// so it's not possible to do this with explicit typing.
/**
* @notice Checks whether a drip should be executable.
*
* @param _params Encoded parameters for the drip check.
*
* @return Whether the drip should be executed.
*/
function check(bytes memory _params) external view returns (bool);
/// @notice Checks whether a drip should be executable.
/// @param _params Encoded parameters for the drip check.
/// @return execute_ Whether the drip should be executed.
function check(bytes memory _params) external view returns (bool execute_);
}
packages/contracts-bedrock/contracts/periphery/drippie/dripchecks/CheckBalanceHigh.sol
View file @
0ae1166b
...
...
@@ -3,30 +3,23 @@ pragma solidity 0.8.15;
import { IDripCheck } from "../IDripCheck.sol";
/**
* @title CheckBalanceHigh
* @notice DripCheck for checking if an account's balance is above a given threshold.
*/
/// @title CheckBalanceHigh
/// @notice DripCheck for checking if an account's balance is above a given threshold.
contract CheckBalanceHigh is IDripCheck {
struct Params {
address target;
uint256 threshold;
}
/**
* @notice External event used to help client-side tooling encode parameters.
*
* @param params Parameters to encode.
*/
/// @notice External event used to help client-side tooling encode parameters.
/// @param params Parameters to encode.
event _EventToExposeStructInABI__Params(Params params);
/**
* @inheritdoc IDripCheck
*/
function check(bytes memory _params) external view returns (bool) {
/// @inheritdoc IDripCheck
function check(bytes memory _params) external view returns (bool execute_) {
Params memory params = abi.decode(_params, (Params));
// Check target balance is above threshold.
return
params.target.balance > params.threshold;
execute_ =
params.target.balance > params.threshold;
}
}
packages/contracts-bedrock/contracts/periphery/drippie/dripchecks/CheckBalanceLow.sol
View file @
0ae1166b
...
...
@@ -3,30 +3,23 @@ pragma solidity 0.8.15;
import { IDripCheck } from "../IDripCheck.sol";
/**
* @title CheckBalanceLow
* @notice DripCheck for checking if an account's balance is below a given threshold.
*/
/// @title CheckBalanceLow
/// @notice DripCheck for checking if an account's balance is below a given threshold.
contract CheckBalanceLow is IDripCheck {
struct Params {
address target;
uint256 threshold;
}
/**
* @notice External event used to help client-side tooling encode parameters.
*
* @param params Parameters to encode.
*/
/// @notice External event used to help client-side tooling encode parameters.
/// @param params Parameters to encode.
event _EventToExposeStructInABI__Params(Params params);
/**
* @inheritdoc IDripCheck
*/
function check(bytes memory _params) external view returns (bool) {
/// @inheritdoc IDripCheck
function check(bytes memory _params) external view returns (bool execute_) {
Params memory params = abi.decode(_params, (Params));
// Check target ETH balance is below threshold.
return
params.target.balance < params.threshold;
execute_ =
params.target.balance < params.threshold;
}
}
packages/contracts-bedrock/contracts/periphery/drippie/dripchecks/CheckGelatoLow.sol
View file @
0ae1166b
...
...
@@ -7,10 +7,8 @@ interface IGelatoTreasury {
function userTokenBalance(address _user, address _token) external view returns (uint256);
}
/**
* @title CheckGelatoLow
* @notice DripCheck for checking if an account's Gelato ETH balance is below some threshold.
*/
/// @title CheckGelatoLow
/// @notice DripCheck for checking if an account's Gelato ETH balance is below some threshold.
contract CheckGelatoLow is IDripCheck {
struct Params {
address treasury;
...
...
@@ -18,25 +16,21 @@ contract CheckGelatoLow is IDripCheck {
address recipient;
}
/**
* @notice External event used to help client-side tooling encode parameters.
*
* @param params Parameters to encode.
*/
/// @notice External event used to help client-side tooling encode parameters.
/// @param params Parameters to encode.
event _EventToExposeStructInABI__Params(Params params);
/**
* @inheritdoc IDripCheck
*/
function check(bytes memory _params) external view returns (bool) {
/// @inheritdoc IDripCheck
function check(bytes memory _params) external view returns (bool execute_) {
Params memory params = abi.decode(_params, (Params));
// Check GelatoTreasury ETH balance is below threshold.
return
execute_ =
IGelatoTreasury(params.treasury).userTokenBalance(
params.recipient,
// Gelato represents ETH as 0xeeeee....eeeee
0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE
) < params.threshold;
) <
params.threshold;
}
}
packages/contracts-bedrock/contracts/periphery/drippie/dripchecks/CheckTrue.sol
View file @
0ae1166b
...
...
@@ -3,15 +3,11 @@ pragma solidity 0.8.15;
import { IDripCheck } from "../IDripCheck.sol";
/**
* @title CheckTrue
* @notice DripCheck that always returns true.
*/
/// @title CheckTrue
/// @notice DripCheck that always returns true.
contract CheckTrue is IDripCheck {
/**
* @inheritdoc IDripCheck
*/
function check(bytes memory) external pure returns (bool) {
return true;
/// @inheritdoc IDripCheck
function check(bytes memory) external pure returns (bool execute_) {
execute_ = true;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment