Skip to content

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

Closed
wants to merge 11 commits into from
Closed

Conversation

dextracker
Copy link
Contributor

Description

Testing instructions

Types of changes

Checklist:

  • Add tests to cover changes as needed.
  • Update documentation as needed.
  • Add new entries to the relevant CHANGELOG.jsons.

@dextracker
Copy link
Contributor Author

still writing the test but here is the protocol related code

@dextracker dextracker changed the title Feat/multi hop sell otc Feat/multi hop sell otc [LIT-870] Feb 22, 2023
Copy link
Collaborator

@duncancmt duncancmt left a 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.
Copy link
Collaborator

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

Copy link
Contributor Author

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.

Copy link
Member

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

);
// Validate tokens.
require(
tokens.length >= 2 &&
Copy link
Collaborator

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?

Copy link
Contributor Author

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

Copy link
Collaborator

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Bump

Copy link
Contributor

@abls abls Feb 23, 2023

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

Copy link
Collaborator

@duncancmt duncancmt Feb 23, 2023

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,
Copy link
Contributor

@patrick-dowell patrick-dowell Feb 22, 2023

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

Copy link
Contributor

Choose a reason for hiding this comment

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

*#665

}

uint256 sellAmount = state.outputTokenAmount;
// Try filling the Otc order. Swallows reverts.
Copy link
Member

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) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why no longer view?

Copy link
Contributor Author

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 &&
Copy link
Collaborator

Choose a reason for hiding this comment

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

Bump

@dextracker dextracker marked this pull request as ready for review February 23, 2023 21:15
Copy link
Collaborator

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

@github-actions
Copy link
Contributor

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.

@github-actions github-actions bot added the stale label Mar 27, 2023
@github-actions github-actions bot closed this Apr 11, 2023
@duncancmt duncancmt reopened this Apr 11, 2023
@github-actions github-actions bot removed the stale label Apr 12, 2023
duncancmt added a commit that referenced this pull request Apr 19, 2023
…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]>
@github-actions
Copy link
Contributor

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.

@github-actions github-actions bot added the stale label May 19, 2023
@github-actions github-actions bot closed this Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants