Skip to content

Commit 3069752

Browse files
authored
fix: auction decay incorrectly calculated window size (#14)
fix: auction decay constant assumed 28,000 seconds in 8 hours isntead of 28,800
1 parent 3d23f0d commit 3069752

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/Namespace.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@ contract Namespace is ERC721, Owned {
250250
if (auctionStartTimestamp > block.timestamp) revert NotBiddable();
251251

252252
// Calculate the num of 8 hr periods since expiry as a fixed point signed decimal. The
253-
// constant approximates fixed point division by 28,000 (num of seconds in 8 hours)
254-
int256 periodsSD59x18 = int256(3.57142857e13 * (block.timestamp - auctionStartTimestamp));
253+
// constant approximates fixed point division by 28,800 (num of seconds in 8 hours)
254+
int256 periodsSD59x18 = int256(3.47222222e13 * (block.timestamp - auctionStartTimestamp));
255255

256256
// Optimization: precompute return values for the first few periods and the last one.
257257

test/Namespace.t.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -377,11 +377,11 @@ contract NameSpaceTest is Test {
377377
vm.warp(aliceBiddableTs + 8 hours);
378378

379379
// 2. Bob bids and fails because bid < price (premium + fee)
380-
// price = (0.9^1 * 1_000) + 0.00916894977 = 900.009
380+
// price = (0.9^1 * 1_000) + 0.00916894977 = 900.009169
381381
vm.deal(bob, 1000 ether);
382382
vm.startPrank(bob);
383383
vm.expectRevert(InsufficientFunds.selector);
384-
namespace.bid{value: 897.303 ether}(aliceTokenId);
384+
namespace.bid{value: 900.0091 ether}(aliceTokenId);
385385

386386
vm.expectRevert(Expired.selector);
387387
assertEq(namespace.ownerOf(aliceTokenId), address(0));
@@ -390,7 +390,7 @@ contract NameSpaceTest is Test {
390390
assertEq(namespace.expiryOf(aliceTokenId), timestamp2023);
391391

392392
// 3. Bob bids and succeeds because bid > price
393-
namespace.bid{value: 898 ether}(aliceTokenId);
393+
namespace.bid{value: 900.0092 ether}(aliceTokenId);
394394
assertEq(namespace.ownerOf(aliceTokenId), bob);
395395
vm.stopPrank();
396396

@@ -410,7 +410,7 @@ contract NameSpaceTest is Test {
410410
vm.deal(bob, 1000 ether);
411411
vm.startPrank(bob);
412412
vm.expectRevert(InsufficientFunds.selector);
413-
namespace.bid{value: 0.0279217 ether}(aliceTokenId);
413+
namespace.bid{value: 0.0348 ether}(aliceTokenId);
414414

415415
vm.expectRevert(Expired.selector);
416416
assertEq(namespace.ownerOf(aliceTokenId), address(0));
@@ -419,7 +419,7 @@ contract NameSpaceTest is Test {
419419
assertEq(namespace.expiryOf(aliceTokenId), timestamp2023);
420420

421421
// 3. Bob bids and succeeds because bid > price
422-
namespace.bid{value: 0.0279218 ether}(aliceTokenId);
422+
namespace.bid{value: 0.0349 ether}(aliceTokenId);
423423
vm.stopPrank();
424424

425425
assertEq(namespace.ownerOf(aliceTokenId), bob);

0 commit comments

Comments
 (0)