Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Launch Auction Price Oracle with reduced half life #70

Merged
merged 25 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
7dd9033
Add parameterized auction half life
stevieraykatz Jul 21, 2024
6b37b28
Merge branch 'main' into launch-auction
stevieraykatz Aug 5, 2024
facd077
Revert to prod exp. price auction
stevieraykatz Aug 5, 2024
0e056b4
Add Launch Auction pricing contract
stevieraykatz Aug 5, 2024
edea68f
Fix tests, get ready for review
stevieraykatz Aug 5, 2024
0a6684a
Cleanup return to avoid overshadowing
stevieraykatz Aug 5, 2024
4774c14
Fix pragma
stevieraykatz Aug 5, 2024
6fb4de2
rename to avoid overshadowing
stevieraykatz Aug 5, 2024
a2f7087
Rename constant
stevieraykatz Aug 5, 2024
17a5a48
Add unit tests
stevieraykatz Aug 7, 2024
0f0589f
Lint
stevieraykatz Aug 7, 2024
d4534f7
Fix comments in test
stevieraykatz Aug 7, 2024
9f22d48
Fix tests per PR
stevieraykatz Aug 8, 2024
ea08a84
Add comment for base prices
stevieraykatz Aug 8, 2024
61c873e
lint
stevieraykatz Aug 8, 2024
1563df6
Change halflife to 1.5 hours, allow auction duration to be specified …
stevieraykatz Aug 9, 2024
f5826c9
Fix typo in natspec
stevieraykatz Aug 9, 2024
71394e9
Switch to Error from require
stevieraykatz Aug 9, 2024
74310cb
Add test for new error message
stevieraykatz Aug 9, 2024
1e46dc1
Fix unit conversion issue in bitshift operation
stevieraykatz Aug 11, 2024
01ac27f
Add launch auction integration tests
stevieraykatz Aug 12, 2024
e9b954d
reorder setup to mimic expected ordering
stevieraykatz Aug 12, 2024
eba4cfa
lint
stevieraykatz Aug 12, 2024
ac267c2
Update src/L2/LaunchAuctionPriceOracle.sol
stevieraykatz Aug 13, 2024
11936e7
Fix some comments, cleanup tests
stevieraykatz Aug 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add parameterized auction half life
  • Loading branch information
stevieraykatz committed Jul 21, 2024
commit 7dd90335173a436268fa8cbf911cb89e0ef6d80f
2 changes: 1 addition & 1 deletion script/deploy/DeployPriceOracle.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ contract DeployPriceOracle is Script {
uint256 premiumStart = 500 ether;
uint256 totalDays = 28 days;

StablePriceOracle oracle = new ExponentialPremiumPriceOracle(prices, premiumStart, totalDays);
StablePriceOracle oracle = new ExponentialPremiumPriceOracle(prices, premiumStart, totalDays, 1 days);
console.log("Price Oracle deployed to:");
console.log(address(oracle));

Expand Down
22 changes: 16 additions & 6 deletions src/L2/ExponentialPremiumPriceOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,29 @@ import {GRACE_PERIOD} from "src/util/Constants.sol";
import {StablePriceOracle} from "src/L2/StablePriceOracle.sol";

contract ExponentialPremiumPriceOracle is StablePriceOracle {
/// @dev The starting price of the dutch auction, denominated in wei.
uint256 public immutable startPremium;

/// @dev The calculated ending value of the dutch auction, denominated in wei.
uint256 public immutable endValue;

constructor(uint256[] memory rentPrices, uint256 startPremium_, uint256 totalDays) StablePriceOracle(rentPrices) {
/// @dev The half-life of the premium price decay
uint256 public immutable secondsInPeriod;

error InvlaidPeriod();

constructor(uint256[] memory rentPrices, uint256 startPremium_, uint256 totalDays, uint256 secondsInPeriod_)
StablePriceOracle(rentPrices)
{
if (secondsInPeriod_ > 1 days) revert InvlaidPeriod();
startPremium = startPremium_;
endValue = startPremium >> totalDays;
secondsInPeriod = secondsInPeriod_;
endValue = startPremium >> ((totalDays * 1 days) / secondsInPeriod_);
}

/**
* @dev Returns the pricing premium in internal base units.
*/

function _premium(string memory, uint256 expires, uint256) internal view override returns (uint256) {
expires = expires + GRACE_PERIOD;
if (expires > block.timestamp) {
Expand All @@ -31,14 +43,12 @@ contract ExponentialPremiumPriceOracle is StablePriceOracle {
}
return 0;
}

/**
* @dev Returns the premium price at current time elapsed
* @param elapsed time past since expiry
*/

function decayedPremium(uint256 elapsed) public view returns (uint256) {
/// @dev The half-life of the premium price decay
uint256 secondsInPeriod = 1 days;
/// @dev 50% decay per period in wad format
uint256 perPeriodDecayPercentWad = FixedPointMathLib.WAD / 2;
uint256 premium = EDAPrice.currentPrice(startPremium, elapsed, secondsInPeriod, perPeriodDecayPercentWad);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ contract ExponentialPremiumOracleBase is Test {

uint256 startPremium = 1e18;
uint256 totalDays = 21;
uint256 secondsInPeriod = 1 days;

function setUp() public {
uint256[] memory rentPrices = new uint256[](6);
Expand All @@ -35,7 +36,7 @@ contract ExponentialPremiumOracleBase is Test {
rentPrices[4] = rent5;
rentPrices[5] = rent10;

oracle = new ExponentialPremiumPriceOracle(rentPrices, startPremium, totalDays);
oracle = new ExponentialPremiumPriceOracle(rentPrices, startPremium, totalDays, secondsInPeriod);
}

function test_constructor() public view {
Expand Down
2 changes: 1 addition & 1 deletion test/IntegrationTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ contract IntegrationTest is Test {
rentPrices[4] = 31_709_791;
rentPrices[5] = 3_170_979; //3,170,979.1983764587 = 1e14 / (365 * 24 * 3600)

exponentialPremiumPriceOracle = new ExponentialPremiumPriceOracle(rentPrices, 1e18, 21);
exponentialPremiumPriceOracle = new ExponentialPremiumPriceOracle(rentPrices, 1e18, 21, 1 days);
baseRegistrar = new BaseRegistrar(registry, owner, BASE_ETH_NODE);

_establishNamespaces();
Expand Down