Skip to content
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

Merged
merged 30 commits into from
Feb 9, 2022
Merged

Auctions #6

merged 30 commits into from
Feb 9, 2022

Conversation

Namaskar-1F64F
Copy link
Contributor

@Namaskar-1F64F Namaskar-1F64F commented Jan 27, 2022

This PR adds a PorterAuction contract. This contract:
Inputs an EasyAuction address in the constructor.
Inputs an CollateralData into configureCollateral to deposit collateral and record that it made it onto the contract.
Inputs AuctionType.AuctionData, BondData, and CollateralData into createAuction which verifies requirements, updates collateral values, and calls initiateAuction.
Inputs AuctionType.AuctionData into initiateAuction which initiates a Gnosis Auction.

@RusseII
Copy link
Contributor

RusseII commented Jan 27, 2022

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

@RusseII
Copy link
Contributor

RusseII commented Jan 27, 2022

Any idea what the common convention is when absorbing another repo like this? Would it make sense for us to start with a fork?

@Namaskar-1F64F
Copy link
Contributor Author

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

11bd375 are tests specifically for the custom Auction wrapper with some things copied & adapted from their testing code.

@Namaskar-1F64F
Copy link
Contributor Author

Any idea what the common convention is when absorbing another repo like this? Would it make sense for us to start with a fork?

Starting with a fork could make sense. I think we'd want all of their tests against the EasyAuction as any modifications to that code should be reflected in the tests.

@RusseII
Copy link
Contributor

RusseII commented Jan 27, 2022

Starting with a fork could make sense. I think we'd want all of their tests against the EasyAuction as any modifications to that code should be reflected in the tests.

The decision is up to you.

contracts/CollateralLockerFactory.sol Outdated Show resolved Hide resolved
contracts/EasyAuction.sol Outdated Show resolved Hide resolved
contracts/EasyAuction.sol Outdated Show resolved Hide resolved
@Namaskar-1F64F Namaskar-1F64F marked this pull request as ready for review February 3, 2022 18:01
@Namaskar-1F64F
Copy link
Contributor Author

Un-drafting this. Updated description.

@RusseII
Copy link
Contributor

RusseII commented Feb 3, 2022

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 PorterAuction?

@Namaskar-1F64F
Copy link
Contributor Author

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?

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.

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

sure

Edit: I should only be looking at PorterAuction?

Good question. Appreciate you looking at this. Most of the files are GnosisAuction, yes. The files that are reviewable are:

PorterAuction.sol
AuctionE2E.spec.ts
utilities.ts (that are used in testing)

@RusseII
Copy link
Contributor

RusseII commented Feb 3, 2022

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.

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

Good question. Appreciate you looking at this. Most of the files are GnosisAuction, yes. The files that are reviewable are:

Sounds good. Will take a look this afternoon.

Copy link

@luckyrobot luckyrobot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 so nice!

address bondTokenAddress
);
event CollateralDeposited(
address indexed collateralDepositor,

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 ?

/// @param creator the caller of the auction
/// @param auctionId the id of the auction
event AuctionCreated(
address indexed creator,

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 ?

Copy link
Contributor Author

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?

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 Show resolved Hide resolved
contracts/PorterAuction.sol Outdated Show resolved Hide resolved
AuctionType.AuctionData memory auctionData,
BondData memory bondData,
CollateralData memory collateralData
) public returns (uint256 auctionCounter) {

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 ^

Copy link
Contributor Author

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.

Comment on lines 203 to 204
] += collateralData.collateralValue;
}

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?

Copy link
Contributor Author

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.

Comment on lines 228 to 239
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

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?

Copy link
Contributor Author

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.

Copy link
Contributor

@RusseII RusseII left a 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 Show resolved Hide resolved
/// @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 {
Copy link
Contributor

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

struct BondData {
address bondContract;
uint256 maturityDate;
uint256 maturityValue;
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

me neither


struct CollateralData {
address collateralAddress;
uint256 collateralValue;
Copy link
Contributor

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

Copy link
Contributor Author

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

console.log("Auction/createAuction");
// only create auction if there is no fee (will need to redeploy contract in this case)
require(
gnosisAuction.feeNumerator() == 0,
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes if I had to guess metamask does some rudimentary execution of the transaction, or at least parses some of the require statements. Here I am trying to renounce ownership of opensea. (It's really expensive)
image

contracts/PorterAuction.sol Outdated Show resolved Hide resolved
bondData.maturityDate >= auctionData.auctionEndDate,
"createAuction/invalid-maturity-date"
);
// Remove collateral from contract mapping before creating the auction
Copy link
Contributor

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

Copy link
Contributor Author

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.

"configureCollateral/sender-inadequate-collateral"
);
require(
collateralToken.transferFrom(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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.

/// @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 {
Copy link
Contributor

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?

Copy link
Contributor Author

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.

contracts/PorterAuction.sol Outdated Show resolved Hide resolved
@RusseII
Copy link
Contributor

RusseII commented Feb 4, 2022

@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.

Copy link

@Pet3ris Pet3ris left a 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

contracts/Broker.sol Outdated Show resolved Hide resolved
contracts/Broker.sol Outdated Show resolved Hide resolved
contracts/Broker.sol Outdated Show resolved Hide resolved
contracts/Broker.sol Outdated Show resolved Hide resolved
contracts/Broker.sol Outdated Show resolved Hide resolved
contracts/Broker.sol Outdated Show resolved Hide resolved
contracts/Broker.sol Outdated Show resolved Hide resolved
contracts/Broker.sol Outdated Show resolved Hide resolved
contracts/Broker.sol Outdated Show resolved Hide resolved
contracts/Broker.sol Outdated Show resolved Hide resolved
Copy link
Contributor

@RusseII RusseII left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants