Skip to content

Conversation

@HongmingWang-Rabbit
Copy link

Summary

  • Add spell to track deposit volume for toroperp broker on Orderly Network (SEI chain)
  • Filters deposits from the Orderly Vault contract by toroperp's broker hash
  • Includes cross-chain aggregation view for future chain expansion

Files Added

  • toroperp_sei_deposits.sql - Incremental model filtering deposits by broker hash
  • toroperp_sei_schema.yml - Schema documentation and data tests
  • toroperp_deposits.sql - Cross-chain aggregation view
  • toroperp_schema.yml - Top-level schema

Technical Details

  • Vault Contract: 0x816f722424B49Cf1275cc86DA9840Fbd5a6167e9
  • Broker Hash: 0x18749138d2f6349916b7fbdc3a498a292169a4e698b2f3d66c8bb3f4249098ce
  • Decodes AccountDepositTo events and filters by broker hash from transaction input data

Test Plan

  • Tested query on Dune - returns correct deposit data including token amounts

🤖 Generated with Claude Code

Add spell to track deposit volume for toroperp broker on Orderly Network.
Filters deposits by broker hash from the Orderly Vault contract on SEI chain.

- toroperp_sei_deposits: incremental model filtering by broker hash
- toroperp_deposits: cross-chain aggregation view

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@cursor
Copy link

cursor bot commented Dec 14, 2025

PR Summary

Adds SEI toroperp deposit model that decodes Orderly Vault deposits filtered by broker hash, plus a cross-chain aggregation view.

  • Models:
    • SEI deposits (incremental): toroperp/sei/toroperp_sei_deposits.sql decodes AccountDepositTo events, extracts broker_hash from tx input (selector 0x322dda6d), filters by vault 0x816f722424B49Cf1275cc86DA9840Fbd5a6167e9 and toroperp broker hash, and outputs deposit fields.
    • Cross-chain aggregation: toroperp/toroperp_deposits.sql unions deposit models across chains (currently SEI).
  • Schema/Docs/Tests:
    • toroperp_sei_schema.yml: column docs + uniqueness test on block_date, tx_hash, evt_index.
    • toroperp_schema.yml: docs for aggregated view.

Written by Cursor Bugbot for commit a8ff39c. Configure here.

@github-actions github-actions bot marked this pull request as draft December 14, 2025 03:24
@github-actions github-actions bot added the WIP work in progress label Dec 14, 2025
@github-actions
Copy link

github-actions bot commented Dec 14, 2025

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

@github-actions github-actions bot added the dbt: daily covers the Daily dbt subproject label Dec 14, 2025
@HongmingWang-Rabbit
Copy link
Author

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

github-actions bot added a commit that referenced this pull request Dec 14, 2025
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Comment @cursor review or bugbot run to trigger another review on this PR

file_format = 'delta',
incremental_strategy = 'merge',
unique_key = ['block_date', 'tx_hash', 'evt_index'],
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')],
Copy link

Choose a reason for hiding this comment

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

Bug: Incremental merge key may duplicate on reorgs

The incremental unique_key includes block_date alongside tx_hash/evt_index. If block_time (and therefore block_date) changes due to chain reorgs/backfills, the same log can be inserted again under a new key instead of being updated, creating duplicates.

Fix in Cursor Fix in Web

WHERE
-- Filter only deposit function calls (selector: 0x322dda6d)
varbinary_substring(d.tx_input_data, 1, 4) = 0x322dda6d
)
Copy link

Choose a reason for hiding this comment

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

Bug: Broker hash extraction assumes direct vault calls

broker_hash is extracted from top-level transactions.data and filtered by the deposit selector. If AccountDepositTo events are emitted via internal calls (e.g., a router/proxy transaction where t.data is not the vault deposit calldata), the model can silently drop valid toroperp deposits and undercount volume.

Fix in Cursor Fix in Web

@HongmingWang-Rabbit HongmingWang-Rabbit marked this pull request as ready for review December 14, 2025 20:05
@github-actions github-actions bot added ready-for-review this PR development is complete, please review and removed WIP work in progress labels Dec 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dbt: daily covers the Daily dbt subproject ready-for-review this PR development is complete, please review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant