-
Notifications
You must be signed in to change notification settings - Fork 212
Feat/multi hop sell otc [LIT-870] #667
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
Conversation
still writing the test but here is the protocol related code |
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.
Short and sweet. I like it.
} | ||
|
||
uint256 sellAmount = state.outputTokenAmount; | ||
// Try filling the Otc order. Swallows reverts. |
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.
Why swallow the revert here? Surely we'd want to bubble
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.
ill probably revert to jacob on this one, there was a reason that otc order reverts did not bubble up but i dont remember what it was.
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.
Definitely want to bubble. In batch fill its possible to append more and recover, MultiHop less so
contracts/zero-ex/contracts/src/features/multiplex/MultiplexOtc.sol
Outdated
Show resolved
Hide resolved
); | ||
// Validate tokens. | ||
require( | ||
tokens.length >= 2 && |
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.
Perhaps this is a dumb question: why allow tokens
to have length > 2
?
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 tokens array will contain all of the tokens in the swap, i.e. it needs to be more than 2 tokens to perform a multihop sell. we need token A, intermediate token, token B
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.
Your comment made me look into this in more detail. As far as I can tell, that's not enforced anywhere. tokens
comes from the subcall data and isn't even signed. As best I can tell, it's totally unconstrained and this require
is basically vacuous
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.
Bump
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.
Duncan is right about this being basically vacuous, unless there is something I'm missing, you should be checking params.tokens
against the makerToken
and takerToken
of the OtcOrder
.
Something like
require(
order.takerToken == params.tokens[state.hopIndex] &&
order.makerToken == params.tokens[state.hopIndex + 1],
"MultiplexOtcOrder::_multiHopSellOtcOrder/INVALID_TOKENS"
);
and then also remove tokens
from the subcall data here
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 we get rid of tokens
altogether? Seems like it's not being used now
Edit: reading is hard; I should learn how to do that sometime
order, | ||
signature, | ||
sellAmount.safeDowncastToUint128(), | ||
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.
This line is going to conflict with #665
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.
*#665
contracts/zero-ex/contracts/src/features/multiplex/MultiplexOtc.sol
Outdated
Show resolved
Hide resolved
} | ||
|
||
uint256 sellAmount = state.outputTokenAmount; | ||
// Try filling the Otc order. Swallows reverts. |
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.
Definitely want to bubble. In batch fill its possible to append more and recover, MultiHop less so
@@ -488,7 +489,7 @@ contract MultiplexFeature is | |||
// If `i == 0`, the target is the address which should hold the input | |||
// tokens prior to executing `calls[0]`. Otherwise, it is the address | |||
// that should receive `tokens[i]` upon executing `calls[i-1]`. | |||
function _computeHopTarget(MultiHopSellParams memory params, uint256 i) private view returns (address target) { | |||
function _computeHopTarget(MultiHopSellParams memory params, uint256 i) private returns (address target) { |
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.
Why no longer view?
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.
was emitting an event for my test and had forgot to change it back, should be fixed now
); | ||
// Validate tokens. | ||
require( | ||
tokens.length >= 2 && |
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.
Bump
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.
LGTM. Please fix the linter complaints
…or MultiplexSubcall.OTC [#667]
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
…ti-Fee Support [RFQ-795] [LIT-870] (#665) * MetaTransactionData changes * MetaTransactionV2 creation and forge tests * MetaTransactionData changes * MetaTransactionV2 creation and forge tests * add multiplexBatchSellTokenForToken, multiplexMultiHopSellTokenForToken, multiplex TokenForEth functions to metatransactions, add msgSender field to multiplex params * Ran prettier to clean up * More linting * Fixing issues with EIP 712 signature, adding test case against MetaMask, and fixing lint issues * Addressing suggestions from PR reviewers * Complex rebase of test code based on changes in #655 * Fixing multiplex test failure * add some tests for multiplex metatransactions * prettier * minor test fix * cleaning up and adding batchExecuteMetaTransaction tests * Removing ZERO_ADDRESS * add multiHopBatchSellOtc to MultiplexFeature, fix _computeHopTarget for MultiplexSubcall.OTC [#667] * fix _computeHopTarget for otc subcalls * Fixing multiHopSellOtcOrder when params.useSelfBalance is true * Making executeMetaTransactionV2 nonpayable and addressing a few other minor issues * Forge update * Add MetaTransactionsFeatureV2 to exported contracts --------- Co-authored-by: abls <[email protected]> Co-authored-by: Duncan Townsend <[email protected]>
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Description
Testing instructions
Types of changes
Checklist: