Skip to content

Commit

Permalink
📚 fix typos in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MathisGD authored and MerlinEgalite committed May 28, 2022
1 parent e3ed4c4 commit 068ebc4
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 81 deletions.
18 changes: 9 additions & 9 deletions test-foundry/common/uniswap/UniswapV3PoolCreator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ contract UniswapV3PoolCreator is IERC721Receiver {

IUniswapV3Factory public uniswapFactory =
IUniswapV3Factory(0x1F98431c8aD98523631AE4a59f267346ea31F984);
INonfungiblePositionManager public nonfungiblePositionManager =
INonfungiblePositionManager public nonFungiblePositionManager =
INonfungiblePositionManager(0xC36442b4a4522E871399CD717aBDD847Ab11FE88);
address public WETH9; // Intermediate token address.
uint24 public constant POOL_FEE = 3000;
Expand All @@ -37,7 +37,7 @@ contract UniswapV3PoolCreator is IERC721Receiver {
uint256 public amountToMint = 1000e18;

constructor() {
WETH9 = nonfungiblePositionManager.WETH9();
WETH9 = nonFungiblePositionManager.WETH9();
}

function createPoolAndMintPosition(address _token0) external {
Expand All @@ -49,7 +49,7 @@ contract UniswapV3PoolCreator is IERC721Receiver {
// createAndInitializePoolIfNecessary requires that token 0 address < token 1 address
(token0, token1) = (token1, token0);
}
nonfungiblePositionManager.createAndInitializePoolIfNecessary(
nonFungiblePositionManager.createAndInitializePoolIfNecessary(
token0,
token1,
POOL_FEE,
Expand All @@ -74,8 +74,8 @@ contract UniswapV3PoolCreator is IERC721Receiver {
)
{
// Approve the position manager
TransferHelper.safeApprove(_token0, address(nonfungiblePositionManager), amountToMint);
TransferHelper.safeApprove(WETH9, address(nonfungiblePositionManager), amountToMint);
TransferHelper.safeApprove(_token0, address(nonFungiblePositionManager), amountToMint);
TransferHelper.safeApprove(WETH9, address(nonFungiblePositionManager), amountToMint);

INonfungiblePositionManager.MintParams memory params = INonfungiblePositionManager
.MintParams({
Expand All @@ -93,20 +93,20 @@ contract UniswapV3PoolCreator is IERC721Receiver {
});

// Note that the pool defined and fee tier 0.3% must already be created and initialized in order to mint
(tokenId, liquidity, amount0, amount1) = nonfungiblePositionManager.mint(params);
(tokenId, liquidity, amount0, amount1) = nonFungiblePositionManager.mint(params);

// Create a deposit
_createDeposit(msg.sender, tokenId);

// Remove allowance and refund in both assets.
if (amount0 < amountToMint) {
TransferHelper.safeApprove(_token0, address(nonfungiblePositionManager), 0);
TransferHelper.safeApprove(_token0, address(nonFungiblePositionManager), 0);
uint256 refund0 = amountToMint - amount0;
TransferHelper.safeTransfer(_token0, msg.sender, refund0);
}

if (amount1 < amountToMint) {
TransferHelper.safeApprove(WETH9, address(nonfungiblePositionManager), 0);
TransferHelper.safeApprove(WETH9, address(nonFungiblePositionManager), 0);
uint256 refund1 = amountToMint - amount1;
TransferHelper.safeTransfer(WETH9, msg.sender, refund1);
}
Expand Down Expand Up @@ -137,7 +137,7 @@ contract UniswapV3PoolCreator is IERC721Receiver {
,
,

) = nonfungiblePositionManager.positions(tokenId);
) = nonFungiblePositionManager.positions(tokenId);

// set the owner and data for position
// operator is msg.sender
Expand Down
4 changes: 2 additions & 2 deletions test-foundry/compound/TestEth.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ contract TestEth is TestSetup {
function testShouldLiquidateUserWithEthBorrowed() public {
uint256 collateral = to6Decimals(100_000 ether);

// supplier1 supplies excedent of USDC to put Morpho clearly above water.
// supplier1 supplies surplus of USDC to put Morpho clearly above water.
supplier1.approve(usdc, address(morpho), collateral);
supplier1.supply(cUsdc, collateral);

Expand Down Expand Up @@ -241,7 +241,7 @@ contract TestEth is TestSetup {
uint256 collateral = 1 ether;
uint256 toSupplyMore = to6Decimals(100_000 ether);

// supplier1 supplies excedent of USDC to put Morpho clearly above water.
// supplier1 supplies surplus of USDC to put Morpho clearly above water.
supplier1.approve(usdc, address(morpho), toSupplyMore);
supplier1.supply(cUsdc, toSupplyMore);

Expand Down
2 changes: 1 addition & 1 deletion test-foundry/compound/TestGasConsumption.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity 0.8.13;
import "./setup/TestSetup.sol";

contract TestGasConsumption is TestSetup {
// Hyperparameters to get the gas estimate for
// Hyper parameters to get the gas estimate for
uint256 public maxSortedUsers = 50;
uint256 public numberOfMatches = 25;

Expand Down
6 changes: 3 additions & 3 deletions test-foundry/compound/TestGovernance.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "./setup/TestSetup.sol";
contract TestGovernance is TestSetup {
using CompoundMath for uint256;

function testShoudDeployContractWithTheRightValues() public {
function testShouldDeployContractWithTheRightValues() public {
assertEq(
morpho.p2pSupplyIndex(cDai),
2 * 10**(16 + ERC20(ICToken(cDai).underlying()).decimals() - 8)
Expand Down Expand Up @@ -137,7 +137,7 @@ contract TestGovernance is TestSetup {
assertTrue(morpho.p2pDisabled(cDai));
}

function testonlyOwnerShouldSetPositionsManager() public {
function testOnlyOwnerShouldSetPositionsManager() public {
IPositionsManager positionsManagerV2 = new PositionsManager();

hevm.prank(address(0));
Expand Down Expand Up @@ -187,7 +187,7 @@ contract TestGovernance is TestSetup {
assertEq(address(morpho.incentivesVault()), address(incentivesVaultV2));
}

function testOnlyOwnerShouldSetTreasuryvault() public {
function testOnlyOwnerShouldSetTreasuryVault() public {
address treasuryVaultV2 = address(2);

hevm.prank(address(0));
Expand Down
2 changes: 1 addition & 1 deletion test-foundry/compound/TestIncentivesVault.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ contract TestIncentivesVault is Config, DSTest, stdCheats {
incentivesVault.tradeCompForMorphoTokens(address(1), 0);
}

function testOnlymorphoShouldTriggerCompConvertFunction() public {
function testOnlyMorphoShouldTriggerCompConvertFunction() public {
incentivesVault.setMorphoDao(address(1));
uint256 amount = 100;
tip(COMP, address(morpho), amount);
Expand Down
30 changes: 15 additions & 15 deletions test-foundry/compound/TestInterestRates.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ contract TestInterestRates is InterestRatesManager, DSTest {
);

(uint256 newP2PSupplyIndex, uint256 newP2PBorrowIndex) = _computeP2PIndexes(params); // prettier-ignore
(uint256 expectednewP2PSupplyIndex, uint256 expectednewP2PBorrowIndex) = computeP2PIndexes(params); // prettier-ignore
assertApproxEq(newP2PSupplyIndex, expectednewP2PSupplyIndex, 1);
assertApproxEq(newP2PBorrowIndex, expectednewP2PBorrowIndex, 1);
(uint256 expectedNewP2PSupplyIndex, uint256 expectedNewP2PBorrowIndex) = computeP2PIndexes(params); // prettier-ignore
assertApproxEq(newP2PSupplyIndex, expectedNewP2PSupplyIndex, 1);
assertApproxEq(newP2PBorrowIndex, expectedNewP2PBorrowIndex, 1);
}

function testIndexComputationWithReserveFactor() public {
Expand All @@ -80,9 +80,9 @@ contract TestInterestRates is InterestRatesManager, DSTest {
);

(uint256 newP2PSupplyIndex, uint256 newP2PBorrowIndex) = _computeP2PIndexes(params); // prettier-ignore
(uint256 expectednewP2PSupplyIndex, uint256 expectednewP2PBorrowIndex) = computeP2PIndexes(params); // prettier-ignore
assertApproxEq(newP2PSupplyIndex, expectednewP2PSupplyIndex, 1);
assertApproxEq(newP2PBorrowIndex, expectednewP2PBorrowIndex, 1);
(uint256 expectedNewP2PSupplyIndex, uint256 expectedNewP2PBorrowIndex) = computeP2PIndexes(params); // prettier-ignore
assertApproxEq(newP2PSupplyIndex, expectedNewP2PSupplyIndex, 1);
assertApproxEq(newP2PBorrowIndex, expectedNewP2PBorrowIndex, 1);
}

function testIndexComputationWithDelta() public {
Expand All @@ -99,9 +99,9 @@ contract TestInterestRates is InterestRatesManager, DSTest {
);

(uint256 newP2PSupplyIndex, uint256 newP2PBorrowIndex) = _computeP2PIndexes(params); // prettier-ignore
(uint256 expectednewP2PSupplyIndex, uint256 expectednewP2PBorrowIndex) = computeP2PIndexes(params); // prettier-ignore
assertApproxEq(newP2PSupplyIndex, expectednewP2PSupplyIndex, 1);
assertApproxEq(newP2PBorrowIndex, expectednewP2PBorrowIndex, 1);
(uint256 expectedNewP2PSupplyIndex, uint256 expectedNewP2PBorrowIndex) = computeP2PIndexes(params); // prettier-ignore
assertApproxEq(newP2PSupplyIndex, expectedNewP2PSupplyIndex, 1);
assertApproxEq(newP2PBorrowIndex, expectedNewP2PBorrowIndex, 1);
}

function testIndexComputationWithDeltaAndReserveFactor() public {
Expand All @@ -118,9 +118,9 @@ contract TestInterestRates is InterestRatesManager, DSTest {
);

(uint256 newP2PSupplyIndex, uint256 newP2PBorrowIndex) = _computeP2PIndexes(params); // prettier-ignore
(uint256 expectednewP2PSupplyIndex, uint256 expectednewP2PBorrowIndex) = computeP2PIndexes(params); // prettier-ignore
assertApproxEq(newP2PSupplyIndex, expectednewP2PSupplyIndex, 1);
assertApproxEq(newP2PBorrowIndex, expectednewP2PBorrowIndex, 1);
(uint256 expectedNewP2PSupplyIndex, uint256 expectedNewP2PBorrowIndex) = computeP2PIndexes(params); // prettier-ignore
assertApproxEq(newP2PSupplyIndex, expectedNewP2PSupplyIndex, 1);
assertApproxEq(newP2PBorrowIndex, expectedNewP2PBorrowIndex, 1);
}

// prettier-ignore
Expand Down Expand Up @@ -160,8 +160,8 @@ contract TestInterestRates is InterestRatesManager, DSTest {
InterestRatesManager.Params memory params = InterestRatesManager.Params(_p2pSupplyIndex, _p2pBorrowIndex, _poolSupplyIndex, _poolBorrowIndex, _lastPoolSupplyIndex, _lastPoolBorrowIndex, _reserveFactor, _p2pIndexCursor, Types.Delta(_p2pSupplyDelta, _p2pBorrowDelta, _p2pSupplyAmount, _p2pBorrowAmount));

(uint256 newP2PSupplyIndex, uint256 newP2PBorrowIndex) = _computeP2PIndexes(params);
(uint256 expectednewP2PSupplyIndex, uint256 expectednewP2PBorrowIndex) = computeP2PIndexes(params);
assertApproxEq(newP2PSupplyIndex, expectednewP2PSupplyIndex, 400);
assertApproxEq(newP2PBorrowIndex, expectednewP2PBorrowIndex, 400);
(uint256 expectedNewP2PSupplyIndex, uint256 expectedNewP2PBorrowIndex) = computeP2PIndexes(params);
assertApproxEq(newP2PSupplyIndex, expectedNewP2PSupplyIndex, 400);
assertApproxEq(newP2PBorrowIndex, expectedNewP2PBorrowIndex, 400);
}
}
80 changes: 40 additions & 40 deletions test-foundry/compound/TestLens.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ contract TestLens is TestSetup {

uint256 collateralValue = total.mul(underlyingPrice);
uint256 maxDebtValue = collateralValue.mul(collateralFactor);
// Divide and multiply to take into account rouding errors.
// Divide and multiply to take into account rounding errors.
uint256 debtValue = toBorrow.div(p2pBorrowIndex).mul(p2pBorrowIndex).mul(underlyingPrice);

assertEq(assetData.underlyingPrice, underlyingPrice, "underlyingPrice");
Expand All @@ -120,63 +120,63 @@ contract TestLens is TestSetup {
borrower1.supply(cDai, amount);
borrower1.borrow(cUsdc, toBorrow);

Types.AssetLiquidityData memory assetDatacDai = lens.getUserLiquidityDataForAsset(
Types.AssetLiquidityData memory assetDataCDai = lens.getUserLiquidityDataForAsset(
address(borrower1),
cDai,
oracle
);

Types.AssetLiquidityData memory assetDatacUsdc = lens.getUserLiquidityDataForAsset(
Types.AssetLiquidityData memory assetDataCUsdc = lens.getUserLiquidityDataForAsset(
address(borrower1),
cUsdc,
oracle
);

// Avoid stack too deep error.
Types.AssetLiquidityData memory expectedDatcUsdc;
Types.AssetLiquidityData memory expectedDataCUsdc;
(, uint256 collateralFactor, ) = comptroller.markets(cUsdc);
expectedDatcUsdc.underlyingPrice = oracle.getUnderlyingPrice(cUsdc);
expectedDataCUsdc.underlyingPrice = oracle.getUnderlyingPrice(cUsdc);

expectedDatcUsdc.debtValue = getBalanceOnCompound(toBorrow, ICToken(cUsdc).borrowIndex())
.mul(expectedDatcUsdc.underlyingPrice);
expectedDataCUsdc.debtValue = getBalanceOnCompound(toBorrow, ICToken(cUsdc).borrowIndex())
.mul(expectedDataCUsdc.underlyingPrice);

assertEq(
assetDatacUsdc.underlyingPrice,
expectedDatcUsdc.underlyingPrice,
assetDataCUsdc.underlyingPrice,
expectedDataCUsdc.underlyingPrice,
"underlyingPriceUsdc"
);
assertEq(assetDatacUsdc.collateralValue, 0, "collateralValue");
assertEq(assetDatacUsdc.maxDebtValue, 0, "maxDebtValue");
assertEq(assetDatacUsdc.debtValue, expectedDatcUsdc.debtValue, "debtValueUsdc");
assertEq(assetDataCUsdc.collateralValue, 0, "collateralValue");
assertEq(assetDataCUsdc.maxDebtValue, 0, "maxDebtValue");
assertEq(assetDataCUsdc.debtValue, expectedDataCUsdc.debtValue, "debtValueUsdc");

// Avoid stack too deep error.
Types.AssetLiquidityData memory expectedDatacDai;
Types.AssetLiquidityData memory expectedDataCDai;

(, expectedDatacDai.collateralFactor, ) = comptroller.markets(cDai);
(, expectedDataCDai.collateralFactor, ) = comptroller.markets(cDai);

expectedDatacDai.underlyingPrice = oracle.getUnderlyingPrice(cDai);
expectedDatacDai.collateralValue = getBalanceOnCompound(
expectedDataCDai.underlyingPrice = oracle.getUnderlyingPrice(cDai);
expectedDataCDai.collateralValue = getBalanceOnCompound(
amount,
ICToken(cDai).exchangeRateStored()
).mul(expectedDatacDai.underlyingPrice);
expectedDatacDai.maxDebtValue = expectedDatacDai.collateralValue.mul(
expectedDatacDai.collateralFactor
).mul(expectedDataCDai.underlyingPrice);
expectedDataCDai.maxDebtValue = expectedDataCDai.collateralValue.mul(
expectedDataCDai.collateralFactor
);

assertEq(assetDatacDai.collateralFactor, collateralFactor, "collateralFactor");
assertEq(assetDataCDai.collateralFactor, collateralFactor, "collateralFactor");
assertEq(
assetDatacDai.underlyingPrice,
expectedDatacDai.underlyingPrice,
assetDataCDai.underlyingPrice,
expectedDataCDai.underlyingPrice,
"underlyingPriceDai"
);

assertEq(
assetDatacDai.collateralValue,
expectedDatacDai.collateralValue,
assetDataCDai.collateralValue,
expectedDataCDai.collateralValue,
"collateralValueDai"
);
assertEq(assetDatacDai.maxDebtValue, expectedDatacDai.maxDebtValue, "maxDebtValueDai");
assertEq(assetDatacDai.debtValue, 0, "debtValueDai");
assertEq(assetDataCDai.maxDebtValue, expectedDataCDai.maxDebtValue, "maxDebtValueDai");
assertEq(assetDataCDai.debtValue, 0, "debtValueDai");
}

function testGetterUserWithNothing() public {
Expand All @@ -195,23 +195,23 @@ contract TestLens is TestSetup {
borrower1.approve(usdc, amount);
borrower1.supply(cUsdc, amount);

Types.AssetLiquidityData memory assetDatacUsdc = lens.getUserLiquidityDataForAsset(
Types.AssetLiquidityData memory assetDataCUsdc = lens.getUserLiquidityDataForAsset(
address(borrower1),
cUsdc,
oracle
);

Types.AssetLiquidityData memory assetDatacDai = lens.getUserLiquidityDataForAsset(
Types.AssetLiquidityData memory assetDataCDai = lens.getUserLiquidityDataForAsset(
address(borrower1),
cDai,
oracle
);

uint256 expectedBorrowableUsdc = assetDatacUsdc.maxDebtValue.div(
assetDatacUsdc.underlyingPrice
uint256 expectedBorrowableUsdc = assetDataCUsdc.maxDebtValue.div(
assetDataCUsdc.underlyingPrice
);
uint256 expectedBorrowableDai = assetDatacUsdc.maxDebtValue.div(
assetDatacDai.underlyingPrice
uint256 expectedBorrowableDai = assetDataCUsdc.maxDebtValue.div(
assetDataCDai.underlyingPrice
);

(uint256 withdrawable, uint256 borrowable) = lens.getUserMaxCapacitiesForAsset(
Expand Down Expand Up @@ -390,19 +390,19 @@ contract TestLens is TestSetup {
borrower1.approve(dai, amount);
borrower1.supply(cDai, amount);

Types.AssetLiquidityData memory assetDatacUsdc = lens.getUserLiquidityDataForAsset(
Types.AssetLiquidityData memory assetDataCUsdc = lens.getUserLiquidityDataForAsset(
address(borrower1),
cUsdc,
oracle
);

Types.AssetLiquidityData memory assetDatacDai = lens.getUserLiquidityDataForAsset(
Types.AssetLiquidityData memory assetDataCDai = lens.getUserLiquidityDataForAsset(
address(borrower1),
cDai,
oracle
);

Types.AssetLiquidityData memory assetDatacUsdt = lens.getUserLiquidityDataForAsset(
Types.AssetLiquidityData memory assetDataCUsdt = lens.getUserLiquidityDataForAsset(
address(borrower1),
cUsdt,
oracle
Expand All @@ -412,8 +412,8 @@ contract TestLens is TestSetup {
(uint256 withdrawableUsdc, ) = lens.getUserMaxCapacitiesForAsset(address(borrower1), cUsdc);
(, uint256 borrowableUsdt) = lens.getUserMaxCapacitiesForAsset(address(borrower1), cUsdt);

uint256 expectedBorrowableUsdt = (assetDatacDai.maxDebtValue + assetDatacUsdc.maxDebtValue)
.div(assetDatacUsdt.underlyingPrice);
uint256 expectedBorrowableUsdt = (assetDataCDai.maxDebtValue + assetDataCUsdc.maxDebtValue)
.div(assetDataCUsdt.underlyingPrice);

assertEq(
withdrawableUsdc,
Expand Down Expand Up @@ -728,7 +728,7 @@ contract TestLens is TestSetup {
}
}

function testGetEnteretMarkets() public {
function testGetEnteredMarkets() public {
uint256 amount = 1e12;
supplier1.approve(dai, amount);
supplier1.approve(usdc, amount);
Expand All @@ -754,12 +754,12 @@ contract TestLens is TestSetup {
uint256 poolBorrowRate
) = lens.getRates(cDai);

(uint256 expectedP2PSupplyRate, uint256 excpectedP2PBorrowRate) = getApproxP2PRates(cDai);
(uint256 expectedP2PSupplyRate, uint256 expectedP2PBorrowRate) = getApproxP2PRates(cDai);
uint256 expectedPoolSupplyRate = ICToken(cDai).supplyRatePerBlock();
uint256 expectedPoolBorrowRate = ICToken(cDai).borrowRatePerBlock();

assertEq(p2pSupplyRate, expectedP2PSupplyRate);
assertEq(p2pBorrowRate, excpectedP2PBorrowRate);
assertEq(p2pBorrowRate, expectedP2PBorrowRate);
assertEq(poolSupplyRate, expectedPoolSupplyRate);
assertEq(poolBorrowRate, expectedPoolBorrowRate);
}
Expand Down
6 changes: 3 additions & 3 deletions test-foundry/compound/setup/Utils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ contract Utils is DSTest {
assertApproxEq(_firstValue, _secondValue, 20, err);
}

/// @dev compounds track balances deposited by divising the amount by a rate to obtain cToken Units.
/// @dev compounds track balances deposited by dividing the amount by a rate to obtain cToken Units.
/// When needed, it goes back to underlying by multiplying by the said rate.
/// However, for the same rate, the following computation will slighty under estimate the amount
/// deposited. This function is usefull to determine compound's users balances.
/// However, for the same rate, the following computation will slightly under estimate the amount
/// deposited. This function is useful to determine compound's users balances.
function getBalanceOnCompound(uint256 _amountInUnderlying, uint256 _rate)
internal
pure
Expand Down
Loading

0 comments on commit 068ebc4

Please sign in to comment.