Skip to content

Commit

Permalink
[ETHEREUM-CONTRACTS] emit Transfer event in updateMemberUnits() (#2051)
Browse files Browse the repository at this point in the history
  • Loading branch information
d10r authored Jan 20, 2025
1 parent bd84747 commit b86ec54
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
3 changes: 2 additions & 1 deletion packages/ethereum-contracts/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

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

### Breaking
- `SuperTokenV1Library.distributeFlow`: return `actualFlowRate` instead of a bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,15 @@ contract SuperfluidPool is ISuperfluidPool, BeaconProxiable {
function updateMemberUnits(address memberAddr, uint128 newUnits) external returns (bool) {
if (msg.sender != admin && msg.sender != address(GDA)) revert SUPERFLUID_POOL_NOT_POOL_ADMIN_OR_GDA();

_updateMemberUnits(memberAddr, newUnits);
uint128 oldUnits = _updateMemberUnits(memberAddr, newUnits);

// Unit updates by admin are effectively mint/burn operations when viewed through the ERC20 lens.
// We thus emit a Transfer event from/to the zero address accordingly.
if (oldUnits < newUnits) {
emit Transfer(address(0), memberAddr, newUnits - oldUnits);
} else if (oldUnits > newUnits) {
emit Transfer(memberAddr, address(0), oldUnits - newUnits);
}

return true;
}
Expand Down Expand Up @@ -433,7 +441,7 @@ contract SuperfluidPool is ISuperfluidPool, BeaconProxiable {
}
}

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

uint128 oldUnits = memberData.ownedUnits;
oldUnits = memberData.ownedUnits;

PDPoolMemberMU memory mu = PDPoolMemberMU(pdPoolIndex, pdPoolMember);

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

_handlePoolMemberNFT(memberAddr, newUnits);

return true;
}

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

0 comments on commit b86ec54

Please sign in to comment.