Skip to content

Commit 376863c

Browse files
committed
fix: clean up mock price
1 parent c95eb96 commit 376863c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/test/mocks/MockUSTBSubscriptionRedemption.sol

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ contract MockUSTBSubscription {
1515

1616
address public immutable asset;
1717
address public immutable liquidity;
18-
uint256 public USTBPrice;
18+
uint256 public USTBPrice; // 1_100_000_000 is 1 USTB = 11 USDC, including chainlink precision
1919

2020
/**
2121
* @param _asset Address of asset token, ie USTB
@@ -47,11 +47,12 @@ contract MockUSTBSubscription {
4747
* @param amount The amount of the USTB token to exchange, in base units
4848
*/
4949
function redeem(uint256 amount) external {
50-
uint256 USDCAmount = amount * USTBPrice;
50+
(uint256 USDCAmount, ) = calculateUsdcOut(amount);
5151
IERC20(asset).safeTransfer(msg.sender, amount);
5252
IERC20(liquidity).safeTransferFrom(msg.sender, address(this), USDCAmount);
5353
}
5454

55+
// for redemption preview
5556
function calculateUsdcOut(
5657
uint256 superstateTokenInAmount
5758
) public view returns (uint256 usdcOutAmount, uint256 usdPerUstbChainlinkRaw) {
@@ -65,6 +66,7 @@ contract MockUSTBSubscription {
6566
usdcOutAmount = (usdcOutAmount * (10_000 - fee)) / 10_000;
6667
}
6768

69+
// for redemption preview
6870
function calculateUstbIn(
6971
uint256 usdcOutAmount
7072
) public view returns (uint256 ustbInAmount, uint256 usdPerUstbChainlinkRaw) {

0 commit comments

Comments
 (0)