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

Allow setCrossPrice to be called by Operator #51

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion src/contracts/AbstractARM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ abstract contract AbstractARM is OwnableOperable, ERC20Upgradeable {
* The cross price can be increased with assets in the ARM.
* @param newCrossPrice The new cross price scaled to 36 decimals.
*/
function setCrossPrice(uint256 newCrossPrice) external onlyOwner {
function setCrossPrice(uint256 newCrossPrice) external onlyOperatorOrOwner {
require(newCrossPrice >= PRICE_SCALE - MAX_CROSS_PRICE_DEVIATION, "ARM: cross price too low");
require(newCrossPrice <= PRICE_SCALE, "ARM: cross price too high");
// The exiting sell price must be greater than or equal to the new cross price
Expand Down
30 changes: 24 additions & 6 deletions test/fork/LidoFixedPriceMultiLpARM/SetCrossPrice.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@ contract Fork_Concrete_LidoARM_SetCrossPrice_Test_ is Fork_Shared_Test_ {
/// --- REVERTING TESTS
//////////////////////////////////////////////////////
function test_RevertWhen_SetCrossPrice_Because_NotOwner() public asRandomAddress {
vm.expectRevert("ARM: Only owner can call this function.");
lidoARM.setCrossPrice(0.9998e36);
}

function test_RevertWhen_SetCrossPrice_Because_Operator() public asOperator {
vm.expectRevert("ARM: Only owner can call this function.");
vm.expectRevert("ARM: Only operator or owner can call this function.");
lidoARM.setCrossPrice(0.9998e36);
}

Expand Down Expand Up @@ -93,3 +88,26 @@ contract Fork_Concrete_LidoARM_SetCrossPrice_Test_ is Fork_Shared_Test_ {
lidoARM.setCrossPrice(0.9999e36);
}
}

contract Fork_Concrete_LidoARM_SetCrossPrice_Operator_Test_ is Fork_Shared_Test_ {
//////////////////////////////////////////////////////
/// --- SETUP
//////////////////////////////////////////////////////
function setUp() public override {
super.setUp();

deal(address(steth), address(lidoARM), MIN_TOTAL_SUPPLY - 1);
}

function test_SetCrossPrice_No_StETH_Operator() public asOperator {
// at 1.0
vm.expectEmit({emitter: address(lidoARM)});
emit AbstractARM.CrossPriceUpdated(1e36);
lidoARM.setCrossPrice(1e36);

// 20 basis points lower than 1.0
vm.expectEmit({emitter: address(lidoARM)});
emit AbstractARM.CrossPriceUpdated(0.998e36);
lidoARM.setCrossPrice(0.998e36);
}
}