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: setup ALM trades + feed Arrakis data #5764

Merged
merged 71 commits into from
Jun 3, 2024

Conversation

0xrusowsky
Copy link
Contributor

@0xrusowsky 0xrusowsky commented Apr 10, 2024

this PR will tackle:

it basically follows the structure of dex.trades for a new sector alm (active liquidity managers), so that for each trade, dune wizards can easily know the subset of swap volume which was served by an ALM.

  • proposed model:
models:

  - name: alm_base_trades
    meta:
      blockchain: ethereum
      sector: alm
      contributors: 0xrusowsky
    config:
      tags: [ 'alm', 'trades' ]
    tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - blockchain
            - project
            - version
            - tx_hash
            - evt_index
            - vault_address
    columns:
      - &blockchain
        name: blockchain
        description: "Blockchain where the ALM is deployed"
      - &project
        name: project
        description: "Project name"
      - &version
        name: version
        description: "Version of the contract built and deployed by the project"
      - &dex
        name: dex
        description: "DEX name"
      - &dex_version
        name: dex_version
        description: "Version of the liquidity pool contract"
      - &block_month
        name: block_month
        description: "Month of the event block time"
      - &block_time
        name: block_time
        description: "UTC event block time of each DEX trade"
      - &block_number
        name: block_number
        description: "Block number of each DEX trade"
      - &pool_address
        name: pool_address
        description: "Project contract address which executed the trade on the blockchain"
      - &vault_address
        name: vault_address
        description: "Address of the vault (liquidity provider)"
      - &token_pair
        name: token_pair
        description: "Token symbol pair for the pool tokens"
      - &token0_address
        name: token0_address
        description: "Contract address of the token bought"
      - &token1_address
        name: token1_address
        description: "Contract address of the token sold"
      - &volume_usd
        name: volume_usd
        description: "USD volume provided by the ALM"
      - &swap_volume_usd
        name: swap_volume_usd
        description: "Full USD volume traded in the DEX pool"
      - &volume_share
        name: volume_share
        description: "Share of the traded volume provided by the ALM"
      - &volume0
        name: volume0
        description: "Amount of token0 provided by the ALM (with parsed decimals)"
      - &swap_volume0
        name: swap_volume0
        description: "Full amount of token0 traded in the DEX pool"
      - &token0_symbol
        name: token0_symbol
        description: "Token symbol for token0 of the pool"
      - &volume1
        name: volume1
        description: "Amount of token1 provided by the ALM (with parsed decimals)"
      - &swap_volume1
        name: swap_volume1
        description: "Full amount of token1 traded in the DEX pool"
      - &token1_symbol
        name: token1_symbol
        description: "Token symbol for token1 of the pool"
      - &volume0_raw
        name: volume0_raw
        description: "Raw amount of token0 provided by the ALM"
      - &volume1_raw
        name: volume1_raw
        description: "Raw amount of token1 provided by the ALM"
      - &tx_hash
        name: tx_hash
        description: "Unique transaction hash value tied to each transaction on the DEX"
      - &evt_index
        name: evt_index
        description: "Index of the corresponding trade event"

Copy link

github-actions bot commented Apr 10, 2024

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@dune-eng
Copy link

Workflow run id 8633904472 approved.

@dune-eng
Copy link

Workflow run id 8633904042 approved.

@0xrusowsky
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

github-actions bot added a commit that referenced this pull request Apr 10, 2024
@dune-eng
Copy link

Workflow run id 8633923184 approved.

@dune-eng
Copy link

Workflow run id 8633923362 approved.

@dune-eng
Copy link

Workflow run id 8634105480 approved.

@dune-eng
Copy link

Workflow run id 8634105204 approved.

@dune-eng
Copy link

Workflow run id 8642631739 approved.

@dune-eng
Copy link

Workflow run id 8642631821 approved.

@dune-eng
Copy link

Workflow run id 8643190908 approved.

@dune-eng
Copy link

Workflow run id 8643191070 approved.

@dune-eng
Copy link

Workflow run id 8643476519 approved.

@dune-eng
Copy link

Workflow run id 8643476763 approved.

@dune-eng
Copy link

Workflow run id 8643657415 approved.

@dune-eng
Copy link

Workflow run id 8643657114 approved.

@dune-eng
Copy link

Workflow run id 8643789626 approved.

@dune-eng
Copy link

Workflow run id 8643789863 approved.

@dune-eng
Copy link

Workflow run id 8643901964 approved.

@dune-eng
Copy link

Workflow run id 8643902133 approved.

@dune-eng
Copy link

Workflow run id 8644033338 approved.

@dune-eng
Copy link

Workflow run id 8644033543 approved.

@dune-eng
Copy link

Workflow run id 8644236622 approved.

@dune-eng
Copy link

Workflow run id 8644236822 approved.

@dune-eng
Copy link

Workflow run id 8644390760 approved.

@dune-eng
Copy link

Workflow run id 8644390649 approved.

@0xrusowsky
Copy link
Contributor Author

@Hosuke @jeff-dude can you help me troubleshoot please?

@Hosuke
Copy link
Collaborator

Hosuke commented Apr 12, 2024

@Hosuke @jeff-dude can you help me troubleshoot please?

I think the problem may be caused by the source definition.
I am checking in details...

@Hosuke Hosuke self-assigned this Apr 12, 2024
schema = 'alm_ethereum'
, alias = 'base_trades'
, materialized = 'view'
, unique_key = ['blockchain', 'project', 'version', 'tx_hash', 'evt_index', 'vault_address']
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since this spell is materialized as view now, I will remove incremental filters and unique_key in this spell.

Copy link
Collaborator

@Hosuke Hosuke left a comment

Choose a reason for hiding this comment

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

LGTM.✅
Thank you @0xrusowsky

Sample alm_trades

models/_sector/alm/ethereum/alm_ethereum_base_trades.sql Outdated Show resolved Hide resolved
@Hosuke Hosuke assigned jeff-dude and unassigned Hosuke May 26, 2024
@Hosuke
Copy link
Collaborator

Hosuke commented May 27, 2024

By the way @0xrusowsky can you add a readme.md for this new sector?

@0xrusowsky
Copy link
Contributor Author

By the way @0xrusowsky can you add a readme.md for this new sector?

sure, where should i place it? and regarding the content, is it enough to explain what i did on the issue #5626? or should i expand it further and also detail the fields, how the queries are built, etc?

@Hosuke
Copy link
Collaborator

Hosuke commented May 29, 2024

By the way @0xrusowsky can you add a readme.md for this new sector?

sure, where should i place it? and regarding the content, is it enough to explain what i did on the issue #5626? or should i expand it further and also detail the fields, how the queries are built, etc?

You can add a readme.md under models/_sector/alm/, and ideally you can explain the spell design in details, and guide for further contribution.

@jeff-dude
Copy link
Member

you can mimic the dex.trades readme here, but it doesn't have to be quite as in depth right away (i.e. okay without the diagram and such). @Hosuke did a killer job on that one!

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.

pushed a final commit to cleanup usage of base_ in table names as this doesn't fully follow that standard. we can look to use that approach as the sector spell grows.

@jeff-dude
Copy link
Member

pushed a final commit to cleanup usage of base_ in table names as this doesn't fully follow that standard. we can look to use that approach as the sector spell grows.

once you push a quick readme, we should be all good to go!

@dune-eng
Copy link

Workflow run id 9301037767 approved.

@dune-eng
Copy link

Workflow run id 9301038039 approved.

@0xrusowsky
Copy link
Contributor Author

0xrusowsky commented May 30, 2024

@jeff-dude @Hosuke i made a readme proposal, feel free to do any changes you'd like!
Also, feel free to add yourselves as contributors since you helped me a lot getting the PR to the finish line :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thank you for adding the readme.

Copy link
Member

Choose a reason for hiding this comment

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

pushed one final commit on what i think was a copy/paste typo. thank you for adding!

@Hosuke Hosuke removed the WIP work in progress label May 30, 2024
@jeff-dude jeff-dude merged commit 4ce1437 into duneanalytics:main Jun 3, 2024
2 checks passed
Copy link

gitpoap-bot bot commented Jun 3, 2024

Congrats, your important contribution to this open-source project has earned you a GitPOAP!

GitPOAP: 2024 Dune Contributor:

GitPOAP: 2024 Dune Contributor GitPOAP Badge

Head to gitpoap.io & connect your GitHub account to mint!

Learn more about GitPOAPs here.

@github-actions github-actions bot locked and limited conversation to collaborators Jun 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.

4 participants