From b83fad5a9014fe72ea661b0aff581680f11b2f46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9Fingen?= Date: Tue, 19 Nov 2024 16:57:58 +0000 Subject: [PATCH 1/2] fix: Emit both amounts coming from LQTYStaking and total ones on unstaking --- src/UserProxy.sol | 13 ++++++++++++- src/interfaces/IUserProxy.sol | 10 +++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/UserProxy.sol b/src/UserProxy.sol index 01df8665..5e2f795a 100644 --- a/src/UserProxy.sol +++ b/src/UserProxy.sol @@ -66,6 +66,9 @@ contract UserProxy is IUserProxy { onlyStakingV2 returns (uint256 lusdAmount, uint256 ethAmount) { + uint256 initialLUSDAmount = lusd.balanceOf(address(this)); + uint256 initialETHAmount = address(this).balance; + stakingV1.unstake(_amount); uint256 lqtyAmount = lqty.balanceOf(address(this)); @@ -78,7 +81,15 @@ contract UserProxy is IUserProxy { require(success, "UserProxy: eth-fail"); } - emit Unstake(_amount, _recipient, lusdAmount, ethAmount); + emit Unstake( + _recipient, + _amount, + lqtyAmount, + lusdAmount - initialLUSDAmount, + lusdAmount, + ethAmount - initialETHAmount, + ethAmount + ); } /// @inheritdoc IUserProxy diff --git a/src/interfaces/IUserProxy.sol b/src/interfaces/IUserProxy.sol index 4169e93f..638ee69d 100644 --- a/src/interfaces/IUserProxy.sol +++ b/src/interfaces/IUserProxy.sol @@ -9,7 +9,15 @@ import {PermitParams} from "../utils/Types.sol"; interface IUserProxy { event Stake(uint256 amount, address lqtyFrom); - event Unstake(uint256 lqtyUnstaked, address indexed lqtyRecipient, uint256 lusdAmount, uint256 ethAmount); + event Unstake( + address indexed lqtyRecipient, + uint256 lqtyUnstaked, + uint256 lqtySent, + uint256 lusdAmountReceived, + uint256 lusdAmountSent, + uint256 ethAmountReceived, + uint256 ethAmountSent + ); /// @notice Address of the LQTY token /// @return lqty Address of the LQTY token From f22ce5ceac8a2ba634b3b01c8fd7efb4b3063297 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9Fingen?= Date: Thu, 21 Nov 2024 18:31:29 +0000 Subject: [PATCH 2/2] fix: Compute real LQTY received on unstaking If you pass any amount higher than your stake, and LQTYStaking will internally truncate it to the maximum withdrawable amount. --- src/UserProxy.sol | 3 ++- src/interfaces/IUserProxy.sol | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/UserProxy.sol b/src/UserProxy.sol index 5e2f795a..cee964c5 100644 --- a/src/UserProxy.sol +++ b/src/UserProxy.sol @@ -66,6 +66,7 @@ contract UserProxy is IUserProxy { onlyStakingV2 returns (uint256 lusdAmount, uint256 ethAmount) { + uint256 initialLQTYAmount = lqty.balanceOf(address(this)); uint256 initialLUSDAmount = lusd.balanceOf(address(this)); uint256 initialETHAmount = address(this).balance; @@ -83,7 +84,7 @@ contract UserProxy is IUserProxy { emit Unstake( _recipient, - _amount, + lqtyAmount - initialLQTYAmount, lqtyAmount, lusdAmount - initialLUSDAmount, lusdAmount, diff --git a/src/interfaces/IUserProxy.sol b/src/interfaces/IUserProxy.sol index 638ee69d..65719a2e 100644 --- a/src/interfaces/IUserProxy.sol +++ b/src/interfaces/IUserProxy.sol @@ -11,7 +11,7 @@ interface IUserProxy { event Stake(uint256 amount, address lqtyFrom); event Unstake( address indexed lqtyRecipient, - uint256 lqtyUnstaked, + uint256 lqtyReceived, uint256 lqtySent, uint256 lusdAmountReceived, uint256 lusdAmountSent,