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

Lido offchain plugin p3, Uniswap plugin #439

Merged
merged 12 commits into from
Sep 14, 2023
Merged

Conversation

luketchang
Copy link
Contributor

@luketchang luketchang commented Sep 8, 2023

Motivation

Add uniswap plugin.

Solution

  • Change op request builder interface to take optional config not optional teller address (we need handler address for uniswap output address and other stuff)
  • Add uniswap plugin

Proof

N/A (will test once UI is ready)
PR so interface still builds is here: https://github.com/nocturne-xyz/interface/pull/128

PR Checklist

  • added tests
  • updated documentation
  • added changeset if necessary
  • tested in dev/testnet
  • tested site with snap (we haven't automated this yet)
  • re-built & tested circuits if any of them changed
  • updated contracts storage layout (if contracts were updated)

@changeset-bot
Copy link

changeset-bot bot commented Sep 8, 2023

🦋 Changeset detected

Latest commit: 0c75bac

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 15 packages
Name Type
@nocturne-xyz/core Major
@nocturne-xyz/op-request-plugins Minor
@nocturne-xyz/deploy Patch
@nocturne-xyz/e2e-tests Patch
@nocturne-xyz/frontend-sdk Patch
@nocturne-xyz/idb-kv-store Patch
@nocturne-xyz/local-prover Patch
@nocturne-xyz/persistent-log Patch
@nocturne-xyz/bundler Patch
@nocturne-xyz/deposit-screener Patch
@nocturne-xyz/insertion-writer Patch
@nocturne-xyz/subtree-updater Patch
@nocturne-xyz/test-actor Patch
@nocturne-xyz/snap Patch
@nocturne-xyz/offchain-utils Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor Author

luketchang commented Sep 8, 2023

Comment on lines +30 to +32
"resolutions": {
"@uniswap/sdk-core": "^4.0.3"
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the life of me could not resolve some versioning issues btwn uniswap router-sdk -> sdk-core and sdk-core. This was the only thing that worked to fix it

Copy link
Contributor

@Sladuca Sladuca Sep 10, 2023

Choose a reason for hiding this comment

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

ok - do you know if it still works if you install the plugin package separately? If not, nw, we can publish an alpha for it and try installing it into interface later when we "acceptance test" it anyways.

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 installing directly into plugins package didn't work

@luketchang luketchang marked this pull request as ready for review September 10, 2023 18:10
@luketchang luketchang requested a review from Sladuca as a code owner September 10, 2023 18:10
Copy link
Contributor

@Sladuca Sladuca left a comment

Choose a reason for hiding this comment

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

looks ok aside from unit tests failing and previously-discussed lack of tests - just had a few small questions and one nit change that may or may not apply

Comment on lines +30 to +32
"resolutions": {
"@uniswap/sdk-core": "^4.0.3"
},
Copy link
Contributor

@Sladuca Sladuca Sep 10, 2023

Choose a reason for hiding this comment

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

ok - do you know if it still works if you install the plugin package separately? If not, nw, we can publish an alpha for it and try installing it into interface later when we "acceptance test" it anyways.

Comment on lines +219 to +225
| {
type: "Action";
actionType: "UniswapV3 Swap";
tokenIn: Address;
inAmount: bigint;
tokenOut: Address;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is ok for now, but we're going to need to come back and generalize this. I think the sanest way to deal with probably going to end up requiring plugins to format metadata.

@@ -109,14 +114,14 @@ export type JoinSplitsAndPaymentsForAsset = [
export function newOpRequestBuilder(
provider: ethers.providers.Provider,
chainId: bigint,
tellerContract?: Address // for testing purposes in case there is no config for test network
Copy link
Contributor

Choose a reason for hiding this comment

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

mashallah

resolve({
unwraps: [unwrap],
confidentialPayments: [],
actions: [approveAction, swapAction], // enqueue approve + swap
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to revoke approval and/or limit the approval? Is the thinking here that it's kind of pointless because handler is shared?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Need to check on this, I don't think I understand permit2 very well rn

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 so you have one-time approve max uint256 for permit2 approvals. See uniswap article here for little bit more of explanation. What's above basically just does max approval if needed, can serve for any user later on to
https://blog.uniswap.org/permit2-integration-guide

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nvm I changed to swap router which does traditional token approval to protocol, just doing max uint256 because anyone can call handler.approve

}
);

this.pluginFn(prom);
Copy link
Contributor

Choose a reason for hiding this comment

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

does pluginFn chain? If so we can just do return this.pluginFn(prom)

Copy link
Contributor Author

@luketchang luketchang Sep 12, 2023

Choose a reason for hiding this comment

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

Yeah it does return this but doing return this.pluginFn(...) throws error because I think it doesn't view EInner as compatible with this?
Screenshot 2023-09-11 at 9 52 31 PM

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah this is what I was referring to re: this getting bound to the wrong thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@luketchang luketchang merged commit 0cb20e3 into main Sep 14, 2023
3 checks passed
@luketchang luketchang deleted the luke/lido-offchain-3 branch September 14, 2023 14:38
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.

2 participants