Skip to content

Commit

Permalink
👷 remove buffer from vault and integrate auction return
Browse files Browse the repository at this point in the history
  • Loading branch information
cmontecoding committed Oct 25, 2024
1 parent c6cca60 commit 16a0769
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
11 changes: 3 additions & 8 deletions src/KSXVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -139,26 +139,21 @@ contract KSXVault is ERC4626, Ownable, Initializable {

/// @notice Starts the auction with the USDC balance of the vault
/// @param _startingBid The starting bid for the auction
/// @param _bidBuffer The bid buffer for the auction
function createAuction(uint256 _startingBid, uint256 _bidBuffer) public {
function createAuction(uint256 _startingBid) public {
if (!isAuctionReady()) {
revert AuctionNotReady();
}

uint256 epochsPassed = (block.timestamp - initialStart) / epochDuration;
lastAuctionStartTime = initialStart + epochsPassed * epochDuration;

auctionFactory.createAuction({
Auction auction = auctionFactory.createAuction({
_owner: address(this),
_usdc: address(USDC),
_kwenta: address(KWENTA),
_startingBid: _startingBid,
_bidBuffer: _bidBuffer
_startingBid: _startingBid
});

address[] memory auctions = auctionFactory.getAllAuctions();
Auction auction = Auction(auctions[auctions.length - 1]);

uint256 auctionAmount = USDC.balanceOf(address(this));
USDC.transferFrom(address(this), address(auction), auctionAmount);
auction.start(auctionAmount);
Expand Down
10 changes: 6 additions & 4 deletions test/KSXVault.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ contract KSXVaultTest is Bootstrap {
mockUSDC = new MockERC20("USDC", "USDC");
stakingRewards = new MockStakingRewards(address(depositToken));
auction = new Auction(address(this), address(0), address(0), 100, 100);
auctionFactory = new AuctionFactory(address(auction));
auctionFactory = new AuctionFactory(PDAOADDR, address(auction));
vm.prank(address(PDAOADDR));
auctionFactory.updateBidBuffer(BID_BUFFER);
initializeLocal(
address(depositToken),
address(mockUSDC),
Expand Down Expand Up @@ -140,7 +142,7 @@ contract KSXVaultAuctionTest is KSXVaultTest {
// vm.warp(block.timestamp + 1);
// assertEq(ksxVault.isAuctionReady(), true);

// ksxVault.createAuction(100, 100);
// ksxVault.createAuction(STARTING_BID);

// vm.warp(block.timestamp + 1 weeks - 1);
// assertEq(ksxVault.isAuctionReady(), false);
Expand Down Expand Up @@ -180,13 +182,13 @@ contract KSXVaultAuctionTest is KSXVaultTest {

function test_createAuction() public {
vm.warp(DEFAULT_START_TIME + DEFAULT_EPOCH_DURATION);
ksxVault.createAuction(100, 100);
ksxVault.createAuction(STARTING_BID);
assertEq(ksxVault.lastAuctionStartTime(), block.timestamp);
}

function test_createAuction_AuctionNotReady() public {
vm.expectRevert(KSXVault.AuctionNotReady.selector);
ksxVault.createAuction(100, 100);
ksxVault.createAuction(STARTING_BID);
}

}

0 comments on commit 16a0769

Please sign in to comment.