Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions src/Namespace.sol
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ contract Namespace is ERC721, Owned {
if (auctionStartTimestamp > block.timestamp) revert NotBiddable();

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

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

Expand Down
10 changes: 5 additions & 5 deletions test/Namespace.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -377,11 +377,11 @@ contract NameSpaceTest is Test {
vm.warp(aliceBiddableTs + 8 hours);

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

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

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

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

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

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

assertEq(namespace.ownerOf(aliceTokenId), bob);
Expand Down