From 662cb40beeb6934021c4c8f46d0e79b77d143be2 Mon Sep 17 00:00:00 2001 From: didi Date: Tue, 14 Jan 2025 21:38:28 +0100 Subject: [PATCH 1/2] emit Transfer event in updateMemberUnits() --- packages/ethereum-contracts/CHANGELOG.md | 3 ++- .../agreements/gdav1/SuperfluidPool.sol | 16 +++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/ethereum-contracts/CHANGELOG.md b/packages/ethereum-contracts/CHANGELOG.md index 12d64aabed..0abf73b3d1 100644 --- a/packages/ethereum-contracts/CHANGELOG.md +++ b/packages/ethereum-contracts/CHANGELOG.md @@ -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 diff --git a/packages/ethereum-contracts/contracts/agreements/gdav1/SuperfluidPool.sol b/packages/ethereum-contracts/contracts/agreements/gdav1/SuperfluidPool.sol index 3320273950..f85c1ffab6 100644 --- a/packages/ethereum-contracts/contracts/agreements/gdav1/SuperfluidPool.sol +++ b/packages/ethereum-contracts/contracts/agreements/gdav1/SuperfluidPool.sol @@ -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 even 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; } @@ -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(); @@ -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); @@ -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) { From 4bf66dd5e35cd72d0977c276af3dfbffc7a7d9e1 Mon Sep 17 00:00:00 2001 From: didi Date: Mon, 20 Jan 2025 19:28:25 +0100 Subject: [PATCH 2/2] fix typo --- .../contracts/agreements/gdav1/SuperfluidPool.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ethereum-contracts/contracts/agreements/gdav1/SuperfluidPool.sol b/packages/ethereum-contracts/contracts/agreements/gdav1/SuperfluidPool.sol index f85c1ffab6..60d586a76c 100644 --- a/packages/ethereum-contracts/contracts/agreements/gdav1/SuperfluidPool.sol +++ b/packages/ethereum-contracts/contracts/agreements/gdav1/SuperfluidPool.sol @@ -389,7 +389,7 @@ contract SuperfluidPool is ISuperfluidPool, BeaconProxiable { 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 even from/to the zero address accordingly. + // 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) {