-
Notifications
You must be signed in to change notification settings - Fork 3
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
Auctions #6
Auctions #6
Conversation
Other than ad6f00b this is just adding the stuff from easy auction? Would probably make sense to merge this + most of the base easyAuction stuff then make modifications in follow up PRs |
Any idea what the common convention is when absorbing another repo like this? Would it make sense for us to start with a fork? |
11bd375 are tests specifically for the custom Auction wrapper with some things copied & adapted from their testing code. |
Starting with a fork could make sense. I think we'd want all of their tests against the |
The decision is up to you. |
Un-drafting this. Updated description. |
Should we pull the gnosis auction stuff out of this repo? Have you had a chance to think about if we can make the entire e2e flow work without modifying gnosis auction? Would you be able to add a loom video or similar walking through this? I'm not sure what I should be looking at exactly as there's ~2000 additions and 25 new files Edit: I should only be looking at |
I am not confident on the entire flow yet, but so far there isn't a reason to deploy gnosis auction. Let me test importing the auction from their github.
sure
Good question. Appreciate you looking at this. Most of the files are GnosisAuction, yes. The files that are reviewable are:
|
Deploy how? Can you do a mainnet fork for testing? Importing through github sounds good. I created #14 where we can discuss wrapping gnosis auction in more depth
Sounds good. Will take a look this afternoon. |
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.
👏 so nice!
contracts/PorterAuction.sol
Outdated
address bondTokenAddress | ||
); | ||
event CollateralDeposited( | ||
address indexed collateralDepositor, |
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.
can this be owner() ? or msg.sender ?
contracts/PorterAuction.sol
Outdated
/// @param creator the caller of the auction | ||
/// @param auctionId the id of the auction | ||
event AuctionCreated( | ||
address indexed creator, |
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.
can this be owner() ? or msg.sender ?
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 don't understand, could you clarify?
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.
to remove the creator parameter, could we just use msg.sender?
contracts/PorterAuction.sol
Outdated
AuctionType.AuctionData memory auctionData, | ||
BondData memory bondData, | ||
CollateralData memory collateralData | ||
) public returns (uint256 auctionCounter) { |
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.
does this need an onlyOwner modifier or can anyone create one? same with the other functiosn ^
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 question. I think configureCollateral
and createAuction
are fine since they are supposed to be called by the user, but initiateAuction
should probably be private.
contracts/PorterAuction.sol
Outdated
] += collateralData.collateralValue; | ||
} |
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.
should we emit() an event here when its all done?
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 end of initiateAuction
emits, unless you think there's value in emitting the collateral in contract updating. The flow does seem weird here. I'll think about this more.
contracts/PorterAuction.sol
Outdated
auctionId = gnosisAuction.initiateAuction( | ||
IERC20(auctioningToken), | ||
auctionData._biddingToken, | ||
auctionData.orderCancellationEndDate, | ||
auctionData.auctionEndDate, | ||
auctionData._auctionedSellAmount, | ||
auctionData._minBuyAmount, | ||
auctionData.minimumBiddingAmountPerOrder, | ||
auctionData.minFundingThreshold, | ||
auctionData.isAtomicClosureAllowed, | ||
auctionData.accessManagerContract, | ||
auctionData.accessManagerContractData |
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.
does any of this data need to be validated before sending to gnosis? or do they do that?
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.
They check all of the params, but I will wrap the approve in a require.
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.
🙏🙏 amazing 🙏🙏
contracts/PorterAuction.sol
Outdated
/// @author Porter | ||
/// @notice This allows for the creation of an auction | ||
/// @dev This deviates from EasyAuction by not having an auctioning token until the auction is settling | ||
contract PorterAuction { |
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.
https://docs.porter.finance/product/spec/pages/create_auction_page#stages All the currently anticipated v1 configs are here - it makes sense to start with a simpler config tho
contracts/PorterAuction.sol
Outdated
struct BondData { | ||
address bondContract; | ||
uint256 maturityDate; | ||
uint256 maturityValue; |
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'm not sure what maturityValue
is
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.
me neither
contracts/PorterAuction.sol
Outdated
|
||
struct CollateralData { | ||
address collateralAddress; | ||
uint256 collateralValue; |
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.
Instead of value
this should be # tokens I think. As far as I'm aware we don't have a way to tell the value without oracles in our smart contracts
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 point. I am not thinking in
t o k e n s
..yet
contracts/PorterAuction.sol
Outdated
console.log("Auction/createAuction"); | ||
// only create auction if there is no fee (will need to redeploy contract in this case) | ||
require( | ||
gnosisAuction.feeNumerator() == 0, |
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.
Does metamask give a warning if a user tries to make this transaction that it will fail? Or will the user submit the transaction, then it fails?
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/PorterAuction.sol
Outdated
bondData.maturityDate >= auctionData.auctionEndDate, | ||
"createAuction/invalid-maturity-date" | ||
); | ||
// Remove collateral from contract mapping before creating the auction |
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.
Interesting. I wonder if this pattern is best over keeping the collateral in the same place and locking it with an additional parameter etc
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.
Yeah, I'm not sure yet.
contracts/PorterAuction.sol
Outdated
"configureCollateral/sender-inadequate-collateral" | ||
); | ||
require( | ||
collateralToken.transferFrom( |
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.
Should this be using safeTransfer
? https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/utils/SafeERC20.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.
I think so. I tried and it said the function didn't exist, since i'm not using SafeERC20, but I think the only downside is a little more gas usage.
contracts/PorterAuction.sol
Outdated
/// @dev The collateral is mapped from the msg.sender & address to the collateral value. | ||
/// @dev Required msg.sender to have adequate balance, and the transfer to be successful (returns true). | ||
/// @param collateralData is a struct containing the address of the collateral and the value of the collateral | ||
function configureCollateral(CollateralData memory collateralData) public { |
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.
We will prompt them to approve the ERC20 token before they call this method on the frontend?
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.
AFAIK, we can't approve for them, so something will have to prompt them beforehand.
@Namaskar-1F64F do you need anything else from me or luckyrobot on this? I think it's good to get feedback from peteris or stu now. |
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.
Great progress.
Some additional notes:
- Worth adding unit testing by mocking Gnosis auction
- Check https://github.com/Rari-Capital/solcurity for variables and functions to make sure you are using appropriate modifiers
- Always think through access control (who is allowed to access each function) and state transitions (when is each function accessible), worth writing these down as a spec
Separate gnosis auction contracts into their own folder
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.
🙏
This PR adds a
PorterAuction
contract. This contract:Inputs an
EasyAuction
address in theconstructor
.Inputs an
CollateralData
intoconfigureCollateral
to deposit collateral and record that it made it onto the contract.Inputs
AuctionType.AuctionData
,BondData
, andCollateralData
intocreateAuction
which verifies requirements, updates collateral values, and callsinitiateAuction
.Inputs
AuctionType.AuctionData
intoinitiateAuction
which initiates a Gnosis Auction.