@@ -9,8 +9,8 @@ import {Ownable} from '@openzeppelin/contracts/access/Ownable.sol';
99import {IGhoToken} from '../../../gho/interfaces/IGhoToken.sol ' ;
1010import {IGsm} from '../interfaces/IGsm.sol ' ;
1111import {IGsmConverter} from './interfaces/IGsmConverter.sol ' ;
12- import {IRedemption} from ' ../dependencies/circle/IRedemption.sol ' ;
13- // TODO: replace with proper issuance implementation later
12+ // TODO: replace with proper issuance implementation/interface later from USTB
13+ import {ISubscriptionRedemption} from ' ../dependencies/USTB/ISubscriptionRedemption.sol ' ;
1414import {MockBUIDLSubscription} from '../../../../test/mocks/MockBUIDLSubscription.sol ' ;
1515
1616import 'forge-std/console2.sol ' ;
@@ -169,7 +169,7 @@ contract USTBGsmConverter is Ownable, EIP712, IGsmConverter {
169169
170170 /**
171171 * @notice Buys the GSM underlying asset in exchange for selling GHO, after asset redemption
172- * @param minAmount The minimum amount of the underlying asset to buy (ie USTB )
172+ * @param minAmount The minimum amount of the underlying asset to buy via conversion (USDC )
173173 * @param receiver Recipient address of the underlying asset being purchased
174174 * @return The amount of underlying asset bought, after asset redemption
175175 * @return The amount of GHO sold by the user
@@ -183,26 +183,20 @@ contract USTBGsmConverter is Ownable, EIP712, IGsmConverter {
183183 uint256 initialIssuedAssetBalance = IERC20 (ISSUED_ASSET).balanceOf (address (this ));
184184 uint256 initialRedeemedAssetBalance = IERC20 (REDEEMED_ASSET).balanceOf (address (this ));
185185
186- (, uint256 ghoAmount , , ) = IGsm (GSM).getGhoAmountForBuyAsset (minAmount);
186+ uint256 minUSTBAmount = ISubscriptionRedemption (REDEMPTION_CONTRACT).calculateUstbIn (minAmount);
187+
188+ (, uint256 ghoAmount , , ) = IGsm (GSM).getGhoAmountForBuyAsset (minUSTBAmount);
187189
188190 IGhoToken (GHO_TOKEN).transferFrom (originator, address (this ), ghoAmount);
189191 IGhoToken (GHO_TOKEN).approve (address (GSM), ghoAmount);
190- (uint256 boughtAssetAmount , uint256 ghoSold ) = IGsm (GSM).buyAsset (minAmount , address (this ));
192+ (uint256 boughtAssetAmount , uint256 ghoSold ) = IGsm (GSM).buyAsset (minUSTBAmount , address (this ));
191193 require (ghoAmount == ghoSold, 'INVALID_GHO_SOLD ' );
192194 IGhoToken (GHO_TOKEN).approve (address (GSM), 0 );
193195
194196 IERC20 (ISSUED_ASSET).approve (address (REDEMPTION_CONTRACT), boughtAssetAmount);
195197 IRedemption (REDEMPTION_CONTRACT).redeem (boughtAssetAmount);
196- // TODO: adjust require depending on how much USDC is redeemed
197- // because USTB increases in price, redemption will NOT be in 1:1 ratio
198- uint256 redeemedAmount = boughtAssetAmount;
199- // require(
200- // IERC20(REDEEMED_ASSET).balanceOf(address(this)) ==
201- // initialRedeemedAssetBalance + ,
202- // 'INVALID_REDEMPTION'
203- // );
204198 IERC20 (ISSUED_ASSET).approve (address (REDEMPTION_CONTRACT), 0 );
205- IERC20 (REDEEMED_ASSET).safeTransfer (receiver, redeemedAmount );
199+ IERC20 (REDEEMED_ASSET).safeTransfer (receiver, minAmount );
206200
207201 require (
208202 IGhoToken (GHO_TOKEN).balanceOf (address (this )) == initialGhoBalance,
0 commit comments