Skip to content

Commit bc28856

Browse files
authored
Merge pull request #15 from ZealynxSecurity/refactor/LM_ManualExternalPriceSetter_v1.t.sol
Refactor: LM_ManualExternalPriceSetter_v1 test file
2 parents b37238e + e34fdd0 commit bc28856

6 files changed

+407
-299
lines changed

src/modules/logicModule/LM_ManualExternalPriceSetter_v1.sol

+7-10
Original file line numberDiff line numberDiff line change
@@ -136,20 +136,17 @@ contract LM_ManualExternalPriceSetter_v1 is
136136
_setRedemptionPrice(redemptionPrice_);
137137
}
138138

139-
/// @notice Gets current price for token issuance (buying tokens).
140-
/// @return price_ Current price in 18 decimals (collateral tokens per 1
141-
/// issuance token).
142-
/// @dev Example: If price is 2 USDC/ISS, returns 2e18 (2 USDC needed for
143-
/// 1 ISS).
139+
/// @inheritdoc ILM_ManualExternalPriceSetter_v1
140+
function getCollateralTokenDecimals() external view returns (uint8) {
141+
return _collateralTokenDecimals;
142+
}
143+
144+
/// @inheritdoc ILM_ManualExternalPriceSetter_v1
144145
function getPriceForIssuance() external view returns (uint) {
145146
return _issuancePrice;
146147
}
147148

148-
/// @notice Gets current price for token redemption (selling tokens).
149-
/// @return price_ Current price in 18 decimals (collateral tokens per 1
150-
/// issuance token).
151-
/// @dev Example: If price is 1.9 USDC/ISS, returns 1.9e18 (1.9 USDC
152-
/// received for 1 ISS).
149+
/// @inheritdoc ILM_ManualExternalPriceSetter_v1
153150
function getPriceForRedemption() external view returns (uint) {
154151
return _redemptionPrice;
155152
}

src/modules/logicModule/interfaces/ILM_ManualExternalPriceSetter_v1.sol

+40-14
Original file line numberDiff line numberDiff line change
@@ -34,33 +34,59 @@ interface ILM_ManualExternalPriceSetter_v1 is IOraclePrice_v1 {
3434
error Module__LM_ExternalPriceSetter__InvalidPrice();
3535

3636
// -------------------------------------------------------------------------
37-
3837
// External Functions
3938

39+
/// @notice Gets current price for token issuance (buying tokens).
40+
/// @return price_ Current price denominated in the collateral token decimals.
41+
/// @dev The price is denominated in the collateral token decimals. For
42+
/// example, if the collateral token has 6 decimals and the issuance
43+
/// price is 1.5, returns 1500000.
44+
function getPriceForIssuance() external view returns (uint);
45+
46+
/// @notice Gets current price for token redemption (selling tokens).
47+
/// @return price_ Current price denominated in the collateral token decimals.
48+
/// @dev The price is denominated in the collateral token decimals. For
49+
/// example, if the collateral token has 6 decimals and the redemption
50+
/// price is 0.5, the price_ parameter should be 500000.
51+
function getPriceForRedemption() external view returns (uint);
52+
4053
/// @notice Sets the issuance price.
4154
/// @dev The price_ parameter should be provided with the same number
4255
/// of decimals as the collateral token. For example, if the
43-
/// collateral token has 6 decimals and the price is 1.5, input
44-
/// should be 1500000.
45-
/// @param price_ The price to set.
56+
/// collateral token has 6 decimals and the issuance price is 1.5,
57+
/// the price_ parameter should be 1500000.
58+
/// @param price_ The issuance price to set, denominated in the collateral
59+
/// token decimals.
4660
function setIssuancePrice(uint price_) external;
4761

4862
/// @notice Sets the redemption price.
4963
/// @dev The price_ parameter should be provided with the same number of
50-
/// decimals as the issuance token. For example, if the issuance
51-
/// token has 18 decimals and the price is 1.5, input should be
52-
/// 1500000000000000000.
53-
/// @param price_ The price to set.
64+
/// of decimals as the collateral token. For example, if the
65+
/// collateral token has 6 decimals and the redemption price is 0.5,
66+
/// the price_ parameter should be 500000.
67+
/// @param price_ The redemption price to set, denominated in the collateral
68+
/// token decimals.
5469
function setRedemptionPrice(uint price_) external;
5570

56-
/// @notice Sets both issuance and redemption prices atomically.
57-
/// @dev Both prices must be non-zero. The issuancePrice_ should be in
58-
/// collateral token decimals and redemptionPrice_ in issuance token
59-
/// decimals.
60-
/// @param issuancePrice_ The issuance price to set.
61-
/// @param redemptionPrice_ The redemption price to set.
71+
/// @notice Sets both issuance and redemption prices atomically, denominated
72+
/// in the collateral token decimals.
73+
/// @dev Both prices must be non-zero. Both the issuance and redemption
74+
/// prices should be denominated in the collateral token decimals.
75+
/// For example, if the collateral token has 6 decimals and the
76+
/// issuance and redemption price are both 1.5, the issuancePrice_
77+
/// and redemptionPrice_ parameters should be 1500000.
78+
/// @param issuancePrice_ The issuance price to set, denominated in the
79+
/// collateral token decimals.
80+
/// @param redemptionPrice_ The redemption price to set, denominated in
81+
/// the collateral token decimals.
6282
function setIssuanceAndRedemptionPrice(
6383
uint issuancePrice_,
6484
uint redemptionPrice_
6585
) external;
86+
87+
/// @notice Gets the decimals of the collateral token.
88+
/// @dev Decimals in which the issuance and redemption prices
89+
/// are denominated.
90+
/// @return decimals_ The decimals of the collateral token.
91+
function getCollateralTokenDecimals() external view returns (uint8);
6692
}

test/external/ERC20Issuance_blacklist_v1.t.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ contract ERC20Issuance_Blacklist_v1_Test is Test {
3333
// State
3434
ERC20Issuance_Blacklist_v1_Exposed token;
3535

36-
// ═══════════════════════════════════════════════════════════════════════════════════════════════════════
36+
// ================================================================================
3737
// Setup
3838
function setUp() public {
3939
// Setup token

test/modules/fundingManager/oracle/FM_PC_ExternalPrice_Redeeming_v1.t.sol

+1
Original file line numberDiff line numberDiff line change
@@ -1032,6 +1032,7 @@ contract FM_PC_ExternalPrice_Redeeming_v1_Test is ModuleTest {
10321032
vm.assume(buyer != address(0));
10331033
vm.assume(buyer != address(this));
10341034
vm.assume(buyer != admin);
1035+
vm.assume(buyer != address(fundingManager));
10351036

10361037
// Given - Grant whitelist role to the user
10371038
// _authorizer.grantRole(roleId, buyer);

0 commit comments

Comments
 (0)