Skip to content

Commit

Permalink
tests: update tests to have correct oracle value
Browse files Browse the repository at this point in the history
  • Loading branch information
0xtekgrinder committed Nov 19, 2024
1 parent 0fbab77 commit 671360c
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions test/fuzz/MultiBlockHarvester.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ contract MultiBlockHarvestertTest is Fixture, FunctionUtils {
)
);

oracleXEVT = AggregatorV3Interface(address(new MockChainlinkOracle()));
circuitChainlink[0] = AggregatorV3Interface(oracleXEVT);
readData = abi.encode(circuitChainlink, stalePeriods, circuitChainIsMultiplied, chainlinkDecimals, quoteType);
MockChainlinkOracle(address(oracleXEVT)).setLatestAnswer(int256(BASE_8));
address oracle = 0x6B102047A4bB943DE39233E44487F2d57bDCb33e;
uint256 normalizationFactor = 1e18; // price == 36 decimals
readData = bytes("");
targetData = abi.encode(oracle, normalizationFactor);
transmuter.setOracle(
XEVT,
abi.encode(
OracleReadType.CHAINLINK_FEEDS,
OracleReadType.STABLE,
OracleReadType.NO_ORACLE,
OracleReadType.MORPHO_ORACLE,
readData,
targetData,
abi.encode(uint128(0), uint128(0))
Expand Down Expand Up @@ -179,6 +179,8 @@ contract MultiBlockHarvestertTest is Fixture, FunctionUtils {
harvester.setYieldBearingToDepositAddress(XEVT, XEVT);
harvester.setYieldBearingToDepositAddress(USDM, receiver);

transmuter.toggleTrusted(address(harvester), TrustedType.Seller);

agToken.mint(address(harvester), 1_000_000e18);

vm.stopPrank();
Expand Down Expand Up @@ -399,7 +401,6 @@ contract MultiBlockHarvestertTest is Fixture, FunctionUtils {

assertEq(expectedIncrease, 0);
assertEq(issuedFromStablecoinBefore, 0);
assertEq(issuedFromYieldBearingAssetBefore, amount * 1e12);
assertEq(totalIssuedBefore, issuedFromYieldBearingAssetBefore);
assertEq(expectedAmount, issuedFromYieldBearingAssetBefore - ((targetExposure * totalIssuedBefore) / 1e9));

Expand Down Expand Up @@ -520,13 +521,13 @@ contract MultiBlockHarvestertTest is Fixture, FunctionUtils {
}

function test_ComputeRebalanceAmount_HigherThanMaxWithHarvest() external {
_loadReserve(XEVT, 1e11);
_loadReserve(EURC, 1e11);
_loadReserve(USDC, 1e11);
_loadReserve(USDM, 1e23);
uint64 minExposure = uint64((15 * 1e9) / 100);
uint64 maxExposure = uint64((60 * 1e9) / 100);
_setYieldBearingData(XEVT, EURC, minExposure, maxExposure);
_setYieldBearingData(USDM, USDC, minExposure, maxExposure);

(uint8 increase, uint256 amount) = harvester.computeRebalanceAmount(XEVT);
(uint8 increase, uint256 amount) = harvester.computeRebalanceAmount(USDM);
assertEq(amount, (2e23 * uint256(maxExposure)) / 1e9 - 1e23);
assertEq(increase, 0);
}
Expand All @@ -544,13 +545,13 @@ contract MultiBlockHarvestertTest is Fixture, FunctionUtils {
}

function test_ComputeRebalanceAmount_LowerThanMinAfterHarvest() external {
_loadReserve(EURC, 9e10);
_loadReserve(XEVT, 1e10);
_loadReserve(USDC, 9e10);
_loadReserve(USDM, 1e22);
uint64 minExposure = uint64((89 * 1e9) / 100);
uint64 maxExposure = uint64((999 * 1e9) / 1000);
_setYieldBearingData(XEVT, EURC, minExposure, maxExposure);
_setYieldBearingData(USDM, USDC, minExposure, maxExposure);

(uint8 increase, uint256 amount) = harvester.computeRebalanceAmount(XEVT);
(uint8 increase, uint256 amount) = harvester.computeRebalanceAmount(USDM);
assertEq(amount, 9e22 - (1e23 * uint256(minExposure)) / 1e9);
assertEq(increase, 1);
}
Expand Down

0 comments on commit 671360c

Please sign in to comment.