Skip to content

Commit

Permalink
v1.5.2 - Long tail assets support with Uniswap v3 TWAP + Chainlink (#153
Browse files Browse the repository at this point in the history
)

* Update coverage [skip ci]

* Deploy LINK/USDC to base sepolia

* v1.5 testnet redeploy to redo migration

* Add SizeFactory and SizeRegistry (#5)

* Add SizeFactory

* Split factory/registry due to contract size limit

* Create SizeRegistryFactoryTest

* Add more tests for 2 markets

* Test createMarket

* Add more tests

* Add fork test

* Bump

* Bump CI

* Refactor SizeRegistryFactoryTest

* Add isMarket function

* Change description to percent instead of BP

* Fix fork test

* Use ISize and implementation in constructor

* Add PriceFeed factory

* Fix slither

* Change _ by | on descriptions

* Fix test

* Remove unused code

* v1.5 migration with `reinitialize` (#7)

* Create migration function

* Create NonTransferrableScaledTokenV1_5Test (WIP)

* Attempt build

* Fix circular dependency

* Add Size deployment to SizeRegistry on tests

* Pin foundry version

* WIP

* WIP + compiling

* Alternate branch

* Fix getUserView

* Create withdrawV1_2 function

* Do migration in a single reinitialize

* Add testFork_ForkReinitializeV1_5_set_2_existing_markets

* Create separate tests to check gas usage

* Add v1.5 at the end of NonTransferrableScaledTokenV1_5

* Fix _testFork_ForkReinitializeV1_5_migrate

* Rollback SizeDataView struct to not break integrations

* Fix getMarketsDescriptions

* Fix tests

* Fix compilation warnings

* Fix fork test

* Attempt fix slither

* fix slither

* attempt fix slither

* Fix slither

* Fix slither

* Add more consistency checks

* Add more checks to reinitialize fn

* Remove blank line

* Add new methods

* Add more tests

* Disable slither calls-loop

* Fix checks by using only scaled balances

* Fix fork test

* Fix CI

* Add v1 token to /deprecated folder

* Remove unused code

* getBorrowATokensDescriptionsV1_5

* Fix README

* Increase test coverage

* Upgrade SizeView.version to v1.5

* Add withdraw checks

* Fix tests

* Add comment

* Fix NonTransferrableScaledTokenV1_5.allowance

* Create deposit/withdraw fork test

* Deploy LINK/USDC to base sepolia

* Deploy SizeRegistry, SizeFactory to base-sepolia

* Update migration procedure

* Add audit tests

* Add per user checks

* Fix recommendations from v1.5 review

* Fix error

* v1.5 libraries on prepare_crytic

* Redeploy SizeFactory to base-sepolia

* Update coverage [skip ci]

* Deploy SizeFactory to production

* Create PriceFeedUniswapV3TWAPChainlink v0

* Improve docs

* Clarify docs

* Improve docs

* Create fork test for VIRTUAL/USDC price feed

* Fix failed test

* Fix failing test

* Create DeployPriceFeedUniswapV3TWAPChainlinkScript

* Deploy VIRTUAL/USDC price feed

* Add data crunch script

---------

Co-authored-by: Size <[email protected]>
  • Loading branch information
aviggiano and sizecash authored Dec 27, 2024
1 parent 262c590 commit b69703d
Show file tree
Hide file tree
Showing 21 changed files with 932 additions and 16 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions script/BaseScript.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {ISizeV1_5} from "@src/v1.5/interfaces/ISizeV1_5.sol";
import {Script} from "forge-std/Script.sol";
import {stdJson} from "forge-std/StdJson.sol";
import {Vm} from "forge-std/Vm.sol";
import {console2 as console} from "forge-std/console2.sol";

struct Deployment {
string name;
Expand Down
42 changes: 42 additions & 0 deletions script/DeployPriceFeedUniswapV3TWAPChainlink.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;

import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";

import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
import {SizeFactory} from "@src/v1.5/SizeFactory.sol";
import {console2 as console} from "forge-std/Script.sol";

import {BaseScript, Deployment, Parameter} from "@script/BaseScript.sol";
import {Deploy} from "@script/Deploy.sol";
import {NetworkConfiguration, Networks} from "@script/Networks.sol";

import {AggregatorV3Interface} from "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";

import {PriceFeedParams} from "@src/oracle/v1.5.1/PriceFeed.sol";
import {PriceFeedUniswapV3TWAPChainlink} from "@src/oracle/v1.5.2/PriceFeedUniswapV3TWAPChainlink.sol";

contract DeployPriceFeedUniswapV3TWAPChainlinkScript is BaseScript, Networks, Deploy {
address deployer;

function setUp() public {}

modifier parseEnv() {
deployer = vm.envOr("DEPLOYER_ADDRESS", vm.addr(vm.deriveKey(TEST_MNEMONIC, 0)));
_;
}

function run() public parseEnv broadcast {
console.log("[PriceFeedUniswapV3TWAPChainlink] deploying...");

(AggregatorV3Interface sequencerUptimeFeed, PriceFeedParams memory base, PriceFeedParams memory quote) =
priceFeedVirtualUsdcBaseMainnet();

PriceFeedUniswapV3TWAPChainlink priceFeedUniswapV3TWAPChainlink =
new PriceFeedUniswapV3TWAPChainlink(sequencerUptimeFeed, base, quote);

console.log("[PriceFeedUniswapV3TWAPChainlink] priceFeed", address(priceFeedUniswapV3TWAPChainlink));

console.log("[PriceFeedUniswapV3TWAPChainlink] done");
}
}
47 changes: 47 additions & 0 deletions script/GetPriceFeedUniswapV3TWAPChainlinkHistoricalData.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;

import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";

import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
import {SizeFactory} from "@src/v1.5/SizeFactory.sol";
import {console2 as console} from "forge-std/Script.sol";

import {BaseScript, Deployment, Parameter} from "@script/BaseScript.sol";
import {Deploy} from "@script/Deploy.sol";
import {NetworkConfiguration, Networks} from "@script/Networks.sol";

import {AggregatorV3Interface} from "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";

import {PriceFeed, PriceFeedParams} from "@src/oracle/v1.5.1/PriceFeed.sol";

import {UniswapV3PriceFeed} from "@src/oracle/v1.5.1/adapters/UniswapV3PriceFeed.sol";
import {PriceFeedUniswapV3TWAPChainlink} from "@src/oracle/v1.5.2/PriceFeedUniswapV3TWAPChainlink.sol";

contract GetPriceFeedUniswapV3TWAPChainlinkHistoricalDataScript is BaseScript, Networks, Deploy {
function setUp() public {}

function run() public broadcast {
console.log("GetPriceFeedUniswapV3TWAPChainlinkHistoricalData...");

uint256 toBlock = vm.getBlockNumber();
uint256 fromBlock = 23921785;
uint256 steps = 30;

vm.rollFork(fromBlock);

PriceFeedUniswapV3TWAPChainlink priceFeedUniswapV3TWAPChainlink =
PriceFeedUniswapV3TWAPChainlink(0x19960f5ffa579a0573BF9b9D0D3258C34F9f69a1);
UniswapV3PriceFeed uniswapV3PriceFeed = priceFeedUniswapV3TWAPChainlink.basePriceFeed();
PriceFeed priceFeed = priceFeedUniswapV3TWAPChainlink.quotePriceFeed();

console.log("timestamp,base,quote");
for (uint256 b = fromBlock; b < toBlock; b += steps) {
vm.rollFork(b);

uint256 base = uniswapV3PriceFeed.getPrice();
uint256 quote = priceFeed.getPrice();
console.log("%s,%s,%s", block.timestamp, base, quote);
}
}
}
32 changes: 32 additions & 0 deletions script/Networks.sol
Original file line number Diff line number Diff line change
Expand Up @@ -248,4 +248,36 @@ abstract contract Networks {
revert InvalidNetworkConfiguration(networkConfiguration);
}
}

function priceFeedVirtualUsdcBaseMainnet()
public
pure
returns (AggregatorV3Interface sequencerUptimeFeed, PriceFeedParams memory base, PriceFeedParams memory quote)
{
sequencerUptimeFeed = AggregatorV3Interface(0xBCF85224fc0756B9Fa45aA7892530B47e10b6433);
base = PriceFeedParams({
uniswapV3Pool: IUniswapV3Pool(0x1D4daB3f27C7F656b6323C1D6Ef713b48A8f72F1), // VIRTUAL/WETH Uniswap v3 0.3% pool
twapWindow: 10 minutes,
averageBlockTime: 2 seconds,
baseToken: IERC20Metadata(0x0b3e328455c4059EEb9e3f84b5543F74E24e7E1b), // VIRTUAL
quoteToken: IERC20Metadata(0x4200000000000000000000000000000000000006), // WETH
baseAggregator: AggregatorV3Interface(address(0)),
quoteAggregator: AggregatorV3Interface(address(0)),
baseStalePriceInterval: 0,
quoteStalePriceInterval: 0,
sequencerUptimeFeed: AggregatorV3Interface(address(0))
});
quote = PriceFeedParams({
uniswapV3Pool: IUniswapV3Pool(0xd0b53D9277642d899DF5C87A3966A349A798F224), // WETH/USDC Uniswap v3 0.05% pool
twapWindow: 10 minutes,
averageBlockTime: 2 seconds,
baseToken: IERC20Metadata(0x4200000000000000000000000000000000000006), // WETH
quoteToken: IERC20Metadata(0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913), // USDC
baseAggregator: AggregatorV3Interface(0x71041dddad3595F9CEd3DcCFBe3D1F4b0a16Bb70),
quoteAggregator: AggregatorV3Interface(0x7e860098F58bBFC8648a4311b374B1D669a2bc6B),
baseStalePriceInterval: 1200 * 1.1e18 / 1e18,
quoteStalePriceInterval: 86400 * 1.1e18 / 1e18,
sequencerUptimeFeed: AggregatorV3Interface(0xBCF85224fc0756B9Fa45aA7892530B47e10b6433)
});
}
}
4 changes: 2 additions & 2 deletions script/UpgradeSizeFactory.s.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;

import {SizeFactory} from "@src/v1.5/SizeFactory.sol";
import {console} from "forge-std/Script.sol";
import {BaseScript} from "@script/BaseScript.sol";
import {Deploy} from "@script/Deploy.sol";
import {SizeFactory} from "@src/v1.5/SizeFactory.sol";
import {console} from "forge-std/Script.sol";

contract UpgradeSizeFactoryScript is BaseScript, Deploy {
address deployer;
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/ISize.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {SetUserConfigurationParams} from "@src/libraries/actions/SetUserConfigur
import {ISizeAdmin} from "@src/interfaces/ISizeAdmin.sol";
import {ISizeV1_5} from "@src/v1.5/interfaces/ISizeV1_5.sol";

string constant VERSION = "v1.5.1";
string constant VERSION = "v1.5.2";

/// @title ISize
/// @custom:security-contact [email protected]
Expand Down
12 changes: 12 additions & 0 deletions src/oracle/v1.5.2/IPriceFeedV1_5_2.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;

import {IPriceFeed} from "@src/oracle/IPriceFeed.sol";

/// @title IPriceFeedV1_5_2
/// @custom:security-contact [email protected]
/// @author Size (https://size.credit/)
interface IPriceFeedV1_5_2 is IPriceFeed {
/// @notice Returns the description of the price feed
function description() external view returns (string memory);
}
76 changes: 76 additions & 0 deletions src/oracle/v1.5.2/PriceFeedUniswapV3TWAPChainlink.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;

import {AggregatorV3Interface} from "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
import {Math} from "@src/libraries/Math.sol";

import {IPriceFeed} from "@src/oracle/IPriceFeed.sol";

import {PriceFeedParams} from "@src/oracle/v1.5.1/PriceFeed.sol";
import {PriceFeed} from "@src/oracle/v1.5.1/PriceFeed.sol";
import {ChainlinkSequencerUptimeFeed} from "@src/oracle/v1.5.1/adapters/ChainlinkSequencerUptimeFeed.sol";
import {UniswapV3PriceFeed} from "@src/oracle/v1.5.1/adapters/UniswapV3PriceFeed.sol";
import {IPriceFeedV1_5_2} from "@src/oracle/v1.5.2/IPriceFeedV1_5_2.sol";

/// @title PriceFeedUniswapV3TWAPChainlink
/// @custom:security-contact [email protected]
/// @author Size (https://size.credit/)
/// @notice A contract that provides the price of a `base` asset in terms of a `quote` asset, scaled to 18 decimals,
/// using Uniswap V3 for `base` and a IPriceFeedV1_5_1 for `quote`
/// The price is defined as `base * quote`
/// For example, this can be used to calculate the price of an ABC token for the ABC/USDC pair through
/// ABC/WETH via UniswapV3PriceFeed and WETH/USDC via IPriceFeedV1_5_1, ie, ABC/USDC = ABC/WETH * WETH/USDC
/// @dev `decimals` must be 18 to comply with Size contracts
/// `sequencerUptimeFeed` can be null for unsupported networks
/// In case the sequencer is down, `getPrice` reverts (see `ChainlinkSequencerUptimeFeed`)
/// This oracle should only be used for assets that are not supported by Chainlink
contract PriceFeedUniswapV3TWAPChainlink is IPriceFeedV1_5_2 {
/* solhint-disable */
uint256 public constant decimals = 18;
ChainlinkSequencerUptimeFeed public immutable chainlinkSequencerUptimeFeed;
UniswapV3PriceFeed public immutable basePriceFeed;
PriceFeed public immutable quotePriceFeed;
/* solhint-enable */

constructor(
AggregatorV3Interface sequencerUptimeFeed,
PriceFeedParams memory basePriceFeedParams,
PriceFeedParams memory quotePriceFeedParams
) {
chainlinkSequencerUptimeFeed = new ChainlinkSequencerUptimeFeed(sequencerUptimeFeed);
basePriceFeed = new UniswapV3PriceFeed(
decimals,
// other parameters of basePriceFeedParams are unused
basePriceFeedParams.baseToken,
basePriceFeedParams.quoteToken,
basePriceFeedParams.uniswapV3Pool,
basePriceFeedParams.twapWindow,
basePriceFeedParams.averageBlockTime
);

quotePriceFeed = new PriceFeed(quotePriceFeedParams); // uses 18 decimals
}

function getPrice() external view override returns (uint256) {
chainlinkSequencerUptimeFeed.validateSequencerIsUp();

uint256 basePrice = basePriceFeed.getPrice();
uint256 quotePrice = quotePriceFeed.getPrice();

return Math.mulDivDown(basePrice, quotePrice, 10 ** decimals);
}

function description() external view override returns (string memory) {
return string.concat(
"PriceFeedUniswapV3TWAPChainlink | (",
basePriceFeed.baseToken().symbol(),
"/",
basePriceFeed.quoteToken().symbol(),
") (Uniswap v3 TWAP) * ((",
quotePriceFeed.base().description(),
") / (",
quotePriceFeed.quote().description(),
")) (PriceFeed)"
);
}
}
15 changes: 13 additions & 2 deletions src/v1.5/SizeFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import {NonTransferrableScaledTokenV1_5FactoryLibrary} from
"@src/v1.5/libraries/NonTransferrableScaledTokenV1_5FactoryLibrary.sol";
import {PriceFeedFactoryLibrary} from "@src/v1.5/libraries/PriceFeedFactoryLibrary.sol";

import {IPriceFeedV1_5_2} from "@src/oracle/v1.5.2/IPriceFeedV1_5_2.sol";

import {PriceFeed, PriceFeedParams} from "@src/oracle/v1.5.1/PriceFeed.sol";
import {NonTransferrableScaledTokenV1_5} from "@src/v1.5/token/NonTransferrableScaledTokenV1_5.sol";

Expand Down Expand Up @@ -239,8 +241,17 @@ contract SizeFactory is ISizeFactory, Ownable2StepUpgradeable, UUPSUpgradeable {
// slither-disable-start calls-loop
for (uint256 i = 0; i < descriptions.length; i++) {
PriceFeed priceFeed = PriceFeed(priceFeeds.at(i));
descriptions[i] =
string.concat("PriceFeed | ", priceFeed.base().description(), " | ", priceFeed.quote().description());
(bool success, bytes memory data) =
address(priceFeed).staticcall(abi.encodeWithSelector(IPriceFeedV1_5_2.description.selector));
if (success) {
// IPriceFeedV1_5_2
descriptions[i] = abi.decode(data, (string));
} else {
// IPriceFeedV1_5
descriptions[i] = string.concat(
"PriceFeed | ", priceFeed.base().description(), " | ", priceFeed.quote().description()
);
}
}
// slither-disable-end calls-loop
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {Test} from "forge-std/Test.sol";
import {console} from "forge-std/console.sol";

// On Oct-18-2024, Chainlink cbBTC/USD price feed went down for over 6h
contract ChainlinkGoesDownUniswapIsUsedAsFallbackTest is ForkTest {
contract ForkChainlinkGoesDownUniswapIsUsedAsFallbackTest is ForkTest {
// https://basescan.org/tx/0x2797a77761aa4eda81640b54faa9fe19608c563e146eb566b3fdadea5941070e (aggregatorRoundId 397 executed at Oct-18-2024 03:37:21 PM +UTC)
uint256 blockNumberChainlinkAggregatorRoundId397 = 21238247;
// https://basescan.org/tx/0x5861fd0da0cdc07265494e4e7f80608f00f4e2e4211735ee06918f8330569786 (aggregatorRoundId 398 executed at Oct-18-2024 10:05:33 PM +UTC)
Expand All @@ -41,7 +41,7 @@ contract ChainlinkGoesDownUniswapIsUsedAsFallbackTest is ForkTest {
AggregatorV3Interface(PriceFeedV1_5(address(sizeCbBtcUsdc.oracle().priceFeed)).base()).latestRoundData();
}

function testFork_ChainlinkGoesDownUniswapIsUsedAsFallbackTest_without_fallback_wrong_stale_interval() public {
function testFork_ForkChainlinkGoesDownUniswapIsUsedAsFallbackTest_without_fallback_wrong_stale_interval() public {
vm.rollFork(blockNumberChainlinkAggregatorRoundId398 - 1); // Chainlink is down

uint256 baseStalePriceInterval =
Expand All @@ -54,7 +54,9 @@ contract ChainlinkGoesDownUniswapIsUsedAsFallbackTest is ForkTest {
assertGt(IPriceFeed(address(sizeCbBtcUsdc.oracle().priceFeed)).getPrice(), 0);
}

function testFork_ChainlinkGoesDownUniswapIsUsedAsFallbackTest_without_fallback_correct_stale_interval() public {
function testFork_ForkChainlinkGoesDownUniswapIsUsedAsFallbackTest_without_fallback_correct_stale_interval()
public
{
AggregatorV3Interface base = PriceFeedV1_5(address(sizeCbBtcUsdc.oracle().priceFeed)).base();
AggregatorV3Interface quote = PriceFeedV1_5(address(sizeCbBtcUsdc.oracle().priceFeed)).quote();
AggregatorV3Interface sequencerUptimeFeed = AggregatorV3Interface(address(0));
Expand All @@ -80,7 +82,7 @@ contract ChainlinkGoesDownUniswapIsUsedAsFallbackTest is ForkTest {
assertGt(v1_5PriceFeedCorrectStaleInterval.getPrice(), 0);
}

function testFork_ChainlinkGoesDownUniswapIsUsedAsFallbackTest_with_fallback_correct_stale_interval() public {
function testFork_ForkChainlinkGoesDownUniswapIsUsedAsFallbackTest_with_fallback_correct_stale_interval() public {
AggregatorV3Interface baseAggregator = PriceFeedV1_5(address(sizeCbBtcUsdc.oracle().priceFeed)).base();
AggregatorV3Interface quoteAggregator = PriceFeedV1_5(address(sizeCbBtcUsdc.oracle().priceFeed)).quote();
AggregatorV3Interface sequencerUptimeFeed = AggregatorV3Interface(address(0));
Expand Down
53 changes: 53 additions & 0 deletions test/fork/oracle/ForkPriceFeedUniswapV3TWAPChainlinkTest.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;

import {AggregatorV3Interface} from "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";

import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import {ISize} from "@src/interfaces/ISize.sol";
import {Errors} from "@src/libraries/Errors.sol";
import {UpdateConfigParams} from "@src/libraries/actions/UpdateConfig.sol";
import {IPriceFeed} from "@src/oracle/IPriceFeed.sol";
import {PriceFeedV1_5} from "@src/oracle/deprecated/PriceFeedV1_5.sol";
import {PriceFeed, PriceFeedParams} from "@src/oracle/v1.5.1/PriceFeed.sol";
import {BaseTest} from "@test/BaseTest.sol";
import {ForkTest} from "@test/fork/ForkTest.sol";

import {IUniswapV3Pool} from "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";
import {Test} from "forge-std/Test.sol";
import {console} from "forge-std/console.sol";

import {PriceFeedUniswapV3TWAPChainlink} from "@src/oracle/v1.5.2/PriceFeedUniswapV3TWAPChainlink.sol";

import {PriceFeedUniswapV3TWAPChainlinkTest} from "@test/local/oracle/PriceFeedUniswapV3TWAPChainlink.t.sol";

import {Networks} from "@script/Networks.sol";

contract ForkPriceFeedUniswapV3TWAPChainlinkTest is ForkTest, Networks {
PriceFeedUniswapV3TWAPChainlink public priceFeedVirtualToUsdc;

function setUp() public override(ForkTest) {
super.setUp();
vm.createSelectFork("base");

// 2024-12-19 16h20
vm.rollFork(23917935);

(AggregatorV3Interface sequencerUptimeFeed, PriceFeedParams memory base, PriceFeedParams memory quote) =
priceFeedVirtualUsdcBaseMainnet();

priceFeedVirtualToUsdc = new PriceFeedUniswapV3TWAPChainlink(sequencerUptimeFeed, base, quote);
}

function testFork_ForkPriceFeedUniswapV3TWAPChainlink_getPrice() public view {
uint256 price = priceFeedVirtualToUsdc.getPrice();
assertEqApprox(price, 2.359e18, 0.001e18);
}

function testFork_PriceFeedUniswapV3TWAPChainlink_description() public view {
assertEq(
priceFeedVirtualToUsdc.description(),
"PriceFeedUniswapV3TWAPChainlink | (VIRTUAL/WETH) (Uniswap v3 TWAP) * ((ETH / USD) / (USDC / USD)) (PriceFeed)"
);
}
}
7 changes: 7 additions & 0 deletions test/local/oracle/PriceFeed.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ contract PriceFeedTest is BaseTest {
);
}

function test_PriceFeed_v1_5() public view {
assertEq(address(priceFeedEthToUsd.base()), address(ethToUsd));
assertEq(address(priceFeedEthToUsd.quote()), address(usdcToUsd));
assertEq(priceFeedEthToUsd.baseStalePriceInterval(), 3600);
assertEq(priceFeedEthToUsd.quoteStalePriceInterval(), 86400);
}

function test_PriceFeed_getPrice_success() public view {
assertEq(priceFeedEthToUsd.getPrice(), Math.mulDivDown(uint256(2200.12e18), 1e18, uint256(0.9999e18)));
assertEq(priceFeedStethToEth.getPrice(), uint256(STETH_TO_ETH));
Expand Down
Loading

0 comments on commit b69703d

Please sign in to comment.