Skip to content

Commit

Permalink
Addressed review feedback from @mcclurejt
Browse files Browse the repository at this point in the history
  • Loading branch information
jalextowle committed May 2, 2024
1 parent cc47823 commit 553b252
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
2 changes: 0 additions & 2 deletions contracts/src/external/HyperdriveTarget0.sol
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,6 @@ abstract contract HyperdriveTarget0 is
_getPresentValueParams(vaultSharePrice)
);
presentValue = presentValue.mulDown(vaultSharePrice);
} else {
presentValue = 0;
}
IHyperdrive.PoolInfo memory poolInfo = IHyperdrive.PoolInfo({
shareReserves: _marketState.shareReserves,
Expand Down
1 change: 0 additions & 1 deletion test/units/hyperdrive/UpdateLiquidityTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pragma solidity 0.8.20;
import { IERC20 } from "contracts/src/interfaces/IERC20.sol";
import { IHyperdrive } from "contracts/src/interfaces/IHyperdrive.sol";
import { FixedPointMath } from "contracts/src/libraries/FixedPointMath.sol";
import { HyperdriveMath } from "contracts/src/libraries/HyperdriveMath.sol";
import { ERC20Mintable } from "contracts/test/ERC20Mintable.sol";
import { MockHyperdrive, MockHyperdriveTarget0, MockHyperdriveTarget1 } from "contracts/test/MockHyperdrive.sol";
import { HyperdriveTest } from "test/utils/HyperdriveTest.sol";
Expand Down
1 change: 0 additions & 1 deletion test/units/libraries/HyperdriveMath.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { IHyperdrive } from "contracts/src/interfaces/IHyperdrive.sol";
import { FixedPointMath, ONE } from "contracts/src/libraries/FixedPointMath.sol";
import { HyperdriveMath } from "contracts/src/libraries/HyperdriveMath.sol";
import { LPMath } from "contracts/src/libraries/LPMath.sol";
import { YieldSpaceMath } from "contracts/src/libraries/YieldSpaceMath.sol";
import { ERC20ForwarderFactory } from "contracts/src/token/ERC20ForwarderFactory.sol";
import { IMockHyperdrive } from "contracts/test/MockHyperdrive.sol";
import { MockHyperdriveMath } from "contracts/test/MockHyperdriveMath.sol";
Expand Down
32 changes: 25 additions & 7 deletions test/units/libraries/LPMath.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ contract LPMathTest is HyperdriveTest {
uint256 vaultSharePrice = 2.5e18;
uint256 apr = 0.001e18;
uint256 positionDuration = 365 days;
uint256 timeStretch = ONE.divDown(1109.3438508425959e18);
uint256 timeStretch = HyperdriveMath.calculateTimeStretch(
0.001e18,
positionDuration
);
(, int256 shareAdjustment, uint256 bondReserves) = lpMath
.calculateInitialReserves(
shareReserves,
Expand All @@ -49,7 +52,10 @@ contract LPMathTest is HyperdriveTest {

// Test 1% APR
apr = 0.01e18;
timeStretch = ONE.divDown(110.93438508425959e18);
timeStretch = HyperdriveMath.calculateTimeStretch(
0.01e18,
positionDuration
);
(, shareAdjustment, bondReserves) = lpMath.calculateInitialReserves(
shareReserves,
vaultSharePrice,
Expand All @@ -73,7 +79,10 @@ contract LPMathTest is HyperdriveTest {

// Test 5% APR
apr = 0.05e18;
timeStretch = ONE.divDown(22.186877016851916266e18);
timeStretch = HyperdriveMath.calculateTimeStretch(
0.05e18,
positionDuration
);
(, shareAdjustment, bondReserves) = lpMath.calculateInitialReserves(
shareReserves,
vaultSharePrice,
Expand All @@ -97,7 +106,10 @@ contract LPMathTest is HyperdriveTest {

// Test 25% APR
apr = 0.25e18;
timeStretch = ONE.divDown(4.437375403370384e18);
timeStretch = HyperdriveMath.calculateTimeStretch(
0.25e18,
positionDuration
);
(, shareAdjustment, bondReserves) = lpMath.calculateInitialReserves(
shareReserves,
vaultSharePrice,
Expand All @@ -120,8 +132,11 @@ contract LPMathTest is HyperdriveTest {
assertApproxEqAbs(result, apr, 1);

// Test 50% APR
apr = 0.50e18;
timeStretch = ONE.divDown(2.218687701685192e18);
apr = 0.5e18;
timeStretch = HyperdriveMath.calculateTimeStretch(
0.5e18,
positionDuration
);
(, shareAdjustment, bondReserves) = lpMath.calculateInitialReserves(
shareReserves,
vaultSharePrice,
Expand All @@ -145,7 +160,10 @@ contract LPMathTest is HyperdriveTest {

// Test 100% APR
apr = 1e18;
timeStretch = ONE.divDown(1.109343850842596e18);
timeStretch = HyperdriveMath.calculateTimeStretch(
1e18,
positionDuration
);
(, shareAdjustment, bondReserves) = lpMath.calculateInitialReserves(
shareReserves,
vaultSharePrice,
Expand Down

0 comments on commit 553b252

Please sign in to comment.