/
IFlowScheduler.sol
157 lines (145 loc) · 6.19 KB
/
IFlowScheduler.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
// SPDX-License-Identifier: AGPLv3
pragma solidity ^0.8.0;
import {
ISuperToken
} from "@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/ISuperfluid.sol";
interface IFlowScheduler {
error TimeWindowInvalid();
error AccountInvalid();
error ZeroAddress();
error HostInvalid();
error ScheduleInvalid();
error UserDataInvalid();
struct FlowSchedule {
uint32 startDate;
uint32 startMaxDelay;
uint32 endDate;
int96 flowRate;
uint256 startAmount;
bytes32 userData;
}
/**
* @dev Event emitted on creation of a new flow schedule
* @param superToken The SuperToken to be sent
* @param sender The sender account
* @param receiver The receiver account
* @param startDate The timestamp when the stream should start (or 0 if starting not required)
* @param startMaxDelay How many seconds the stream is allowed to start after startDate
* @param flowRate The flowRate for the stream (or 0 if starting not required)
* @param endDate The timestamp when the stream should stop (or 0 if closing not required)
* @param startAmount The amount to be transferred at startDate additionally to starting a stream
* @param userData Arbitrary UserData to be added to the stream (or bytes(0) if no data needed)
*/
event FlowScheduleCreated(
ISuperToken indexed superToken,
address indexed sender,
address indexed receiver,
uint32 startDate,
uint32 startMaxDelay,
int96 flowRate,
uint32 endDate,
uint256 startAmount,
bytes userData
);
/**
* @dev Event emitted on deletion of a flow schedule
* @param superToken The SuperToken to be sent
* @param sender The sender account
* @param receiver The receiver account
*/
event FlowScheduleDeleted(ISuperToken indexed superToken, address indexed sender, address indexed receiver);
/**
* @dev Emitted when the start of a stream is executed
* @param superToken The SuperToken to be sent
* @param sender The sender account
* @param receiver The receiver account
* @param startDate The timestamp when the stream should start (or 0 if starting not required)
* @param startMaxDelay How many seconds the stream is allowed to start after startDate
* @param flowRate The flowRate for the stream (or 0 if starting not required)
* @param startAmount The amount you would like to transfer at the startDate when you start streaming
* @param userData Arbitrary UserData to be added to the stream (or bytes(0) if no data needed)
*/
event CreateFlowExecuted(
ISuperToken indexed superToken,
address indexed sender,
address indexed receiver,
uint32 startDate,
uint32 startMaxDelay,
int96 flowRate,
uint256 startAmount,
bytes userData
);
/**
* @dev Emitted when the stopping of a stream is executed
* @param superToken The SuperToken to be sent
* @param sender The sender account
* @param receiver The receiver account
* @param endDate The timestamp when the stream should stop (or 0 if closing not required)
* @param userData Arbitrary UserData to be added to the stream (or bytes(0) if no data needed)
*/
event DeleteFlowExecuted(
ISuperToken indexed superToken, address indexed sender, address indexed receiver, uint32 endDate, bytes userData
);
/**
* @dev Creates a new flow schedule
* @param superToken The SuperToken to be sent
* @param receiver The receiver account
* @param startDate The timestamp when the stream should start (or 0 if starting not required)
* @param startMaxDelay How many seconds the stream is allowed to start after startDate
* @param flowRate The flowRate for the stream (or 0 if starting not required)
* @param startAmount The amount to be transferred at startDate additionally to starting a stream
* @param endDate The timestamp when the stream should stop (or 0 if closing not required)
* @param userData Arbitrary UserData to be added to the stream (or bytes(0) if no data needed)
* @param ctx Superfluid context used when batching operations. (or bytes(0) if not SF batching)
*/
function createFlowSchedule(
ISuperToken superToken,
address receiver,
uint32 startDate,
uint32 startMaxDelay,
int96 flowRate,
uint256 startAmount,
uint32 endDate,
bytes memory userData,
bytes memory ctx
) external returns (bytes memory newCtx);
/**
* @dev Deletes a flow schedule
* @param superToken The SuperToken to be sent
* @param receiver The receiver account
* @param ctx Superfluid context used when batching operations. (or bytes(0) if not SF batching)
*/
function deleteFlowSchedule(ISuperToken superToken, address receiver, bytes memory ctx)
external
returns (bytes memory newCtx);
/**
* @dev Executes the starting of a stream
* @param superToken The SuperToken to be sent
* @param sender The sender account
* @param receiver The receiver account
* @param userData Arbitrary UserData to be added to the stream (or bytes(0) if no data needed)
*/
function executeCreateFlow(ISuperToken superToken, address sender, address receiver, bytes memory userData)
external
returns (bool success);
/**
* @dev Executes the stopping of a stream
* @param superToken The SuperToken to be sent
* @param sender The sender account
* @param receiver The receiver account
* @param userData Arbitrary UserData to be added to the stream (or bytes(0) if no data needed)
*/
function executeDeleteFlow(ISuperToken superToken, address sender, address receiver, bytes memory userData)
external
returns (bool success);
/**
* @dev Get data currently stored for a flow schedule
* @param superToken The SuperToken to be sent
* @param sender The sender account
* @param receiver The receiver account
*/
function getFlowSchedule(address superToken, address sender, address receiver)
external
view
returns (FlowSchedule memory);
}