-
Notifications
You must be signed in to change notification settings - Fork 34
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
build: dutch auction and factory #36
Merged
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
698b893
build: auction swapper
Schlagonia 9e7fabd
build: auction factory
Schlagonia 2ce7373
fix: transfer to specific address
Schlagonia 6ca8443
chore: comments
Schlagonia 826aa33
build: factory fixes
Schlagonia 094c5fa
chore: auction tweaks
Schlagonia 545f362
test: auction
Schlagonia dd06466
chore: add reentrancy gaurd
Schlagonia 4987809
fix: uni swapper
Schlagonia bc6d105
build: callback
Schlagonia 5fc61ff
feat: add callback
Schlagonia 5641bae
test: swapper
Schlagonia 19fc831
fix: small fixes
Schlagonia 33b97d9
fix: remove extra check
Schlagonia 05799ab
feat: fp reviewssssszz
Schlagonia 47804ad
chore: pull
Schlagonia 09c808a
feat: pack it up
Schlagonia a466d8c
build: add hook flags
Schlagonia 2510766
test: hook flags
Schlagonia 1850b2c
chore: comments
Schlagonia f048481
feat: track enabled auctions
Schlagonia 42b6f9a
feat: check decimals and optional index
Schlagonia 1ef3ce5
chore: deploy
Schlagonia 29c6ca2
fix: interface
Schlagonia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,7 +112,7 @@ | |
/// @notice Array of all the enabled auction for this contract. | ||
bytes32[] public enabledAuctions; | ||
|
||
constructor() Governance(msg.sender) {} | ||
|
||
/** | ||
* @notice Initializes the Auction contract with initial parameters. | ||
|
@@ -137,10 +137,14 @@ | |
require(_auctionLength < _auctionCooldown, "cooldown"); | ||
require(_startingPrice != 0, "starting price"); | ||
|
||
// Cannot have more than 18 decimals. | ||
uint256 decimals = ERC20(_want).decimals(); | ||
require(decimals <= WAD, "unsupported decimals"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good catch |
||
|
||
// Set variables | ||
wantInfo = TokenInfo({ | ||
tokenAddress: _want, | ||
scaler: uint96(WAD / 10 ** ERC20(_want).decimals()) | ||
scaler: uint96(WAD / 10 ** decimals) | ||
}); | ||
|
||
// If we are using a hook. | ||
|
@@ -425,6 +429,9 @@ | |
_receiver != address(0) && _receiver != address(this), | ||
"receiver" | ||
); | ||
// Cannot have more than 18 decimals. | ||
uint256 decimals = ERC20(_from).decimals(); | ||
require(decimals <= WAD, "unsupported decimals"); | ||
|
||
// Calculate the id. | ||
_auctionId = getAuctionId(_from); | ||
Schlagonia marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
@@ -437,7 +444,7 @@ | |
// Store all needed info. | ||
auctions[_auctionId].fromInfo = TokenInfo({ | ||
tokenAddress: _from, | ||
scaler: uint96(WAD / 10 ** ERC20(_from).decimals()) | ||
scaler: uint96(WAD / 10 ** decimals) | ||
}); | ||
auctions[_auctionId].receiver = _receiver; | ||
|
||
|
@@ -452,7 +459,20 @@ | |
* @dev Only callable by governance. | ||
* @param _from The address of the token being sold. | ||
*/ | ||
function disable(address _from) external virtual onlyGovernance { | ||
function disable(address _from) external virtual { | ||
disable(_from, 0); | ||
} | ||
|
||
/** | ||
* @notice Disables an existing auction. | ||
* @dev Only callable by governance. | ||
* @param _from The address of the token being sold. | ||
* @param _index The index the auctionId is at in the array. | ||
*/ | ||
function disable( | ||
address _from, | ||
uint256 _index | ||
) public virtual onlyGovernance { | ||
bytes32 _auctionId = getAuctionId(_from); | ||
|
||
// Make sure the auction was enabled. | ||
|
@@ -466,19 +486,28 @@ | |
|
||
// Remove the auction ID from the array. | ||
bytes32[] memory _enabledAuctions = enabledAuctions; | ||
for (uint256 i = 0; i < _enabledAuctions.length; ++i) { | ||
if (_enabledAuctions[i] == _auctionId) { | ||
if (i < _enabledAuctions.length - 1) { | ||
_enabledAuctions[i] = _enabledAuctions[ | ||
_enabledAuctions.length - 1 | ||
]; | ||
enabledAuctions = _enabledAuctions; | ||
if (_enabledAuctions[_index] != _auctionId) { | ||
// If the _index given is not the id find it. | ||
for (uint256 i = 0; i < _enabledAuctions.length; ++i) { | ||
if (_enabledAuctions[i] == _auctionId) { | ||
_index = i; | ||
break; | ||
} | ||
enabledAuctions.pop(); | ||
break; | ||
} | ||
} | ||
|
||
// Move the id to the last spot if not there. | ||
if (_index < _enabledAuctions.length - 1) { | ||
_enabledAuctions[_index] = _enabledAuctions[ | ||
_enabledAuctions.length - 1 | ||
]; | ||
// Update the array. | ||
enabledAuctions = _enabledAuctions; | ||
} | ||
|
||
// Pop the id off the array. | ||
enabledAuctions.pop(); | ||
|
||
emit AuctionDisabled(_auctionId, _from, want(), address(this)); | ||
} | ||
|
||
|
@@ -602,7 +631,7 @@ | |
} | ||
|
||
/// @dev Implements the take of the auction. | ||
function _take( | ||
bytes32 _auctionId, | ||
uint256 _maxAmount, | ||
fp-crypto marked this conversation as resolved.
Show resolved
Hide resolved
|
||
address _receiver, | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Nice