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(handlefi): add support for HandleFi swap plugin #144

Merged
merged 39 commits into from
Jan 3, 2024

Conversation

mmackz
Copy link
Collaborator

@mmackz mmackz commented Dec 24, 2023

Integration of handlefi swap action plugin for QuestDK

This PR introduces the integration of the handlefi swap plugin for QuestDK.

About The Project

HandleFi is a decentralized multi currency stablecoin protocol based on Arbitrum. They offer several products including perpetual swaps, convert, staking, and fxTokens.

Implementation Details

There are several contracts that a swap may be routed through, making this plugin quite complex to implement. The majority of swaps will be routed via paraswap. fxTokens are routed through handlefis contracts or external curve/balancer pools.

Current Limitations

  • amountOut may not be accurate due to some methods using amountOutMin which takes into account the amount of slippage set.
  • amountOut will not be considered if the swap is routed through the HPSM2 contract.
  • trades routed through curve V2 factory may have some false positives. Since there is not a really good way to tell what pool it is without having the contract address passed in as an argument. Because of this, false positives can occur if the tokenOut is selected as USDT and USDC.e is traded, and vice-versa.

@mmackz mmackz requested a review from a team as a code owner December 24, 2023 03:41
Copy link

changeset-bot bot commented Dec 24, 2023

🦋 Changeset detected

Latest commit: 4a116f7

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

This PR includes changesets to release 2 packages
Name Type
@rabbitholegg/questdk-plugin-handlefi Minor
@rabbitholegg/questdk-plugin-registry Minor

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
Member

@Quazia Quazia left a comment

Choose a reason for hiding this comment

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

LGTM - Nice work on this one. This has gotta be one of the most complex plugins yet.

} from './abi'
import { WETH } from './constants'

export function getParaSwapFilter(params: SwapActionParams) {
Copy link
Member

Choose a reason for hiding this comment

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

This is super cool - this way we can just recycle the filter generators for a given protocol against aggregates! Good idea.


export function getParaSwapFilter(params: SwapActionParams) {
const { tokenIn, tokenOut, amountIn, amountOut } = params
const internalEthAddress = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE'
Copy link
Member

Choose a reason for hiding this comment

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

This has to be my least favorite way to represent ETH lol

fromAmount: amountIn,
toAmount: amountOut,
toToken: tokenOutUsed,
partner: '0xFa2c1bE677BE4BEc8851D1577B343F7060B51E3A',
Copy link
Member

Choose a reason for hiding this comment

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

What do you think about making this a param from the function call? I would either do that or hardcode it to a const.


// There isnt really a good way to tell which pool you are in without knowing the contract address of the pool
// i will always be fxUSD (0)
// j can either be FRAX, USDC.e, or USDT (may get false posiitves here)
Copy link
Member

Choose a reason for hiding this comment

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

I think the false positives are fine - it's a pretty obscure edge-case. We'll find out if there's a way for the users to leverage this though, if there's a way they'll find it 😆

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Very obscure. The fxUSD frax pool sees roughly 1 tx a day, and the 3pool sees maybe 1 per week.

packages/handlefi/src/utils.ts Outdated Show resolved Hide resolved
@Quazia
Copy link
Member

Quazia commented Jan 3, 2024

Changes look good! Let's get this merged in.

@mmackz mmackz merged commit edc7aef into main Jan 3, 2024
9 checks passed
@mmackz mmackz deleted the mmackz-handlefi-swap branch January 3, 2024 19:45
@github-actions github-actions bot mentioned this pull request Jan 3, 2024
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