-
Notifications
You must be signed in to change notification settings - Fork 0
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
USDC/KWENTA Auctions #3
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
really good work here!
auction logic is really impressive tbh. very elegant 😎
approving this now but would be good to get a deployment / factory test suite to make sure that entire process goes as expected
|
||
import {IERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | ||
import "@openzeppelin/contracts/access/Ownable.sol"; | ||
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contracts-upgradeable gitmodule is missing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The contract exists in the repo that is included.
I change the import to:
"import "@openzeppelin/contracts/proxy/utils/Initializable.sol";"
and it worked fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Flocqst resolved?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good clean contract written from scratch, nice work. Architecture is nice too.
Still some logic issues to iron out if I'm understanding correctly, and left you some questions to think about / respond to.
Will do a second pass after you look over this again.
|
||
// Extend the auction if it is ending in less than an hour | ||
if (endAt - block.timestamp < 1 hours) { | ||
endAt = block.timestamp + 1 hours; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we were making auction time countdown length customizable? Or are you implicitly assuming we will change via upgradeability (new version) in the future (which is fine).
Even so, this should probably be a constant for DRY purposes. Not good to hardcode the same value in multiple places.
constant COUNTDOWN_EXTENSION_PERIOD = 1 hours
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, if we want to change auction time in the future (currently one day) then yes it will be done through a new version of the auctionImplementation
, as each new auction is its own contract deployed by the AuctionFactory (which means we cannot change the auction time for an auction that already started, but this should not be a problem according to the spec).
function withdraw() external { | ||
uint256 bal = bids[msg.sender]; | ||
bids[msg.sender] = 0; | ||
|
||
kwenta.transfer(msg.sender, bal); | ||
|
||
emit Withdraw(msg.sender, bal); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if you are a winning bid, auction ends, and then you withdraw before the auction is settled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't withdraw winning bid, even when the auction ends.
src/Auction.sol
Outdated
uint256 public endAt; | ||
|
||
/// @notice Indicates if the auction has started. | ||
bool public started; | ||
|
||
/// @notice Indicates if the auction has ended. | ||
bool public ended; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typically it's better to only use 1 state variable to mark the state of a contract. What I mean is that technically you could end up in a state where endAt
is in the past and ended
is still false. This is an invariant you don't want.
Like it's better to have a endAt
state variable and then a view function ended()
that returns the result of the expression block.timestamp > endAt
for example. Singular source of truth.
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless you are using ended
as a way to mark that the auction is already settled. Because I don't see it being used anywhere else. If that's the case it should just be settled
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renamed settled
for clarity
Latest changes look good but lmk when you add the new requested things we talked about |
Create an auction contract that sells off lots/tranches of USDC fees for KWENTA tokens
Description
** Auction lasts 1 day
** Bidding extends the auction by 1 hour if it is ending in less than an hour
** There is a configurable
bidBuffer
in order to prevent the auction running forever** Every bidder can withdraw except for the highest bid
** Owner can pause bidding and withdraw funds in case there is an issue
Auctions will be started every wednesday at UTC (noon) based off USDC in the KSX contract, so there will need to be some off-chain mechanism that create an auction each week using the auction factory.
Motivation and Context
Will be used by the KSX vault to compound usdc rewards into KWENTA tokens