Skip to content

Commit

Permalink
fix: clean up mock price
Browse files Browse the repository at this point in the history
  • Loading branch information
yan-man committed Nov 15, 2024
1 parent c95eb96 commit 376863c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/test/mocks/MockUSTBSubscriptionRedemption.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ contract MockUSTBSubscription {

address public immutable asset;
address public immutable liquidity;
uint256 public USTBPrice;
uint256 public USTBPrice; // 1_100_000_000 is 1 USTB = 11 USDC, including chainlink precision

/**
* @param _asset Address of asset token, ie USTB
Expand Down Expand Up @@ -47,11 +47,12 @@ contract MockUSTBSubscription {
* @param amount The amount of the USTB token to exchange, in base units
*/
function redeem(uint256 amount) external {
uint256 USDCAmount = amount * USTBPrice;
(uint256 USDCAmount, ) = calculateUsdcOut(amount);
IERC20(asset).safeTransfer(msg.sender, amount);
IERC20(liquidity).safeTransferFrom(msg.sender, address(this), USDCAmount);
}

// for redemption preview
function calculateUsdcOut(
uint256 superstateTokenInAmount
) public view returns (uint256 usdcOutAmount, uint256 usdPerUstbChainlinkRaw) {
Expand All @@ -65,6 +66,7 @@ contract MockUSTBSubscription {
usdcOutAmount = (usdcOutAmount * (10_000 - fee)) / 10_000;
}

// for redemption preview
function calculateUstbIn(
uint256 usdcOutAmount
) public view returns (uint256 ustbInAmount, uint256 usdPerUstbChainlinkRaw) {
Expand Down

0 comments on commit 376863c

Please sign in to comment.