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

Audit Fixes QS-3 #37

Merged
merged 5 commits into from
Nov 28, 2023
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
23 changes: 0 additions & 23 deletions contracts/oracle/VSTOracle.sol

This file was deleted.

4 changes: 2 additions & 2 deletions scripts/configurations.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from brownie import VaultCore, MasterPriceOracle, ChainlinkOracle, VSTOracle, USDs
from brownie import VaultCore, MasterPriceOracle, ChainlinkOracle, USDs

from .utils import (
Deployment_data,
Expand All @@ -20,7 +20,7 @@
FRAX = "0x17FC002b466eEc40DaE837Fc4bE5c67993ddBd6F"
USDT = "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"
LUSD = "0x93b346b6bc2548da6a1e7d98e9a421b42541425b"
VST = "0x64343594Ab9b56e99087BfA6F2335Db24c2d1F17"


deployment_config = {
"vault": Deployment_data(
Expand Down
9 changes: 2 additions & 7 deletions scripts/deploy_oracles.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from brownie import VSTOracle, MasterPriceOracle, ChainlinkOracle, SPAOracle, USDsOracle
from brownie import MasterPriceOracle, ChainlinkOracle, SPAOracle, USDsOracle

from .configurations import (
USDS_OWNER_ADDR,
Expand All @@ -9,7 +9,6 @@
FRAX,
DAI,
LUSD,
VST,
)

from .utils import get_user
Expand All @@ -29,7 +28,6 @@ def main():
chainlink_oracle = ChainlinkOracle.deploy(
chainlink_feeds, {"from": user}, publish_source=True
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something wrong with formatting @bayou020.
please use Black formatter in vs-code for consistency

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vst_oracle = VSTOracle.deploy({"from": user}, publish_source=True)
master_price_oracle = MasterPriceOracle.deploy({"from": user}, publish_source=True)

master_price_oracle.updateTokenPriceFeed(
Expand All @@ -47,9 +45,6 @@ def main():
master_price_oracle.updateTokenPriceFeed(
LUSD, chainlink_oracle, chainlink_oracle.getTokenPrice.encode_input(LUSD)
)
master_price_oracle.updateTokenPriceFeed(
VST, vst_oracle, vst_oracle.getPrice.encode_input()
)

spa_oracle = SPAOracle.deploy(
master_price_oracle, USDC_E, 10000, 600, 70, {"from": user}, publish_source=True
Expand All @@ -71,6 +66,6 @@ def main():
usds_oracle.transferOwnership(USDS_OWNER_ADDR, {"from": user})
master_price_oracle.transferOwnership(USDS_OWNER_ADDR, {"from": user})

tokens = [SPA, USDS, USDC_E, USDT, FRAX, DAI, VST, LUSD]
tokens = [SPA, USDS, USDC_E, USDT, FRAX, DAI, LUSD]
for token in tokens:
print(f"Fetching Price feed for {token}: {master_price_oracle.getPrice(token)}")
4 changes: 1 addition & 3 deletions test/oracle/ChainlinkOracle.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ contract ChainlinkOracleTest is BaseTest {
super.setUp();
setArbitrumFork();
vm.prank(USDS_OWNER);
chainlinkOracle = new ChainlinkOracle(
new ChainlinkOracle.SetupTokenData[](0)
);
chainlinkOracle = new ChainlinkOracle(new ChainlinkOracle.SetupTokenData[](0));
}

function _getTokenData() internal pure returns (ChainlinkOracle.SetupTokenData[] memory) {
Expand Down
12 changes: 4 additions & 8 deletions test/oracle/MasterPriceOracle.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity 0.8.19;
import {BaseTest} from "../utils/BaseTest.sol";
import {MasterPriceOracle} from "../../contracts/oracle/MasterPriceOracle.sol";
import {ChainlinkOracle} from "../../contracts/oracle/ChainlinkOracle.sol";
import {VSTOracle} from "../../contracts/oracle/VSTOracle.sol";

import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";

// import {console} from "forge-std/console.sol";
Expand All @@ -24,7 +24,6 @@ contract MasterPriceOracleTest is BaseTest {

MasterPriceOracle public masterOracle;
ChainlinkOracle public chainlinkOracle;
VSTOracle public vstOracle;
address spaOracle;
address usdsOracle;

Expand All @@ -40,7 +39,6 @@ contract MasterPriceOracleTest is BaseTest {

// @dev Deploy and configure all the underlying oracles
deployAndConfigureChainlink();
vstOracle = new VSTOracle();
// A pre-requisite for initializing SPA and USDs oracles
masterOracle.updateTokenPriceFeed(
USDCe, address(chainlinkOracle), abi.encodeWithSelector(ChainlinkOracle.getTokenPrice.selector, USDCe)
Expand Down Expand Up @@ -140,17 +138,15 @@ contract MasterPriceOracleTest is BaseTest {
}

function getPriceFeedConfig() private view returns (PriceFeedData[] memory) {
PriceFeedData[] memory feedData = new PriceFeedData[](5);
PriceFeedData[] memory feedData = new PriceFeedData[](4);
feedData[0] = PriceFeedData(
FRAX, address(chainlinkOracle), abi.encodeWithSelector(ChainlinkOracle.getTokenPrice.selector, FRAX)
);
feedData[1] = PriceFeedData(
DAI, address(chainlinkOracle), abi.encodeWithSelector(ChainlinkOracle.getTokenPrice.selector, DAI)
);
feedData[2] = PriceFeedData(VST, address(vstOracle), abi.encodeWithSelector(VSTOracle.getPrice.selector));
feedData[3] = PriceFeedData(SPA, spaOracle, abi.encodeWithSelector(ICustomOracle.getPrice.selector));
feedData[4] = PriceFeedData(USDS, usdsOracle, abi.encodeWithSelector(ICustomOracle.getPrice.selector));
// feedData[0] = PriceFeedData(USDCe, address(chainlinkOracle), abi.encodeWithSelector(ChainlinkOracle.getTokenPrice.selector, USDCe));
feedData[2] = PriceFeedData(SPA, spaOracle, abi.encodeWithSelector(ICustomOracle.getPrice.selector));
feedData[3] = PriceFeedData(USDS, usdsOracle, abi.encodeWithSelector(ICustomOracle.getPrice.selector));
return feedData;
}
}
8 changes: 1 addition & 7 deletions test/oracle/SPAOracle.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,7 @@ contract SPAOracleTest is BaseUniOracleTest {
function setUp() public override {
super.setUp();
vm.startPrank(USDS_OWNER);
spaOracle = new SPAOracle(
masterOracle,
USDCe,
FEE_TIER,
MA_PERIOD,
WEIGHT_DIA
);
spaOracle = new SPAOracle(masterOracle, USDCe, FEE_TIER, MA_PERIOD, WEIGHT_DIA);
spaOracle.updateDIAParams(WEIGHT_DIA, type(uint128).max);
vm.stopPrank();
}
Expand Down
2 changes: 1 addition & 1 deletion test/rebase/Dripper.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ contract RecoverTokens is DripperTest {
}

function test_RecoverTokens(uint128 amount) external useKnownActor(USDS_OWNER) {
address[5] memory assets = [USDCe, USDT, VST, FRAX, DAI];
address[4] memory assets = [USDCe, USDT, FRAX, DAI];
vm.assume(amount != 0);
for (uint8 i = 0; i < assets.length; i++) {
deal(address(assets[i]), address(dripper), amount, true);
Expand Down
1 change: 0 additions & 1 deletion test/utils/BaseTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ abstract contract Setup is Test {
address public constant USDCe = 0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8;
address public constant USDT = 0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9;
address public constant FRAX = 0x17FC002b466eEc40DaE837Fc4bE5c67993ddBd6F;
address public constant VST = 0x64343594Ab9b56e99087BfA6F2335Db24c2d1F17;
address public constant DAI = 0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1;
address public constant USDC = 0xaf88d065e77c8cC2239327C5EDb3A432268e5831;

Expand Down
15 changes: 4 additions & 11 deletions test/utils/DeploymentSetup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {ChainlinkOracle} from "../../contracts/oracle/ChainlinkOracle.sol";
import {StargateStrategy} from "../../contracts/strategies/stargate/StargateStrategy.sol";
import {AaveStrategy} from "../../contracts/strategies/aave/AaveStrategy.sol";
import {CompoundStrategy} from "../../contracts/strategies/compound/CompoundStrategy.sol";
import {VSTOracle} from "../../contracts/oracle/VSTOracle.sol";

interface ICustomOracle {
function updateDIAParams(uint256 _weightDIA, uint128 _maxTime) external;
Expand All @@ -39,7 +38,6 @@ abstract contract PreMigrationSetup is Setup {
UpgradeUtil internal upgradeUtil;
MasterPriceOracle internal masterOracle;
ChainlinkOracle chainlinkOracle;
VSTOracle vstOracle;
address internal spaOracle;
address internal usdsOracle;
StargateStrategy internal stargateStrategy;
Expand Down Expand Up @@ -75,9 +73,7 @@ abstract contract PreMigrationSetup is Setup {
CollateralManager collateralManager = new CollateralManager(VAULT);

ORACLE = address(new MasterPriceOracle());
FeeCalculator feeCalculator = new FeeCalculator(
address(collateralManager)
);
FeeCalculator feeCalculator = new FeeCalculator(address(collateralManager));
FEE_CALCULATOR = address(feeCalculator);

COLLATERAL_MANAGER = address(collateralManager);
Expand All @@ -91,7 +87,6 @@ abstract contract PreMigrationSetup is Setup {
vault.updateRebaseManager(REBASE_MANAGER);
vault.updateFeeVault(FEE_VAULT);

vstOracle = new VSTOracle();
masterOracle = MasterPriceOracle(ORACLE);
// A pre-requisite for initializing SPA and USDs oracles
deployAndConfigureChainlink();
Expand Down Expand Up @@ -135,7 +130,6 @@ abstract contract PreMigrationSetup is Setup {
collateralManager.addCollateral(USDCe, _data);
collateralManager.addCollateral(USDT, _data);
collateralManager.addCollateral(FRAX, _data);
collateralManager.addCollateral(VST, _data);
collateralManager.addCollateral(USDC, _data);
collateralManager.addCollateralStrategy(USDCe, address(stargateStrategy), 3000);
collateralManager.addCollateralStrategy(USDCe, address(aaveStrategy), 4000);
Expand Down Expand Up @@ -171,16 +165,15 @@ abstract contract PreMigrationSetup is Setup {
}

function updatePriceFeeds() private {
PriceFeedData[] memory feedData = new PriceFeedData[](5);
PriceFeedData[] memory feedData = new PriceFeedData[](4);
feedData[0] = PriceFeedData(
FRAX, address(chainlinkOracle), abi.encodeWithSelector(ChainlinkOracle.getTokenPrice.selector, FRAX)
);
feedData[1] = PriceFeedData(
DAI, address(chainlinkOracle), abi.encodeWithSelector(ChainlinkOracle.getTokenPrice.selector, DAI)
);
feedData[2] = PriceFeedData(VST, address(vstOracle), abi.encodeWithSelector(VSTOracle.getPrice.selector));
feedData[3] = PriceFeedData(SPA, spaOracle, abi.encodeWithSelector(ICustomOracle.getPrice.selector));
feedData[4] = PriceFeedData(USDS, usdsOracle, abi.encodeWithSelector(ICustomOracle.getPrice.selector));
feedData[2] = PriceFeedData(SPA, spaOracle, abi.encodeWithSelector(ICustomOracle.getPrice.selector));
feedData[3] = PriceFeedData(USDS, usdsOracle, abi.encodeWithSelector(ICustomOracle.getPrice.selector));
// feedData[0] = PriceFeedData(USDCe, address(chainlinkOracle), abi.encodeWithSelector(ChainlinkOracle.getTokenPrice.selector, USDCe));
for (uint8 i = 0; i < feedData.length; ++i) {
masterOracle.updateTokenPriceFeed(feedData[i].token, feedData[i].source, feedData[i].msgData);
Expand Down
6 changes: 1 addition & 5 deletions test/utils/UpgradeUtil.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ contract UpgradeUtil {
}

function deployErc1967Proxy(address impl) public returns (address) {
TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(
impl,
address(proxyAdmin),
""
);
TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(impl, address(proxyAdmin), "");
return address(proxy);
}
}
10 changes: 5 additions & 5 deletions test/vault/CollateralManager.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ contract CollateralManager_AddCollateral_Test is CollateralManagerTest {
uint16 _downsidePeg,
uint16 _colComp
) external useKnownActor(USDS_OWNER) {
address[5] memory collaterals = [USDCe, USDT, VST, FRAX, DAI];
address[4] memory collaterals = [USDCe, USDT, FRAX, DAI];
vm.assume(_baseMintFee <= Helpers.MAX_PERCENTAGE);
vm.assume(_baseRedeemFee <= Helpers.MAX_PERCENTAGE);
vm.assume(_downsidePeg <= Helpers.MAX_PERCENTAGE);
Expand Down Expand Up @@ -283,7 +283,7 @@ contract CollateralManager_updateCollateral_Test is CollateralManagerTest {
uint16 _colComp,
uint16 _colComp2
) external useKnownActor(USDS_OWNER) {
address[5] memory collaterals = [USDCe, USDT, VST, FRAX, DAI];
address[4] memory collaterals = [USDCe, USDT, FRAX, DAI];
vm.assume(_baseMintFee <= Helpers.MAX_PERCENTAGE);
vm.assume(_baseRedeemFee <= Helpers.MAX_PERCENTAGE);
vm.assume(_downsidePeg <= Helpers.MAX_PERCENTAGE);
Expand Down Expand Up @@ -330,7 +330,7 @@ contract CollateralManager_removeCollateral_Test is CollateralManagerTest {
external
useKnownActor(USDS_OWNER)
{
address[5] memory collaterals = [USDCe, USDT, VST, FRAX, DAI];
address[4] memory collaterals = [USDCe, USDT, FRAX, DAI];
vm.assume(_baseMintFee <= Helpers.MAX_PERCENTAGE);
vm.assume(_baseRedeemFee <= Helpers.MAX_PERCENTAGE);
vm.assume(_downsidePeg <= Helpers.MAX_PERCENTAGE);
Expand Down Expand Up @@ -698,7 +698,7 @@ contract CollateralManager_removeCollateralStrategy_Test is CollateralManagerTes
collateralSetUp(USDCe, _colComp, _baseMintFee, _baseRedeemFee, _downsidePeg);
manager.addCollateralStrategy(USDCe, STARGATE, 2000);
vm.expectRevert(abi.encodeWithSelector(CollateralManager.CollateralStrategyNotMapped.selector));
manager.updateCollateralDefaultStrategy(VST, STARGATE);
manager.updateCollateralDefaultStrategy(FRAX, STARGATE);
}
}

Expand Down Expand Up @@ -769,7 +769,7 @@ contract CollateralManager_validateAllocation_test is CollateralManagerTest {
vm.assume(_baseRedeemFee <= Helpers.MAX_PERCENTAGE);
vm.assume(_downsidePeg <= Helpers.MAX_PERCENTAGE);
vm.assume(_collateralComposition <= Helpers.MAX_PERCENTAGE);
address[5] memory collaterals = [USDCe, USDT, VST, FRAX, DAI];
address[4] memory collaterals = [USDCe, USDT, FRAX, DAI];

ICollateralManager.CollateralBaseData memory _data = ICollateralManager.CollateralBaseData({
mintAllowed: true,
Expand Down