Skip to content

Commit

Permalink
feat: change sigma values for rootFinder tests
Browse files Browse the repository at this point in the history
  • Loading branch information
robertleifke committed Oct 25, 2024
1 parent efc28f8 commit f7bc1cb
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions test/rootFinder.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ contract RootFinderTest is Test {
rootFinder = new RootFinder();
}

// Test findRootNewX to ensure it converges on the expected result
// for a given set of input parameters
// Test findRootNewX to ensure it converges
function testFindRootNewX() public {
// Define inputs for findRootNewX
uint256 reserveY_ = 1000 ether;
uint256 liquidity = 5000 ether;
uint256 strike_ = 1500 ether;
uint256 sigma_ = 1e18; // 100% volatility
uint256 sigma_ = 8e17; // 80% volatility
uint256 tau_ = 365 days; // 1-year duration

bytes memory args = abi.encode(reserveY_, liquidity, strike_, sigma_, tau_);
Expand All @@ -32,7 +31,7 @@ contract RootFinderTest is Test {
assertApproxEqAbs(result, expectedValue, 1 ether, "Root did not converge to expected value within tolerance");
}

// Test computeTfDReserveX to verify the accuracy of the derivative computation
// Test computeTfDReserveX to ensure accuracy of f'(L)
function testComputeTfDReserveX() public {
// Define inputs for derivative computation
uint256 reserveY_ = 1000 ether;
Expand All @@ -53,8 +52,8 @@ contract RootFinderTest is Test {
// Test findX function to ensure it returns the expected value for given inputs
function testFindX() public {
// Test data for findX
uint256 reserveY_ = 1000 ether;
uint256 liquidity = 5000 ether;
uint256 reserveY_ = 10 ether;
uint256 liquidity = 500 ether;
uint256 strike_ = 1500 ether;
uint256 sigma_ = 1e18; // 100% volatility
uint256 tau_ = 365 days; // 1-year duration
Expand All @@ -70,11 +69,11 @@ contract RootFinderTest is Test {

// Test computeTradingFunction with known parameters to verify correct calculation
function testComputeTradingFunction() public {
uint256 reserveX_ = 2000 ether;
uint256 reserveY_ = 3000 ether;
uint256 reserveX_ = 200 ether;
uint256 reserveY_ = 10 ether;
uint256 liquidity = 10000 ether;
uint256 strike_ = 1500 ether;
uint256 sigma_ = 1e18; // 100% volatility
uint256 sigma_ = 8e17; // 80% volatility
uint256 tau_ = 365 days; // 1-year duration

int256 result = rootFinder.computeTradingFunction(reserveX_, reserveY_, liquidity, strike_, sigma_, tau_);
Expand All @@ -85,12 +84,12 @@ contract RootFinderTest is Test {

// Test computeSigmaSqrtTau to ensure correct calculation of sigma * sqrt(tau)
function testComputeSigmaSqrtTau() public {
uint256 sigma_ = 1e18; // 100% volatility
uint256 sigma_ = 8e17; // 80% volatility
uint256 tau_ = 365 days; // 1-year duration

uint256 result = rootFinder.computeSigmaSqrtTau(sigma_, tau_);

uint256 expectedValue = 1e18; // TODO: Replace with actual expected sigma * sqrt(tau) result
uint256 expectedValue = 1157e14; // TODO: Replace with actual expected sigma * sqrt(tau) result
assertApproxEqAbs(result, expectedValue, 1e16, "computeSigmaSqrtTau result does not match expected value");
}

Expand Down

0 comments on commit f7bc1cb

Please sign in to comment.