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

feat: /swap endpoint #1269

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft

feat: /swap endpoint #1269

wants to merge 4 commits into from

Conversation

dohaki
Copy link
Contributor

@dohaki dohaki commented Nov 8, 2024

Epic branch for /swap endpoint

Copy link

vercel bot commented Nov 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
app-frontend-v3 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 15, 2024 10:32am
sepolia-frontend-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 15, 2024 10:32am

* feat: add exact output trade type support uniswap

* test with base

* fixup

* fixup

* fixup

* ci: fix dep review

* fixup

* test uniswap universal

* fixup

* test 1inch

* fixup

* fixup
Comment on lines +21 to 31
export const SWAP_ROUTER_02_ADDRESS = {
[CHAIN_IDs.ARBITRUM]: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",
[CHAIN_IDs.BASE]: "0x2626664c2603336E57B271c5C0b26F421741e481",
[CHAIN_IDs.BLAST]: "0x549FEB8c9bd4c12Ad2AB27022dA12492aC452B66",
[CHAIN_IDs.MAINNET]: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",
[CHAIN_IDs.OPTIMISM]: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",
[CHAIN_IDs.POLYGON]: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",
[CHAIN_IDs.WORLD_CHAIN]: "0x091AD9e2e6e5eD44c1c66dB50e49A601F9f36cF6",
[CHAIN_IDs.ZK_SYNC]: "0x99c56385daBCE3E81d8499d0b8d0257aBC07E8A3",
[CHAIN_IDs.ZORA]: "0x7De04c96BE5159c3b5CeffC82aa176dc81281557",
};
Copy link
Contributor

Choose a reason for hiding this comment

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

These all checked out OK 👍

Copy link
Contributor

@pxrl pxrl left a comment

Choose a reason for hiding this comment

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

@dohaki Do we want to consider merging this into a feature branch? Or is that already what swap-endpoint is?

Comment on lines +51 to +52
swap.tokenIn = getMainnetToken(swap.tokenIn);
swap.tokenOut = getMainnetToken(swap.tokenOut);
Copy link
Contributor

Choose a reason for hiding this comment

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

getMainnetToken() is existing functionality, but ooc, is it intending to distinguish testnet from mainnet? There's an unfortunate collision between mainnet (Ethereum) vs other chains and mainnet vs. testnet. If it's intending to distinguish testnet from prod, should we consider renaming it to getProdToken() instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yea getProdToken is a better name def. Will change!

originChainId: positiveIntStr(),
destinationChainId: positiveIntStr(),
recipient: validAddress(),
integratorId: string(),
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 intend for this to be a required input? Seems like it's a value-add, but making it mandatory might be heavy-handed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, yea we can make it optional

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 want to add Mainnet, Blast, World Chain & Zora here?

[CHAIN_IDs.OPTIMISM]: "0x3E7448657409278C9d6E192b92F2b69B234FCc42",
[CHAIN_IDs.ARBITRUM]: "0xC456398D5eE3B93828252e48beDEDbc39e03368E",
[CHAIN_IDs.BASE]: "0x7CFaBF2eA327009B39f40078011B0Fb714b65926",
[CHAIN_IDs.POLYGON]: "0xF9735e425A36d22636EF4cb75c7a6c63378290CA",
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see any deployment for 1inch in this pr - is that intentional?

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, I actually deployed one for Polygon already back then when we introduced the initial swap feature

Copy link
Contributor

Choose a reason for hiding this comment

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

ooc, do we have a merge-time check that this file matches 1:1 the output of the generate-routes script? I could see how they could accidentally get out of sync on a long-running PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no we don't... we should add that to CI

@dohaki
Copy link
Contributor Author

dohaki commented Nov 14, 2024

@dohaki Do we want to consider merging this into a feature branch? Or is that already what swap-endpoint is?

Yea this branch is supposed to be the long-living epic branch actually. That's why I am keeping it in a draft state for now

* feat: cross swap quotes resolve uniswap min output

* add test script

* refine min output and leftover tokens handling
* resolve arbitrary token details

* fixup

* use wrapped addresses to resolve native tokens

* create error class, refactor using multicall

* Update api/_utils.ts

Co-authored-by: Dong-Ha Kim <[email protected]>

* validate inputs, add cause to error

---------

Co-authored-by: Dong-Ha Kim <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants