@@ -103,7 +103,7 @@ abstract contract CFASuperAppBase is ISuperApp {
103
103
104
104
/// @dev override if the SuperApp shall have custom logic invoked when a new flow
105
105
/// to it is created.
106
- function onFlowCreated (
106
+ function onInflowCreated (
107
107
ISuperToken /*superToken*/ ,
108
108
address /*sender*/ ,
109
109
bytes calldata ctx
@@ -113,7 +113,7 @@ abstract contract CFASuperAppBase is ISuperApp {
113
113
114
114
/// @dev override if the SuperApp shall have custom logic invoked when an existing flow
115
115
/// to it is updated (flowrate change).
116
- function onFlowUpdated (
116
+ function onInflowUpdated (
117
117
ISuperToken /*superToken*/ ,
118
118
address /*sender*/ ,
119
119
int96 /*previousFlowRate*/ ,
@@ -127,9 +127,25 @@ abstract contract CFASuperAppBase is ISuperApp {
127
127
/// to it is deleted (flowrate set to 0).
128
128
/// Unlike the other callbacks, this method is NOT allowed to revert.
129
129
/// Failing to satisfy that requirement leads to jailing (defunct SuperApp).
130
- function onFlowDeleted (
130
+ function onInflowDeleted (
131
131
ISuperToken /*superToken*/ ,
132
132
address /*sender*/ ,
133
+ int96 /*previousFlowRate*/ ,
134
+ uint256 /*lastUpdated*/ ,
135
+ bytes calldata ctx
136
+ ) internal virtual returns (bytes memory /*newCtx*/ ) {
137
+ return ctx;
138
+ }
139
+
140
+ /// @dev override if the SuperApp shall have custom logic invoked when an outgoing flow
141
+ /// is deleted by the receiver (it's not triggered when deleted by the SuperApp itself).
142
+ /// A possible implementation is to make outflows "sticky" by simply reopening it.
143
+ /// Like onInflowDeleted, this method is NOT allowed to revert.
144
+ /// Note: In theory this hook could also be triggered by a liquidation, but this would imply
145
+ /// that the SuperApp is insolvent, and would thus be jailed already.
146
+ /// Thus in practice this is triggered only when a receiver deletes the flow.
147
+ function onOutflowDeleted (
148
+ ISuperToken /*superToken*/ ,
133
149
address /*receiver*/ ,
134
150
int96 /*previousFlowRate*/ ,
135
151
uint256 /*lastUpdated*/ ,
@@ -173,7 +189,7 @@ abstract contract CFASuperAppBase is ISuperApp {
173
189
(address sender , ) = abi.decode (agreementData, (address , address ));
174
190
175
191
return
176
- onFlowCreated (
192
+ onInflowCreated (
177
193
superToken,
178
194
sender,
179
195
ctx // userData can be acquired with `host.decodeCtx(ctx).userData`
@@ -218,7 +234,7 @@ abstract contract CFASuperAppBase is ISuperApp {
218
234
(int96 previousFlowRate , uint256 lastUpdated ) = abi.decode (cbdata, (int96 , uint256 ));
219
235
220
236
return
221
- onFlowUpdated (
237
+ onInflowUpdated (
222
238
superToken,
223
239
sender,
224
240
previousFlowRate,
@@ -272,15 +288,26 @@ abstract contract CFASuperAppBase is ISuperApp {
272
288
(address sender , address receiver ) = abi.decode (agreementData, (address , address ));
273
289
(uint256 lastUpdated , int96 previousFlowRate ) = abi.decode (cbdata, (uint256 , int96 ));
274
290
275
- return
276
- onFlowDeleted (
277
- superToken,
278
- sender,
279
- receiver,
280
- previousFlowRate,
281
- lastUpdated,
282
- ctx
291
+ if (receiver == address (this )) {
292
+ return
293
+ onInflowDeleted (
294
+ superToken,
295
+ sender,
296
+ previousFlowRate,
297
+ lastUpdated,
298
+ ctx
299
+ );
300
+ } else {
301
+ return
302
+ onOutflowDeleted (
303
+ superToken,
304
+ receiver,
305
+ previousFlowRate,
306
+ lastUpdated,
307
+ ctx
308
+ )
283
309
);
310
+ }
284
311
}
285
312
286
313
0 commit comments