@superfluid-finance/ethereum-contracts 1.3.2-dev.bf84335.0 → 1.3.2-dev.e55bf9f.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.
Files changed (122) hide show
  1. package/build/contracts/AccessControl.json +1 -1
  2. package/build/contracts/AccessControlEnumerable.json +1 -1
  3. package/build/contracts/Address.json +1 -1
  4. package/build/contracts/AgreementBase.json +18 -18
  5. package/build/contracts/AgreementLibrary.json +1272 -1183
  6. package/build/contracts/BaseRelayRecipient.json +55 -55
  7. package/build/contracts/BatchLiquidator.json +211 -211
  8. package/build/contracts/BatchOperation.json +599 -599
  9. package/build/contracts/CFAv1Library.json +2282 -2282
  10. package/build/contracts/CallUtils.json +198 -198
  11. package/build/contracts/ClosingOnUpdateFlowTestApp.json +2472 -2472
  12. package/build/contracts/ConstantFlowAgreementV1.json +12931 -13308
  13. package/build/contracts/Context.json +1 -1
  14. package/build/contracts/ContextDefinitions.json +599 -599
  15. package/build/contracts/Create2.json +1 -1
  16. package/build/contracts/CustomSuperTokenBase.json +20 -20
  17. package/build/contracts/ERC165.json +1 -1
  18. package/build/contracts/ERC1820Implementer.json +1 -1
  19. package/build/contracts/ERC1820RegistryCompiled.json +22 -22
  20. package/build/contracts/ERC20.json +1 -1
  21. package/build/contracts/ERC20Burnable.json +1 -1
  22. package/build/contracts/ERC20Pausable.json +1 -1
  23. package/build/contracts/ERC20PresetMinterPauser.json +1 -1
  24. package/build/contracts/ERC20WithTokenInfo.json +23 -23
  25. package/build/contracts/ERC777Helper.json +380 -380
  26. package/build/contracts/ERC777RecipientDrainingGas.json +858 -858
  27. package/build/contracts/ERC777RecipientReverting.json +858 -858
  28. package/build/contracts/EnumerableSet.json +1 -1
  29. package/build/contracts/EventsEmitter.json +43 -43
  30. package/build/contracts/ExclusiveInflowTestApp.json +2473 -2473
  31. package/build/contracts/FixedSizeData.json +200 -200
  32. package/build/contracts/FlowExchangeTestApp.json +2473 -2473
  33. package/build/contracts/FlowOperatorDefinitions.json +599 -599
  34. package/build/contracts/FullUpgradableSuperTokenProxy.json +115 -115
  35. package/build/contracts/IAccessControl.json +1 -1
  36. package/build/contracts/IAccessControlEnumerable.json +1 -1
  37. package/build/contracts/IConstantFlowAgreementV1.json +567 -567
  38. package/build/contracts/IDAv1Library.json +2614 -2614
  39. package/build/contracts/IERC165.json +1 -1
  40. package/build/contracts/IERC1820Implementer.json +1 -1
  41. package/build/contracts/IERC1820Registry.json +1 -1
  42. package/build/contracts/IERC20.json +1 -1
  43. package/build/contracts/IERC20Metadata.json +1 -1
  44. package/build/contracts/IERC20Permit.json +1 -1
  45. package/build/contracts/IERC777.json +1 -1
  46. package/build/contracts/IERC777Recipient.json +1 -1
  47. package/build/contracts/IERC777Sender.json +1 -1
  48. package/build/contracts/IInstantDistributionAgreementV1.json +640 -640
  49. package/build/contracts/IMaticBridgedNativeSuperToken.json +63 -63
  50. package/build/contracts/IMaticBridgedNativeSuperTokenCustom.json +63 -63
  51. package/build/contracts/IMultiSigWallet.json +24 -24
  52. package/build/contracts/IPureSuperToken.json +43 -43
  53. package/build/contracts/IPureSuperTokenCustom.json +43 -43
  54. package/build/contracts/IRelayRecipient.json +27 -27
  55. package/build/contracts/IResolver.json +38 -38
  56. package/build/contracts/ISETH.json +48 -48
  57. package/build/contracts/ISETHCustom.json +48 -48
  58. package/build/contracts/ISuperAgreement.json +50 -50
  59. package/build/contracts/ISuperApp.json +192 -192
  60. package/build/contracts/ISuperToken.json +524 -524
  61. package/build/contracts/ISuperTokenFactory.json +161 -161
  62. package/build/contracts/ISuperfluid.json +1145 -1178
  63. package/build/contracts/ISuperfluidGovernance.json +243 -243
  64. package/build/contracts/ISuperfluidToken.json +389 -389
  65. package/build/contracts/ITOGAv1.json +1442 -1442
  66. package/build/contracts/ITOGAv2.json +1442 -1442
  67. package/build/contracts/Initializable.json +1 -1
  68. package/build/contracts/InstantDistributionAgreementV1.json +5820 -5820
  69. package/build/contracts/MaticBridgedNativeSuperTokenProxy.json +231 -231
  70. package/build/contracts/NonClosableOutflowTestApp.json +2473 -2473
  71. package/build/contracts/Ownable.json +1 -1
  72. package/build/contracts/Pausable.json +1 -1
  73. package/build/contracts/Proxy.json +1 -1
  74. package/build/contracts/PureSuperToken.json +109 -109
  75. package/build/contracts/Resolver.json +98 -98
  76. package/build/contracts/SETHProxy.json +227 -227
  77. package/build/contracts/SafeCast.json +1 -1
  78. package/build/contracts/SafeERC20.json +1 -1
  79. package/build/contracts/SafeMath.json +1 -1
  80. package/build/contracts/SelfDeletingFlowTestApp.json +2472 -2472
  81. package/build/contracts/SlotsBitmapLibrary.json +457 -457
  82. package/build/contracts/StreamRedirector.json +748 -748
  83. package/build/contracts/Strings.json +1 -1
  84. package/build/contracts/SuperAppBase.json +240 -240
  85. package/build/contracts/SuperAppDefinitions.json +599 -599
  86. package/build/contracts/SuperToken.json +4732 -4732
  87. package/build/contracts/SuperTokenFactory.json +750 -750
  88. package/build/contracts/SuperTokenFactoryBase.json +738 -738
  89. package/build/contracts/SuperTokenFactoryHelper.json +743 -743
  90. package/build/contracts/SuperUpgrader.json +440 -440
  91. package/build/contracts/Superfluid.json +15366 -16050
  92. package/build/contracts/SuperfluidFrameworkDeployer.json +765 -765
  93. package/build/contracts/SuperfluidGovernanceBase.json +2233 -2233
  94. package/build/contracts/SuperfluidGovernanceConfigs.json +599 -599
  95. package/build/contracts/SuperfluidGovernanceII.json +149 -149
  96. package/build/contracts/SuperfluidGovernanceIIProxy.json +131 -131
  97. package/build/contracts/SuperfluidLoader.json +210 -210
  98. package/build/contracts/SuperfluidToken.json +2420 -2420
  99. package/build/contracts/TOGA.json +1461 -1461
  100. package/build/contracts/TestGovernance.json +248 -248
  101. package/build/contracts/TestToken.json +93 -93
  102. package/build/contracts/TokenCustodian.json +214 -214
  103. package/build/contracts/TokenInfo.json +32 -32
  104. package/build/contracts/UUPSProxiable.json +139 -139
  105. package/build/contracts/UUPSProxy.json +81 -81
  106. package/build/contracts/UUPSUtils.json +37 -37
  107. package/build/contracts-sizes.txt +6 -6
  108. package/contracts/agreements/AgreementLibrary.sol +39 -15
  109. package/contracts/agreements/ConstantFlowAgreementV1.sol +65 -53
  110. package/contracts/interfaces/superfluid/ISuperfluid.sol +29 -23
  111. package/contracts/mocks/AgreementMock.sol +2 -2
  112. package/contracts/mocks/CFAAppMocks.sol +1 -1
  113. package/contracts/mocks/MultiFlowTesterApp.sol +13 -12
  114. package/contracts/mocks/SuperTokenMock.sol +2 -2
  115. package/contracts/mocks/SuperfluidMock.sol +9 -9
  116. package/contracts/superfluid/Superfluid.sol +34 -38
  117. package/contracts/superfluid/SuperfluidToken.sol +14 -14
  118. package/package.json +2 -2
  119. package/scripts/deploy-mfa.ts +27 -0
  120. package/scripts/libs/getConfig.js +14 -0
  121. package/utils/README.md +18 -0
  122. package/utils/mfa-tester.html +687 -0
@@ -269,7 +269,7 @@ interface ISuperfluid {
269
269
  * Agreement Framework
270
270
  *
271
271
  * Agreements use these function to trigger super app callbacks, updates
272
- * app allowance and charge gas fees.
272
+ * app credit and charge gas fees.
273
273
  *
274
274
  * These functions can only be called by registered agreements.
275
275
  *************************************************************************/
@@ -316,16 +316,16 @@ interface ISuperfluid {
316
316
  * @dev (For agreements) Create a new callback stack
317
317
  * @param ctx The current ctx, it will be validated.
318
318
  * @param app The super app.
319
- * @param appAllowanceGranted App allowance granted so far.
320
- * @param appAllowanceUsed App allowance used so far.
319
+ * @param appCreditGranted App credit granted so far.
320
+ * @param appCreditUsed App credit used so far.
321
321
  * @return newCtx The current context of the transaction.
322
322
  */
323
323
  function appCallbackPush(
324
324
  bytes calldata ctx,
325
325
  ISuperApp app,
326
- uint256 appAllowanceGranted,
327
- int256 appAllowanceUsed,
328
- ISuperfluidToken appAllowanceToken
326
+ uint256 appCreditGranted,
327
+ int256 appCreditUsed,
328
+ ISuperfluidToken appCreditToken
329
329
  )
330
330
  external
331
331
  // onlyAgreement
@@ -335,32 +335,30 @@ interface ISuperfluid {
335
335
  /**
336
336
  * @dev (For agreements) Pop from the current app callback stack
337
337
  * @param ctx The ctx that was pushed before the callback stack.
338
- * @param appAllowanceUsedDelta App allowance used by the app.
338
+ * @param appCreditUsedDelta App credit used by the app.
339
339
  * @return newCtx The current context of the transaction.
340
340
  *
341
- * @custom:security
341
+ * @custom:security
342
342
  * - Here we cannot do assertValidCtx(ctx), since we do not really save the stack in memory.
343
343
  * - Hence there is still implicit trust that the agreement handles the callback push/pop pair correctly.
344
344
  */
345
345
  function appCallbackPop(
346
346
  bytes calldata ctx,
347
- int256 appAllowanceUsedDelta
347
+ int256 appCreditUsedDelta
348
348
  )
349
349
  external
350
350
  // onlyAgreement
351
351
  returns (bytes memory newCtx);
352
352
 
353
353
  /**
354
- * @dev (For agreements) Use app allowance.
354
+ * @dev (For agreements) Use app credit.
355
355
  * @param ctx The current ctx, it will be validated.
356
- * @param appAllowanceWantedMore See app allowance for more details.
357
- * @param appAllowanceUsedDelta See app allowance for more details.
356
+ * @param appCreditUsedMore See app credit for more details.
358
357
  * @return newCtx The current context of the transaction.
359
358
  */
360
- function ctxUseAllowance(
359
+ function ctxUseCredit(
361
360
  bytes calldata ctx,
362
- uint256 appAllowanceWantedMore,
363
- int256 appAllowanceUsedDelta
361
+ int256 appCreditUsedMore
364
362
  )
365
363
  external
366
364
  // onlyAgreement
@@ -455,6 +453,7 @@ interface ISuperfluid {
455
453
  * - The order of the fields hence should not be rearranged in order to be backward compatible:
456
454
  * - non-dynamic fields will be parsed at the same memory location,
457
455
  * - and dynamic fields will simply have a greater offset than it was.
456
+ * - We cannot change the structure of the Context struct because of ABI compatibility requirements
458
457
  */
459
458
  struct Context {
460
459
  //
@@ -480,16 +479,23 @@ interface ISuperfluid {
480
479
  //
481
480
  // App context
482
481
  //
483
- // app allowance granted
484
- uint256 appAllowanceGranted;
485
- // app allowance wanted by the app callback
486
- uint256 appAllowanceWanted;
487
- // app allowance used, allowing negative values over a callback session
488
- int256 appAllowanceUsed;
482
+ // app credit granted
483
+ uint256 appCreditGranted;
484
+ // app credit wanted by the app callback
485
+ uint256 appCreditWantedDeprecated;
486
+ // app credit used, allowing negative values over a callback session
487
+ // the appCreditUsed value over a callback sessions is calculated with:
488
+ // existing flow data owed deposit + sum of the callback agreements
489
+ // deposit deltas
490
+ // the final value used to modify the state is determined by the
491
+ // _adjustNewAppCreditUsed function (in AgreementLibrary.sol) which takes
492
+ // the appCreditUsed value reached in the callback session and the app
493
+ // credit granted
494
+ int256 appCreditUsed;
489
495
  // app address
490
496
  address appAddress;
491
- // app allowance in super token
492
- ISuperfluidToken appAllowanceToken;
497
+ // app credit in super token
498
+ ISuperfluidToken appCreditToken;
493
499
  }
494
500
 
495
501
  function callAgreementWithContext(
@@ -193,10 +193,10 @@ contract AgreementMock is AgreementBase {
193
193
  return host.appCallbackPop(ctx, 0);
194
194
  }
195
195
 
196
- function tryCtxUseAllowance(ISuperfluid host, bool hackCtx, bytes calldata ctx)
196
+ function tryCtxUseCredit(ISuperfluid host, bool hackCtx, bytes calldata ctx)
197
197
  external returns (bytes memory newCtx)
198
198
  {
199
- return host.ctxUseAllowance(hackCtx ? new bytes(0) : ctx, 0, 0);
199
+ return host.ctxUseCredit(hackCtx ? new bytes(0) : ctx, 0);
200
200
  }
201
201
 
202
202
  function tryJailApp(ISuperfluid host, ISuperApp appMock, bool hackCtx, bytes calldata ctx)
@@ -12,7 +12,7 @@ import { IConstantFlowAgreementV1 } from "../interfaces/agreements/IConstantFlow
12
12
  /**
13
13
  * @dev This is a CFA SuperApp that maintains at most one inflow from a sender at any moment.
14
14
  *
15
- * This can test the deposit allowance logic in the deleteFlow as a recipient.
15
+ * This can test the deposit credit logic in the deleteFlow as a recipient.
16
16
  */
17
17
  contract ExclusiveInflowTestApp is SuperAppBase {
18
18
 
@@ -77,7 +77,7 @@ contract MultiFlowTesterApp is SuperAppBase {
77
77
  ISuperToken superToken,
78
78
  bytes4 selector,
79
79
  int96 flowRate,
80
- uint256 appAllowanceGranted,
80
+ uint256 appCreditGranted,
81
81
  bytes calldata ctx
82
82
  )
83
83
  private
@@ -87,21 +87,22 @@ contract MultiFlowTesterApp is SuperAppBase {
87
87
 
88
88
  newCtx = ctx;
89
89
 
90
- // in case of mfa, we underutlize the app allowance for simplicity
91
- int96 safeFlowRate = _cfa.getMaximumFlowRateFromDeposit(superToken, appAllowanceGranted - 1);
92
- appAllowanceGranted = _cfa.getDepositRequiredForFlowRate(superToken, safeFlowRate);
90
+ // in case of mfa, we underutlize the app credit for simplicity
91
+ uint256 flowRateDeposit = _cfa.getDepositRequiredForFlowRate(superToken, flowRate);
92
+ int96 safeFlowRate = _cfa.getMaximumFlowRateFromDeposit(superToken, flowRateDeposit - 1);
93
+ appCreditGranted = _cfa.getDepositRequiredForFlowRate(superToken, safeFlowRate);
93
94
 
94
- // scale the flow rate and app allowance numbers
95
- appAllowanceGranted = appAllowanceGranted * configuration.ratioPct / 100;
95
+ // scale the flow rate and app credit numbers
96
+ appCreditGranted = appCreditGranted * configuration.ratioPct / 100;
96
97
  // NOTE casting to int96 is okay here because ratioPct is uint8
97
98
  flowRate = flowRate * int96(uint96(configuration.ratioPct)) / 100;
98
99
 
99
100
  for(uint256 i = 0; i < configuration.receivers.length; i++) {
100
101
  ReceiverData memory receiverData = configuration.receivers[i];
101
- uint256 targetAllowance = appAllowanceGranted * receiverData.proportion / sum;
102
+ uint256 targetCredit = appCreditGranted * receiverData.proportion / sum;
102
103
  int96 targetFlowRate = _cfa.getMaximumFlowRateFromDeposit(
103
104
  superToken,
104
- targetAllowance
105
+ targetCredit
105
106
  );
106
107
  flowRate -= targetFlowRate;
107
108
  bytes memory callData = abi.encodeWithSelector(
@@ -179,7 +180,7 @@ contract MultiFlowTesterApp is SuperAppBase {
179
180
  (vars.flowSender, vars.flowReceiver) = abi.decode(agreementData, (address, address));
180
181
  assert(vars.flowSender == vars.context.msgSender);
181
182
  assert(vars.flowReceiver == address(this));
182
- assert(vars.context.appAllowanceGranted > 0);
183
+ assert(vars.context.appCreditGranted > 0);
183
184
  }
184
185
  int96 flowRate;
185
186
  (,flowRate,,) = _cfa.getFlowByID(superToken, agreementId);
@@ -188,7 +189,7 @@ contract MultiFlowTesterApp is SuperAppBase {
188
189
  superToken,
189
190
  _cfa.createFlow.selector,
190
191
  flowRate,
191
- vars.context.appAllowanceGranted,
192
+ vars.context.appCreditGranted,
192
193
  ctx);
193
194
  }
194
195
 
@@ -231,7 +232,7 @@ contract MultiFlowTesterApp is SuperAppBase {
231
232
  (vars.flowSender, vars.flowReceiver) = abi.decode(agreementData, (address, address));
232
233
  assert(vars.flowSender == vars.context.msgSender);
233
234
  assert(vars.flowReceiver == address(this));
234
- assert(vars.context.appAllowanceGranted > 0);
235
+ assert(vars.context.appCreditGranted > 0);
235
236
  }
236
237
  int96 flowRate;
237
238
  (,flowRate,,) = _cfa.getFlowByID(superToken, agreementId);
@@ -240,7 +241,7 @@ contract MultiFlowTesterApp is SuperAppBase {
240
241
  superToken,
241
242
  _cfa.updateFlow.selector,
242
243
  flowRate,
243
- vars.context.appAllowanceGranted,
244
+ vars.context.appCreditGranted,
244
245
  ctx);
245
246
  }
246
247
 
@@ -27,8 +27,8 @@ contract SuperTokenStorageLayoutTester is SuperToken {
27
27
  assembly { slot:= _inactiveAgreementBitmap.slot offset := _inactiveAgreementBitmap.offset }
28
28
  require (slot == 1 && offset == 0, "_inactiveAgreementBitmap changed location");
29
29
 
30
- assembly { slot:= _balances.slot offset := _balances.offset }
31
- require (slot == 2 && offset == 0, "_balances changed location");
30
+ assembly { slot:= _sharedSettledBalances.slot offset := _sharedSettledBalances.offset }
31
+ require (slot == 2 && offset == 0, "_sharedSettledBalances changed location");
32
32
 
33
33
  assembly { slot:= _totalSupply.slot offset := _totalSupply.offset }
34
34
  require (slot == 3 && offset == 0, "_totalSupply changed location");
@@ -94,35 +94,35 @@ contract SuperfluidUpgradabilityTester is Superfluid {
94
94
  assembly { dataLen := mload(dataOffset) }
95
95
  require(dataLen == 42, "userData changed location");
96
96
  }
97
- // context.appAllowanceGranted
97
+ // context.appCreditGranted
98
98
  {
99
99
  Context memory context;
100
100
  assembly { mstore(add(context, mul(32, 6)), 42) }
101
- require(context.appAllowanceGranted == 42, "appAllowanceGranted changed location");
101
+ require(context.appCreditGranted == 42, "appCreditGranted changed location");
102
102
  }
103
- // context.appAllowanceGranted
103
+ // context.appCreditWantedDeprecated
104
104
  {
105
105
  Context memory context;
106
106
  assembly { mstore(add(context, mul(32, 7)), 42) }
107
- require(context.appAllowanceWanted == 42, "appAllowanceWanted changed location");
107
+ require(context.appCreditWantedDeprecated == 42, "appCreditWantedDeprecated changed location");
108
108
  }
109
- // context.appAllowanceGranted
109
+ // context.appCreditUsed
110
110
  {
111
111
  Context memory context;
112
112
  assembly { mstore(add(context, mul(32, 8)), 42) }
113
- require(context.appAllowanceUsed == 42, "appAllowanceUsed changed location");
113
+ require(context.appCreditUsed == 42, "appCreditUsed changed location");
114
114
  }
115
- // context.appAllowanceGranted
115
+ // context.appAddress
116
116
  {
117
117
  Context memory context;
118
118
  assembly { mstore(add(context, mul(32, 9)), 42) }
119
119
  require(context.appAddress == address(42), "appAddress changed location");
120
120
  }
121
- // context.appAllowanceToken
121
+ // context.appCreditToken
122
122
  {
123
123
  Context memory context;
124
124
  assembly { mstore(add(context, mul(32, 10)), 42) }
125
- require(address(context.appAllowanceToken) == address(42), "appAllowanceToken changed location");
125
+ require(address(context.appCreditToken) == address(42), "appCreditToken changed location");
126
126
  }
127
127
  }
128
128
  }
@@ -507,9 +507,9 @@ contract Superfluid is
507
507
  function appCallbackPush(
508
508
  bytes calldata ctx,
509
509
  ISuperApp app,
510
- uint256 appAllowanceGranted,
511
- int256 appAllowanceUsed,
512
- ISuperfluidToken appAllowanceToken
510
+ uint256 appCreditGranted,
511
+ int256 appCreditUsed,
512
+ ISuperfluidToken appCreditToken
513
513
  )
514
514
  external override
515
515
  onlyAgreement
@@ -525,31 +525,29 @@ contract Superfluid is
525
525
  }
526
526
  context.appCallbackLevel++;
527
527
  context.callType = ContextDefinitions.CALL_INFO_CALL_TYPE_APP_CALLBACK;
528
- context.appAllowanceGranted = appAllowanceGranted;
529
- context.appAllowanceWanted = 0;
530
- context.appAllowanceUsed = appAllowanceUsed;
528
+ context.appCreditGranted = appCreditGranted;
529
+ context.appCreditUsed = appCreditUsed;
531
530
  context.appAddress = address(app);
532
- context.appAllowanceToken = appAllowanceToken;
531
+ context.appCreditToken = appCreditToken;
533
532
  appCtx = _updateContext(context);
534
533
  }
535
534
 
536
535
  function appCallbackPop(
537
536
  bytes calldata ctx,
538
- int256 appAllowanceUsedDelta
537
+ int256 appCreditUsedDelta
539
538
  )
540
539
  external override
541
540
  onlyAgreement
542
541
  returns (bytes memory newCtx)
543
542
  {
544
543
  Context memory context = decodeCtx(ctx);
545
- context.appAllowanceUsed = context.appAllowanceUsed + appAllowanceUsedDelta;
544
+ context.appCreditUsed += appCreditUsedDelta;
546
545
  newCtx = _updateContext(context);
547
546
  }
548
547
 
549
- function ctxUseAllowance(
548
+ function ctxUseCredit(
550
549
  bytes calldata ctx,
551
- uint256 appAllowanceWantedMore,
552
- int256 appAllowanceUsedDelta
550
+ int256 appCreditUsedMore
553
551
  )
554
552
  external override
555
553
  onlyAgreement
@@ -557,9 +555,7 @@ contract Superfluid is
557
555
  returns (bytes memory newCtx)
558
556
  {
559
557
  Context memory context = decodeCtx(ctx);
560
-
561
- context.appAllowanceWanted = context.appAllowanceWanted + appAllowanceWantedMore;
562
- context.appAllowanceUsed = context.appAllowanceUsed + appAllowanceUsedDelta;
558
+ context.appCreditUsed += appCreditUsedMore;
563
559
 
564
560
  newCtx = _updateContext(context);
565
561
  }
@@ -604,11 +600,11 @@ contract Superfluid is
604
600
  msgSender: msgSender,
605
601
  agreementSelector: agreementSelector,
606
602
  userData: userData,
607
- appAllowanceGranted: 0,
608
- appAllowanceWanted: 0,
609
- appAllowanceUsed: 0,
603
+ appCreditGranted: 0,
604
+ appCreditWantedDeprecated: 0,
605
+ appCreditUsed: 0,
610
606
  appAddress: address(0),
611
- appAllowanceToken: ISuperfluidToken(address(0))
607
+ appCreditToken: ISuperfluidToken(address(0))
612
608
  }));
613
609
  bool success;
614
610
  (success, returnedData) = _callExternalWithReplacedCtx(address(agreementClass), callData, ctx);
@@ -649,11 +645,11 @@ contract Superfluid is
649
645
  msgSender: msgSender,
650
646
  agreementSelector: 0,
651
647
  userData: "",
652
- appAllowanceGranted: 0,
653
- appAllowanceWanted: 0,
654
- appAllowanceUsed: 0,
648
+ appCreditGranted: 0,
649
+ appCreditWantedDeprecated: 0,
650
+ appCreditUsed: 0,
655
651
  appAddress: address(app),
656
- appAllowanceToken: ISuperfluidToken(address(0))
652
+ appCreditToken: ISuperfluidToken(address(0))
657
653
  }));
658
654
  bool success;
659
655
  (success, returnedData) = _callExternalWithReplacedCtx(address(app), callData, ctx);
@@ -868,9 +864,9 @@ contract Superfluid is
868
864
  {
869
865
  require(context.appCallbackLevel <= MAX_APP_CALLBACK_LEVEL, "SF: APP_RULE_MAX_APP_LEVEL_REACHED");
870
866
  uint256 callInfo = ContextDefinitions.encodeCallInfo(context.appCallbackLevel, context.callType);
871
- uint256 allowanceIO =
872
- context.appAllowanceGranted.toUint128() |
873
- (uint256(context.appAllowanceWanted.toUint128()) << 128);
867
+ uint256 creditIO =
868
+ context.appCreditGranted.toUint128() |
869
+ (uint256(context.appCreditWantedDeprecated.toUint128()) << 128);
874
870
  // NOTE: nested encoding done due to stack too deep error when decoding in _decodeCtx
875
871
  ctx = abi.encode(
876
872
  abi.encode(
@@ -881,10 +877,10 @@ contract Superfluid is
881
877
  context.userData
882
878
  ),
883
879
  abi.encode(
884
- allowanceIO,
885
- context.appAllowanceUsed,
880
+ creditIO,
881
+ context.appCreditUsed,
886
882
  context.appAddress,
887
- context.appAllowanceToken
883
+ context.appCreditToken
888
884
  )
889
885
  );
890
886
  _ctxStamp = keccak256(ctx);
@@ -914,19 +910,19 @@ contract Superfluid is
914
910
  (context.appCallbackLevel, context.callType) = ContextDefinitions.decodeCallInfo(callInfo);
915
911
  }
916
912
  {
917
- uint256 allowanceIO;
913
+ uint256 creditIO;
918
914
  (
919
- allowanceIO,
920
- context.appAllowanceUsed,
915
+ creditIO,
916
+ context.appCreditUsed,
921
917
  context.appAddress,
922
- context.appAllowanceToken
918
+ context.appCreditToken
923
919
  ) = abi.decode(ctx2, (
924
920
  uint256,
925
921
  int256,
926
922
  address,
927
923
  ISuperfluidToken));
928
- context.appAllowanceGranted = allowanceIO & type(uint128).max;
929
- context.appAllowanceWanted = allowanceIO >> 128;
924
+ context.appCreditGranted = creditIO & type(uint128).max;
925
+ context.appCreditWantedDeprecated = creditIO >> 128;
930
926
  }
931
927
  }
932
928
 
@@ -1019,7 +1015,7 @@ contract Superfluid is
1019
1015
  // NOTE: len(data) is data.length + 32 https://docs.soliditylang.org/en/latest/abi-spec.html
1020
1016
  // solhint-disable-next-line no-inline-assembly
1021
1017
  assembly { placeHolderCtxLength := mload(add(data, dataLen)) }
1022
- require(placeHolderCtxLength == 0, "SF: placerholder ctx should have zero length");
1018
+ require(placeHolderCtxLength == 0, "SF: placeholder ctx should have zero length");
1023
1019
  }
1024
1020
 
1025
1021
  // 1.b remove the placeholder ctx
@@ -1055,7 +1051,7 @@ contract Superfluid is
1055
1051
  }
1056
1052
 
1057
1053
  modifier isAgreement(ISuperAgreement agreementClass) {
1058
- require(isAgreementClassListed(agreementClass), "SF: only listed agreeement allowed");
1054
+ require(isAgreementClassListed(agreementClass), "SF: only listed agreement allowed");
1059
1055
  _;
1060
1056
  }
1061
1057
 
@@ -1065,7 +1061,7 @@ contract Superfluid is
1065
1061
  }
1066
1062
 
1067
1063
  modifier onlyAgreement() {
1068
- require(isAgreementClassListed(ISuperAgreement(msg.sender)), "SF: sender is not listed agreeement");
1064
+ require(isAgreementClassListed(ISuperAgreement(msg.sender)), "SF: sender is not listed agreement");
1069
1065
  _;
1070
1066
  }
1071
1067
 
@@ -30,8 +30,8 @@ abstract contract SuperfluidToken is ISuperfluidToken
30
30
  /// @dev Active agreement bitmap
31
31
  mapping(address => uint256) internal _inactiveAgreementBitmap;
32
32
 
33
- /// @dev Settled balance for the account
34
- mapping(address => int256) internal _balances;
33
+ /// @dev Shared Settled balance for the account
34
+ mapping(address => int256) internal _sharedSettledBalances;
35
35
 
36
36
  /// @dev Total supply
37
37
  uint256 internal _totalSupply;
@@ -79,7 +79,7 @@ abstract contract SuperfluidToken is ISuperfluidToken
79
79
  uint256 deposit,
80
80
  uint256 owedDeposit)
81
81
  {
82
- availableBalance = _balances[account];
82
+ availableBalance = _sharedSettledBalances[account];
83
83
  ISuperAgreement[] memory activeAgreements = getAccountActiveAgreements(account);
84
84
  for (uint256 i = 0; i < activeAgreements.length; i++) {
85
85
  (
@@ -185,7 +185,7 @@ abstract contract SuperfluidToken is ISuperfluidToken
185
185
  )
186
186
  internal
187
187
  {
188
- _balances[account] = _balances[account] + amount.toInt256();
188
+ _sharedSettledBalances[account] = _sharedSettledBalances[account] + amount.toInt256();
189
189
  _totalSupply = _totalSupply + amount;
190
190
  }
191
191
 
@@ -197,7 +197,7 @@ abstract contract SuperfluidToken is ISuperfluidToken
197
197
  {
198
198
  (int256 availableBalance,,) = realtimeBalanceOf(account, _host.getNow());
199
199
  require(availableBalance >= amount.toInt256(), "SuperfluidToken: burn amount exceeds balance");
200
- _balances[account] = _balances[account] - amount.toInt256();
200
+ _sharedSettledBalances[account] = _sharedSettledBalances[account] - amount.toInt256();
201
201
  _totalSupply = _totalSupply - amount;
202
202
  }
203
203
 
@@ -210,8 +210,8 @@ abstract contract SuperfluidToken is ISuperfluidToken
210
210
  {
211
211
  (int256 availableBalance,,) = realtimeBalanceOf(from, _host.getNow());
212
212
  require(availableBalance >= amount, "SuperfluidToken: move amount exceeds balance");
213
- _balances[from] = _balances[from] - amount;
214
- _balances[to] = _balances[to] + amount;
213
+ _sharedSettledBalances[from] = _sharedSettledBalances[from] - amount;
214
+ _sharedSettledBalances[to] = _sharedSettledBalances[to] + amount;
215
215
  }
216
216
 
217
217
  function _getRewardAccount() internal view returns (address rewardAccount) {
@@ -311,7 +311,7 @@ abstract contract SuperfluidToken is ISuperfluidToken
311
311
  external override
312
312
  onlyAgreement
313
313
  {
314
- _balances[account] = _balances[account] + delta;
314
+ _sharedSettledBalances[account] = _sharedSettledBalances[account] + delta;
315
315
  }
316
316
 
317
317
  /// @dev ISuperfluidToken.makeLiquidationPayoutsV2 implementation
@@ -338,17 +338,17 @@ abstract contract SuperfluidToken is ISuperfluidToken
338
338
  // LIKELY BRANCH: target account pays penalty to rewarded account
339
339
  assert(rewardAmount.toInt256() == -targetAccountBalanceDelta);
340
340
 
341
- _balances[rewardAmountReceiver] += rewardAmount.toInt256();
342
- _balances[targetAccount] += targetAccountBalanceDelta;
341
+ _sharedSettledBalances[rewardAmountReceiver] += rewardAmount.toInt256();
342
+ _sharedSettledBalances[targetAccount] += targetAccountBalanceDelta;
343
343
  EventsEmitter.emitTransfer(targetAccount, rewardAmountReceiver, rewardAmount);
344
344
  } else {
345
345
  // LESS LIKELY BRANCH: target account is bailed out
346
346
  // NOTE: useDefaultRewardAccount being true is undefined behavior
347
347
  // because the default reward account isn't receiving the rewardAmount by default
348
348
  assert(!useDefaultRewardAccount);
349
- _balances[rewardAccount] -= (rewardAmount.toInt256() + targetAccountBalanceDelta);
350
- _balances[liquidatorAccount] += rewardAmount.toInt256();
351
- _balances[targetAccount] += targetAccountBalanceDelta;
349
+ _sharedSettledBalances[rewardAccount] -= (rewardAmount.toInt256() + targetAccountBalanceDelta);
350
+ _sharedSettledBalances[liquidatorAccount] += rewardAmount.toInt256();
351
+ _sharedSettledBalances[targetAccount] += targetAccountBalanceDelta;
352
352
  EventsEmitter.emitTransfer(rewardAccount, liquidatorAccount, rewardAmount);
353
353
  EventsEmitter.emitTransfer(rewardAccount, targetAccount, uint256(targetAccountBalanceDelta));
354
354
  }
@@ -372,7 +372,7 @@ abstract contract SuperfluidToken is ISuperfluidToken
372
372
  modifier onlyAgreement() {
373
373
  require(
374
374
  _host.isAgreementClassListed(ISuperAgreement(msg.sender)),
375
- "SuperfluidToken: only listed agreeement");
375
+ "SuperfluidToken: only listed agreement");
376
376
  _;
377
377
  }
378
378
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superfluid-finance/ethereum-contracts",
3
- "version": "1.3.2-dev.bf84335.0",
3
+ "version": "1.3.2-dev.e55bf9f.0",
4
4
  "description": " Ethereum contracts implementation for the Superfluid Protocol",
5
5
  "homepage": "https://github.com/superfluid-finance/protocol-monorepo/tree/dev/packages/ethereum-contracts#readme",
6
6
  "repository": {
@@ -57,7 +57,7 @@
57
57
  "dependencies": {
58
58
  "@decentral.ee/web3-helpers": "0.5.3",
59
59
  "@openzeppelin/contracts": "4.7.0",
60
- "@superfluid-finance/js-sdk": "^0.6.3-dev.bf84335.0",
60
+ "@superfluid-finance/js-sdk": "^0.6.4-dev.e55bf9f.0",
61
61
  "@truffle/contract": "4.5.15",
62
62
  "ethereumjs-tx": "2.1.2",
63
63
  "ethereumjs-util": "7.1.5",
@@ -0,0 +1,27 @@
1
+ import {ethers} from "hardhat";
2
+
3
+ const deployMFA = async () => {
4
+ const provider = new ethers.providers.JsonRpcProvider(
5
+ "http://127.0.0.1:8545/"
6
+ );
7
+ const signer = provider.getSigner(
8
+ "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
9
+ );
10
+ const MFAContractFactory = await ethers.getContractFactory(
11
+ "MultiFlowTesterApp"
12
+ );
13
+ const mfa = await MFAContractFactory.connect(signer).deploy(
14
+ "0x9bd03768a7DCc129555dE410FF8E85528A4F88b5",
15
+ "0xa513E6E4b8f2a923D98304ec87F64353C4D5C853"
16
+ );
17
+ console.log("MFA deployed at:", mfa.address);
18
+ };
19
+
20
+ deployMFA()
21
+ .then(() => {
22
+ process.exit(0);
23
+ })
24
+ .catch((err) => {
25
+ console.error(err);
26
+ process.exit(1);
27
+ });
@@ -140,6 +140,13 @@ module.exports = function getConfig(chainId) {
140
140
  getLogsRange: 50000,
141
141
  },
142
142
  },
143
+ 420: {
144
+ // optimism testnet (goerli)
145
+ data: {
146
+ initialBlockNumber: 340000,
147
+ getLogsRange: 50000,
148
+ },
149
+ },
143
150
 
144
151
  //
145
152
  // Arbitrum: https://developer.offchainlabs.com
@@ -165,6 +172,13 @@ module.exports = function getConfig(chainId) {
165
172
  getLogsRange: 50000,
166
173
  },
167
174
  },
175
+ 421613: {
176
+ // arbitrum testnet (goerli)
177
+ data: {
178
+ initialBlockNumber: 93000,
179
+ getLogsRange: 50000,
180
+ },
181
+ },
168
182
 
169
183
  //
170
184
  // ARTIS
package/utils/README.md CHANGED
@@ -25,3 +25,21 @@ Alternatively, you can also find it on IPFS: [QmRJmHatYiGgGsXYCsYZdqPMx4dd2qbMsk
25
25
 
26
26
  In order to set the parameter in the URL, use this format:
27
27
  stream-closer.html?chainId=<chainId>&token=<tokenAddress>&sender=<senderAddress>&receiver=<receiverAddress>
28
+
29
+ ## MFA Tester
30
+
31
+ This is a single-file dApp for testing the MultiFlowTesterApp contract.
32
+
33
+ There are a few steps to complete to get everything up and running:
34
+ 1. Open a terminal window and start a hardhat node instance: `npx hardhat node` in `packages/ethereum-contracts`
35
+ 2. Open another terminal window and deploy contracts and token: `yarn deploy-contracts-local` in `packages/subgraph`
36
+ 3. Deploy MFA contract: `npx hardhat run scripts/deploy-mfa.ts` in `packages/ethereum-contracts`
37
+ 4. Build SDK-Core: `yarn build` in `packages/sdk-core` and copy `packages/sdk-core/dist/index.umd.js` into `packages/ethereum-contracts/utils/dist`.
38
+
39
+ > NOTE: There are hardcoded addresses for the resolver and MFA in mfa-tester.html, make sure that these addresses are in sync with what is deployed otherwise it won't work.
40
+
41
+ If you have python installed, you can start a webserver with the document root set to the current directory with
42
+ ```python
43
+ python -m SimpleHTTPServer 1337
44
+ ```
45
+ Then navigate to http://localhost:1337/mfa-tester.html