@superfluid-finance/ethereum-contracts 1.5.2-dev.a97f248.0 → 1.5.2-dev.fe6f63e.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/contracts/AccessControl.json +1 -1
- package/build/contracts/AccessControlEnumerable.json +1 -1
- package/build/contracts/Address.json +1 -1
- package/build/contracts/AgreementBase.json +1 -1
- package/build/contracts/AgreementLibrary.json +1 -1
- package/build/contracts/BaseRelayRecipient.json +1 -1
- package/build/contracts/BatchLiquidator.json +1 -1
- package/build/contracts/BatchOperation.json +1 -1
- package/build/contracts/CFAv1Forwarder.json +1 -1
- package/build/contracts/CFAv1Library.json +1 -1
- package/build/contracts/CallUtils.json +1 -1
- package/build/contracts/ClosingOnUpdateFlowTestApp.json +1 -1
- package/build/contracts/ConstantFlowAgreementV1.json +1 -1
- package/build/contracts/Context.json +1 -1
- package/build/contracts/ContextDefinitions.json +1 -1
- package/build/contracts/CustomSuperTokenBase.json +1 -1
- package/build/contracts/ERC165.json +1 -1
- package/build/contracts/ERC1820Implementer.json +1 -1
- package/build/contracts/ERC1820RegistryCompiled.json +1 -1
- package/build/contracts/ERC20.json +1 -1
- package/build/contracts/ERC20WithTokenInfo.json +1 -1
- package/build/contracts/ERC777Helper.json +1 -1
- package/build/contracts/ERC777RecipientDrainingGas.json +1 -1
- package/build/contracts/ERC777RecipientReverting.json +1 -1
- package/build/contracts/EnumerableSet.json +1 -1
- package/build/contracts/EventsEmitter.json +1 -1
- package/build/contracts/ExclusiveInflowTestApp.json +1 -1
- package/build/contracts/FixedSizeData.json +1 -1
- package/build/contracts/FlowExchangeTestApp.json +1 -1
- package/build/contracts/FlowOperatorDefinitions.json +1 -1
- package/build/contracts/FullUpgradableSuperTokenProxy.json +1 -1
- package/build/contracts/IAccessControl.json +1 -1
- package/build/contracts/IAccessControlEnumerable.json +1 -1
- package/build/contracts/IConstantFlowAgreementHook.json +1 -1
- package/build/contracts/IConstantFlowAgreementV1.json +1 -1
- package/build/contracts/IDAv1Library.json +1 -1
- package/build/contracts/IERC165.json +1 -1
- package/build/contracts/IERC1820Implementer.json +1 -1
- package/build/contracts/IERC1820Registry.json +1 -1
- package/build/contracts/IERC20.json +1 -1
- package/build/contracts/IERC20Metadata.json +1 -1
- package/build/contracts/IERC20Permit.json +1 -1
- package/build/contracts/IERC777.json +1 -1
- package/build/contracts/IERC777Recipient.json +1 -1
- package/build/contracts/IERC777Sender.json +1 -1
- package/build/contracts/IInstantDistributionAgreementV1.json +1 -1
- package/build/contracts/IMultiSigWallet.json +1 -1
- package/build/contracts/IPureSuperToken.json +1 -1
- package/build/contracts/IPureSuperTokenCustom.json +1 -1
- package/build/contracts/IRelayRecipient.json +1 -1
- package/build/contracts/IResolver.json +1 -1
- package/build/contracts/ISETH.json +1 -1
- package/build/contracts/ISETHCustom.json +1 -1
- package/build/contracts/ISuperAgreement.json +1 -1
- package/build/contracts/ISuperApp.json +1 -1
- package/build/contracts/ISuperToken.json +1 -1
- package/build/contracts/ISuperTokenFactory.json +1 -1
- package/build/contracts/ISuperfluid.json +1 -1
- package/build/contracts/ISuperfluidGovernance.json +1 -1
- package/build/contracts/ISuperfluidToken.json +1 -1
- package/build/contracts/ITOGAv1.json +1 -1
- package/build/contracts/ITOGAv2.json +1 -1
- package/build/contracts/ITOGAv3.json +1 -1
- package/build/contracts/Initializable.json +1 -1
- package/build/contracts/InstantDistributionAgreementV1.json +1 -1
- package/build/contracts/Math.json +1 -1
- package/build/contracts/NonClosableOutflowTestApp.json +1 -1
- package/build/contracts/Ownable.json +1 -1
- package/build/contracts/Proxy.json +1 -1
- package/build/contracts/PureSuperToken.json +1 -1
- package/build/contracts/Resolver.json +1 -1
- package/build/contracts/SETHProxy.json +1 -1
- package/build/contracts/SafeCast.json +1 -1
- package/build/contracts/SafeERC20.json +1 -1
- package/build/contracts/SafeMath.json +1 -1
- package/build/contracts/SelfDeletingFlowTestApp.json +1 -1
- package/build/contracts/SlotsBitmapLibrary.json +1 -1
- package/build/contracts/StreamRedirector.json +1 -1
- package/build/contracts/Strings.json +1 -1
- package/build/contracts/SuperAppBase.json +1 -1
- package/build/contracts/SuperAppDefinitions.json +1 -1
- package/build/contracts/SuperToken.json +1 -1
- package/build/contracts/SuperTokenDeployerLibrary.json +1 -1
- package/build/contracts/SuperTokenFactory.json +1 -1
- package/build/contracts/SuperTokenFactoryBase.json +1 -1
- package/build/contracts/SuperTokenV1Library.json +1 -1
- package/build/contracts/SuperUpgrader.json +1 -1
- package/build/contracts/Superfluid.json +1 -1
- package/build/contracts/SuperfluidCFAv1DeployerLibrary.json +1 -1
- package/build/contracts/SuperfluidFrameworkDeployer.json +1 -1
- package/build/contracts/SuperfluidGovDeployerLibrary.json +1 -1
- package/build/contracts/SuperfluidGovernanceBase.json +1 -1
- package/build/contracts/SuperfluidGovernanceConfigs.json +1 -1
- package/build/contracts/SuperfluidGovernanceII.json +1 -1
- package/build/contracts/SuperfluidGovernanceIIProxy.json +1 -1
- package/build/contracts/SuperfluidHostDeployerLibrary.json +1 -1
- package/build/contracts/SuperfluidIDAv1DeployerLibrary.json +1 -1
- package/build/contracts/SuperfluidLoader.json +1 -1
- package/build/contracts/SuperfluidPeripheryDeployerLibrary.json +1 -1
- package/build/contracts/SuperfluidToken.json +1 -1
- package/build/contracts/TOGA.json +1 -1
- package/build/contracts/TestGovernance.json +1 -1
- package/build/contracts/TestResolver.json +1 -1
- package/build/contracts/TestToken.json +1 -1
- package/build/contracts/TokenInfo.json +1 -1
- package/build/contracts/UUPSProxiable.json +1 -1
- package/build/contracts/UUPSProxy.json +1 -1
- package/build/contracts/UUPSUtils.json +1 -1
- package/build/contracts-sizes.txt +9 -9
- package/package.json +2 -2
- package/contracts/mocks/AgreementMock.sol +0 -375
- package/contracts/mocks/CFAAppMocks.sol +0 -361
- package/contracts/mocks/CFAHookMocks.sol +0 -148
- package/contracts/mocks/CFALibraryMock.sol +0 -213
- package/contracts/mocks/CallUtilsMock.sol +0 -79
- package/contracts/mocks/CallUtilsTester.sol +0 -14
- package/contracts/mocks/CustomSuperTokenMock.sol +0 -104
- package/contracts/mocks/ERC777SenderRecipientMock.sol +0 -238
- package/contracts/mocks/FakeSuperfluidMock.sol +0 -21
- package/contracts/mocks/ForwarderMock.sol +0 -39
- package/contracts/mocks/IDASuperAppTester.sol +0 -297
- package/contracts/mocks/IDAv1LibraryMock.sol +0 -400
- package/contracts/mocks/MockSmartWallet.sol +0 -15
- package/contracts/mocks/MultiFlowTesterApp.sol +0 -336
- package/contracts/mocks/StreamRedirector.sol +0 -179
- package/contracts/mocks/SuperAppMocks.sol +0 -622
- package/contracts/mocks/SuperTokenFactoryMock.sol +0 -98
- package/contracts/mocks/SuperTokenLibraryV1Mock.sol +0 -583
- package/contracts/mocks/SuperTokenMock.sol +0 -113
- package/contracts/mocks/SuperfluidDestructorMock.sol +0 -14
- package/contracts/mocks/SuperfluidGovernanceIIMock.sol +0 -22
- package/contracts/mocks/SuperfluidMock.sol +0 -177
- package/contracts/mocks/UUPSProxiableMock.sol +0 -29
|
@@ -1,361 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: AGPLv3
|
|
2
|
-
pragma solidity 0.8.18;
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
ISuperfluid,
|
|
6
|
-
ISuperToken,
|
|
7
|
-
SuperAppBase,
|
|
8
|
-
SuperAppDefinitions
|
|
9
|
-
} from "../apps/SuperAppBase.sol";
|
|
10
|
-
import { IConstantFlowAgreementV1 } from "../interfaces/agreements/IConstantFlowAgreementV1.sol";
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @dev This is a CFA SuperApp that maintains at most one inflow from a sender at any moment.
|
|
14
|
-
*
|
|
15
|
-
* This can test the deposit credit logic in the deleteFlow as a recipient.
|
|
16
|
-
*/
|
|
17
|
-
contract ExclusiveInflowTestApp is SuperAppBase {
|
|
18
|
-
|
|
19
|
-
IConstantFlowAgreementV1 private _cfa;
|
|
20
|
-
ISuperfluid private _host;
|
|
21
|
-
address private _currentSender;
|
|
22
|
-
|
|
23
|
-
constructor(IConstantFlowAgreementV1 cfa, ISuperfluid superfluid) {
|
|
24
|
-
assert(address(cfa) != address(0));
|
|
25
|
-
assert(address(superfluid) != address(0));
|
|
26
|
-
_cfa = cfa;
|
|
27
|
-
_host = superfluid;
|
|
28
|
-
|
|
29
|
-
uint256 configWord =
|
|
30
|
-
SuperAppDefinitions.APP_LEVEL_FINAL
|
|
31
|
-
| SuperAppDefinitions.BEFORE_AGREEMENT_CREATED_NOOP
|
|
32
|
-
// | SuperAppDefinitions.AFTER_AGREEMENT_CREATED_NOOP
|
|
33
|
-
| SuperAppDefinitions.BEFORE_AGREEMENT_UPDATED_NOOP
|
|
34
|
-
| SuperAppDefinitions.AFTER_AGREEMENT_UPDATED_NOOP
|
|
35
|
-
| SuperAppDefinitions.BEFORE_AGREEMENT_TERMINATED_NOOP
|
|
36
|
-
// | SuperAppDefinitions.AFTER_AGREEMENT_TERMINATED_NOOP
|
|
37
|
-
;
|
|
38
|
-
|
|
39
|
-
_host.registerAppWithKey(configWord, "");
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function afterAgreementCreated(
|
|
43
|
-
ISuperToken superToken,
|
|
44
|
-
address /*agreementClass*/,
|
|
45
|
-
bytes32 /*agreementId*/,
|
|
46
|
-
bytes calldata /*agreementData*/,
|
|
47
|
-
bytes calldata /*cbdata*/,
|
|
48
|
-
bytes calldata ctx
|
|
49
|
-
)
|
|
50
|
-
external override
|
|
51
|
-
returns(bytes memory newCtx)
|
|
52
|
-
{
|
|
53
|
-
newCtx = ctx;
|
|
54
|
-
ISuperfluid.Context memory context = _host.decodeCtx(ctx);
|
|
55
|
-
if (_currentSender != address(0)) {
|
|
56
|
-
bytes memory callData = abi.encodeCall(
|
|
57
|
-
_cfa.deleteFlow,
|
|
58
|
-
(
|
|
59
|
-
superToken,
|
|
60
|
-
_currentSender,
|
|
61
|
-
address(this),
|
|
62
|
-
new bytes(0)
|
|
63
|
-
)
|
|
64
|
-
);
|
|
65
|
-
(newCtx, ) = _host.callAgreementWithContext(
|
|
66
|
-
_cfa,
|
|
67
|
-
callData,
|
|
68
|
-
new bytes(0), // user data
|
|
69
|
-
newCtx
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
_currentSender = context.msgSender;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function afterAgreementTerminated(
|
|
76
|
-
ISuperToken /*superToken*/,
|
|
77
|
-
address /*agreementClass*/,
|
|
78
|
-
bytes32 /*agreementId*/,
|
|
79
|
-
bytes calldata agreementData,
|
|
80
|
-
bytes calldata /*cbdata*/,
|
|
81
|
-
bytes calldata ctx
|
|
82
|
-
)
|
|
83
|
-
external override
|
|
84
|
-
returns(bytes memory newCtx)
|
|
85
|
-
{
|
|
86
|
-
(address flowSender, ) = abi.decode(agreementData, (address, address));
|
|
87
|
-
assert(flowSender == _currentSender);
|
|
88
|
-
_currentSender = address(0);
|
|
89
|
-
return ctx;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* @dev This is CFA SuperApp that refuses to close its outflow by its receiver.
|
|
96
|
-
*
|
|
97
|
-
* This test the logic that the app re-opens the same stream in the termination callback.
|
|
98
|
-
* In reality, the app would have to fund the app with enough tokens to not to be jailed due
|
|
99
|
-
* to low balance.
|
|
100
|
-
*/
|
|
101
|
-
contract NonClosableOutflowTestApp is SuperAppBase {
|
|
102
|
-
|
|
103
|
-
IConstantFlowAgreementV1 private _cfa;
|
|
104
|
-
ISuperfluid private _host;
|
|
105
|
-
address private _receiver;
|
|
106
|
-
int96 private _flowRate;
|
|
107
|
-
|
|
108
|
-
constructor(IConstantFlowAgreementV1 cfa, ISuperfluid superfluid) {
|
|
109
|
-
assert(address(cfa) != address(0));
|
|
110
|
-
assert(address(superfluid) != address(0));
|
|
111
|
-
_cfa = cfa;
|
|
112
|
-
_host = superfluid;
|
|
113
|
-
|
|
114
|
-
uint256 configWord =
|
|
115
|
-
SuperAppDefinitions.APP_LEVEL_FINAL
|
|
116
|
-
| SuperAppDefinitions.BEFORE_AGREEMENT_CREATED_NOOP
|
|
117
|
-
| SuperAppDefinitions.AFTER_AGREEMENT_CREATED_NOOP
|
|
118
|
-
| SuperAppDefinitions.BEFORE_AGREEMENT_UPDATED_NOOP
|
|
119
|
-
| SuperAppDefinitions.AFTER_AGREEMENT_UPDATED_NOOP
|
|
120
|
-
| SuperAppDefinitions.BEFORE_AGREEMENT_TERMINATED_NOOP
|
|
121
|
-
// | SuperAppDefinitions.AFTER_AGREEMENT_TERMINATED_NOOP
|
|
122
|
-
;
|
|
123
|
-
|
|
124
|
-
_host.registerAppWithKey(configWord, "");
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function setupOutflow(
|
|
128
|
-
ISuperToken superToken,
|
|
129
|
-
address receiver,
|
|
130
|
-
int96 flowRate
|
|
131
|
-
)
|
|
132
|
-
external
|
|
133
|
-
{
|
|
134
|
-
_receiver = receiver;
|
|
135
|
-
_flowRate = flowRate;
|
|
136
|
-
_host.callAgreement(
|
|
137
|
-
_cfa,
|
|
138
|
-
abi.encodeCall(
|
|
139
|
-
_cfa.createFlow,
|
|
140
|
-
(
|
|
141
|
-
superToken,
|
|
142
|
-
receiver,
|
|
143
|
-
flowRate,
|
|
144
|
-
new bytes(0)
|
|
145
|
-
)
|
|
146
|
-
),
|
|
147
|
-
new bytes(0) // user data
|
|
148
|
-
);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
function afterAgreementTerminated(
|
|
152
|
-
ISuperToken superToken,
|
|
153
|
-
address /*agreementClass*/,
|
|
154
|
-
bytes32 /*agreementId*/,
|
|
155
|
-
bytes calldata agreementData,
|
|
156
|
-
bytes calldata /*cbdata*/,
|
|
157
|
-
bytes calldata ctx
|
|
158
|
-
)
|
|
159
|
-
external override
|
|
160
|
-
returns(bytes memory newCtx)
|
|
161
|
-
{
|
|
162
|
-
(address flowSender, address flowReceiver) = abi.decode(agreementData, (address, address));
|
|
163
|
-
assert(flowSender == address(this));
|
|
164
|
-
assert(flowReceiver == _receiver);
|
|
165
|
-
|
|
166
|
-
// moved out to avoid stack too deep error
|
|
167
|
-
bytes memory callData = abi.encodeCall(
|
|
168
|
-
_cfa.createFlow,
|
|
169
|
-
(
|
|
170
|
-
superToken,
|
|
171
|
-
flowReceiver,
|
|
172
|
-
_flowRate,
|
|
173
|
-
new bytes(0)
|
|
174
|
-
)
|
|
175
|
-
);
|
|
176
|
-
|
|
177
|
-
// recreate the flow
|
|
178
|
-
(newCtx, ) = _host.callAgreementWithContext(
|
|
179
|
-
_cfa,
|
|
180
|
-
callData,
|
|
181
|
-
"0x",
|
|
182
|
-
ctx
|
|
183
|
-
);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* @dev This is CFA SuperApp that refuses to accept any opening flow without reverting them.
|
|
189
|
-
*/
|
|
190
|
-
contract SelfDeletingFlowTestApp is SuperAppBase {
|
|
191
|
-
|
|
192
|
-
IConstantFlowAgreementV1 private _cfa;
|
|
193
|
-
ISuperfluid private _host;
|
|
194
|
-
address private _receiver;
|
|
195
|
-
int96 private _flowRate;
|
|
196
|
-
|
|
197
|
-
constructor(IConstantFlowAgreementV1 cfa, ISuperfluid superfluid) {
|
|
198
|
-
assert(address(cfa) != address(0));
|
|
199
|
-
assert(address(superfluid) != address(0));
|
|
200
|
-
_cfa = cfa;
|
|
201
|
-
_host = superfluid;
|
|
202
|
-
|
|
203
|
-
uint256 configWord =
|
|
204
|
-
SuperAppDefinitions.APP_LEVEL_FINAL
|
|
205
|
-
| SuperAppDefinitions.BEFORE_AGREEMENT_CREATED_NOOP
|
|
206
|
-
// | SuperAppDefinitions.AFTER_AGREEMENT_CREATED_NOOP
|
|
207
|
-
| SuperAppDefinitions.BEFORE_AGREEMENT_UPDATED_NOOP
|
|
208
|
-
| SuperAppDefinitions.AFTER_AGREEMENT_UPDATED_NOOP
|
|
209
|
-
| SuperAppDefinitions.BEFORE_AGREEMENT_TERMINATED_NOOP
|
|
210
|
-
| SuperAppDefinitions.AFTER_AGREEMENT_TERMINATED_NOOP
|
|
211
|
-
;
|
|
212
|
-
|
|
213
|
-
_host.registerAppWithKey(configWord, "");
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
function afterAgreementCreated(
|
|
217
|
-
ISuperToken superToken,
|
|
218
|
-
address /*agreementClass*/,
|
|
219
|
-
bytes32 /*agreementId*/,
|
|
220
|
-
bytes calldata /*agreementData*/,
|
|
221
|
-
bytes calldata /*cbdata*/,
|
|
222
|
-
bytes calldata ctx
|
|
223
|
-
)
|
|
224
|
-
external override
|
|
225
|
-
returns(bytes memory newCtx)
|
|
226
|
-
{
|
|
227
|
-
newCtx = ctx;
|
|
228
|
-
ISuperfluid.Context memory context = _host.decodeCtx(ctx);
|
|
229
|
-
(newCtx, ) = _host.callAgreementWithContext(
|
|
230
|
-
_cfa,
|
|
231
|
-
abi.encodeCall(
|
|
232
|
-
_cfa.deleteFlow,
|
|
233
|
-
(
|
|
234
|
-
superToken,
|
|
235
|
-
context.msgSender,
|
|
236
|
-
address(this),
|
|
237
|
-
new bytes(0)
|
|
238
|
-
)
|
|
239
|
-
),
|
|
240
|
-
new bytes(0), // user data
|
|
241
|
-
newCtx
|
|
242
|
-
);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
/**
|
|
247
|
-
* @dev This is CFA SuperApp that closes an updated flow.
|
|
248
|
-
*/
|
|
249
|
-
contract ClosingOnUpdateFlowTestApp is SuperAppBase {
|
|
250
|
-
|
|
251
|
-
IConstantFlowAgreementV1 private _cfa;
|
|
252
|
-
ISuperfluid private _host;
|
|
253
|
-
|
|
254
|
-
constructor(IConstantFlowAgreementV1 cfa, ISuperfluid superfluid) {
|
|
255
|
-
assert(address(cfa) != address(0));
|
|
256
|
-
assert(address(superfluid) != address(0));
|
|
257
|
-
_cfa = cfa;
|
|
258
|
-
_host = superfluid;
|
|
259
|
-
|
|
260
|
-
uint256 configWord =
|
|
261
|
-
SuperAppDefinitions.APP_LEVEL_FINAL
|
|
262
|
-
| SuperAppDefinitions.BEFORE_AGREEMENT_CREATED_NOOP
|
|
263
|
-
| SuperAppDefinitions.AFTER_AGREEMENT_CREATED_NOOP
|
|
264
|
-
| SuperAppDefinitions.BEFORE_AGREEMENT_UPDATED_NOOP
|
|
265
|
-
// | SuperAppDefinitions.AFTER_AGREEMENT_UPDATED_NOOP
|
|
266
|
-
| SuperAppDefinitions.BEFORE_AGREEMENT_TERMINATED_NOOP
|
|
267
|
-
| SuperAppDefinitions.AFTER_AGREEMENT_TERMINATED_NOOP
|
|
268
|
-
;
|
|
269
|
-
|
|
270
|
-
_host.registerAppWithKey(configWord, "");
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
function afterAgreementUpdated(
|
|
274
|
-
ISuperToken superToken,
|
|
275
|
-
address /*agreementClass*/,
|
|
276
|
-
bytes32 /*agreementId*/,
|
|
277
|
-
bytes calldata /*agreementData*/,
|
|
278
|
-
bytes calldata /*cbdata*/,
|
|
279
|
-
bytes calldata ctx
|
|
280
|
-
)
|
|
281
|
-
external override
|
|
282
|
-
returns(bytes memory newCtx)
|
|
283
|
-
{
|
|
284
|
-
newCtx = ctx;
|
|
285
|
-
ISuperfluid.Context memory context = _host.decodeCtx(ctx);
|
|
286
|
-
(newCtx, ) = _host.callAgreementWithContext(
|
|
287
|
-
_cfa,
|
|
288
|
-
abi.encodeCall(
|
|
289
|
-
_cfa.deleteFlow,
|
|
290
|
-
(
|
|
291
|
-
superToken,
|
|
292
|
-
context.msgSender,
|
|
293
|
-
address(this),
|
|
294
|
-
new bytes(0)
|
|
295
|
-
)
|
|
296
|
-
),
|
|
297
|
-
new bytes(0), // user data
|
|
298
|
-
newCtx
|
|
299
|
-
);
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
contract FlowExchangeTestApp is SuperAppBase {
|
|
304
|
-
|
|
305
|
-
IConstantFlowAgreementV1 private _cfa;
|
|
306
|
-
ISuperfluid private _host;
|
|
307
|
-
ISuperToken private _targetToken;
|
|
308
|
-
|
|
309
|
-
constructor(
|
|
310
|
-
IConstantFlowAgreementV1 cfa,
|
|
311
|
-
ISuperfluid superfluid,
|
|
312
|
-
ISuperToken targetToken) {
|
|
313
|
-
assert(address(cfa) != address(0));
|
|
314
|
-
assert(address(superfluid) != address(0));
|
|
315
|
-
_cfa = cfa;
|
|
316
|
-
_host = superfluid;
|
|
317
|
-
_targetToken = targetToken;
|
|
318
|
-
|
|
319
|
-
uint256 configWord =
|
|
320
|
-
SuperAppDefinitions.APP_LEVEL_FINAL
|
|
321
|
-
| SuperAppDefinitions.BEFORE_AGREEMENT_CREATED_NOOP
|
|
322
|
-
// | SuperAppDefinitions.AFTER_AGREEMENT_CREATED_NOOP
|
|
323
|
-
| SuperAppDefinitions.BEFORE_AGREEMENT_UPDATED_NOOP
|
|
324
|
-
| SuperAppDefinitions.AFTER_AGREEMENT_UPDATED_NOOP
|
|
325
|
-
| SuperAppDefinitions.BEFORE_AGREEMENT_TERMINATED_NOOP
|
|
326
|
-
| SuperAppDefinitions.AFTER_AGREEMENT_TERMINATED_NOOP
|
|
327
|
-
;
|
|
328
|
-
|
|
329
|
-
_host.registerAppWithKey(configWord, "");
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
function afterAgreementCreated(
|
|
333
|
-
ISuperToken superToken,
|
|
334
|
-
address /*agreementClass*/,
|
|
335
|
-
bytes32 /*agreementId*/,
|
|
336
|
-
bytes calldata /*agreementData*/,
|
|
337
|
-
bytes calldata /*cbdata*/,
|
|
338
|
-
bytes calldata ctx
|
|
339
|
-
)
|
|
340
|
-
external override
|
|
341
|
-
returns(bytes memory newCtx)
|
|
342
|
-
{
|
|
343
|
-
newCtx = ctx;
|
|
344
|
-
ISuperfluid.Context memory context = _host.decodeCtx(ctx);
|
|
345
|
-
(,int96 flowRate,,) = _cfa.getFlow(superToken, context.msgSender, address(this));
|
|
346
|
-
(newCtx, ) = _host.callAgreementWithContext(
|
|
347
|
-
_cfa,
|
|
348
|
-
abi.encodeCall(
|
|
349
|
-
_cfa.createFlow,
|
|
350
|
-
(
|
|
351
|
-
_targetToken,
|
|
352
|
-
context.msgSender,
|
|
353
|
-
flowRate,
|
|
354
|
-
new bytes(0)
|
|
355
|
-
)
|
|
356
|
-
),
|
|
357
|
-
new bytes(0), // user data
|
|
358
|
-
newCtx
|
|
359
|
-
);
|
|
360
|
-
}
|
|
361
|
-
}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: AGPLv3
|
|
2
|
-
pragma solidity ^0.8.0;
|
|
3
|
-
|
|
4
|
-
import { IConstantFlowAgreementHook } from "../interfaces/agreements/IConstantFlowAgreementHook.sol";
|
|
5
|
-
import { ISuperfluidToken } from "../interfaces/superfluid/ISuperfluidToken.sol";
|
|
6
|
-
import { ConstantFlowAgreementV1 } from "../agreements/ConstantFlowAgreementV1.sol";
|
|
7
|
-
|
|
8
|
-
/// @title BaseCFAHookMock abstract contract
|
|
9
|
-
/// @author Superfluid
|
|
10
|
-
/// @notice An abstract contract with functionality inherited by both hook mocks
|
|
11
|
-
/// @dev This should provide a good starting point of some of the properties the CFAHook contract should have
|
|
12
|
-
abstract contract BaseCFAHookMock is IConstantFlowAgreementHook {
|
|
13
|
-
ConstantFlowAgreementV1 internal cfaV1;
|
|
14
|
-
address internal immutable owner;
|
|
15
|
-
|
|
16
|
-
// Custom Errors
|
|
17
|
-
error NOT_CFA();
|
|
18
|
-
error NOT_OWNER();
|
|
19
|
-
|
|
20
|
-
modifier onlyCFA() {
|
|
21
|
-
if (msg.sender != address(cfaV1)) revert NOT_CFA();
|
|
22
|
-
_;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
modifier onlyOwner() {
|
|
26
|
-
if (msg.sender != owner) revert NOT_OWNER();
|
|
27
|
-
_;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
constructor() {
|
|
31
|
-
owner = msg.sender;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/// @notice Sets the CFA contract which can call the hooks
|
|
35
|
-
/// @dev Only the owner of the contract can set the CFA contract
|
|
36
|
-
/// @param _cfaV1 address of cfav1 contract
|
|
37
|
-
function setCFA(ConstantFlowAgreementV1 _cfaV1) external onlyOwner {
|
|
38
|
-
cfaV1 = _cfaV1;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/// @title GoodCFAHookMock contract
|
|
43
|
-
/// @author Superfluid
|
|
44
|
-
/// @dev A "good" mock contract which just emits an event in the hooks and returns true
|
|
45
|
-
contract GoodCFAHookMock is BaseCFAHookMock {
|
|
46
|
-
event OnCreateEvent(
|
|
47
|
-
ISuperfluidToken token,
|
|
48
|
-
address sender,
|
|
49
|
-
address receiver,
|
|
50
|
-
address flowOperator,
|
|
51
|
-
int96 flowRate
|
|
52
|
-
);
|
|
53
|
-
event OnUpdateEvent(
|
|
54
|
-
ISuperfluidToken token,
|
|
55
|
-
address sender,
|
|
56
|
-
address receiver,
|
|
57
|
-
address flowOperator,
|
|
58
|
-
int96 flowRate,
|
|
59
|
-
int96 oldFlowRate
|
|
60
|
-
);
|
|
61
|
-
event OnDeleteEvent(
|
|
62
|
-
ISuperfluidToken token,
|
|
63
|
-
address sender,
|
|
64
|
-
address receiver,
|
|
65
|
-
address flowOperator,
|
|
66
|
-
int96 flowRate,
|
|
67
|
-
int96 oldFlowRate
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
function onCreate(
|
|
71
|
-
ISuperfluidToken token,
|
|
72
|
-
IConstantFlowAgreementHook.CFAHookParams memory newFlowData
|
|
73
|
-
) external onlyCFA returns (bool) {
|
|
74
|
-
emit OnCreateEvent(
|
|
75
|
-
token,
|
|
76
|
-
newFlowData.sender,
|
|
77
|
-
newFlowData.receiver,
|
|
78
|
-
newFlowData.flowOperator,
|
|
79
|
-
newFlowData.flowRate
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
return true;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function onUpdate(
|
|
86
|
-
ISuperfluidToken token,
|
|
87
|
-
IConstantFlowAgreementHook.CFAHookParams memory newFlowData,
|
|
88
|
-
int96 oldFlowRate
|
|
89
|
-
) external onlyCFA returns (bool) {
|
|
90
|
-
emit OnUpdateEvent(
|
|
91
|
-
token,
|
|
92
|
-
newFlowData.sender,
|
|
93
|
-
newFlowData.receiver,
|
|
94
|
-
newFlowData.flowOperator,
|
|
95
|
-
newFlowData.flowRate,
|
|
96
|
-
oldFlowRate
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
return true;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function onDelete(
|
|
103
|
-
ISuperfluidToken token,
|
|
104
|
-
IConstantFlowAgreementHook.CFAHookParams memory newFlowData,
|
|
105
|
-
int96 oldFlowRate
|
|
106
|
-
) external onlyCFA returns (bool) {
|
|
107
|
-
emit OnDeleteEvent(
|
|
108
|
-
token,
|
|
109
|
-
newFlowData.sender,
|
|
110
|
-
newFlowData.receiver,
|
|
111
|
-
newFlowData.flowOperator,
|
|
112
|
-
newFlowData.flowRate,
|
|
113
|
-
oldFlowRate
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
return true;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/// @title BadCFAHookMock contract
|
|
121
|
-
/// @author Superfluid
|
|
122
|
-
/// @dev A "bad" mock contract which just reverts
|
|
123
|
-
contract BadCFAHookMock is BaseCFAHookMock {
|
|
124
|
-
error BAD_HOOK();
|
|
125
|
-
|
|
126
|
-
function onCreate(
|
|
127
|
-
ISuperfluidToken, // token
|
|
128
|
-
IConstantFlowAgreementHook.CFAHookParams memory // newFlowData,
|
|
129
|
-
) external view onlyCFA returns (bool) {
|
|
130
|
-
revert BAD_HOOK();
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
function onUpdate(
|
|
134
|
-
ISuperfluidToken, // token,
|
|
135
|
-
IConstantFlowAgreementHook.CFAHookParams memory, // newFlowData,
|
|
136
|
-
int96 // oldFlowRate
|
|
137
|
-
) external view onlyCFA returns (bool) {
|
|
138
|
-
revert BAD_HOOK();
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
function onDelete(
|
|
142
|
-
ISuperfluidToken, // token,
|
|
143
|
-
IConstantFlowAgreementHook.CFAHookParams memory, // newFlowData,
|
|
144
|
-
int96 // oldFlowRate
|
|
145
|
-
) external view onlyCFA returns (bool) {
|
|
146
|
-
revert BAD_HOOK();
|
|
147
|
-
}
|
|
148
|
-
}
|