Skip to content

Commit

Permalink
Fix some comments, cleanup tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stevieraykatz committed Aug 13, 2024
1 parent ac267c2 commit 11936e7
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
42 changes: 41 additions & 1 deletion test/Integration/PostLaunchAuctionConfig.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {Test, console} from "forge-std/Test.sol";
import {IntegrationTestBase} from "./IntegrationTestBase.t.sol";
import {RegistrarController} from "src/L2/RegistrarController.sol";
import {ExponentialPremiumPriceOracle} from "src/L2/ExponentialPremiumPriceOracle.sol";
import {GRACE_PERIOD} from "src/util/Constants.sol";
import {IPriceOracle} from "src/L2/interface/IPriceOracle.sol";

contract PostLaunchAuctionConfig is IntegrationTestBase {
Expand All @@ -21,6 +22,9 @@ contract PostLaunchAuctionConfig is IntegrationTestBase {
// Jump forward 30 days
vm.warp(LAUNCH_TIME + 30 days);

// Get price before oracle changes
uint256 priceBeforeSwitch = registrarController.registerPrice(name, duration);

// Set new price oracle on registrar controller (ownerOnly method)
vm.prank(owner);
registrarController.setPriceOracle(IPriceOracle(exponentialPremiumPriceOracle));
Expand All @@ -29,6 +33,8 @@ contract PostLaunchAuctionConfig is IntegrationTestBase {
uint256 price = registrarController.registerPrice(name, duration);
vm.deal(alice, price);

assertEq(priceBeforeSwitch, price);

RegistrarController.RegisterRequest memory request = RegistrarController.RegisterRequest({
name: name,
owner: alice,
Expand Down Expand Up @@ -63,7 +69,7 @@ contract PostLaunchAuctionConfig is IntegrationTestBase {
// Jump forward 1 day
vm.warp(LAUNCH_TIME + 1 days);

// Set the launch time to 0 (no-op for launch pricing)
// Set the launch time to 0 (eliminates launch premium auction, see: RegistrarController.sol:_getExpiry(id))
vm.prank(owner);
registrarController.setLaunchTime(0);
// Set new price oracle on registrar controller (ownerOnly method)
Expand Down Expand Up @@ -98,4 +104,38 @@ contract PostLaunchAuctionConfig is IntegrationTestBase {
console.log("Price (WEI): ", price);
console.log("______________________________");
}

function test_showAuctionPriceDifferences() public {
// Jump forward 30 days
vm.warp(LAUNCH_TIME + 30 days);

//// Register a name
uint256 price = registrarController.registerPrice(name, duration);
vm.deal(alice, price);
RegistrarController.RegisterRequest memory request = RegistrarController.RegisterRequest({
name: name,
owner: alice,
duration: duration,
resolver: address(defaultL2Resolver),
data: new bytes[](0),
reverseRecord: true
});
vm.prank(alice);
registrarController.register{value: price}(request);

// Jump ahead to expiry
vm.warp(block.timestamp + duration + GRACE_PERIOD);

uint256 priceWithLaunchAuction = registrarController.registerPrice(name, duration);
// Deploy original price oracle and set as price oracle
exponentialPremiumPriceOracle = new ExponentialPremiumPriceOracle(
_getBasePrices(), EXPIRY_AUCTION_START_PRICE, EXPIRY_AUCTION_DURATION_DAYS
);
vm.prank(owner);
registrarController.setPriceOracle(IPriceOracle(exponentialPremiumPriceOracle));
uint256 priceWithProdAuction = registrarController.registerPrice(name, duration);

console.log("Price with launch auction: ", priceWithLaunchAuction);
console.log("Price with prod auction: ", priceWithProdAuction);
}
}
4 changes: 2 additions & 2 deletions test/LaunchAuctionPriceOracle/DecayedPremium.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ contract DecayedPremium is LaunchAuctionPriceOracleBase {
}

function test_decayedPremium_halfPeriod() public view {
uint256 elapsed = 1 hours / 2;
uint256 elapsed = PRICE_PREMIUM_HALF_LIFE / 2;
uint256 expectedPremium = _calculateDecayedPremium(elapsed);
uint256 actualPremium = oracle.decayedPremium(elapsed);
assertEq(actualPremium, expectedPremium);
}

function test_decayedPremium_threePeriods() public view {
uint256 elapsed = 3 hours;
uint256 elapsed = 3 * PRICE_PREMIUM_HALF_LIFE;
uint256 expectedPremium = _calculateDecayedPremium(elapsed);
uint256 actualPremium = oracle.decayedPremium(elapsed);
assertEq(actualPremium, expectedPremium);
Expand Down

0 comments on commit 11936e7

Please sign in to comment.