From f71284f2bf35bf51ba9c5e67eefe4531f331b6a0 Mon Sep 17 00:00:00 2001 From: Flocqst Date: Thu, 13 Mar 2025 15:06:54 +0100 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=91=B7=20add=20external=20functions?= =?UTF-8?q?=20for=20zapping=20USDX?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Zap.sol | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/Zap.sol b/src/Zap.sol index 3549cc6..57e0bb7 100644 --- a/src/Zap.sol +++ b/src/Zap.sol @@ -136,6 +136,25 @@ contract Zap is Reentrancy, Errors, Flush(msg.sender) { zapped = _wrap(STATA, SSTATA_SPOT_ID, zapped, _minAmountOut); } + /// @notice zap USDC into USDx + /// @dev caller must grant USDC allowance to this contract + /// @param _amount amount of USDC to zap + /// @param _minAmountOut acceptable slippage for wrapping and selling + /// @param _receiver address to receive USDx + /// @return zapped amount of USDx received + function zapInUSDX( + uint256 _amount, + uint256 _minAmountOut, + address _receiver + ) + external + returns (uint256 zapped) + { + _pull(USDC, msg.sender, _amount); + zapped = _zapInUSDx(_amount, _minAmountOut); + _push(USDX, _receiver, zapped); + } + /// @dev allowance is assumed /// @dev following execution, this contract will hold the zapped USDx function _zapInUSDx( @@ -181,6 +200,25 @@ contract Zap is Reentrancy, Errors, Flush(msg.sender) { zapped = _redeemStata(zapped, address(this)); } + /// @notice zap USDx into USDC + /// @dev caller must grant USDx allowance to this contract + /// @param _amount amount of USDx to zap + /// @param _minAmountOut acceptable slippage for buying and unwrapping + /// @param _receiver address to receive USDC + /// @return zapped amount of USDC received + function zapOutUSDX( + uint256 _amount, + uint256 _minAmountOut, + address _receiver + ) + external + returns (uint256 zapped) + { + _pull(USDX, msg.sender, _amount); + zapped = _zapOutUSDx(_amount, _minAmountOut); + _push(USDC, _receiver, zapped); + } + /// @dev allowance is assumed /// @dev following execution, this contract will hold the zapped USDC function _zapOutUSDx( From a6a24fcb2ebb96c2f6c49f0f2d4ec2650579afdc Mon Sep 17 00:00:00 2001 From: Flocqst Date: Thu, 13 Mar 2025 16:27:08 +0100 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=91=B7=20=5FzapOutUSDx?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Zap.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Zap.sol b/src/Zap.sol index 57e0bb7..47f76d8 100644 --- a/src/Zap.sol +++ b/src/Zap.sol @@ -228,8 +228,8 @@ contract Zap is Reentrancy, Errors, Flush(msg.sender) { internal returns (uint256 zapped) { - zapped = _buy(SSTATA_SPOT_ID, _amount, _minAmountOut); - zapped = _unwrap(SSTATA_SPOT_ID, zapped, _minAmountOut); + zapped = _buy(SUSDC_SPOT_ID, _amount, _minAmountOut); + zapped = _unwrap(SUSDC_SPOT_ID, zapped, _minAmountOut); } /*//////////////////////////////////////////////////////////////