Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: LM_ManualExternalPriceSetter_v1 test file #15

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions src/modules/logicModule/LM_ManualExternalPriceSetter_v1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -136,20 +136,17 @@ contract LM_ManualExternalPriceSetter_v1 is
_setRedemptionPrice(redemptionPrice_);
}

/// @notice Gets current price for token issuance (buying tokens).
/// @return price_ Current price in 18 decimals (collateral tokens per 1
/// issuance token).
/// @dev Example: If price is 2 USDC/ISS, returns 2e18 (2 USDC needed for
/// 1 ISS).
/// @inheritdoc ILM_ManualExternalPriceSetter_v1
function getCollateralTokenDecimals() external view returns (uint8) {
return _collateralTokenDecimals;
}

/// @inheritdoc ILM_ManualExternalPriceSetter_v1
function getPriceForIssuance() external view returns (uint) {
return _issuancePrice;
}

/// @notice Gets current price for token redemption (selling tokens).
/// @return price_ Current price in 18 decimals (collateral tokens per 1
/// issuance token).
/// @dev Example: If price is 1.9 USDC/ISS, returns 1.9e18 (1.9 USDC
/// received for 1 ISS).
/// @inheritdoc ILM_ManualExternalPriceSetter_v1
function getPriceForRedemption() external view returns (uint) {
return _redemptionPrice;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,33 +34,59 @@ interface ILM_ManualExternalPriceSetter_v1 is IOraclePrice_v1 {
error Module__LM_ExternalPriceSetter__InvalidPrice();

// -------------------------------------------------------------------------

// External Functions

/// @notice Gets current price for token issuance (buying tokens).
/// @return price_ Current price denominated in the collateral token decimals.
/// @dev The price is denominated in the collateral token decimals. For
/// example, if the collateral token has 6 decimals and the issuance
/// price is 1.5, returns 1500000.
function getPriceForIssuance() external view returns (uint);

/// @notice Gets current price for token redemption (selling tokens).
/// @return price_ Current price denominated in the collateral token decimals.
/// @dev The price is denominated in the collateral token decimals. For
/// example, if the collateral token has 6 decimals and the redemption
/// price is 0.5, the price_ parameter should be 500000.
function getPriceForRedemption() external view returns (uint);

/// @notice Sets the issuance price.
/// @dev The price_ parameter should be provided with the same number
/// of decimals as the collateral token. For example, if the
/// collateral token has 6 decimals and the price is 1.5, input
/// should be 1500000.
/// @param price_ The price to set.
/// collateral token has 6 decimals and the issuance price is 1.5,
/// the price_ parameter should be 1500000.
/// @param price_ The issuance price to set, denominated in the collateral
/// token decimals.
function setIssuancePrice(uint price_) external;

/// @notice Sets the redemption price.
/// @dev The price_ parameter should be provided with the same number of
/// decimals as the issuance token. For example, if the issuance
/// token has 18 decimals and the price is 1.5, input should be
/// 1500000000000000000.
/// @param price_ The price to set.
/// of decimals as the collateral token. For example, if the
/// collateral token has 6 decimals and the redemption price is 0.5,
/// the price_ parameter should be 500000.
/// @param price_ The redemption price to set, denominated in the collateral
/// token decimals.
function setRedemptionPrice(uint price_) external;

/// @notice Sets both issuance and redemption prices atomically.
/// @dev Both prices must be non-zero. The issuancePrice_ should be in
/// collateral token decimals and redemptionPrice_ in issuance token
/// decimals.
/// @param issuancePrice_ The issuance price to set.
/// @param redemptionPrice_ The redemption price to set.
/// @notice Sets both issuance and redemption prices atomically, denominated
/// in the collateral token decimals.
/// @dev Both prices must be non-zero. Both the issuance and redemption
/// prices should be denominated in the collateral token decimals.
/// For example, if the collateral token has 6 decimals and the
/// issuance and redemption price are both 1.5, the issuancePrice_
/// and redemptionPrice_ parameters should be 1500000.
/// @param issuancePrice_ The issuance price to set, denominated in the
/// collateral token decimals.
/// @param redemptionPrice_ The redemption price to set, denominated in
/// the collateral token decimals.
function setIssuanceAndRedemptionPrice(
uint issuancePrice_,
uint redemptionPrice_
) external;

/// @notice Gets the decimals of the collateral token.
/// @dev Decimals in which the issuance and redemption prices
/// are denominated.
/// @return decimals_ The decimals of the collateral token.
function getCollateralTokenDecimals() external view returns (uint8);
}
2 changes: 1 addition & 1 deletion test/external/ERC20Issuance_blacklist_v1.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ contract ERC20Issuance_Blacklist_v1_Test is Test {
// State
ERC20Issuance_Blacklist_v1_Exposed token;

// ═══════════════════════════════════════════════════════════════════════════════════════════════════════
// ================================================================================
// Setup
function setUp() public {
// Setup token
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,7 @@ contract FM_PC_ExternalPrice_Redeeming_v1_Test is ModuleTest {
vm.assume(buyer != address(0));
vm.assume(buyer != address(this));
vm.assume(buyer != admin);
vm.assume(buyer != address(fundingManager));

// Given - Grant whitelist role to the user
// _authorizer.grantRole(roleId, buyer);
Expand Down
Loading
Loading