Skip to content

Commit b86ec54

Browse files
authored
[ETHEREUM-CONTRACTS] emit Transfer event in updateMemberUnits() (#2051)
1 parent bd84747 commit b86ec54

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

packages/ethereum-contracts/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
1414

1515
### Changed
1616
- Fixed deployment of SimpleForwarder (solved an issue which caused batch operation `OPERATION_TYPE_SIMPLE_FORWARD_CALL` to always revert)
17-
- `SuperTokenV1Library.getFlowRate` and `SuperTokenV1Library.getFlowInfo` now also allow querying the flowrate between pools and pool members.
17+
- `SuperTokenV1Library.getFlowRate` and `SuperTokenV1Library.getFlowInfo` now also allow querying the flowrate between pools and pool members
18+
- Superfluid Pools now emit a Transfer event when changing units with `updateMemberUnits`.
1819

1920
### Breaking
2021
- `SuperTokenV1Library.distributeFlow`: return `actualFlowRate` instead of a bool

packages/ethereum-contracts/contracts/agreements/gdav1/SuperfluidPool.sol

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,15 @@ contract SuperfluidPool is ISuperfluidPool, BeaconProxiable {
386386
function updateMemberUnits(address memberAddr, uint128 newUnits) external returns (bool) {
387387
if (msg.sender != admin && msg.sender != address(GDA)) revert SUPERFLUID_POOL_NOT_POOL_ADMIN_OR_GDA();
388388

389-
_updateMemberUnits(memberAddr, newUnits);
389+
uint128 oldUnits = _updateMemberUnits(memberAddr, newUnits);
390+
391+
// Unit updates by admin are effectively mint/burn operations when viewed through the ERC20 lens.
392+
// We thus emit a Transfer event from/to the zero address accordingly.
393+
if (oldUnits < newUnits) {
394+
emit Transfer(address(0), memberAddr, newUnits - oldUnits);
395+
} else if (oldUnits > newUnits) {
396+
emit Transfer(memberAddr, address(0), oldUnits - newUnits);
397+
}
390398

391399
return true;
392400
}
@@ -433,7 +441,7 @@ contract SuperfluidPool is ISuperfluidPool, BeaconProxiable {
433441
}
434442
}
435443

436-
function _updateMemberUnits(address memberAddr, uint128 newUnits) internal returns (bool) {
444+
function _updateMemberUnits(address memberAddr, uint128 newUnits) internal returns (uint128 oldUnits) {
437445
// @note normally we keep the sanitization in the external functions, but here
438446
// this is used in both updateMemberUnits and transfer
439447
if (GDA.isPool(superToken, memberAddr)) revert SUPERFLUID_POOL_NO_POOL_MEMBERS();
@@ -447,7 +455,7 @@ contract SuperfluidPool is ISuperfluidPool, BeaconProxiable {
447455
MemberData memory memberData = _membersData[memberAddr];
448456
PDPoolMember memory pdPoolMember = _memberDataToPDPoolMember(memberData);
449457

450-
uint128 oldUnits = memberData.ownedUnits;
458+
oldUnits = memberData.ownedUnits;
451459

452460
PDPoolMemberMU memory mu = PDPoolMemberMU(pdPoolIndex, pdPoolMember);
453461

@@ -468,8 +476,6 @@ contract SuperfluidPool is ISuperfluidPool, BeaconProxiable {
468476
emit MemberUnitsUpdated(superToken, memberAddr, oldUnits, newUnits);
469477

470478
_handlePoolMemberNFT(memberAddr, newUnits);
471-
472-
return true;
473479
}
474480

475481
function _claimAll(address memberAddr, uint32 time) internal returns (int256 amount) {

0 commit comments

Comments
 (0)