DeFi Saver
Search…
Strategy Storage
Record of all the Strategies created
All the data associated with the Strategies are stored in this contract; users can subscribe to specific strategies that are created.
StrategyStorage stores an array of strategies (struct detailed below).
1
/// @dev Template/Class which defines a Strategy
2
/// @param name Name of the strategy useful for logging what strategy is executing
3
/// @param creator Address of the user which created the strategy
4
/// @param triggerIds Array of identifiers for trigger - bytes4(keccak256(TriggerName))
5
/// @param actionIds Array of identifiers for actions - bytes4(keccak256(ActionName))
6
/// @param paramMapping Describes how inputs to functions are piped from return/subbed values
7
/// @param continuous If the action is repeated (continuos) or one time
8
struct Strategy {
9
string name;
10
address creator;
11
bytes4[] triggerIds;
12
bytes4[] actionIds;
13
uint8[][] paramMapping;
14
bool continuous;
15
}
Copied!
Strategies can currently only be created by the owner, but there is a flag to open it so anyone can create strategies.
Below is the interface of the contract:
1
contract StrategyStorage {
2
/// @notice Creates a new strategy and writes the data in an array
3
/// @dev Can only be called by auth addresses if it's not open to public
4
/// @param _name Name of the strategy useful for logging what strategy is executing
5
/// @param _triggerIds Array of identifiers for trigger - bytes4(keccak256(TriggerName))
6
/// @param _actionIds Array of identifiers for actions - bytes4(keccak256(ActionName))
7
/// @param _paramMapping Describes how inputs to functions are piped from return/subbed values
8
/// @param _continuous If the action is repeated (continuos) or one time
9
function createStrategy(
10
string memory _name,
11
bytes4[] memory _triggerIds,
12
bytes4[] memory _actionIds,
13
uint8[][] memory _paramMapping,
14
bool _continuous
15
) public onlyAuthCreators returns (uint256);
16
17
/// @notice Switch to determine if bundles can be created by anyone
18
/// @dev Callable only by the owner
19
/// @param _openToPublic Flag if true anyone can create bundles
20
function changeEditPermission(bool _openToPublic) public onlyOwner;
21
22
////////////////////////////// VIEW METHODS /////////////////////////////////
23
24
function getStrategy(uint _strategyId) public view returns (Strategy memory);
25
function getStrategyCount() public view returns (uint256);
26
function getPaginatedStrategies(uint _page, uint _perPage) public view returns (Strategy[] memory);
27
}
Copied!
Last modified 6mo ago
Copy link