Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
EdNoepel committed Dec 13, 2023
1 parent 2bfbbf8 commit bc9522b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/PoolInfoUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ contract PoolInfoUtils {

uint256 quoteTokenBalance = IERC20Token(pool.quoteTokenAddress()).balanceOf(ajnaPool_) * pool.quoteTokenScale();

(uint256 bondEscrowed, uint256 unclaimedReserve, uint256 lastKickedReserves, uint256 auctionKickTime, ) = pool.reservesInfo();
(uint256 bondEscrowed, uint256 unclaimedReserve, uint256 auctionKickTime, uint256 lastKickedReserves, ) = pool.reservesInfo();

// due to rounding issues, especially in Auction.settle, this can be slighly negative
if (poolDebt + quoteTokenBalance >= poolSize + bondEscrowed + unclaimedReserve) {
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/helpers/PoolHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ import { Maths } from '../internal/Maths.sol';
uint256 secondsElapsed = block.timestamp - reserveAuctionKicked_;
uint256 hoursComponent = 1e27 >> secondsElapsed / 3600;
uint256 minutesComponent = Maths.rpow(MINUTE_HALF_LIFE, secondsElapsed % 3600 / 60);
uint256 initialPrice = Maths.wdiv(1_000_000_000 * 1e18, lastKickedReserves_);
uint256 initialPrice = lastKickedReserves_ == 0 ? 0 : Maths.wdiv(1_000_000_000 * 1e18, lastKickedReserves_);

// TODO: clean up rounding by implementing appropriate Math library method
price_ = initialPrice * Maths.rmul(hoursComponent, minutesComponent) / 1e27;
Expand Down
3 changes: 3 additions & 0 deletions tests/forge/unit/Auctions.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ contract AuctionsTest is DSTestPlus {
assertEq(_reserveAuctionPrice(block.timestamp - 16 hours, lastKickedReserves), 0.000005086263020833 * 1e18);
assertEq(_reserveAuctionPrice(block.timestamp - 32 hours, lastKickedReserves), 0.000000000077610214 * 1e18);
assertEq(_reserveAuctionPrice(block.timestamp - 64 hours, lastKickedReserves), 0);

// ensure it handles zeros properly
assertEq(_reserveAuctionPrice(0, 0), 0);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions tests/forge/unit/ERC20Pool/ERC20PoolReserveAuction.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ contract ERC20PoolReserveAuctionTest is ERC20HelperContract {
});
}

function testStartAndTakeUsdcReserveAuction() external {
function testStartAndTakeUsdcReserveAuction() external tearDown {
// skip time to accumulate interest
skip(26 weeks);

Expand Down Expand Up @@ -89,7 +89,7 @@ contract ERC20PoolReserveAuctionTest is ERC20HelperContract {
_kickReserveAuction({
from: _bidder,
remainingReserves: 1.471235793861737556 * 1e18,
price: 1000000000 * 1e18,
price: 679_700_700.711729067726118823 * 1e18,
epoch: 1
});

Expand All @@ -99,7 +99,7 @@ contract ERC20PoolReserveAuctionTest is ERC20HelperContract {
reserves: 0.000001006397976200 * 1e18,
claimableReserves : 0,
claimableReservesRemaining: 1.471235793861737556 * 1e18,
auctionPrice: 0.000000000867361737 * 1e18,
auctionPrice: 0.000000000589546380 * 1e18,
timeRemaining: 43200
});

Expand All @@ -113,7 +113,7 @@ contract ERC20PoolReserveAuctionTest is ERC20HelperContract {
_pool.takeReserves(10 * 1e18);
assertEq(USDC.balanceOf(address(_pool)), 1_006.397978 * 1e6);
assertEq(USDC.balanceOf(address(_bidder)), 1.471235 * 1e6);
assertEq(AJNA.balanceOf(address(_bidder)), 9.999999998723906366 * 1e18);
assertEq(AJNA.balanceOf(address(_bidder)), 9.999999999132638263 * 1e18);
}

function testZeroBid() external {
Expand Down

0 comments on commit bc9522b

Please sign in to comment.