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

add uniswapx v2 initial structs #213

Merged
merged 25 commits into from Jan 23, 2024
Merged

Conversation

marktoda
Copy link
Collaborator

@marktoda marktoda commented Dec 14, 2023

Add Initial UniswapXV2 reactor implementation

marktoda and others added 13 commits August 21, 2023 15:58
This commit fixes a couple typos.

Fixes: N-03
Gas limit for native transfer can cause some reasonable smart contract
wallets that perform operations in their receive function to be unable
to receive native output from uniswapX. compatibilty preferred here

Resolves M-02
Previously there was ambiguous undefined behavior for if startTime and
endTime were the same - This commit removes that ambiguity by enforcing
startTime !== endTime
document magic numbers in orderquoter

Fixes: L-08
* Remove unused return names

* Update OrderQuoter.sol
@marktoda marktoda changed the base branch from main to development December 14, 2023 20:47
@marktoda marktoda changed the base branch from development to main December 18, 2023 19:19
@marktoda marktoda changed the base branch from main to development December 18, 2023 19:19
@marktoda marktoda changed the base branch from development to main December 18, 2023 19:22
Copy link
Collaborator

@hensha256 hensha256 left a comment

Choose a reason for hiding this comment

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

some thoughts

src/lib/V2DutchOrderLib.sol Outdated Show resolved Hide resolved
src/lib/V2DutchOrderLib.sol Outdated Show resolved Hide resolved
src/lib/V2DutchOrderLib.sol Show resolved Hide resolved
src/reactors/V2DutchOrderReactor.sol Outdated Show resolved Hide resolved
// The tokens that the swapper will provide when settling the order
uint256 inputOverride;
// The tokens that must be received to satisfy the order
uint256[] outputOverrides;
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we need inputOverride and outputOverrides? if a filler is overriding, theyre going to do so at exactly the bps that are required to override right (because why would they override by more).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

inputOverride is for exactOutput trades, outputOverrides are for exactInput

if a filler is overriding, theyre going to do so at exactly the bps that are required to override right (because why would they override by more).

note its not up to the filler to override in this case, these are strictly enforced on top of the inner order based on the secondary auction. True that fillers wouldn't do more than required, but that's ok in this case

src/reactors/V2DutchOrderReactor.sol Outdated Show resolved Hide resolved
src/reactors/V2DutchOrderReactor.sol Outdated Show resolved Hide resolved
src/reactors/V2DutchOrderReactor.sol Outdated Show resolved Hide resolved
sig: signedOrder.sig,
hash: order.hash()
});
resolvedOrder.handleOverride(order.exclusiveFiller, order.decayStartTime, order.exclusivityOverrideBps);
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe im missing something but i feel like the override logic is weird…

  • first in validateOrder it validates the overrides exist and arent bigger/smaller than the original amount but not their %s
  • then it goes through again and overrides the actual amounts of the order with the override values that were provided, without checking that they were big enough
  • then it calls handleOverride which increases all of the values of the order with one increased by x%

Copy link
Collaborator

Choose a reason for hiding this comment

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

i feel like you definitely dont need both updateOverrides and handleOverrides

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ohh ok theres 2 types of overrides - the first 2 are the newly introduced cosigner overrides which define the result of the secondary auction. Agreed we can remove the validation loop

the third bullet is the filler override which we already had in xv1, it basically is if some other public market filler that didn't compete in the auction has a significantly better price they can fill it at some fixed rate above the resolved price. I think we might want to remove that for v2 but keeping in anyways

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

overloaded the terminology :D

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removing the public override for now

This commit flattens the V2 struct to maintain the reactor interface
requirement that OrderInfo should be first struct so integrations like
quoters can reliably fetch the reactor address and other order info
fields

Also saves a decent amt of gas from less encoding/decoding
@marktoda marktoda marked this pull request as ready for review December 21, 2023 19:57

(bytes32 r, bytes32 s) = abi.decode(order.cosignature, (bytes32, bytes32));
uint8 v = uint8(order.cosignature[64]);
// cosigner signs over (orderHash || cosignerData)
Copy link
Member

Choose a reason for hiding this comment

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

this means orderHash 'concat' cosignerData right? at first I thought it's logical or

Although I guess EIP-712 spec used the same way too

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oh yea its concat

Copy link
Collaborator

Choose a reason for hiding this comment

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

i was taught at university that this was the symbol for concat... but now that im googling i think that ive just been living a lie 😆
image

hensha256
hensha256 previously approved these changes Jan 17, 2024
Copy link
Collaborator

@hensha256 hensha256 left a comment

Choose a reason for hiding this comment

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

left a couple of nits, but it looks great!

@marktoda marktoda merged commit 3c52662 into main Jan 23, 2024
2 checks passed
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.

None yet

3 participants