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: add cross-account trading for 1inch #5834

Merged
merged 2 commits into from
Dec 12, 2023
Merged

Conversation

0xApotheosis
Copy link
Contributor

@0xApotheosis 0xApotheosis commented Dec 12, 2023

Description

Enables cross-account trading for 1inch.

Cross-account 1inch transactions created from this branch:

  1. Fee asset account 0 to ERC20 account 1: https://snowtrace.dev/tx/0x93dea99cfa2663635a6314e0340fd890404ed3d999c04862520e83dbbacdf95f
  2. Approval from non-0 ERC20 account: https://snowtrace.dev/tx/0xff2c18378bd4fff274d471841a7d28d5d188d86c84866f420aa4677e52ec213b
  3. ERC20 account 1 to fee asset account 0: https://snowtrace.dev/tx/0xa9b8cca119c09f3bd6c96f1b9eaea31b0119a71b537b7d592164154cde79c695

Pull Request Type

  • 🐛 Bug fix (Non-breaking Change: Fixes an issue)
  • 🛠️ Chore (Non-breaking Change: Doc updates, pkg upgrades, typos, etc..)
  • 💅 New Feature (Breaking/Non-breaking Change)

Issue (if applicable)

Closes #4966

Risk

Medium. It's a small change, but as always, touching account selection is risky as mistakes can mean lost funds.

Testing

Confirm that 1inch quotes now show up when trading between accounts, and that they and sent and received from the correct accounts when executed.

Engineering

Sanity check logic.

Operations

☝️

Screenshots (if applicable)

Screenshot 2023-12-12 at 11 09 58 am

Copy link
Contributor

@gomesalexandre gomesalexandre left a comment

Choose a reason for hiding this comment

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

Looks sane to me pending runtime testing

Copy link
Contributor

@gomesalexandre gomesalexandre left a comment

Choose a reason for hiding this comment

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

Runtime test - note, I had to bump QUOTE_TIMEOUT_MS up to handle currrent Li.Fi timeouts

Account 0 -> 1 (ERC-20 -> native asset)

Screenshot 2023-12-12 at 12 05 50 Screenshot 2023-12-12 at 12 06 01
  • Approve Tx from account 0
Screenshot 2023-12-12 at 12 07 20
  • Trade complete account 0 -> 1
Screenshot 2023-12-12 at 12 07 30 image image

Fundus successfully sent to account 1 🎉

Account 0 -> 1 (native asset -> ERC-20)

image image

Note, no approval here as this is a native asset

  • Trade complete account 0 -> 1

Note recipient / srcTo where srcTo (the sender) is address zero, which is expected as this is an abstraction when dealing with native assets

image image image

Fundus successfully sent to account 1 🎉

Account 1 -> 0 (ERC-20 -> native asset)

image image
  • Approve Tx from account 1

Untestable as this is from account 1 which already has allowance granted, and I cannot add the account as account 1 in MM as they use a different account path component for derivation.

  • Trade complete account 1 -> 0

Note, had to switch to Gnosisscan for this one as the funds were definitely received (got that sweet Zerion notification for funds received), but Blockscout couldn't pick the XDAI transfer internal Tx 🤦🏽

image image

Fundus successfully sent to account 0 🎉

Account 1 -> 0 (native asset -> ERC-20)

image image

Note, no approval here as this is a native asset

  • Trade complete account 1 -> 0

Note recipient / srcTo where srcTo (the sender) is address zero, which is expected as this is an abstraction when dealing with native assets

image image image

Fundus successfully sent to account 0 🎉

Account 1 -> 1 as a paranoia regression test

image image image

Fundus successfully sent to account 1 🎉

Account 0 -> 0 as a paranoia regression test

image image image image

Fundus successfully sent to account 1 🎉

Copy link
Contributor

@gomesalexandre gomesalexandre left a comment

Choose a reason for hiding this comment

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

Retest of Account 1 -> 0 (ERC-20 -> native asset), since I noticed this was sent from account 0 (i.e 0 -> 0) in the Tx above.

image image
  • Approval step is displayed
image
  • Happy Tx
image image image

Two things to note here:

  1. While testing this PR, I've noticed these consistently failing:
image Not related to this PR per se, but we should never make THOR requests in the first place for e.g. XDAI. Perhaps something to guard against as a follow-up @0xApotheosis ? 🙏🏽
  1. WRT the wrong account used above, I believe this has to do with backing off from preview step and going back to input step, though I haven't been able to repro - may have been a one-off shenanigan

@gomesalexandre gomesalexandre enabled auto-merge (squash) December 12, 2023 09:20
@gomesalexandre gomesalexandre merged commit 6d964eb into develop Dec 12, 2023
3 checks passed
@gomesalexandre gomesalexandre deleted the cross-account-1inch branch December 12, 2023 09:26
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.

Unable to fetch rates for all swapper protocols when trading between acounts
2 participants