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 camelot pair fee rates spellbook #5846

Merged

Conversation

whalehunting
Copy link
Contributor

@whalehunting whalehunting commented Apr 28, 2024

The Camelot DEX on Arbitrum has a dynamic fee rate model, both for v2 and v3 architecture:

  • Fee rates can be configured by pair
  • Fee rates can be set by swap direction (token0 -> token1 and token1 -> token0 can have individual fee rates)
  • Fee rates can be updated over time

The Camelot ⚔️🤴🏼 Dashboard has been broken since 2 months, because the query logic that determines the latest fee rate for each swap is super inefficient, which leads to >30min execution runtimes, so the query runs fail.

I discussed potential solutions with @0xBoxer and the Camelot team and came up with this structure. The spellbook should contain fee rates for every pair by minute, since the deployment of each pair.
Once live, a swap can be simply joined like this.

SELECT
    *
FROM
    swaps
    JOIN camelot_arbitrum.pair_fee_rates ON (
        swaps.minute = camelot_arbitrum.pair_fee_rates.minute
    )

Sample

Filtered version with a single pair
https://dune.com/queries/3677413?sidebar=none

Thoughts

  • I formatted the code using sqlfmt, lmk if this matches your coding style!

@dune-eng
Copy link

Workflow run id 8868362688 approved.

@dune-eng
Copy link

Workflow run id 8868362582 approved.

@dune-eng
Copy link

Workflow run id 8868389985 approved.

@dune-eng
Copy link

Workflow run id 8868390209 approved.

@dune-eng
Copy link

Workflow run id 8868391866 approved.

@dune-eng
Copy link

Workflow run id 8868391946 approved.

@dune-eng
Copy link

Workflow run id 8868444968 approved.

@dune-eng
Copy link

Workflow run id 8868445164 approved.

@dune-eng
Copy link

Workflow run id 8869537619 approved.

@dune-eng
Copy link

Workflow run id 8869537641 approved.

@whalehunting whalehunting changed the title feat: add camelot fee rates spellbook [WIP] feat: add camelot fee rate updates spellbook [WIP] Apr 28, 2024
@whalehunting whalehunting changed the title feat: add camelot fee rate updates spellbook [WIP] feat: add camelot fee rate rates spellbook [WIP] Apr 28, 2024
@whalehunting whalehunting changed the title feat: add camelot fee rate rates spellbook [WIP] feat: add camelot pair fee rates spellbook [WIP] Apr 28, 2024
@dune-eng
Copy link

Workflow run id 8869651739 approved.

@dune-eng
Copy link

Workflow run id 8869651810 approved.

@dune-eng
Copy link

Workflow run id 8869725013 approved.

@dune-eng
Copy link

Workflow run id 8869725059 approved.

@dune-eng
Copy link

Workflow run id 8869862292 approved.

@dune-eng
Copy link

Workflow run id 8869862371 approved.

@dune-eng
Copy link

Workflow run id 8869962623 approved.

@dune-eng
Copy link

Workflow run id 8869962679 approved.

@dune-eng
Copy link

dune-eng commented May 2, 2024

Workflow run id 8929303512 approved.

@dune-eng
Copy link

dune-eng commented May 2, 2024

Workflow run id 8929339607 approved.

@dune-eng
Copy link

dune-eng commented May 2, 2024

Workflow run id 8929339778 approved.

@dune-eng
Copy link

dune-eng commented May 2, 2024

Workflow run id 8929399358 approved.

@dune-eng
Copy link

dune-eng commented May 2, 2024

Workflow run id 8929399510 approved.

@whalehunting whalehunting force-pushed the feat-add-camelot-pair-fee-updates branch from 51ef6a6 to 209bcef Compare May 2, 2024 19:33
@dune-eng
Copy link

dune-eng commented May 2, 2024

Workflow run id 8929443037 approved.

@dune-eng
Copy link

dune-eng commented May 2, 2024

Workflow run id 8929443371 approved.

@dune-eng
Copy link

dune-eng commented May 2, 2024

Workflow run id 8929502868 approved.

@dune-eng
Copy link

dune-eng commented May 2, 2024

Workflow run id 8929503042 approved.

This reverts commit ad80d3f.
@dune-eng
Copy link

dune-eng commented May 2, 2024

Workflow run id 8929554074 approved.

@dune-eng
Copy link

dune-eng commented May 2, 2024

Workflow run id 8929554219 approved.

@dune-eng
Copy link

dune-eng commented May 3, 2024

Workflow run id 8934862933 approved.

@dune-eng
Copy link

dune-eng commented May 3, 2024

Workflow run id 8934863151 approved.

@dune-eng
Copy link

dune-eng commented May 3, 2024

Workflow run id 8934913155 approved.

@dune-eng
Copy link

dune-eng commented May 3, 2024

Workflow run id 8934913380 approved.

@whalehunting whalehunting requested a review from jeff-dude May 3, 2024 07:27
Copy link
Member

@jeff-dude jeff-dude left a comment

Choose a reason for hiding this comment

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

good stuff here 🔥
let's get it merged

@jeff-dude jeff-dude added ready-for-merging and removed WIP work in progress in review Assignee is currently reviewing the PR labels May 3, 2024
@jeff-dude jeff-dude merged commit b7bb723 into duneanalytics:main May 3, 2024
3 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators May 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants