Skip to content

Commit

Permalink
Allow the cross price to be 20 basis points below 1
Browse files Browse the repository at this point in the history
  • Loading branch information
naddison36 committed Oct 9, 2024
1 parent 322ec2f commit db0b95a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
17 changes: 13 additions & 4 deletions src/contracts/AbstractARM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ abstract contract AbstractARM is OwnableOperable, ERC20Upgradeable {
/// Constants
////////////////////////////////////////////////////

/// @notice Maximum amount the Operator can set the price from 1 scaled to 36 decimals.
/// 2e33 is a 0.02% deviation, or 2 basis points.
uint256 public constant MAX_PRICE_DEVIATION = 2e32;
/// @notice Maximum amount the Owner can set the cross price below 1 scaled to 36 decimals.
/// 20e32 is a 0.2% deviation, or 20 basis points.
uint256 public constant MAX_CROSS_PRICE_DEVIATION = 20e32;
/// @notice Scale of the prices.
uint256 public constant PRICE_SCALE = 1e36;
/// @dev The amount of shares that are minted to a dead address on initalization
Expand Down Expand Up @@ -391,8 +391,17 @@ abstract contract AbstractARM is OwnableOperable, ERC20Upgradeable {
emit TraderateChanged(_baseToTokenRate, _tokenToBaseRate);
}

/**
* @notice set the price that buy and sell prices can not cross.
* That is, the buy prices must be below the cross price
* and the sell prices must be above the cross price.
* If the cross price is being lowered, there can not be any base assets in the ARM. eg stETH.
* The base assets should be sent to the withdrawal queue before the cross price can be lowered.
* 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 {
require(newCrossPrice >= PRICE_SCALE - MAX_PRICE_DEVIATION, "ARM: cross price too low");
require(newCrossPrice >= PRICE_SCALE - MAX_CROSS_PRICE_DEVIATION, "ARM: cross price too low");
require(newCrossPrice <= PRICE_SCALE, "ARM: cross price too high");

// If the new cross price is lower than the current cross price
Expand Down
10 changes: 5 additions & 5 deletions test/fork/LidoFixedPriceMultiLpARM/Setters.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ contract Fork_Concrete_lidoARM_Setters_Test_ is Fork_Shared_Test_ {
}

function test_RevertWhen_SetCrossPrice_Because_PriceRange() public asLidoARMOwner {
// 3 basis points lower than 1.0
// 21 basis points lower than 1.0
vm.expectRevert("ARM: cross price too low");
lidoARM.setCrossPrice(0.9997e36);
lidoARM.setCrossPrice(0.9979e36);

// 1 basis points higher than 1.0
vm.expectRevert("ARM: cross price too high");
Expand All @@ -201,10 +201,10 @@ contract Fork_Concrete_lidoARM_Setters_Test_ is Fork_Shared_Test_ {
emit AbstractARM.CrossPriceUpdated(1e36);
lidoARM.setCrossPrice(1e36);

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

function test_SetCrossPrice_With_StETH_PriceUp_Owner() public {
Expand Down

0 comments on commit db0b95a

Please sign in to comment.