From ffae6c568820b22bf8b930739f07e830554645e8 Mon Sep 17 00:00:00 2001 From: "A.L." Date: Fri, 20 Sep 2024 10:58:35 +0100 Subject: [PATCH] lint: forge fmt --- script/{Deploy.s.sol => 01_Deploy.s.sol} | 7 +++---- src/ReservoirPriceOracle.sol | 3 ++- src/libraries/Constants.sol | 9 +++++---- test/unit/ReservoirPriceOracle.t.sol | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) rename script/{Deploy.s.sol => 01_Deploy.s.sol} (62%) diff --git a/script/Deploy.s.sol b/script/01_Deploy.s.sol similarity index 62% rename from script/Deploy.s.sol rename to script/01_Deploy.s.sol index 53a6cb2..80b66f5 100644 --- a/script/Deploy.s.sol +++ b/script/01_Deploy.s.sol @@ -6,12 +6,11 @@ import { ReservoirPriceOracle, PriceType } from "src/ReservoirPriceOracle.sol"; contract Deploy is Script { function run() external { - vm.startBroadcast(address(1)); + vm.startBroadcast(); string memory lTestnetRpcUrl = vm.rpcUrl("sepolia"); -// uint256 lForkId = vm.createFork(lTestnetRpcUrl); - - ReservoirPriceOracle asd = new ReservoirPriceOracle(15 minutes, 200_000, PriceType.CLAMPED_PRICE); + ReservoirPriceOracle lOracle = + new ReservoirPriceOracle(Constants.DEFAULT_TWAP_PERIOD, 200_000, PriceType.CLAMPED_PRICE); vm.stopBroadcast(); } diff --git a/src/ReservoirPriceOracle.sol b/src/ReservoirPriceOracle.sol index a68a3b7..029299e 100644 --- a/src/ReservoirPriceOracle.sol +++ b/src/ReservoirPriceOracle.sol @@ -195,7 +195,8 @@ contract ReservoirPriceOracle is IPriceOracle, Owned(msg.sender), ReentrancyGuar } function _calculateReward(uint256 aPrevPrice, uint256 aNewPrice, uint256 aRewardThreshold) - private returns (uint256 rReward) + private + returns (uint256 rReward) { // SAFETY: this mul will not overflow as 0 < `aRewardThreshold` <= `Constants.BP_SCALE`, as checked by `setRoute` uint256 lRewardThresholdWAD; diff --git a/src/libraries/Constants.sol b/src/libraries/Constants.sol index 175c3b9..4e61c15 100644 --- a/src/libraries/Constants.sol +++ b/src/libraries/Constants.sol @@ -2,10 +2,6 @@ pragma solidity ^0.8.0; library Constants { - /////////////////////////////////////////////////////////////////////////////////////////////// - // CONSTANTS // - /////////////////////////////////////////////////////////////////////////////////////////////// - uint256 public constant MAX_DEVIATION_THRESHOLD = 0.1e18; // 10% uint256 public constant MAX_TWAP_PERIOD = 1 hours; uint256 public constant MAX_ROUTE_LENGTH = 4; @@ -13,4 +9,9 @@ library Constants { uint256 public constant MAX_SUPPORTED_PRICE = type(uint128).max; uint256 public constant MAX_AMOUNT_IN = type(uint128).max; uint16 public constant BP_SCALE = 1e4; + + // Defaults + uint256 public constant DEFAULT_TWAP_PERIOD = 15 minutes; + uint256 public constant DEFAULT_DEVIATION_THRESHOLD_VOLATILE = 200; // 2% + uint256 public constant DEFAULT_DEVIATION_THRESHOLD_STABLE = 2; // 0.02% } diff --git a/test/unit/ReservoirPriceOracle.t.sol b/test/unit/ReservoirPriceOracle.t.sol index 8a2c2b6..0ab90b9 100644 --- a/test/unit/ReservoirPriceOracle.t.sol +++ b/test/unit/ReservoirPriceOracle.t.sol @@ -692,7 +692,7 @@ contract ReservoirPriceOracleTest is BaseTest { skip(_oracle.twapPeriod()); // act - uint256 lSwapAmt = 1_000_000; + uint256 lSwapAmt = 1_000_000; _tokenA.mint(address(lAC), lSwapAmt * 10 ** _tokenA.decimals()); lAC.swap(int256(lSwapAmt * 10 ** _tokenA.decimals()), true, address(this), "");