diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 00000000000..688cbc3a965 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,23 @@ +"dbt: daily": +- changed-files: + - any-glob-to-any-file: 'dbt_subprojects/daily_spellbook/**' + +"dbt: dex": +- changed-files: + - any-glob-to-any-file: 'dbt_subprojects/dex/**' + +"dbt: hourly": +- changed-files: + - any-glob-to-any-file: 'dbt_subprojects/hourly_spellbook/**' + +"dbt: nft": +- changed-files: + - any-glob-to-any-file: 'dbt_subprojects/nft/**' + +"dbt: solana": +- changed-files: + - any-glob-to-any-file: 'dbt_subprojects/solana/**' + +"dbt: tokens": +- changed-files: + - any-glob-to-any-file: 'dbt_subprojects/tokens/**' diff --git a/.github/workflows/pr_automation.yml b/.github/workflows/pr_automation.yml new file mode 100644 index 00000000000..e43f95343f5 --- /dev/null +++ b/.github/workflows/pr_automation.yml @@ -0,0 +1,46 @@ +name: PR automation + +on: + pull_request_target: + types: + - opened + - ready_for_review + - converted_to_draft + - synchronize + - labeled + +permissions: + pull-requests: write + contents: write + +jobs: + pr-automation: + runs-on: ubuntu-latest + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + NUMBER: ${{ github.event.number }} + steps: + - name: Mark new PR as Draft + if: (github.event.action == 'opened' && github.event.pull_request.draft == false) + run: gh pr ready "$NUMBER" --undo + + - name: Set labels on Open + if: github.event.action == 'opened' + run: gh pr edit "$NUMBER" --add-label "WIP" + + - name: Set labels on Draft + if: github.event.action == 'converted_to_draft' + run: gh pr edit "$NUMBER" --add-label "WIP" --remove-label "ready-for-review" + + - name: Set labels on ready-for-review + if: github.event.action == 'ready_for_review' + run: gh pr edit "$NUMBER" --add-label "ready-for-review" --remove-label "WIP" + + - name: Add subproject labels + if: contains('synchronize,opened,reopened', github.event.action) + uses: actions/labeler@v5 + with: + sync-labels: true + + diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 41761301108..2102ae9d859 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -19,7 +19,7 @@ Contributions in the form of issues and pull requests are very much welcome here ## [BETA] Pre-push hooks -UPDATE: These pre-push hooks require running `dbt compile` which is a fairly slow step due to the size of our project. We intend to rewrite these hooks to be more efficient but for the time being they remain cumbersome. Feel free to use them if you find them useful but the same checks will run in a Github Action when you commit your code. Feel free to uninstall if they do not bring joy, we'll let wizards know when we think we've improved them enought to warrant making them part of the general development flow. +UPDATE: These pre-push hooks require running `dbt compile` which is a fairly slow step due to the size of our project. We intend to rewrite these hooks to be more efficient but for the time being they remain cumbersome. Feel free to use them if you find them useful but the same checks will run in a Github Action when you commit your code. Feel free to uninstall if they do not bring joy, we'll let wizards know when we think we've improved them enough to warrant making them part of the general development flow. We are testing out adding pre-push hooks to our workflow. The goal is to catch common errors before code is pushed and streamline the pull request review process. @@ -126,13 +126,13 @@ example custom test: ```sql with unit_test1 as (select - case when col1 == 2 and col2 == 'moon' then True else False end as test + case when col1 = 2 and col2 = 'moon' then True else False end as test from {{ ref('mock_table' )}} where tx_id = '102'), unit_test2 as (select - case when col1 == 2 and col2 == 'moon' then True else False end as test + case when col1 = 2 and col2 = 'moon' then True else False end as test from {{ ref('mock_table' )}} where tx_id = '103'), diff --git a/Pipfile b/Pipfile index fe5bde4c96d..c9ae7c5f591 100644 --- a/Pipfile +++ b/Pipfile @@ -7,7 +7,7 @@ name = "pypi" numpy = "2.0.12" pre-commit = "2.20.0" pytest = "7.1.3" -dbt-trino = "1.8.2" +dbt-trino = "1.9.0" [requires] -python_version = "3.9" \ No newline at end of file +python_version = "3.9" diff --git a/Pipfile.lock b/Pipfile.lock index f7261af038c..4be5af25b65 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "ad039719a8fc32f6782de06f76f191e442fce11863ff3248c65ee3ab7e137618" + "sha256": "82294d4746cf046802c3e59758a47a7e13d24a6abec9e6f8fbfd5d2384217b9a" }, "pipfile-spec": 6, "requires": { @@ -33,11 +33,11 @@ }, "attrs": { "hashes": [ - "sha256:5cfb1b9148b5b086569baec03f20d7b6bf3bcacc9a42bebf87ffaaca362f6346", - "sha256:81921eb96de3191c8258c199618104dd27ac608d9366f5e35d011eae1867ede2" + "sha256:8f5c07333d543103541ba7be0e2ce16eeee8130cb0b3f9238ab904ce1e85baff", + "sha256:ac96cd038792094f438ad1f6ff80837353805ac950cd2aa0e0625ef19850c308" ], - "markers": "python_version >= '3.7'", - "version": "==24.2.0" + "markers": "python_version >= '3.8'", + "version": "==24.3.0" }, "babel": { "hashes": [ @@ -49,11 +49,11 @@ }, "certifi": { "hashes": [ - "sha256:922820b53db7a7257ffbda3f597266d435245903d80737e34f8a45ff3e3230d8", - "sha256:bec941d2aa8195e248a60b31ff9f0558284cf01a52591ceda73ea9afffd69fd9" + "sha256:1275f7a45be9464efc1173084eaa30f866fe2e47d389406136d332ed4967ec56", + "sha256:b650d30f370c2b724812bee08008be0c4163b163ddaec3f2546c1caf65f191db" ], "markers": "python_version >= '3.6'", - "version": "==2024.8.30" + "version": "==2024.12.14" }, "cfgv": { "hashes": [ @@ -65,122 +65,109 @@ }, "charset-normalizer": { "hashes": [ - "sha256:0099d79bdfcf5c1f0c2c72f91516702ebf8b0b8ddd8905f97a8aecf49712c621", - "sha256:0713f3adb9d03d49d365b70b84775d0a0d18e4ab08d12bc46baa6132ba78aaf6", - "sha256:07afec21bbbbf8a5cc3651aa96b980afe2526e7f048fdfb7f1014d84acc8b6d8", - "sha256:0b309d1747110feb25d7ed6b01afdec269c647d382c857ef4663bbe6ad95a912", - "sha256:0d99dd8ff461990f12d6e42c7347fd9ab2532fb70e9621ba520f9e8637161d7c", - "sha256:0de7b687289d3c1b3e8660d0741874abe7888100efe14bd0f9fd7141bcbda92b", - "sha256:1110e22af8ca26b90bd6364fe4c763329b0ebf1ee213ba32b68c73de5752323d", - "sha256:130272c698667a982a5d0e626851ceff662565379baf0ff2cc58067b81d4f11d", - "sha256:136815f06a3ae311fae551c3df1f998a1ebd01ddd424aa5603a4336997629e95", - "sha256:14215b71a762336254351b00ec720a8e85cada43b987da5a042e4ce3e82bd68e", - "sha256:1db4e7fefefd0f548d73e2e2e041f9df5c59e178b4c72fbac4cc6f535cfb1565", - "sha256:1ffd9493de4c922f2a38c2bf62b831dcec90ac673ed1ca182fe11b4d8e9f2a64", - "sha256:2006769bd1640bdf4d5641c69a3d63b71b81445473cac5ded39740a226fa88ab", - "sha256:20587d20f557fe189b7947d8e7ec5afa110ccf72a3128d61a2a387c3313f46be", - "sha256:223217c3d4f82c3ac5e29032b3f1c2eb0fb591b72161f86d93f5719079dae93e", - "sha256:27623ba66c183eca01bf9ff833875b459cad267aeeb044477fedac35e19ba907", - "sha256:285e96d9d53422efc0d7a17c60e59f37fbf3dfa942073f666db4ac71e8d726d0", - "sha256:2de62e8801ddfff069cd5c504ce3bc9672b23266597d4e4f50eda28846c322f2", - "sha256:2f6c34da58ea9c1a9515621f4d9ac379871a8f21168ba1b5e09d74250de5ad62", - "sha256:309a7de0a0ff3040acaebb35ec45d18db4b28232f21998851cfa709eeff49d62", - "sha256:35c404d74c2926d0287fbd63ed5d27eb911eb9e4a3bb2c6d294f3cfd4a9e0c23", - "sha256:3710a9751938947e6327ea9f3ea6332a09bf0ba0c09cae9cb1f250bd1f1549bc", - "sha256:3d59d125ffbd6d552765510e3f31ed75ebac2c7470c7274195b9161a32350284", - "sha256:40d3ff7fc90b98c637bda91c89d51264a3dcf210cade3a2c6f838c7268d7a4ca", - "sha256:425c5f215d0eecee9a56cdb703203dda90423247421bf0d67125add85d0c4455", - "sha256:43193c5cda5d612f247172016c4bb71251c784d7a4d9314677186a838ad34858", - "sha256:44aeb140295a2f0659e113b31cfe92c9061622cadbc9e2a2f7b8ef6b1e29ef4b", - "sha256:47334db71978b23ebcf3c0f9f5ee98b8d65992b65c9c4f2d34c2eaf5bcaf0594", - "sha256:4796efc4faf6b53a18e3d46343535caed491776a22af773f366534056c4e1fbc", - "sha256:4a51b48f42d9358460b78725283f04bddaf44a9358197b889657deba38f329db", - "sha256:4b67fdab07fdd3c10bb21edab3cbfe8cf5696f453afce75d815d9d7223fbe88b", - "sha256:4ec9dd88a5b71abfc74e9df5ebe7921c35cbb3b641181a531ca65cdb5e8e4dea", - "sha256:4f9fc98dad6c2eaa32fc3af1417d95b5e3d08aff968df0cd320066def971f9a6", - "sha256:54b6a92d009cbe2fb11054ba694bc9e284dad30a26757b1e372a1fdddaf21920", - "sha256:55f56e2ebd4e3bc50442fbc0888c9d8c94e4e06a933804e2af3e89e2f9c1c749", - "sha256:5726cf76c982532c1863fb64d8c6dd0e4c90b6ece9feb06c9f202417a31f7dd7", - "sha256:5d447056e2ca60382d460a604b6302d8db69476fd2015c81e7c35417cfabe4cd", - "sha256:5ed2e36c3e9b4f21dd9422f6893dec0abf2cca553af509b10cd630f878d3eb99", - "sha256:5ff2ed8194587faf56555927b3aa10e6fb69d931e33953943bc4f837dfee2242", - "sha256:62f60aebecfc7f4b82e3f639a7d1433a20ec32824db2199a11ad4f5e146ef5ee", - "sha256:63bc5c4ae26e4bc6be6469943b8253c0fd4e4186c43ad46e713ea61a0ba49129", - "sha256:6b40e8d38afe634559e398cc32b1472f376a4099c75fe6299ae607e404c033b2", - "sha256:6b493a043635eb376e50eedf7818f2f322eabbaa974e948bd8bdd29eb7ef2a51", - "sha256:6dba5d19c4dfab08e58d5b36304b3f92f3bd5d42c1a3fa37b5ba5cdf6dfcbcee", - "sha256:6fd30dc99682dc2c603c2b315bded2799019cea829f8bf57dc6b61efde6611c8", - "sha256:707b82d19e65c9bd28b81dde95249b07bf9f5b90ebe1ef17d9b57473f8a64b7b", - "sha256:7706f5850360ac01d80c89bcef1640683cc12ed87f42579dab6c5d3ed6888613", - "sha256:7782afc9b6b42200f7362858f9e73b1f8316afb276d316336c0ec3bd73312742", - "sha256:79983512b108e4a164b9c8d34de3992f76d48cadc9554c9e60b43f308988aabe", - "sha256:7f683ddc7eedd742e2889d2bfb96d69573fde1d92fcb811979cdb7165bb9c7d3", - "sha256:82357d85de703176b5587dbe6ade8ff67f9f69a41c0733cf2425378b49954de5", - "sha256:84450ba661fb96e9fd67629b93d2941c871ca86fc38d835d19d4225ff946a631", - "sha256:86f4e8cca779080f66ff4f191a685ced73d2f72d50216f7112185dc02b90b9b7", - "sha256:8cda06946eac330cbe6598f77bb54e690b4ca93f593dee1568ad22b04f347c15", - "sha256:8ce7fd6767a1cc5a92a639b391891bf1c268b03ec7e021c7d6d902285259685c", - "sha256:8ff4e7cdfdb1ab5698e675ca622e72d58a6fa2a8aa58195de0c0061288e6e3ea", - "sha256:9289fd5dddcf57bab41d044f1756550f9e7cf0c8e373b8cdf0ce8773dc4bd417", - "sha256:92a7e36b000bf022ef3dbb9c46bfe2d52c047d5e3f3343f43204263c5addc250", - "sha256:92db3c28b5b2a273346bebb24857fda45601aef6ae1c011c0a997106581e8a88", - "sha256:95c3c157765b031331dd4db3c775e58deaee050a3042fcad72cbc4189d7c8dca", - "sha256:980b4f289d1d90ca5efcf07958d3eb38ed9c0b7676bf2831a54d4f66f9c27dfa", - "sha256:9ae4ef0b3f6b41bad6366fb0ea4fc1d7ed051528e113a60fa2a65a9abb5b1d99", - "sha256:9c98230f5042f4945f957d006edccc2af1e03ed5e37ce7c373f00a5a4daa6149", - "sha256:9fa2566ca27d67c86569e8c85297aaf413ffab85a8960500f12ea34ff98e4c41", - "sha256:a14969b8691f7998e74663b77b4c36c0337cb1df552da83d5c9004a93afdb574", - "sha256:a8aacce6e2e1edcb6ac625fb0f8c3a9570ccc7bfba1f63419b3769ccf6a00ed0", - "sha256:a8e538f46104c815be19c975572d74afb53f29650ea2025bbfaef359d2de2f7f", - "sha256:aa41e526a5d4a9dfcfbab0716c7e8a1b215abd3f3df5a45cf18a12721d31cb5d", - "sha256:aa693779a8b50cd97570e5a0f343538a8dbd3e496fa5dcb87e29406ad0299654", - "sha256:ab22fbd9765e6954bc0bcff24c25ff71dcbfdb185fcdaca49e81bac68fe724d3", - "sha256:ab2e5bef076f5a235c3774b4f4028a680432cded7cad37bba0fd90d64b187d19", - "sha256:ab973df98fc99ab39080bfb0eb3a925181454d7c3ac8a1e695fddfae696d9e90", - "sha256:af73657b7a68211996527dbfeffbb0864e043d270580c5aef06dc4b659a4b578", - "sha256:b197e7094f232959f8f20541ead1d9862ac5ebea1d58e9849c1bf979255dfac9", - "sha256:b295729485b06c1a0683af02a9e42d2caa9db04a373dc38a6a58cdd1e8abddf1", - "sha256:b8831399554b92b72af5932cdbbd4ddc55c55f631bb13ff8fe4e6536a06c5c51", - "sha256:b8dcd239c743aa2f9c22ce674a145e0a25cb1566c495928440a181ca1ccf6719", - "sha256:bcb4f8ea87d03bc51ad04add8ceaf9b0f085ac045ab4d74e73bbc2dc033f0236", - "sha256:bd7af3717683bea4c87acd8c0d3d5b44d56120b26fd3f8a692bdd2d5260c620a", - "sha256:bf4475b82be41b07cc5e5ff94810e6a01f276e37c2d55571e3fe175e467a1a1c", - "sha256:c3e446d253bd88f6377260d07c895816ebf33ffffd56c1c792b13bff9c3e1ade", - "sha256:c57516e58fd17d03ebe67e181a4e4e2ccab1168f8c2976c6a334d4f819fe5944", - "sha256:c94057af19bc953643a33581844649a7fdab902624d2eb739738a30e2b3e60fc", - "sha256:cab5d0b79d987c67f3b9e9c53f54a61360422a5a0bc075f43cab5621d530c3b6", - "sha256:ce031db0408e487fd2775d745ce30a7cd2923667cf3b69d48d219f1d8f5ddeb6", - "sha256:cee4373f4d3ad28f1ab6290684d8e2ebdb9e7a1b74fdc39e4c211995f77bec27", - "sha256:d5b054862739d276e09928de37c79ddeec42a6e1bfc55863be96a36ba22926f6", - "sha256:dbe03226baf438ac4fda9e2d0715022fd579cb641c4cf639fa40d53b2fe6f3e2", - "sha256:dc15e99b2d8a656f8e666854404f1ba54765871104e50c8e9813af8a7db07f12", - "sha256:dcaf7c1524c0542ee2fc82cc8ec337f7a9f7edee2532421ab200d2b920fc97cf", - "sha256:dd4eda173a9fcccb5f2e2bd2a9f423d180194b1bf17cf59e3269899235b2a114", - "sha256:dd9a8bd8900e65504a305bf8ae6fa9fbc66de94178c420791d0293702fce2df7", - "sha256:de7376c29d95d6719048c194a9cf1a1b0393fbe8488a22008610b0361d834ecf", - "sha256:e7fdd52961feb4c96507aa649550ec2a0d527c086d284749b2f582f2d40a2e0d", - "sha256:e91f541a85298cf35433bf66f3fab2a4a2cff05c127eeca4af174f6d497f0d4b", - "sha256:e9e3c4c9e1ed40ea53acf11e2a386383c3304212c965773704e4603d589343ed", - "sha256:ee803480535c44e7f5ad00788526da7d85525cfefaf8acf8ab9a310000be4b03", - "sha256:f09cb5a7bbe1ecae6e87901a2eb23e0256bb524a79ccc53eb0b7629fbe7677c4", - "sha256:f19c1585933c82098c2a520f8ec1227f20e339e33aca8fa6f956f6691b784e67", - "sha256:f1a2f519ae173b5b6a2c9d5fa3116ce16e48b3462c8b96dfdded11055e3d6365", - "sha256:f28f891ccd15c514a0981f3b9db9aa23d62fe1a99997512b0491d2ed323d229a", - "sha256:f3e73a4255342d4eb26ef6df01e3962e73aa29baa3124a8e824c5d3364a65748", - "sha256:f606a1881d2663630ea5b8ce2efe2111740df4b687bd78b34a8131baa007f79b", - "sha256:fe9f97feb71aa9896b81973a7bbada8c49501dc73e58a10fcef6663af95e5079", - "sha256:ffc519621dce0c767e96b9c53f09c5d215578e10b02c285809f76509a3931482" - ], - "markers": "python_full_version >= '3.7.0'", - "version": "==3.4.0" + "sha256:0167ddc8ab6508fe81860a57dd472b2ef4060e8d378f0cc555707126830f2537", + "sha256:01732659ba9b5b873fc117534143e4feefecf3b2078b0a6a2e925271bb6f4cfa", + "sha256:01ad647cdd609225c5350561d084b42ddf732f4eeefe6e678765636791e78b9a", + "sha256:04432ad9479fa40ec0f387795ddad4437a2b50417c69fa275e212933519ff294", + "sha256:0907f11d019260cdc3f94fbdb23ff9125f6b5d1039b76003b5b0ac9d6a6c9d5b", + "sha256:0924e81d3d5e70f8126529951dac65c1010cdf117bb75eb02dd12339b57749dd", + "sha256:09b26ae6b1abf0d27570633b2b078a2a20419c99d66fb2823173d73f188ce601", + "sha256:09b5e6733cbd160dcc09589227187e242a30a49ca5cefa5a7edd3f9d19ed53fd", + "sha256:0af291f4fe114be0280cdd29d533696a77b5b49cfde5467176ecab32353395c4", + "sha256:0f55e69f030f7163dffe9fd0752b32f070566451afe180f99dbeeb81f511ad8d", + "sha256:1a2bc9f351a75ef49d664206d51f8e5ede9da246602dc2d2726837620ea034b2", + "sha256:22e14b5d70560b8dd51ec22863f370d1e595ac3d024cb8ad7d308b4cd95f8313", + "sha256:234ac59ea147c59ee4da87a0c0f098e9c8d169f4dc2a159ef720f1a61bbe27cd", + "sha256:2369eea1ee4a7610a860d88f268eb39b95cb588acd7235e02fd5a5601773d4fa", + "sha256:237bdbe6159cff53b4f24f397d43c6336c6b0b42affbe857970cefbb620911c8", + "sha256:28bf57629c75e810b6ae989f03c0828d64d6b26a5e205535585f96093e405ed1", + "sha256:2967f74ad52c3b98de4c3b32e1a44e32975e008a9cd2a8cc8966d6a5218c5cb2", + "sha256:2a75d49014d118e4198bcee5ee0a6f25856b29b12dbf7cd012791f8a6cc5c496", + "sha256:2bdfe3ac2e1bbe5b59a1a63721eb3b95fc9b6817ae4a46debbb4e11f6232428d", + "sha256:2d074908e1aecee37a7635990b2c6d504cd4766c7bc9fc86d63f9c09af3fa11b", + "sha256:2fb9bd477fdea8684f78791a6de97a953c51831ee2981f8e4f583ff3b9d9687e", + "sha256:311f30128d7d333eebd7896965bfcfbd0065f1716ec92bd5638d7748eb6f936a", + "sha256:329ce159e82018d646c7ac45b01a430369d526569ec08516081727a20e9e4af4", + "sha256:345b0426edd4e18138d6528aed636de7a9ed169b4aaf9d61a8c19e39d26838ca", + "sha256:363e2f92b0f0174b2f8238240a1a30142e3db7b957a5dd5689b0e75fb717cc78", + "sha256:3a3bd0dcd373514dcec91c411ddb9632c0d7d92aed7093b8c3bbb6d69ca74408", + "sha256:3bed14e9c89dcb10e8f3a29f9ccac4955aebe93c71ae803af79265c9ca5644c5", + "sha256:44251f18cd68a75b56585dd00dae26183e102cd5e0f9f1466e6df5da2ed64ea3", + "sha256:44ecbf16649486d4aebafeaa7ec4c9fed8b88101f4dd612dcaf65d5e815f837f", + "sha256:4532bff1b8421fd0a320463030c7520f56a79c9024a4e88f01c537316019005a", + "sha256:49402233c892a461407c512a19435d1ce275543138294f7ef013f0b63d5d3765", + "sha256:4c0907b1928a36d5a998d72d64d8eaa7244989f7aaaf947500d3a800c83a3fd6", + "sha256:4d86f7aff21ee58f26dcf5ae81a9addbd914115cdebcbb2217e4f0ed8982e146", + "sha256:5777ee0881f9499ed0f71cc82cf873d9a0ca8af166dfa0af8ec4e675b7df48e6", + "sha256:5df196eb874dae23dcfb968c83d4f8fdccb333330fe1fc278ac5ceeb101003a9", + "sha256:619a609aa74ae43d90ed2e89bdd784765de0a25ca761b93e196d938b8fd1dbbd", + "sha256:6e27f48bcd0957c6d4cb9d6fa6b61d192d0b13d5ef563e5f2ae35feafc0d179c", + "sha256:6ff8a4a60c227ad87030d76e99cd1698345d4491638dfa6673027c48b3cd395f", + "sha256:73d94b58ec7fecbc7366247d3b0b10a21681004153238750bb67bd9012414545", + "sha256:7461baadb4dc00fd9e0acbe254e3d7d2112e7f92ced2adc96e54ef6501c5f176", + "sha256:75832c08354f595c760a804588b9357d34ec00ba1c940c15e31e96d902093770", + "sha256:7709f51f5f7c853f0fb938bcd3bc59cdfdc5203635ffd18bf354f6967ea0f824", + "sha256:78baa6d91634dfb69ec52a463534bc0df05dbd546209b79a3880a34487f4b84f", + "sha256:7974a0b5ecd505609e3b19742b60cee7aa2aa2fb3151bc917e6e2646d7667dcf", + "sha256:7a4f97a081603d2050bfaffdefa5b02a9ec823f8348a572e39032caa8404a487", + "sha256:7b1bef6280950ee6c177b326508f86cad7ad4dff12454483b51d8b7d673a2c5d", + "sha256:7d053096f67cd1241601111b698f5cad775f97ab25d81567d3f59219b5f1adbd", + "sha256:804a4d582ba6e5b747c625bf1255e6b1507465494a40a2130978bda7b932c90b", + "sha256:807f52c1f798eef6cf26beb819eeb8819b1622ddfeef9d0977a8502d4db6d534", + "sha256:80ed5e856eb7f30115aaf94e4a08114ccc8813e6ed1b5efa74f9f82e8509858f", + "sha256:8417cb1f36cc0bc7eaba8ccb0e04d55f0ee52df06df3ad55259b9a323555fc8b", + "sha256:8436c508b408b82d87dc5f62496973a1805cd46727c34440b0d29d8a2f50a6c9", + "sha256:89149166622f4db9b4b6a449256291dc87a99ee53151c74cbd82a53c8c2f6ccd", + "sha256:8bfa33f4f2672964266e940dd22a195989ba31669bd84629f05fab3ef4e2d125", + "sha256:8c60ca7339acd497a55b0ea5d506b2a2612afb2826560416f6894e8b5770d4a9", + "sha256:91b36a978b5ae0ee86c394f5a54d6ef44db1de0815eb43de826d41d21e4af3de", + "sha256:955f8851919303c92343d2f66165294848d57e9bba6cf6e3625485a70a038d11", + "sha256:97f68b8d6831127e4787ad15e6757232e14e12060bec17091b85eb1486b91d8d", + "sha256:9b23ca7ef998bc739bf6ffc077c2116917eabcc901f88da1b9856b210ef63f35", + "sha256:9f0b8b1c6d84c8034a44893aba5e767bf9c7a211e313a9605d9c617d7083829f", + "sha256:aabfa34badd18f1da5ec1bc2715cadc8dca465868a4e73a0173466b688f29dda", + "sha256:ab36c8eb7e454e34e60eb55ca5d241a5d18b2c6244f6827a30e451c42410b5f7", + "sha256:b010a7a4fd316c3c484d482922d13044979e78d1861f0e0650423144c616a46a", + "sha256:b1ac5992a838106edb89654e0aebfc24f5848ae2547d22c2c3f66454daa11971", + "sha256:b7b2d86dd06bfc2ade3312a83a5c364c7ec2e3498f8734282c6c3d4b07b346b8", + "sha256:b97e690a2118911e39b4042088092771b4ae3fc3aa86518f84b8cf6888dbdb41", + "sha256:bc2722592d8998c870fa4e290c2eec2c1569b87fe58618e67d38b4665dfa680d", + "sha256:c0429126cf75e16c4f0ad00ee0eae4242dc652290f940152ca8c75c3a4b6ee8f", + "sha256:c30197aa96e8eed02200a83fba2657b4c3acd0f0aa4bdc9f6c1af8e8962e0757", + "sha256:c4c3e6da02df6fa1410a7680bd3f63d4f710232d3139089536310d027950696a", + "sha256:c75cb2a3e389853835e84a2d8fb2b81a10645b503eca9bcb98df6b5a43eb8886", + "sha256:c96836c97b1238e9c9e3fe90844c947d5afbf4f4c92762679acfe19927d81d77", + "sha256:d7f50a1f8c450f3925cb367d011448c39239bb3eb4117c36a6d354794de4ce76", + "sha256:d973f03c0cb71c5ed99037b870f2be986c3c05e63622c017ea9816881d2dd247", + "sha256:d98b1668f06378c6dbefec3b92299716b931cd4e6061f3c875a71ced1780ab85", + "sha256:d9c3cdf5390dcd29aa8056d13e8e99526cda0305acc038b96b30352aff5ff2bb", + "sha256:dad3e487649f498dd991eeb901125411559b22e8d7ab25d3aeb1af367df5efd7", + "sha256:dccbe65bd2f7f7ec22c4ff99ed56faa1e9f785482b9bbd7c717e26fd723a1d1e", + "sha256:dd78cfcda14a1ef52584dbb008f7ac81c1328c0f58184bf9a84c49c605002da6", + "sha256:e218488cd232553829be0664c2292d3af2eeeb94b32bea483cf79ac6a694e037", + "sha256:e358e64305fe12299a08e08978f51fc21fac060dcfcddd95453eabe5b93ed0e1", + "sha256:ea0d8d539afa5eb2728aa1932a988a9a7af94f18582ffae4bc10b3fbdad0626e", + "sha256:eab677309cdb30d047996b36d34caeda1dc91149e4fdca0b1a039b3f79d9a807", + "sha256:eb8178fe3dba6450a3e024e95ac49ed3400e506fd4e9e5c32d30adda88cbd407", + "sha256:ecddf25bee22fe4fe3737a399d0d177d72bc22be6913acfab364b40bce1ba83c", + "sha256:eea6ee1db730b3483adf394ea72f808b6e18cf3cb6454b4d86e04fa8c4327a12", + "sha256:f08ff5e948271dc7e18a35641d2f11a4cd8dfd5634f55228b691e62b37125eb3", + "sha256:f30bf9fd9be89ecb2360c7d94a711f00c09b976258846efe40db3d05828e8089", + "sha256:fa88b843d6e211393a37219e6a1c1df99d35e8fd90446f1118f4216e307e48cd", + "sha256:fc54db6c8593ef7d4b2a331b58653356cf04f67c960f584edb7c3d8c97e8f39e", + "sha256:fd4ec41f914fa74ad1b8304bbc634b3de73d2a0889bd32076342a573e0779e00", + "sha256:ffc9202a29ab3920fa812879e95a9e78b2465fd10be7fcbd042899695d75e616" + ], + "markers": "python_version >= '3.7'", + "version": "==3.4.1" }, "click": { "hashes": [ - "sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28", - "sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de" + "sha256:63c132bbbed01578a06712a2d1f497bb62d9c1c0d329b7903a866228027263b2", + "sha256:ed53c9d8990d83c2a27deae68e4ee337473f6330c040a31d4225c9574d16096a" ], "markers": "python_version >= '3.7'", - "version": "==8.1.7" + "version": "==8.1.8" }, "colorama": { "hashes": [ @@ -198,27 +185,27 @@ }, "dbt-adapters": { "hashes": [ - "sha256:ad3392794ed0504e2082e19b3e447701982af1ab28b91f829bb3feb986bd1b29", - "sha256:f192294112d5722c6a0981a104f7a9f57548aeeefe31b0b9d5708493f74a09f5" + "sha256:2e4e743d3613e7d72319edf6eb85ea2ca57133472e32ff0148c1325f21ff6d16", + "sha256:4888f9b7d0ddb709e8219e722ee01678e31aade2b8b19595cf094a177c71dc56" ], - "markers": "python_full_version >= '3.8.0'", - "version": "==1.7.0" + "markers": "python_full_version >= '3.9.0'", + "version": "==1.13.0" }, "dbt-common": { "hashes": [ - "sha256:458d60383f83c849e8f811e6746366323b85aa9246004ec876eed3f22772eb73", - "sha256:4798b16ea58db0cac6bc86250d2fe696599a7627c304b60dcaa804227c732a9b" + "sha256:2227e24a165780c5368320dedd3c6bc40038dedece48af03daab43c11bf20372", + "sha256:239b568a0dd764a431b93cdfe247628622c975f2eed8abf3bc04f4dc770ad161" ], - "markers": "python_version >= '3.8'", - "version": "==1.11.0" + "markers": "python_version >= '3.9'", + "version": "==1.14.0" }, "dbt-core": { "hashes": [ - "sha256:0786999515f6eb704a0b2337f7d1846fee54eaf74add71e7a1c5f83778fc224f", - "sha256:3dc6a5c994cb58a2448e092bf80c071ae2bfa8e3ecdde8fa4bcd45b78c41695d" + "sha256:38c931dd5206fdb11a9db1decf1075ce891ad9f4692bd00a9ba760a6cfe4358d", + "sha256:a1db009c30f08a95fcf2620f70b2258aeca43a480229d7eb710e2243f5f622ea" ], - "markers": "python_version >= '3.8'", - "version": "==1.8.7" + "markers": "python_version >= '3.9'", + "version": "==1.9.1" }, "dbt-extractor": { "hashes": [ @@ -244,19 +231,19 @@ }, "dbt-semantic-interfaces": { "hashes": [ - "sha256:3a497abef1ba8112affdf804b26bfdcd5468ed95cc924b509068e18d371c7c4d", - "sha256:b95ff3a6721dc30f6278cb84933d95e0ef27766e67eeb6bb41906242e77f7c9b" + "sha256:63965478ef27056f20a8c9a0f59b1355ebbc15133c1a6f0d368d93996a31dd5d", + "sha256:dcedda6702ecabb633aa4e8ab3b1eb7f9c4301dcc0026076a4a0ef64f9e59cf0" ], "markers": "python_version >= '3.8'", - "version": "==0.5.1" + "version": "==0.7.4" }, "dbt-trino": { "hashes": [ - "sha256:5380c38ec8c4ad58829f6b78341eb9d55c6c43ddc5f21b6fdbdb47b1e4f38f2f", - "sha256:fdd8019337bbdfb3810be3c7be52cfe7cb4ec4c07d9187cfbd644ac916ce91cf" + "sha256:1df942e1927bdde641120a2d76dac0a0b2f9360df3fe17489399f0aaac672f41", + "sha256:c665a001a79bc3f9cf71ea20dea56d2efd8af826cb9cf0298725395dfd806421" ], "index": "pypi", - "version": "==1.8.2" + "version": "==1.9.0" }, "deepdiff": { "hashes": [ @@ -291,11 +278,11 @@ }, "identify": { "hashes": [ - "sha256:53863bcac7caf8d2ed85bd20312ea5dcfc22226800f6d6881f232d861db5a8f0", - "sha256:91478c5fb7c3aac5ff7bf9b4344f803843dc586832d5f110d672b19aa1984c98" + "sha256:62f5dae9b5fef52c84cc188514e9ea4f3f636b1d8799ab5ebc475471f9e47a02", + "sha256:9edba65473324c2ea9684b1f944fe3191db3345e50b6d04571d10ed164f8d7bd" ], - "markers": "python_version >= '3.8'", - "version": "==2.6.1" + "markers": "python_version >= '3.9'", + "version": "==2.6.3" }, "idna": { "hashes": [ @@ -330,11 +317,11 @@ }, "jinja2": { "hashes": [ - "sha256:4a3aee7acbbe7303aede8e9648d13b8bf88a429282aa6122a993f0ac800cb369", - "sha256:bc5dd2abb727a5319567b7a813e6a2e7318c39f4f487cfe6c89c6f9c7d25197d" + "sha256:8fefff8dc3034e27bb80d67c671eb8a9bc424c0ef4c0826edbff304cceff43bb", + "sha256:aba0f4dc9ed8013c424088f68a5c226f7d6097ed89b246d7749c2ec4175c6adb" ], "markers": "python_version >= '3.7'", - "version": "==3.1.4" + "version": "==3.1.5" }, "jsonschema": { "hashes": [ @@ -359,20 +346,6 @@ ], "version": "==0.4.0" }, - "logbook": { - "hashes": [ - "sha256:0cf2cdbfb65a03b5987d19109dacad13417809dcf697f66e1a7084fb21744ea9", - "sha256:2dc85f1510533fddb481e97677bb7bca913560862734c0b3b289bfed04f78c92", - "sha256:56ee54c11df3377314cedcd6507638f015b4b88c0238c2e01b5eb44fd3a6ad1b", - "sha256:66f454ada0f56eae43066f604a222b09893f98c1adc18df169710761b8f32fe8", - "sha256:7c533eb728b3d220b1b5414ba4635292d149d79f74f6973b4aa744c850ca944a", - "sha256:8f76a2e7b1f72595f753228732f81ce342caf03babc3fed6bbdcf366f2f20f18", - "sha256:94e2e11ff3c2304b0d09a36c6208e5ae756eb948b210e5cbd63cd8d27f911542", - "sha256:97fee1bd9605f76335b169430ed65e15e457a844b2121bd1d90a08cf7e30aba0", - "sha256:e18f7422214b1cf0240c56f884fd9c9b4ff9d0da2eabca9abccba56df7222f66" - ], - "version": "==1.5.3" - }, "markupsafe": { "hashes": [ "sha256:0bff5e0ae4ef2e1ae4fdf2dfd5b76c75e5c2fa4132d05fc1b0dabcd20c7e28c4", @@ -445,17 +418,11 @@ "msgpack" ], "hashes": [ - "sha256:169f0290253b3e6077bcb39c14a9dd0791a3fdedd9e286e536ae561d4ff1975b", - "sha256:ad0a162b8f4ea232dadd2891d77ff20165b855b9d84610f36ac84462d4576aa0" + "sha256:5ef6f2b963892cbe9a4ceb3441dfbea37f8c3412523f25d42e9b3a7186555f1d", + "sha256:c12a649599a8f7b1a0b35d18f12e678423c3066189f7bc7bd8dd431c5c8132c3" ], "markers": "python_version >= '3.8'", - "version": "==3.13.1" - }, - "minimal-snowplow-tracker": { - "hashes": [ - "sha256:acabf7572db0e7f5cbf6983d495eef54081f71be392330eb3aadb9ccb39daaa4" - ], - "version": "==0.0.2" + "version": "==3.14" }, "more-itertools": { "hashes": [ @@ -611,11 +578,11 @@ }, "packaging": { "hashes": [ - "sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002", - "sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124" + "sha256:09abb1bccd265c01f4a3aa3f7a7db064b36514d2cba19a2f694fe6150451a759", + "sha256:c228a6dc5e932d346bc5739379109d49e8853dd8223571c7c5b55260edc0b97f" ], "markers": "python_version >= '3.8'", - "version": "==24.1" + "version": "==24.2" }, "parsedatetime": { "hashes": [ @@ -658,131 +625,142 @@ }, "protobuf": { "hashes": [ - "sha256:0aebecb809cae990f8129ada5ca273d9d670b76d9bfc9b1809f0a9c02b7dbf41", - "sha256:4be0571adcbe712b282a330c6e89eae24281344429ae95c6d85e79e84780f5ea", - "sha256:5e61fd921603f58d2f5acb2806a929b4675f8874ff5f330b7d6f7e2e784bbcd8", - "sha256:7a183f592dc80aa7c8da7ad9e55091c4ffc9497b3054452d629bb85fa27c2a45", - "sha256:7f8249476b4a9473645db7f8ab42b02fe1488cbe5fb72fddd445e0665afd8584", - "sha256:919ad92d9b0310070f8356c24b855c98df2b8bd207ebc1c0c6fcc9ab1e007f3d", - "sha256:98d8d8aa50de6a2747efd9cceba361c9034050ecce3e09136f90de37ddba66e1", - "sha256:abe32aad8561aa7cc94fc7ba4fdef646e576983edb94a73381b03c53728a626f", - "sha256:b0234dd5a03049e4ddd94b93400b67803c823cfc405689688f59b34e0742381a", - "sha256:b2fde3d805354df675ea4c7c6338c1aecd254dfc9925e88c6d31a2bcb97eb173", - "sha256:fe14e16c22be926d3abfcb500e60cab068baf10b542b8c858fa27e098123e331" + "sha256:13d6d617a2a9e0e82a88113d7191a1baa1e42c2cc6f5f1398d3b054c8e7e714a", + "sha256:2d2e674c58a06311c8e99e74be43e7f3a8d1e2b2fdf845eaa347fbd866f23355", + "sha256:36000f97ea1e76e8398a3f02936aac2a5d2b111aae9920ec1b769fc4a222c4d9", + "sha256:494229ecd8c9009dd71eda5fd57528395d1eacdf307dbece6c12ad0dd09e912e", + "sha256:842de6d9241134a973aab719ab42b008a18a90f9f07f06ba480df268f86432f9", + "sha256:a0c53d78383c851bfa97eb42e3703aefdc96d2036a41482ffd55dc5f529466eb", + "sha256:b2cc8e8bb7c9326996f0e160137b0861f1a82162502658df2951209d0cb0309e", + "sha256:b6b0d416bbbb9d4fbf9d0561dbfc4e324fd522f61f7af0fe0f282ab67b22477e", + "sha256:c12ba8249f5624300cf51c3d0bfe5be71a60c63e4dcf51ffe9a68771d958c851", + "sha256:e621a98c0201a7c8afe89d9646859859be97cb22b8bf1d8eacfd90d5bda2eb19", + "sha256:fde4554c0e578a5a0bcc9a276339594848d1e89f9ea47b4427c80e5d72f90181" ], "markers": "python_version >= '3.8'", - "version": "==4.25.5" + "version": "==5.29.2" }, "pydantic": { "hashes": [ - "sha256:d155cef71265d1e9807ed1c32b4c8deec042a44a50a4188b25ac67ecd81a9c0f", - "sha256:f048cec7b26778210e28a0459867920654d48e5e62db0958433636cde4254f12" + "sha256:597e135ea68be3a37552fb524bc7d0d66dcf93d395acd93a00682f1efcb8ee3d", + "sha256:82f12e9723da6de4fe2ba888b5971157b3be7ad914267dea8f05f82b28254f06" ], "markers": "python_version >= '3.8'", - "version": "==2.9.2" + "version": "==2.10.4" }, "pydantic-core": { "hashes": [ - "sha256:0a7df63886be5e270da67e0966cf4afbae86069501d35c8c1b3b6c168f42cb36", - "sha256:0cb3da3fd1b6a5d0279a01877713dbda118a2a4fc6f0d821a57da2e464793f05", - "sha256:0dbd8dbed2085ed23b5c04afa29d8fd2771674223135dc9bc937f3c09284d071", - "sha256:0dff76e0602ca7d4cdaacc1ac4c005e0ce0dcfe095d5b5259163a80d3a10d327", - "sha256:1278e0d324f6908e872730c9102b0112477a7f7cf88b308e4fc36ce1bdb6d58c", - "sha256:128585782e5bfa515c590ccee4b727fb76925dd04a98864182b22e89a4e6ed36", - "sha256:1498bec4c05c9c787bde9125cfdcc63a41004ff167f495063191b863399b1a29", - "sha256:19442362866a753485ba5e4be408964644dd6a09123d9416c54cd49171f50744", - "sha256:1b84d168f6c48fabd1f2027a3d1bdfe62f92cade1fb273a5d68e621da0e44e6d", - "sha256:1e90d2e3bd2c3863d48525d297cd143fe541be8bbf6f579504b9712cb6b643ec", - "sha256:20152074317d9bed6b7a95ade3b7d6054845d70584216160860425f4fbd5ee9e", - "sha256:216f9b2d7713eb98cb83c80b9c794de1f6b7e3145eef40400c62e86cee5f4e1e", - "sha256:233710f069d251feb12a56da21e14cca67994eab08362207785cf8c598e74577", - "sha256:255a8ef062cbf6674450e668482456abac99a5583bbafb73f9ad469540a3a232", - "sha256:2584f7cf844ac4d970fba483a717dbe10c1c1c96a969bf65d61ffe94df1b2863", - "sha256:2971bb5ffe72cc0f555c13e19b23c85b654dd2a8f7ab493c262071377bfce9f6", - "sha256:29d2c342c4bc01b88402d60189f3df065fb0dda3654744d5a165a5288a657368", - "sha256:2e203fdf807ac7e12ab59ca2bfcabb38c7cf0b33c41efeb00f8e5da1d86af480", - "sha256:33e3d65a85a2a4a0dc3b092b938a4062b1a05f3a9abde65ea93b233bca0e03f2", - "sha256:374a5e5049eda9e0a44c696c7ade3ff355f06b1fe0bb945ea3cac2bc336478a2", - "sha256:37b0fe330e4a58d3c58b24d91d1eb102aeec675a3db4c292ec3928ecd892a9a6", - "sha256:3d5639516376dce1940ea36edf408c554475369f5da2abd45d44621cb616f769", - "sha256:42c6dcb030aefb668a2b7009c85b27f90e51e6a3b4d5c9bc4c57631292015b0d", - "sha256:4a7cd62e831afe623fbb7aabbb4fe583212115b3ef38a9f6b71869ba644624a2", - "sha256:4ba762ed58e8d68657fc1281e9bb72e1c3e79cc5d464be146e260c541ec12d84", - "sha256:4fc714bdbfb534f94034efaa6eadd74e5b93c8fa6315565a222f7b6f42ca1166", - "sha256:4ffa2ebd4c8530079140dd2d7f794a9d9a73cbb8e9d59ffe24c63436efa8f271", - "sha256:5a1504ad17ba4210df3a045132a7baeeba5a200e930f57512ee02909fc5c4cb5", - "sha256:5c364564d17da23db1106787675fc7af45f2f7b58b4173bfdd105564e132e6fb", - "sha256:5e11661ce0fd30a6790e8bcdf263b9ec5988e95e63cf901972107efc49218b13", - "sha256:5f54b118ce5de9ac21c363d9b3caa6c800341e8c47a508787e5868c6b79c9323", - "sha256:5f5ff8d839f4566a474a969508fe1c5e59c31c80d9e140566f9a37bba7b8d556", - "sha256:61817945f2fe7d166e75fbfb28004034b48e44878177fc54d81688e7b85a3665", - "sha256:624e278a7d29b6445e4e813af92af37820fafb6dcc55c012c834f9e26f9aaaef", - "sha256:63e46b3169866bd62849936de036f901a9356e36376079b05efa83caeaa02ceb", - "sha256:6531b7ca5f951d663c339002e91aaebda765ec7d61b7d1e3991051906ddde119", - "sha256:68665f4c17edcceecc112dfed5dbe6f92261fb9d6054b47d01bf6371a6196126", - "sha256:696dd8d674d6ce621ab9d45b205df149399e4bb9aa34102c970b721554828510", - "sha256:6f783e0ec4803c787bcea93e13e9932edab72068f68ecffdf86a99fd5918878b", - "sha256:723314c1d51722ab28bfcd5240d858512ffd3116449c557a1336cbe3919beb87", - "sha256:74b9127ffea03643e998e0c5ad9bd3811d3dac8c676e47db17b0ee7c3c3bf35f", - "sha256:7530e201d10d7d14abce4fb54cfe5b94a0aefc87da539d0346a484ead376c3cc", - "sha256:77733e3892bb0a7fa797826361ce8a9184d25c8dffaec60b7ffe928153680ba8", - "sha256:78ddaaa81421a29574a682b3179d4cf9e6d405a09b99d93ddcf7e5239c742e21", - "sha256:7c9129eb40958b3d4500fa2467e6a83356b3b61bfff1b414c7361d9220f9ae8f", - "sha256:7d32706badfe136888bdea71c0def994644e09fff0bfe47441deaed8e96fdbc6", - "sha256:81965a16b675b35e1d09dd14df53f190f9129c0202356ed44ab2728b1c905658", - "sha256:8394d940e5d400d04cad4f75c0598665cbb81aecefaca82ca85bd28264af7f9b", - "sha256:86d2f57d3e1379a9525c5ab067b27dbb8a0642fb5d454e17a9ac434f9ce523e3", - "sha256:883a91b5dd7d26492ff2f04f40fbb652de40fcc0afe07e8129e8ae779c2110eb", - "sha256:88ad334a15b32a791ea935af224b9de1bf99bcd62fabf745d5f3442199d86d59", - "sha256:9261d3ce84fa1d38ed649c3638feefeae23d32ba9182963e465d58d62203bd24", - "sha256:97df63000f4fea395b2824da80e169731088656d1818a11b95f3b173747b6cd9", - "sha256:98d134c954828488b153d88ba1f34e14259284f256180ce659e8d83e9c05eaa3", - "sha256:996a38a83508c54c78a5f41456b0103c30508fed9abcad0a59b876d7398f25fd", - "sha256:9a5bce9d23aac8f0cf0836ecfc033896aa8443b501c58d0602dbfd5bd5b37753", - "sha256:9a6b5099eeec78827553827f4c6b8615978bb4b6a88e5d9b93eddf8bb6790f55", - "sha256:9d18368b137c6295db49ce7218b1a9ba15c5bc254c96d7c9f9e924a9bc7825ad", - "sha256:a4fa4fc04dff799089689f4fd502ce7d59de529fc2f40a2c8836886c03e0175a", - "sha256:a5c7ba8ffb6d6f8f2ab08743be203654bb1aaa8c9dcb09f82ddd34eadb695605", - "sha256:aea443fffa9fbe3af1a9ba721a87f926fe548d32cab71d188a6ede77d0ff244e", - "sha256:b10bd51f823d891193d4717448fab065733958bdb6a6b351967bd349d48d5c9b", - "sha256:ba1a0996f6c2773bd83e63f18914c1de3c9dd26d55f4ac302a7efe93fb8e7433", - "sha256:bb2802e667b7051a1bebbfe93684841cc9351004e2badbd6411bf357ab8d5ac8", - "sha256:cfdd16ab5e59fc31b5e906d1a3f666571abc367598e3e02c83403acabc092e07", - "sha256:d06b0c8da4f16d1d1e352134427cb194a0a6e19ad5db9161bf32b2113409e728", - "sha256:d0776dea117cf5272382634bd2a5c1b6eb16767c223c6a5317cd3e2a757c61a0", - "sha256:d18ca8148bebe1b0a382a27a8ee60350091a6ddaf475fa05ef50dc35b5df6327", - "sha256:d4488a93b071c04dc20f5cecc3631fc78b9789dd72483ba15d423b5b3689b555", - "sha256:d5f7a395a8cf1621939692dba2a6b6a830efa6b3cee787d82c7de1ad2930de64", - "sha256:d7a80d21d613eec45e3d41eb22f8f94ddc758a6c4720842dc74c0581f54993d6", - "sha256:d97683ddee4723ae8c95d1eddac7c192e8c552da0c73a925a89fa8649bf13eea", - "sha256:dcedcd19a557e182628afa1d553c3895a9f825b936415d0dbd3cd0bbcfd29b4b", - "sha256:de6d1d1b9e5101508cb37ab0d972357cac5235f5c6533d1071964c47139257df", - "sha256:df49e7a0861a8c36d089c1ed57d308623d60416dab2647a4a17fe050ba85de0e", - "sha256:df933278128ea1cd77772673c73954e53a1c95a4fdf41eef97c2b779271bd0bd", - "sha256:e08277a400de01bc72436a0ccd02bdf596631411f592ad985dcee21445bd0068", - "sha256:e38e63e6f3d1cec5a27e0afe90a085af8b6806ee208b33030e65b6516353f1a3", - "sha256:e55541f756f9b3ee346b840103f32779c695a19826a4c442b7954550a0972040", - "sha256:ec4e55f79b1c4ffb2eecd8a0cfba9955a2588497d96851f4c8f99aa4a1d39b12", - "sha256:ed1a53de42fbe34853ba90513cea21673481cd81ed1be739f7f2efb931b24916", - "sha256:ed541d70698978a20eb63d8c5d72f2cc6d7079d9d90f6b50bad07826f1320f5f", - "sha256:f09e2ff1f17c2b51f2bc76d1cc33da96298f0a036a137f5440ab3ec5360b624f", - "sha256:f220b0eea5965dec25480b6333c788fb72ce5f9129e8759ef876a1d805d00801", - "sha256:f3e0da4ebaef65158d4dfd7d3678aad692f7666877df0002b8a522cdf088f231", - "sha256:f455ee30a9d61d3e1a15abd5068827773d6e4dc513e795f380cdd59932c782d5", - "sha256:f5ef8f42bec47f21d07668a043f077d507e5bf4e668d5c6dfe6aaba89de1a5b8", - "sha256:f69a8e0b033b747bb3e36a44e7732f0c99f7edd5cea723d45bc0d6e95377ffee", - "sha256:ff02b6d461a6de369f07ec15e465a88895f3223eb75073ffea56b84d9331f607" + "sha256:00bad2484fa6bda1e216e7345a798bd37c68fb2d97558edd584942aa41b7d278", + "sha256:0296abcb83a797db256b773f45773da397da75a08f5fcaef41f2044adec05f50", + "sha256:03d0f86ea3184a12f41a2d23f7ccb79cdb5a18e06993f8a45baa8dfec746f0e9", + "sha256:044a50963a614ecfae59bb1eaf7ea7efc4bc62f49ed594e18fa1e5d953c40e9f", + "sha256:05e3a55d124407fffba0dd6b0c0cd056d10e983ceb4e5dbd10dda135c31071d6", + "sha256:08e125dbdc505fa69ca7d9c499639ab6407cfa909214d500897d02afb816e7cc", + "sha256:097830ed52fd9e427942ff3b9bc17fab52913b2f50f2880dc4a5611446606a54", + "sha256:0d1e85068e818c73e048fe28cfc769040bb1f475524f4745a5dc621f75ac7630", + "sha256:0d75070718e369e452075a6017fbf187f788e17ed67a3abd47fa934d001863d9", + "sha256:14d4a5c49d2f009d62a2a7140d3064f686d17a5d1a268bc641954ba181880236", + "sha256:172fce187655fece0c90d90a678424b013f8fbb0ca8b036ac266749c09438cb7", + "sha256:18a101c168e4e092ab40dbc2503bdc0f62010e95d292b27827871dc85450d7ee", + "sha256:1a4207639fb02ec2dbb76227d7c751a20b1a6b4bc52850568e52260cae64ca3b", + "sha256:1c1fd185014191700554795c99b347d64f2bb637966c4cfc16998a0ca700d048", + "sha256:1e2cb691ed9834cd6a8be61228471d0a503731abfb42f82458ff27be7b2186fc", + "sha256:1ebaf1d0481914d004a573394f4be3a7616334be70261007e47c2a6fe7e50130", + "sha256:220f892729375e2d736b97d0e51466252ad84c51857d4d15f5e9692f9ef12be4", + "sha256:251136cdad0cb722e93732cb45ca5299fb56e1344a833640bf93b2803f8d1bfd", + "sha256:26f0d68d4b235a2bae0c3fc585c585b4ecc51382db0e3ba402a22cbc440915e4", + "sha256:26f32e0adf166a84d0cb63be85c562ca8a6fa8de28e5f0d92250c6b7e9e2aff7", + "sha256:280d219beebb0752699480fe8f1dc61ab6615c2046d76b7ab7ee38858de0a4e7", + "sha256:28ccb213807e037460326424ceb8b5245acb88f32f3d2777427476e1b32c48c4", + "sha256:2bf14caea37e91198329b828eae1618c068dfb8ef17bb33287a7ad4b61ac314e", + "sha256:2d367ca20b2f14095a8f4fa1210f5a7b78b8a20009ecced6b12818f455b1e9fa", + "sha256:30c5f68ded0c36466acede341551106821043e9afaad516adfb6e8fa80a4e6a6", + "sha256:337b443af21d488716f8d0b6164de833e788aa6bd7e3a39c005febc1284f4962", + "sha256:3911ac9284cd8a1792d3cb26a2da18f3ca26c6908cc434a18f730dc0db7bfa3b", + "sha256:3d591580c34f4d731592f0e9fe40f9cc1b430d297eecc70b962e93c5c668f15f", + "sha256:3de3ce3c9ddc8bbd88f6e0e304dea0e66d843ec9de1b0042b0911c1663ffd474", + "sha256:3de9961f2a346257caf0aa508a4da705467f53778e9ef6fe744c038119737ef5", + "sha256:40d02e7d45c9f8af700f3452f329ead92da4c5f4317ca9b896de7ce7199ea459", + "sha256:42c5f762659e47fdb7b16956c71598292f60a03aa92f8b6351504359dbdba6cf", + "sha256:47956ae78b6422cbd46f772f1746799cbb862de838fd8d1fbd34a82e05b0983a", + "sha256:491a2b73db93fab69731eaee494f320faa4e093dbed776be1a829c2eb222c34c", + "sha256:4c9775e339e42e79ec99c441d9730fccf07414af63eac2f0e48e08fd38a64d76", + "sha256:4e0b4220ba5b40d727c7f879eac379b822eee5d8fff418e9d3381ee45b3b0362", + "sha256:50a68f3e3819077be2c98110c1f9dcb3817e93f267ba80a2c05bb4f8799e2ff4", + "sha256:519f29f5213271eeeeb3093f662ba2fd512b91c5f188f3bb7b27bc5973816934", + "sha256:521eb9b7f036c9b6187f0b47318ab0d7ca14bd87f776240b90b21c1f4f149320", + "sha256:57762139821c31847cfb2df63c12f725788bd9f04bc2fb392790959b8f70f118", + "sha256:5e4f4bb20d75e9325cc9696c6802657b58bc1dbbe3022f32cc2b2b632c3fbb96", + "sha256:5e68c4446fe0810e959cdff46ab0a41ce2f2c86d227d96dc3847af0ba7def306", + "sha256:669e193c1c576a58f132e3158f9dfa9662969edb1a250c54d8fa52590045f046", + "sha256:688d3fd9fcb71f41c4c015c023d12a79d1c4c0732ec9eb35d96e3388a120dcf3", + "sha256:6fb4aadc0b9a0c063206846d603b92030eb6f03069151a625667f982887153e2", + "sha256:7041c36f5680c6e0f08d922aed302e98b3745d97fe1589db0a3eebf6624523af", + "sha256:71b24c7d61131bb83df10cc7e687433609963a944ccf45190cfc21e0887b08c9", + "sha256:77d1bca19b0f7021b3a982e6f903dcd5b2b06076def36a652e3907f596e29f67", + "sha256:7969e133a6f183be60e9f6f56bfae753585680f3b7307a8e555a948d443cc05a", + "sha256:7a66efda2387de898c8f38c0cf7f14fca0b51a8ef0b24bfea5849f1b3c95af27", + "sha256:7d0c8399fcc1848491f00e0314bd59fb34a9c008761bcb422a057670c3f65e35", + "sha256:7d14bd329640e63852364c306f4d23eb744e0f8193148d4044dd3dacdaacbd8b", + "sha256:7e17b560be3c98a8e3aa66ce828bdebb9e9ac6ad5466fba92eb74c4c95cb1151", + "sha256:8083d4e875ebe0b864ffef72a4304827015cff328a1be6e22cc850753bfb122b", + "sha256:82f91663004eb8ed30ff478d77c4d1179b3563df6cdb15c0817cd1cdaf34d154", + "sha256:82f986faf4e644ffc189a7f1aafc86e46ef70372bb153e7001e8afccc6e54133", + "sha256:83097677b8e3bd7eaa6775720ec8e0405f1575015a463285a92bfdfe254529ef", + "sha256:85210c4d99a0114f5a9481b44560d7d1e35e32cc5634c656bc48e590b669b145", + "sha256:8c19d1ea0673cd13cc2f872f6c9ab42acc4e4f492a7ca9d3795ce2b112dd7e15", + "sha256:8d9b3388db186ba0c099a6d20f0604a44eabdeef1777ddd94786cdae158729e4", + "sha256:8e10c99ef58cfdf2a66fc15d66b16c4a04f62bca39db589ae8cba08bc55331bc", + "sha256:953101387ecf2f5652883208769a79e48db18c6df442568a0b5ccd8c2723abee", + "sha256:9c3ed807c7b91de05e63930188f19e921d1fe90de6b4f5cd43ee7fcc3525cb8c", + "sha256:9e0c8cfefa0ef83b4da9588448b6d8d2a2bf1a53c3f1ae5fca39eb3061e2f0b0", + "sha256:9fdbe7629b996647b99c01b37f11170a57ae675375b14b8c13b8518b8320ced5", + "sha256:a0fcd29cd6b4e74fe8ddd2c90330fd8edf2e30cb52acda47f06dd615ae72da57", + "sha256:ac4dbfd1691affb8f48c2c13241a2e3b60ff23247cbcf981759c768b6633cf8b", + "sha256:b0cb791f5b45307caae8810c2023a184c74605ec3bcbb67d13846c28ff731ff8", + "sha256:ba5dd002f88b78a4215ed2f8ddbdf85e8513382820ba15ad5ad8955ce0ca19a1", + "sha256:bca101c00bff0adb45a833f8451b9105d9df18accb8743b08107d7ada14bd7da", + "sha256:bd8086fa684c4775c27f03f062cbb9eaa6e17f064307e86b21b9e0abc9c0f02e", + "sha256:bec317a27290e2537f922639cafd54990551725fc844249e64c523301d0822fc", + "sha256:c10eb4f1659290b523af58fa7cffb452a61ad6ae5613404519aee4bfbf1df993", + "sha256:c33939a82924da9ed65dab5a65d427205a73181d8098e79b6b426bdf8ad4e656", + "sha256:c61709a844acc6bf0b7dce7daae75195a10aac96a596ea1b776996414791ede4", + "sha256:c70c26d2c99f78b125a3459f8afe1aed4d9687c24fd677c6a4436bc042e50d6c", + "sha256:c817e2b40aba42bac6f457498dacabc568c3b7a986fc9ba7c8d9d260b71485fb", + "sha256:cabb9bcb7e0d97f74df8646f34fc76fbf793b7f6dc2438517d7a9e50eee4f14d", + "sha256:cc3f1a99a4f4f9dd1de4fe0312c114e740b5ddead65bb4102884b384c15d8bc9", + "sha256:cca63613e90d001b9f2f9a9ceb276c308bfa2a43fafb75c8031c4f66039e8c6e", + "sha256:ce8918cbebc8da707ba805b7fd0b382816858728ae7fe19a942080c24e5b7cd1", + "sha256:d2088237af596f0a524d3afc39ab3b036e8adb054ee57cbb1dcf8e09da5b29cc", + "sha256:d262606bf386a5ba0b0af3b97f37c83d7011439e3dc1a9298f21efb292e42f1a", + "sha256:d2d63f1215638d28221f664596b1ccb3944f6e25dd18cd3b86b0a4c408d5ebb9", + "sha256:d3e8d504bdd3f10835468f29008d72fc8359d95c9c415ce6e767203db6127506", + "sha256:d4041c0b966a84b4ae7a09832eb691a35aec90910cd2dbe7a208de59be77965b", + "sha256:d716e2e30c6f140d7560ef1538953a5cd1a87264c737643d481f2779fc247fe1", + "sha256:d81d2068e1c1228a565af076598f9e7451712700b673de8f502f0334f281387d", + "sha256:d9640b0059ff4f14d1f37321b94061c6db164fbe49b334b31643e0528d100d99", + "sha256:de3cd1899e2c279b140adde9357c4495ed9d47131b4a4eaff9052f23398076b3", + "sha256:e0fd26b16394ead34a424eecf8a31a1f5137094cabe84a1bcb10fa6ba39d3d31", + "sha256:e2bb4d3e5873c37bb3dd58714d4cd0b0e6238cebc4177ac8fe878f8b3aa8e74c", + "sha256:eb026e5a4c1fee05726072337ff51d1efb6f59090b7da90d30ea58625b1ffb39", + "sha256:eda3f5c2a021bbc5d976107bb302e0131351c2ba54343f8a496dc8783d3d3a6a", + "sha256:ef592d4bad47296fb11f96cd7dc898b92e795032b4894dfb4076cfccd43a9308", + "sha256:f141ee28a0ad2123b6611b6ceff018039df17f32ada8b534e6aa039545a3efb2", + "sha256:f66d89ba397d92f840f8654756196d93804278457b5fbede59598a1f9f90b228", + "sha256:f6f8e111843bbb0dee4cb6594cdc73e79b3329b526037ec242a3e49012495b3b", + "sha256:fa8e459d4954f608fa26116118bb67f56b93b209c39b008277ace29937453dc9", + "sha256:fd1aea04935a508f62e0d0ef1f5ae968774a32afc306fb8545e06f5ff5cdf3ad" ], "markers": "python_version >= '3.8'", - "version": "==2.23.4" + "version": "==2.27.2" }, "pytest": { "hashes": [ - "sha256:70b98107bd648308a7952b06e6ca9a50bc660be218d53c257cc1fc94fda10181", - "sha256:a6853c7375b2663155079443d2e45de913a911a11d669df02a50814944db57b2" + "sha256:50e16d954148559c9a74109af1eaf0c945ba2d8f30f0a3d3335edde19788b6f6", + "sha256:965370d062bce11e73868e0335abac31b4d3de0e82f4007408d242b4f8610761" ], "index": "pypi", - "version": "==8.3.3" + "version": "==8.3.4" }, "python-dateutil": { "hashes": [ @@ -891,128 +869,135 @@ }, "rpds-py": { "hashes": [ - "sha256:06db23d43f26478303e954c34c75182356ca9aa7797d22c5345b16871ab9c45c", - "sha256:0e13e6952ef264c40587d510ad676a988df19adea20444c2b295e536457bc585", - "sha256:11ef6ce74616342888b69878d45e9f779b95d4bd48b382a229fe624a409b72c5", - "sha256:1259c7b3705ac0a0bd38197565a5d603218591d3f6cee6e614e380b6ba61c6f6", - "sha256:18d7585c463087bddcfa74c2ba267339f14f2515158ac4db30b1f9cbdb62c8ef", - "sha256:1e0f80b739e5a8f54837be5d5c924483996b603d5502bfff79bf33da06164ee2", - "sha256:1e5f3cd7397c8f86c8cc72d5a791071431c108edd79872cdd96e00abd8497d29", - "sha256:220002c1b846db9afd83371d08d239fdc865e8f8c5795bbaec20916a76db3318", - "sha256:22e6c9976e38f4d8c4a63bd8a8edac5307dffd3ee7e6026d97f3cc3a2dc02a0b", - "sha256:238a2d5b1cad28cdc6ed15faf93a998336eb041c4e440dd7f902528b8891b399", - "sha256:2580b0c34583b85efec8c5c5ec9edf2dfe817330cc882ee972ae650e7b5ef739", - "sha256:28527c685f237c05445efec62426d285e47a58fb05ba0090a4340b73ecda6dee", - "sha256:2cf126d33a91ee6eedc7f3197b53e87a2acdac63602c0f03a02dd69e4b138174", - "sha256:338ca4539aad4ce70a656e5187a3a31c5204f261aef9f6ab50e50bcdffaf050a", - "sha256:39ed0d010457a78f54090fafb5d108501b5aa5604cc22408fc1c0c77eac14344", - "sha256:3ad0fda1635f8439cde85c700f964b23ed5fc2d28016b32b9ee5fe30da5c84e2", - "sha256:3d2b1ad682a3dfda2a4e8ad8572f3100f95fad98cb99faf37ff0ddfe9cbf9d03", - "sha256:3d61339e9f84a3f0767b1995adfb171a0d00a1185192718a17af6e124728e0f5", - "sha256:3fde368e9140312b6e8b6c09fb9f8c8c2f00999d1823403ae90cc00480221b22", - "sha256:40ce74fc86ee4645d0a225498d091d8bc61f39b709ebef8204cb8b5a464d3c0e", - "sha256:49a8063ea4296b3a7e81a5dfb8f7b2d73f0b1c20c2af401fb0cdf22e14711a96", - "sha256:4a1f1d51eccb7e6c32ae89243cb352389228ea62f89cd80823ea7dd1b98e0b91", - "sha256:4b16aa0107ecb512b568244ef461f27697164d9a68d8b35090e9b0c1c8b27752", - "sha256:4f1ed4749a08379555cebf4650453f14452eaa9c43d0a95c49db50c18b7da075", - "sha256:4fe84294c7019456e56d93e8ababdad5a329cd25975be749c3f5f558abb48253", - "sha256:50eccbf054e62a7b2209b28dc7a22d6254860209d6753e6b78cfaeb0075d7bee", - "sha256:514b3293b64187172bc77c8fb0cdae26981618021053b30d8371c3a902d4d5ad", - "sha256:54b43a2b07db18314669092bb2de584524d1ef414588780261e31e85846c26a5", - "sha256:55fea87029cded5df854ca7e192ec7bdb7ecd1d9a3f63d5c4eb09148acf4a7ce", - "sha256:569b3ea770c2717b730b61998b6c54996adee3cef69fc28d444f3e7920313cf7", - "sha256:56e27147a5a4c2c21633ff8475d185734c0e4befd1c989b5b95a5d0db699b21b", - "sha256:57eb94a8c16ab08fef6404301c38318e2c5a32216bf5de453e2714c964c125c8", - "sha256:5a35df9f5548fd79cb2f52d27182108c3e6641a4feb0f39067911bf2adaa3e57", - "sha256:5a8c94dad2e45324fc74dce25e1645d4d14df9a4e54a30fa0ae8bad9a63928e3", - "sha256:5b4f105deeffa28bbcdff6c49b34e74903139afa690e35d2d9e3c2c2fba18cec", - "sha256:5c1dc0f53856b9cc9a0ccca0a7cc61d3d20a7088201c0937f3f4048c1718a209", - "sha256:614fdafe9f5f19c63ea02817fa4861c606a59a604a77c8cdef5aa01d28b97921", - "sha256:617c7357272c67696fd052811e352ac54ed1d9b49ab370261a80d3b6ce385045", - "sha256:65794e4048ee837494aea3c21a28ad5fc080994dfba5b036cf84de37f7ad5074", - "sha256:6632f2d04f15d1bd6fe0eedd3b86d9061b836ddca4c03d5cf5c7e9e6b7c14580", - "sha256:6c8ef2ebf76df43f5750b46851ed1cdf8f109d7787ca40035fe19fbdc1acc5a7", - "sha256:758406267907b3781beee0f0edfe4a179fbd97c0be2e9b1154d7f0a1279cf8e5", - "sha256:7e60cb630f674a31f0368ed32b2a6b4331b8350d67de53c0359992444b116dd3", - "sha256:89c19a494bf3ad08c1da49445cc5d13d8fefc265f48ee7e7556839acdacf69d0", - "sha256:8a86a9b96070674fc88b6f9f71a97d2c1d3e5165574615d1f9168ecba4cecb24", - "sha256:8bc7690f7caee50b04a79bf017a8d020c1f48c2a1077ffe172abec59870f1139", - "sha256:8d7919548df3f25374a1f5d01fbcd38dacab338ef5f33e044744b5c36729c8db", - "sha256:9426133526f69fcaba6e42146b4e12d6bc6c839b8b555097020e2b78ce908dcc", - "sha256:9824fb430c9cf9af743cf7aaf6707bf14323fb51ee74425c380f4c846ea70789", - "sha256:9bb4a0d90fdb03437c109a17eade42dfbf6190408f29b2744114d11586611d6f", - "sha256:9bc2d153989e3216b0559251b0c260cfd168ec78b1fac33dd485750a228db5a2", - "sha256:9d35cef91e59ebbeaa45214861874bc6f19eb35de96db73e467a8358d701a96c", - "sha256:a1862d2d7ce1674cffa6d186d53ca95c6e17ed2b06b3f4c476173565c862d232", - "sha256:a84ab91cbe7aab97f7446652d0ed37d35b68a465aeef8fc41932a9d7eee2c1a6", - "sha256:aa7f429242aae2947246587d2964fad750b79e8c233a2367f71b554e9447949c", - "sha256:aa9a0521aeca7d4941499a73ad7d4f8ffa3d1affc50b9ea11d992cd7eff18a29", - "sha256:ac2f4f7a98934c2ed6505aead07b979e6f999389f16b714448fb39bbaa86a489", - "sha256:ae94bd0b2f02c28e199e9bc51485d0c5601f58780636185660f86bf80c89af94", - "sha256:af0fc424a5842a11e28956e69395fbbeab2c97c42253169d87e90aac2886d751", - "sha256:b2a5db5397d82fa847e4c624b0c98fe59d2d9b7cf0ce6de09e4d2e80f8f5b3f2", - "sha256:b4c29cbbba378759ac5786730d1c3cb4ec6f8ababf5c42a9ce303dc4b3d08cda", - "sha256:b74b25f024b421d5859d156750ea9a65651793d51b76a2e9238c05c9d5f203a9", - "sha256:b7f19250ceef892adf27f0399b9e5afad019288e9be756d6919cb58892129f51", - "sha256:b80d4a7900cf6b66bb9cee5c352b2d708e29e5a37fe9bf784fa97fc11504bf6c", - "sha256:b8c00a3b1e70c1d3891f0db1b05292747f0dbcfb49c43f9244d04c70fbc40eb8", - "sha256:bb273176be34a746bdac0b0d7e4e2c467323d13640b736c4c477881a3220a989", - "sha256:c3c20f0ddeb6e29126d45f89206b8291352b8c5b44384e78a6499d68b52ae511", - "sha256:c3e130fd0ec56cb76eb49ef52faead8ff09d13f4527e9b0c400307ff72b408e1", - "sha256:c52d3f2f82b763a24ef52f5d24358553e8403ce05f893b5347098014f2d9eff2", - "sha256:c6377e647bbfd0a0b159fe557f2c6c602c159fc752fa316572f012fc0bf67150", - "sha256:c638144ce971df84650d3ed0096e2ae7af8e62ecbbb7b201c8935c370df00a2c", - "sha256:ce9845054c13696f7af7f2b353e6b4f676dab1b4b215d7fe5e05c6f8bb06f965", - "sha256:cf258ede5bc22a45c8e726b29835b9303c285ab46fc7c3a4cc770736b5304c9f", - "sha256:d0a26ffe9d4dd35e4dfdd1e71f46401cff0181c75ac174711ccff0459135fa58", - "sha256:d0b67d87bb45ed1cd020e8fbf2307d449b68abc45402fe1a4ac9e46c3c8b192b", - "sha256:d20277fd62e1b992a50c43f13fbe13277a31f8c9f70d59759c88f644d66c619f", - "sha256:d454b8749b4bd70dd0a79f428731ee263fa6995f83ccb8bada706e8d1d3ff89d", - "sha256:d4c7d1a051eeb39f5c9547e82ea27cbcc28338482242e3e0b7768033cb083821", - "sha256:d72278a30111e5b5525c1dd96120d9e958464316f55adb030433ea905866f4de", - "sha256:d72a210824facfdaf8768cf2d7ca25a042c30320b3020de2fa04640920d4e121", - "sha256:d807dc2051abe041b6649681dce568f8e10668e3c1c6543ebae58f2d7e617855", - "sha256:dbe982f38565bb50cb7fb061ebf762c2f254ca3d8c20d4006878766e84266272", - "sha256:dcedf0b42bcb4cfff4101d7771a10532415a6106062f005ab97d1d0ab5681c60", - "sha256:deb62214c42a261cb3eb04d474f7155279c1a8a8c30ac89b7dcb1721d92c3c02", - "sha256:def7400461c3a3f26e49078302e1c1b38f6752342c77e3cf72ce91ca69fb1bc1", - "sha256:df3de6b7726b52966edf29663e57306b23ef775faf0ac01a3e9f4012a24a4140", - "sha256:e1940dae14e715e2e02dfd5b0f64a52e8374a517a1e531ad9412319dc3ac7879", - "sha256:e4df1e3b3bec320790f699890d41c59d250f6beda159ea3c44c3f5bac1976940", - "sha256:e6900ecdd50ce0facf703f7a00df12374b74bbc8ad9fe0f6559947fb20f82364", - "sha256:ea438162a9fcbee3ecf36c23e6c68237479f89f962f82dae83dc15feeceb37e4", - "sha256:eb851b7df9dda52dc1415ebee12362047ce771fc36914586b2e9fcbd7d293b3e", - "sha256:ec31a99ca63bf3cd7f1a5ac9fe95c5e2d060d3c768a09bc1d16e235840861420", - "sha256:f0475242f447cc6cb8a9dd486d68b2ef7fbee84427124c232bff5f63b1fe11e5", - "sha256:f2fbf7db2012d4876fb0d66b5b9ba6591197b0f165db8d99371d976546472a24", - "sha256:f60012a73aa396be721558caa3a6fd49b3dd0033d1675c6d59c4502e870fcf0c", - "sha256:f8e604fe73ba048c06085beaf51147eaec7df856824bfe7b98657cf436623daf", - "sha256:f90a4cd061914a60bd51c68bcb4357086991bd0bb93d8aa66a6da7701370708f", - "sha256:f918a1a130a6dfe1d7fe0f105064141342e7dd1611f2e6a21cd2f5c8cb1cfb3e", - "sha256:fa518bcd7600c584bf42e6617ee8132869e877db2f76bcdc281ec6a4113a53ab", - "sha256:faefcc78f53a88f3076b7f8be0a8f8d35133a3ecf7f3770895c25f8813460f08", - "sha256:fcaeb7b57f1a1e071ebd748984359fef83ecb026325b9d4ca847c95bc7311c92", - "sha256:fd2d84f40633bc475ef2d5490b9c19543fbf18596dcb1b291e3a12ea5d722f7a", - "sha256:fdfc3a892927458d98f3d55428ae46b921d1f7543b89382fdb483f5640daaec8" + "sha256:009de23c9c9ee54bf11303a966edf4d9087cd43a6003672e6aa7def643d06518", + "sha256:02fbb9c288ae08bcb34fb41d516d5eeb0455ac35b5512d03181d755d80810059", + "sha256:0a0461200769ab3b9ab7e513f6013b7a97fdeee41c29b9db343f3c5a8e2b9e61", + "sha256:0b09865a9abc0ddff4e50b5ef65467cd94176bf1e0004184eb915cbc10fc05c5", + "sha256:0b8db6b5b2d4491ad5b6bdc2bc7c017eec108acbf4e6785f42a9eb0ba234f4c9", + "sha256:0c150c7a61ed4a4f4955a96626574e9baf1adf772c2fb61ef6a5027e52803543", + "sha256:0f3cec041684de9a4684b1572fe28c7267410e02450f4561700ca5a3bc6695a2", + "sha256:1352ae4f7c717ae8cba93421a63373e582d19d55d2ee2cbb184344c82d2ae55a", + "sha256:177c7c0fce2855833819c98e43c262007f42ce86651ffbb84f37883308cb0e7d", + "sha256:1978d0021e943aae58b9b0b196fb4895a25cc53d3956b8e35e0b7682eefb6d56", + "sha256:1a60bce91f81ddaac922a40bbb571a12c1070cb20ebd6d49c48e0b101d87300d", + "sha256:1aef18820ef3e4587ebe8b3bc9ba6e55892a6d7b93bac6d29d9f631a3b4befbd", + "sha256:1e9663daaf7a63ceccbbb8e3808fe90415b0757e2abddbfc2e06c857bf8c5e2b", + "sha256:20070c65396f7373f5df4005862fa162db5d25d56150bddd0b3e8214e8ef45b4", + "sha256:214b7a953d73b5e87f0ebece4a32a5bd83c60a3ecc9d4ec8f1dca968a2d91e99", + "sha256:22bebe05a9ffc70ebfa127efbc429bc26ec9e9b4ee4d15a740033efda515cf3d", + "sha256:24e8abb5878e250f2eb0d7859a8e561846f98910326d06c0d51381fed59357bd", + "sha256:26fd7cac7dd51011a245f29a2cc6489c4608b5a8ce8d75661bb4a1066c52dfbe", + "sha256:27b1d3b3915a99208fee9ab092b8184c420f2905b7d7feb4aeb5e4a9c509b8a1", + "sha256:27e98004595899949bd7a7b34e91fa7c44d7a97c40fcaf1d874168bb652ec67e", + "sha256:2b8f60e1b739a74bab7e01fcbe3dddd4657ec685caa04681df9d562ef15b625f", + "sha256:2de29005e11637e7a2361fa151f780ff8eb2543a0da1413bb951e9f14b699ef3", + "sha256:2e8b55d8517a2fda8d95cb45d62a5a8bbf9dd0ad39c5b25c8833efea07b880ca", + "sha256:2fa4331c200c2521512595253f5bb70858b90f750d39b8cbfd67465f8d1b596d", + "sha256:3445e07bf2e8ecfeef6ef67ac83de670358abf2996916039b16a218e3d95e97e", + "sha256:3453e8d41fe5f17d1f8e9c383a7473cd46a63661628ec58e07777c2fff7196dc", + "sha256:378753b4a4de2a7b34063d6f95ae81bfa7b15f2c1a04a9518e8644e81807ebea", + "sha256:3af6e48651c4e0d2d166dc1b033b7042ea3f871504b6805ba5f4fe31581d8d38", + "sha256:3dfcbc95bd7992b16f3f7ba05af8a64ca694331bd24f9157b49dadeeb287493b", + "sha256:3f21f0495edea7fdbaaa87e633a8689cd285f8f4af5c869f27bc8074638ad69c", + "sha256:4041711832360a9b75cfb11b25a6a97c8fb49c07b8bd43d0d02b45d0b499a4ff", + "sha256:44d61b4b7d0c2c9ac019c314e52d7cbda0ae31078aabd0f22e583af3e0d79723", + "sha256:4617e1915a539a0d9a9567795023de41a87106522ff83fbfaf1f6baf8e85437e", + "sha256:4b232061ca880db21fa14defe219840ad9b74b6158adb52ddf0e87bead9e8493", + "sha256:5246b14ca64a8675e0a7161f7af68fe3e910e6b90542b4bfb5439ba752191df6", + "sha256:5725dd9cc02068996d4438d397e255dcb1df776b7ceea3b9cb972bdb11260a83", + "sha256:583f6a1993ca3369e0f80ba99d796d8e6b1a3a2a442dd4e1a79e652116413091", + "sha256:59259dc58e57b10e7e18ce02c311804c10c5a793e6568f8af4dead03264584d1", + "sha256:593eba61ba0c3baae5bc9be2f5232430453fb4432048de28399ca7376de9c627", + "sha256:59f4a79c19232a5774aee369a0c296712ad0e77f24e62cad53160312b1c1eaa1", + "sha256:5f0e260eaf54380380ac3808aa4ebe2d8ca28b9087cf411649f96bad6900c728", + "sha256:62d9cfcf4948683a18a9aff0ab7e1474d407b7bab2ca03116109f8464698ab16", + "sha256:64607d4cbf1b7e3c3c8a14948b99345eda0e161b852e122c6bb71aab6d1d798c", + "sha256:655ca44a831ecb238d124e0402d98f6212ac527a0ba6c55ca26f616604e60a45", + "sha256:666ecce376999bf619756a24ce15bb14c5bfaf04bf00abc7e663ce17c3f34fe7", + "sha256:68049202f67380ff9aa52f12e92b1c30115f32e6895cd7198fa2a7961621fc5a", + "sha256:69803198097467ee7282750acb507fba35ca22cc3b85f16cf45fb01cb9097730", + "sha256:6c7b99ca52c2c1752b544e310101b98a659b720b21db00e65edca34483259967", + "sha256:6dd9412824c4ce1aca56c47b0991e65bebb7ac3f4edccfd3f156150c96a7bf25", + "sha256:70eb60b3ae9245ddea20f8a4190bd79c705a22f8028aaf8bbdebe4716c3fab24", + "sha256:70fb28128acbfd264eda9bf47015537ba3fe86e40d046eb2963d75024be4d055", + "sha256:7b2513ba235829860b13faa931f3b6846548021846ac808455301c23a101689d", + "sha256:7ef9d9da710be50ff6809fed8f1963fecdfecc8b86656cadfca3bc24289414b0", + "sha256:81e69b0a0e2537f26d73b4e43ad7bc8c8efb39621639b4434b76a3de50c6966e", + "sha256:8633e471c6207a039eff6aa116e35f69f3156b3989ea3e2d755f7bc41754a4a7", + "sha256:8bd7c8cfc0b8247c8799080fbff54e0b9619e17cdfeb0478ba7295d43f635d7c", + "sha256:9253fc214112405f0afa7db88739294295f0e08466987f1d70e29930262b4c8f", + "sha256:99b37292234e61325e7a5bb9689e55e48c3f5f603af88b1642666277a81f1fbd", + "sha256:9bd7228827ec7bb817089e2eb301d907c0d9827a9e558f22f762bb690b131652", + "sha256:9beeb01d8c190d7581a4d59522cd3d4b6887040dcfc744af99aa59fef3e041a8", + "sha256:a63cbdd98acef6570c62b92a1e43266f9e8b21e699c363c0fef13bd530799c11", + "sha256:a76e42402542b1fae59798fab64432b2d015ab9d0c8c47ba7addddbaf7952333", + "sha256:ac0a03221cdb5058ce0167ecc92a8c89e8d0decdc9e99a2ec23380793c4dcb96", + "sha256:b0b4136a252cadfa1adb705bb81524eee47d9f6aab4f2ee4fa1e9d3cd4581f64", + "sha256:b25bc607423935079e05619d7de556c91fb6adeae9d5f80868dde3468657994b", + "sha256:b3d504047aba448d70cf6fa22e06cb09f7cbd761939fdd47604f5e007675c24e", + "sha256:bb47271f60660803ad11f4c61b42242b8c1312a31c98c578f79ef9387bbde21c", + "sha256:bbb232860e3d03d544bc03ac57855cd82ddf19c7a07651a7c0fdb95e9efea8b9", + "sha256:bc27863442d388870c1809a87507727b799c8460573cfbb6dc0eeaef5a11b5ec", + "sha256:bc51abd01f08117283c5ebf64844a35144a0843ff7b2983e0648e4d3d9f10dbb", + "sha256:be2eb3f2495ba669d2a985f9b426c1797b7d48d6963899276d22f23e33d47e37", + "sha256:bf9db5488121b596dbfc6718c76092fda77b703c1f7533a226a5a9f65248f8ad", + "sha256:c58e2339def52ef6b71b8f36d13c3688ea23fa093353f3a4fee2556e62086ec9", + "sha256:cfbc454a2880389dbb9b5b398e50d439e2e58669160f27b60e5eca11f68ae17c", + "sha256:cff63a0272fcd259dcc3be1657b07c929c466b067ceb1c20060e8d10af56f5bf", + "sha256:d115bffdd417c6d806ea9069237a4ae02f513b778e3789a359bc5856e0404cc4", + "sha256:d20cfb4e099748ea39e6f7b16c91ab057989712d31761d3300d43134e26e165f", + "sha256:d48424e39c2611ee1b84ad0f44fb3b2b53d473e65de061e3f460fc0be5f1939d", + "sha256:e0fa2d4ec53dc51cf7d3bb22e0aa0143966119f42a0c3e4998293a3dd2856b09", + "sha256:e32fee8ab45d3c2db6da19a5323bc3362237c8b653c70194414b892fd06a080d", + "sha256:e35ba67d65d49080e8e5a1dd40101fccdd9798adb9b050ff670b7d74fa41c566", + "sha256:e3fb866d9932a3d7d0c82da76d816996d1667c44891bd861a0f97ba27e84fc74", + "sha256:e61b02c3f7a1e0b75e20c3978f7135fd13cb6cf551bf4a6d29b999a88830a338", + "sha256:e67ba3c290821343c192f7eae1d8fd5999ca2dc99994114643e2f2d3e6138b15", + "sha256:e79dd39f1e8c3504be0607e5fc6e86bb60fe3584bec8b782578c3b0fde8d932c", + "sha256:e89391e6d60251560f0a8f4bd32137b077a80d9b7dbe6d5cab1cd80d2746f648", + "sha256:ea7433ce7e4bfc3a85654aeb6747babe3f66eaf9a1d0c1e7a4435bbdf27fea84", + "sha256:eaf16ae9ae519a0e237a0f528fd9f0197b9bb70f40263ee57ae53c2b8d48aeb3", + "sha256:eb0c341fa71df5a4595f9501df4ac5abfb5a09580081dffbd1ddd4654e6e9123", + "sha256:f276b245347e6e36526cbd4a266a417796fc531ddf391e43574cf6466c492520", + "sha256:f47ad3d5f3258bd7058d2d506852217865afefe6153a36eb4b6928758041d831", + "sha256:f56a6b404f74ab372da986d240e2e002769a7d7102cc73eb238a4f72eec5284e", + "sha256:f5cf2a0c2bdadf3791b5c205d55a37a54025c6e18a71c71f82bb536cf9a454bf", + "sha256:f5d36399a1b96e1a5fdc91e0522544580dbebeb1f77f27b2b0ab25559e103b8b", + "sha256:f60bd8423be1d9d833f230fdbccf8f57af322d96bcad6599e5a771b151398eb2", + "sha256:f612463ac081803f243ff13cccc648578e2279295048f2a8d5eb430af2bae6e3", + "sha256:f73d3fef726b3243a811121de45193c0ca75f6407fe66f3f4e183c983573e130", + "sha256:f82a116a1d03628a8ace4859556fb39fd1424c933341a08ea3ed6de1edb0283b", + "sha256:fb0ba113b4983beac1a2eb16faffd76cb41e176bf58c4afe3e14b9c681f702de", + "sha256:fb4f868f712b2dd4bcc538b0a0c1f63a2b1d584c925e69a224d759e7070a12d5", + "sha256:fb6116dfb8d1925cbdb52595560584db42a7f664617a1f7d7f6e32f138cdf37d", + "sha256:fda7cb070f442bf80b642cd56483b5548e43d366fe3f39b98e67cce780cded00", + "sha256:feea821ee2a9273771bae61194004ee2fc33f8ec7db08117ef9147d4bbcbca8e" ], - "markers": "python_version >= '3.8'", - "version": "==0.20.0" + "markers": "python_version >= '3.9'", + "version": "==0.22.3" }, "six": { "hashes": [ - "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926", - "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254" + "sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274", + "sha256:ff70335d468e7eb6ec65b95b99d3a2836546063f63acc5171de367e834932a81" ], "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", - "version": "==1.16.0" + "version": "==1.17.0" + }, + "snowplow-tracker": { + "hashes": [ + "sha256:16d8a3c001a7847d91dc081d508324550c314a4cbf5d6106b5ab35f77fa34678", + "sha256:382e289811550f6ce7d5abc9e68590cc080ac9b21916b701b17497cfd6b32038" + ], + "version": "==1.0.4" }, "sqlparse": { "hashes": [ - "sha256:773dcbf9a5ab44a090f3441e2180efe2560220203dc2f8c0b0fa141e18b505e4", - "sha256:bb6b4df465655ef332548e24f08e205afc81b9ab86cb1c45657a7ff173a3a00e" + "sha256:09f67787f56a0b16ecdbde1bfc7f5d9c3371ca683cfeaa8e6ff60b4807ec9272", + "sha256:cf2196ed3418f3ba5de6af7e82c694a9fbdbfecccdfc72e281548517081f16ca" ], "markers": "python_version >= '3.8'", - "version": "==0.5.1" + "version": "==0.5.3" }, "text-unidecode": { "hashes": [ @@ -1023,19 +1008,57 @@ }, "tomli": { "hashes": [ - "sha256:2ebe24485c53d303f690b0ec092806a085f07af5a5aa1464f3931eec36caaa38", - "sha256:d46d457a85337051c36524bc5349dd91b1877838e2979ac5ced3e710ed8a60ed" + "sha256:023aa114dd824ade0100497eb2318602af309e5a55595f76b626d6d9f3b7b0a6", + "sha256:02abe224de6ae62c19f090f68da4e27b10af2b93213d36cf44e6e1c5abd19fdd", + "sha256:286f0ca2ffeeb5b9bd4fcc8d6c330534323ec51b2f52da063b11c502da16f30c", + "sha256:2d0f2fdd22b02c6d81637a3c95f8cd77f995846af7414c5c4b8d0545afa1bc4b", + "sha256:33580bccab0338d00994d7f16f4c4ec25b776af3ffaac1ed74e0b3fc95e885a8", + "sha256:400e720fe168c0f8521520190686ef8ef033fb19fc493da09779e592861b78c6", + "sha256:40741994320b232529c802f8bc86da4e1aa9f413db394617b9a256ae0f9a7f77", + "sha256:465af0e0875402f1d226519c9904f37254b3045fc5084697cefb9bdde1ff99ff", + "sha256:4a8f6e44de52d5e6c657c9fe83b562f5f4256d8ebbfe4ff922c495620a7f6cea", + "sha256:4e340144ad7ae1533cb897d406382b4b6fede8890a03738ff1683af800d54192", + "sha256:678e4fa69e4575eb77d103de3df8a895e1591b48e740211bd1067378c69e8249", + "sha256:6972ca9c9cc9f0acaa56a8ca1ff51e7af152a9f87fb64623e31d5c83700080ee", + "sha256:7fc04e92e1d624a4a63c76474610238576942d6b8950a2d7f908a340494e67e4", + "sha256:889f80ef92701b9dbb224e49ec87c645ce5df3fa2cc548664eb8a25e03127a98", + "sha256:8d57ca8095a641b8237d5b079147646153d22552f1c637fd3ba7f4b0b29167a8", + "sha256:8dd28b3e155b80f4d54beb40a441d366adcfe740969820caf156c019fb5c7ec4", + "sha256:9316dc65bed1684c9a98ee68759ceaed29d229e985297003e494aa825ebb0281", + "sha256:a198f10c4d1b1375d7687bc25294306e551bf1abfa4eace6650070a5c1ae2744", + "sha256:a38aa0308e754b0e3c67e344754dff64999ff9b513e691d0e786265c93583c69", + "sha256:a92ef1a44547e894e2a17d24e7557a5e85a9e1d0048b0b5e7541f76c5032cb13", + "sha256:ac065718db92ca818f8d6141b5f66369833d4a80a9d74435a268c52bdfa73140", + "sha256:b82ebccc8c8a36f2094e969560a1b836758481f3dc360ce9a3277c65f374285e", + "sha256:c954d2250168d28797dd4e3ac5cf812a406cd5a92674ee4c8f123c889786aa8e", + "sha256:cb55c73c5f4408779d0cf3eef9f762b9c9f147a77de7b258bef0a5628adc85cc", + "sha256:cd45e1dc79c835ce60f7404ec8119f2eb06d38b1deba146f07ced3bbc44505ff", + "sha256:d3f5614314d758649ab2ab3a62d4f2004c825922f9e370b29416484086b264ec", + "sha256:d920f33822747519673ee656a4b6ac33e382eca9d331c87770faa3eef562aeb2", + "sha256:db2b95f9de79181805df90bedc5a5ab4c165e6ec3fe99f970d0e302f384ad222", + "sha256:e59e304978767a54663af13c07b3d1af22ddee3bb2fb0618ca1593e4f593a106", + "sha256:e85e99945e688e32d5a35c1ff38ed0b3f41f43fad8df0bdf79f72b2ba7bc5272", + "sha256:ece47d672db52ac607a3d9599a9d48dcb2f2f735c6c2d1f34130085bb12b112a", + "sha256:f4039b9cbc3048b2416cc57ab3bda989a6fcf9b36cf8937f01a6e731b64f80d7" ], "markers": "python_version < '3.11'", - "version": "==2.0.2" + "version": "==2.2.1" }, "trino": { "hashes": [ - "sha256:1e731be22bc6fb4ce6537287419c3d221faaa8d089f5a05b0f01ef25b860e96e", - "sha256:535f612d754338cfefa4b3fe86b63c8c000d21cb5ea476ae4ec4390d5cc37659" + "sha256:2d9acdf7b19d136c97c98e55599fb9a5556e124282b0a40afb93bdfbb5371708", + "sha256:4f909e6c2966d23917e2538bc7f342d5dcc6e512102811fb1e53bdaf15bd49e3" + ], + "markers": "python_version >= '3.9'", + "version": "==0.331.0" + }, + "types-requests": { + "hashes": [ + "sha256:0d9cad2f27515d0e3e3da7134a1b6f28fb97129d86b867f24d9c726452634d95", + "sha256:4195d62d6d3e043a4eaaf08ff8a62184584d2e8684e9d2aa178c7915a7da3747" ], "markers": "python_version >= '3.8'", - "version": "==0.330.0" + "version": "==2.32.0.20241016" }, "typing-extensions": { "hashes": [ @@ -1055,27 +1078,27 @@ }, "urllib3": { "hashes": [ - "sha256:ca899ca043dcb1bafa3e262d73aa25c465bfb49e0bd9dd5d59f1d0acba2f8fac", - "sha256:e7d814a81dad81e6caf2ec9fdedb284ecc9c73076b62654547cc64ccdcae26e9" + "sha256:1cee9ad369867bfdbbb48b7dd50374c0967a0bb7710050facf0dd6911440e3df", + "sha256:f8c5449b3cf0861679ce7e0503c7b44b5ec981bec0d1d3795a07f1ba96f0204d" ], - "markers": "python_version >= '3.8'", - "version": "==2.2.3" + "markers": "python_version >= '3.9'", + "version": "==2.3.0" }, "virtualenv": { "hashes": [ - "sha256:2ca56a68ed615b8fe4326d11a0dca5dfbe8fd68510fb6c6349163bed3c15f2b2", - "sha256:44a72c29cceb0ee08f300b314848c86e57bf8d1f13107a5e671fb9274138d655" + "sha256:23eae1b4516ecd610481eda647f3a7c09aea295055337331bb4e6892ecce47b0", + "sha256:2c9c3262bb8e7b87ea801d715fae4495e6032450c71d2309be9550e7364049aa" ], "markers": "python_version >= '3.8'", - "version": "==20.27.0" + "version": "==20.28.0" }, "zipp": { "hashes": [ - "sha256:a817ac80d6cf4b23bf7f2828b7cabf326f15a001bea8b1f9b49631780ba28350", - "sha256:bc9eb26f4506fda01b81bcde0ca78103b6e62f991b381fec825435c836edbc29" + "sha256:2c9958f6430a2040341a52eb608ed6dd93ef4392e02ffe219417c1b28b5dd1f4", + "sha256:ac1bbe05fd2991f160ebce24ffbac5f6d11d83dc90891255885223d42b3cd931" ], - "markers": "python_version >= '3.8'", - "version": "==3.20.2" + "markers": "python_version >= '3.9'", + "version": "==3.21.0" } }, "develop": {} diff --git a/README.md b/README.md index 8e70873c945..3c6381fe0db 100644 --- a/README.md +++ b/README.md @@ -11,10 +11,10 @@ Welcome to [Spellbook](https://youtu.be/o7p0BNt7NHs). Cast a magical incantation - Are you building something new? **Please make sure to open a Draft PR**, so we minimize duplicated work, and other wizards can help you if you need - Don't know where to start? The docs below will guide you, but as a summary: - Want to make an incremental improvement to one of our spells? (add a new project, fix a bug you found), simply open a PR with your changes. - - Follow the guide for [Submitting a PR](), [Setting up your dev environment]() and [Using dbt to write spells]() if you find yourself lost. - - Not sure how to start? Follow the walkthrough [here](https://dune.com/docs/spellbook/). + - Follow the guide for [Submitting a PR](#submitting-a-pr), [Setting up your dev environment](#setting-up-your-local-dev-environment) and [Using dbt to write spells](#how-to-use-dbt-to-create-spells) if you find yourself lost. + - Not sure how to start? Follow the walkthrough [here](#introduction). - Make sure to open a draft PR if you will work on your spell for longer than a few days, to avoid duplicated work - - Do you want to get started building spells and you don't know what to build? Check [Issues]() to see what the community needs. + - Do you want to get started building spells and you don't know what to build? Check [Issues](https://github.com/duneanalytics/spellbook/issues) to see what the community needs. - Check the Discussions section to see what problems the community is trying to solve (i.e. non-incremental changes) or propose your own! - Have questions? Head over to #spellbook on our [discord](https://discord.com/channels/757637422384283659/999683200563564655) and the community will be happy to help out! - Like with most OSS projects, your contributions to Spellbook are your own IP, you can find more details in the [Contributor License Agreement](CLA.md) diff --git a/dbt_macros/shared/balancer/balancer_bpt_prices_macro.sql b/dbt_macros/shared/balancer/balancer_bpt_prices_macro.sql index 4e71e626d50..92fae3fa1b5 100644 --- a/dbt_macros/shared/balancer/balancer_bpt_prices_macro.sql +++ b/dbt_macros/shared/balancer/balancer_bpt_prices_macro.sql @@ -349,3 +349,278 @@ WITH pool_labels AS ( WHERE supply > 0 {% endmacro %} + + {# ######################################################################### #} + + {% macro + balancer_v3_compatible_bpt_prices_macro( + blockchain, version, project_decoded_as, base_spells_namespace, pool_labels_spell + ) +%} + +WITH pool_labels AS ( + SELECT + address AS pool_id, + name AS pool_symbol, + pool_type + FROM {{ pool_labels_spell }} + WHERE blockchain = '{{blockchain}}' + ), + + token_data AS ( + SELECT + pool, + ARRAY_AGG(FROM_HEX(json_extract_scalar(token, '$.token')) ORDER BY token_index) AS tokens + FROM ( + SELECT + pool, + tokenConfig, + SEQUENCE(1, CARDINALITY(tokenConfig)) AS token_index_array + FROM {{ source(project_decoded_as + '_' + blockchain, 'Vault_evt_PoolRegistered') }} + ) AS pool_data + CROSS JOIN UNNEST(tokenConfig, token_index_array) AS t(token, token_index) + GROUP BY 1 + ), + +-- liquidity formulation, with a few simplifications, compared to liquidity spell + + prices AS ( + SELECT + date_trunc('day', minute) AS day, + contract_address AS token, + decimals, + AVG(price) AS price + FROM {{ source('prices', 'usd') }} + WHERE blockchain = '{{blockchain}}' + GROUP BY 1, 2, 3 + ), + + erc4626_prices AS( + SELECT + date_trunc('day', minute) AS day, + wrapped_token AS token, + decimals, + APPROX_PERCENTILE(median_price, 0.5) AS price, + DATE_TRUNC ('day', next_change) AS next_change + FROM {{ ref('balancer_v3_erc4626_token_prices') }} + WHERE blockchain = '{{blockchain}}' + GROUP BY 1, 2, 3, 5 + ), + + swaps_changes AS ( + SELECT + day, + pool_id, + token, + SUM(COALESCE(delta, INT256 '0')) AS delta + FROM + ( + SELECT + date_trunc('day', evt_block_time) AS day, + pool AS pool_id, + tokenIn AS token, + CAST(amountIn AS INT256) AS delta + FROM {{ source(project_decoded_as + '_' + blockchain, 'Vault_evt_Swap') }} + + UNION ALL + + SELECT + date_trunc('day', evt_block_time) AS day, + pool AS pool_id, + tokenOut AS token, + -CAST(amountOut AS INT256) AS delta + FROM {{ source(project_decoded_as + '_' + blockchain, 'Vault_evt_Swap') }} + ) swaps + GROUP BY 1, 2, 3 + ), + + balance_changes AS( + SELECT + evt_block_time, + pool_id, + category, + deltas, + swapFeeAmountsRaw + FROM + ( + SELECT + evt_block_time, + pool AS pool_id, + 'add' AS category, + amountsAddedRaw AS deltas, + swapFeeAmountsRaw + FROM {{ source(project_decoded_as + '_' + blockchain, 'Vault_evt_LiquidityAdded') }} + + UNION ALL + + SELECT + evt_block_time, + pool AS pool_id, + 'remove' AS category, + amountsRemovedRaw AS deltas, + swapFeeAmountsRaw + FROM {{ source(project_decoded_as + '_' + blockchain, 'Vault_evt_LiquidityRemoved') }} + ) adds_and_removes + ), + + zipped_balance_changes AS ( + SELECT + date_trunc('day', evt_block_time) AS day, + pool_id, + t.tokens, + CASE WHEN b.category = 'add' + THEN d.deltas + WHEN b.category = 'remove' + THEN -d.deltas + END AS deltas, + p.swapFeeAmountsRaw + FROM balance_changes b + JOIN token_data td ON b.pool_id = td.pool + CROSS JOIN UNNEST (td.tokens) WITH ORDINALITY as t(tokens,i) + CROSS JOIN UNNEST (b.deltas) WITH ORDINALITY as d(deltas,i) + CROSS JOIN UNNEST (b.swapFeeAmountsRaw) WITH ORDINALITY as p(swapFeeAmountsRaw,i) + WHERE t.i = d.i + AND d.i = p.i + ORDER BY 1,2,3 + ), + + balances_changes AS ( + SELECT + day, + pool_id, + tokens AS token, + deltas - CAST(swapFeeAmountsRaw as int256) AS delta + FROM zipped_balance_changes + ORDER BY 1, 2, 3 + ), + + daily_delta_balance AS ( + SELECT + day, + pool_id, + token, + SUM(COALESCE(amount, INT256 '0')) AS amount + FROM + ( + SELECT + day, + pool_id, + token, + SUM(COALESCE(delta, INT256 '0')) AS amount + FROM balances_changes + GROUP BY 1, 2, 3 + + UNION ALL + + SELECT + day, + pool_id, + token, + delta AS amount + FROM + swaps_changes + ) balance + GROUP BY 1, 2, 3 + ), + + + cumulative_balance AS ( + SELECT + DAY, + pool_id, + token, + LEAD(DAY, 1, NOW()) OVER (PARTITION BY token, pool_id ORDER BY DAY) AS day_of_next_change, + SUM(amount) OVER (PARTITION BY pool_id, token ORDER BY DAY ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS cumulative_amount + FROM daily_delta_balance + ), + + calendar AS ( + SELECT date_sequence AS day + FROM unnest(sequence(date('2024-12-01'), date(now()), interval '1' day)) as t(date_sequence) + ), + + cumulative_usd_balance AS ( + SELECT + c.day, + '{{blockchain}}' as blockchain, + b.pool_id, + b.token, + cumulative_amount / POWER(10, COALESCE(t.decimals, p1.decimals, p4.decimals)) * COALESCE(p1.price, p4.price, 0) AS protocol_liquidity_usd + FROM calendar c + LEFT JOIN cumulative_balance b ON b.day <= c.day + AND c.day < b.day_of_next_change + LEFT JOIN {{ source('tokens', 'erc20') }} t ON t.contract_address = b.token + AND blockchain = '{{blockchain}}' + LEFT JOIN prices p1 ON p1.day = b.day + AND p1.token = b.token + LEFT JOIN erc4626_prices p4 ON p4.day <= c.day + AND c.day < p4.next_change + AND p4.token = b.token + WHERE b.token != BYTEARRAY_SUBSTRING(b.pool_id, 1, 20) + ), + + weighted_pool_liquidity_estimates AS ( + SELECT + b.day, + b.pool_id, + q.name, + pool_type, + ROW_NUMBER() OVER (partition by b.day, b.pool_id ORDER BY SUM(b.protocol_liquidity_usd) ASC) AS pricing_count, --to avoid double count in pools with multiple pricing assets + SUM(b.protocol_liquidity_usd) / COALESCE(SUM(w.normalized_weight), 1) AS protocol_liquidity + FROM cumulative_usd_balance b + LEFT JOIN {{ ref(base_spells_namespace + '_pools_tokens_weights') }} w ON b.pool_id = w.pool_id + AND b.token = w.token_address + AND b.protocol_liquidity_usd > 0 + LEFT JOIN {{ source('balancer','token_whitelist') }} q ON b.token = q.address + AND b.blockchain = q.chain + LEFT JOIN pool_labels p ON p.pool_id = BYTEARRAY_SUBSTRING(b.pool_id, 1, 20) + WHERE q.name IS NOT NULL + AND p.pool_type IN ('weighted') -- filters for weighted pools with pricing assets + AND w.blockchain = '{{blockchain}}' + AND w.version = '{{version}}' + GROUP BY 1, 2, 3, 4 + ), + + weighted_pool_liquidity_estimates_2 AS( + SELECT e.day, + e.pool_id, + SUM(e.protocol_liquidity) / MAX(e.pricing_count) AS protocol_liquidity + FROM weighted_pool_liquidity_estimates e + GROUP BY 1,2 + ), + + tvl AS( + SELECT + c.day, + BYTEARRAY_SUBSTRING(c.pool_id, 1, 20) AS pool_address, + '{{version}}' AS version, + '{{blockchain}}' AS blockchain, + SUM(COALESCE(b.protocol_liquidity * w.normalized_weight, c.protocol_liquidity_usd)) AS liquidity + FROM cumulative_usd_balance c + FULL OUTER JOIN weighted_pool_liquidity_estimates_2 b ON c.day = b.day + AND c.pool_id = b.pool_id + LEFT JOIN {{ ref(base_spells_namespace + '_pools_tokens_weights') }} w ON b.pool_id = w.pool_id + AND w.blockchain = '{{blockchain}}' + AND w.version = '{{version}}' + AND w.token_address = c.token + LEFT JOIN pool_labels p ON p.pool_id = BYTEARRAY_SUBSTRING(c.pool_id, 1, 20) + GROUP BY 1, 2, 3, 4 + ) + + SELECT + l.day, + l.blockchain, + l.version, + 18 AS decimals, + l.pool_address AS contract_address, + pl.pool_type, + l.liquidity / s.supply AS bpt_price + FROM tvl l + LEFT JOIN {{ ref(base_spells_namespace + '_bpt_supply') }} s ON l.pool_address = s.token_address + AND l.blockchain = s.blockchain + AND l.version = s.version + AND l.day = s.day + LEFT JOIN pool_labels pl ON pl.pool_id = l.pool_address + WHERE supply > 0 + + {% endmacro %} diff --git a/dbt_macros/shared/balancer/balancer_bpt_supply_macro.sql b/dbt_macros/shared/balancer/balancer_bpt_supply_macro.sql index 9d128983005..d9a5f75abdc 100644 --- a/dbt_macros/shared/balancer/balancer_bpt_supply_macro.sql +++ b/dbt_macros/shared/balancer/balancer_bpt_supply_macro.sql @@ -138,3 +138,103 @@ WITH pool_labels AS ( HAVING SUM(b.supply - COALESCE(preminted_bpts, 0) + COALESCE(adelta, 0)) >= 0 --simple filter to remove outliers {% endmacro %} + +{# ######################################################################### #} + +{% macro + balancer_v3_compatible_bpt_supply_macro( + blockchain, version, project_decoded_as, base_spells_namespace, pool_labels_spell + ) +%} + + WITH pool_labels AS ( + SELECT * FROM ( + SELECT + address, + name, + pool_type, + ROW_NUMBER() OVER (PARTITION BY address ORDER BY MAX(updated_at) DESC) AS num + FROM {{ pool_labels_spell }} + WHERE blockchain = '{{blockchain}}' + GROUP BY 1, 2, 3) + WHERE num = 1 + ), + + -- Extract mints and burns from transfers + transfers AS ( + SELECT + block_date AS day, + contract_address AS token, + COALESCE(SUM(CASE WHEN t."from" = 0x0000000000000000000000000000000000000000 THEN value / POWER(10, 18) ELSE 0 END), 0) AS mints, + COALESCE(SUM(CASE WHEN t.to = 0x0000000000000000000000000000000000000000 THEN value / POWER(10, 18) ELSE 0 END), 0) AS burns + FROM {{ ref(base_spells_namespace + '_transfers_bpt') }} t + WHERE blockchain = '{{blockchain}}' + AND version = '{{version}}' + GROUP BY 1, 2 + ), + + -- Calculate token balances over time + balances AS ( + SELECT + day, + token, + LEAD(DAY, 1, NOW()) OVER (PARTITION BY token ORDER BY DAY) AS day_of_next_change, + SUM(COALESCE(mints, 0) - COALESCE(burns, 0)) OVER (PARTITION BY token ORDER BY DAY ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS supply + FROM transfers + ), + + -- Calculating Joins(mint) and Exits(burn) via Swap + joins AS ( + SELECT + DATE_TRUNC('day', evt_block_time) AS block_date, + tokenOut, + pool_type, + SUM(amountOut / POWER(10, 18)) AS ajoins + FROM {{ source(project_decoded_as + '_' + blockchain, 'Vault_evt_Swap') }} + LEFT JOIN pool_labels ON pool = address + WHERE tokenOut = pool + GROUP BY 1, 2, 3 + ), + + exits AS ( + SELECT + DATE_TRUNC('day', evt_block_time) AS block_date, + tokenIn, + pool_type, + SUM(amountIn / POWER(10, 18)) AS aexits + FROM {{ source(project_decoded_as + '_' + blockchain, 'Vault_evt_Swap') }} + LEFT JOIN pool_labels ON pool = address + WHERE tokenIn = pool + GROUP BY 1, 2, 3 + ), + + joins_and_exits AS ( + SELECT + j.block_date, + j.tokenOut AS bpt, + SUM(COALESCE(ajoins, 0) - COALESCE(aexits, 0)) OVER (PARTITION BY j.tokenOut ORDER BY j.block_date ASC) AS adelta + FROM joins j + FULL OUTER JOIN exits e ON j.block_date = e.block_date AND e.tokenIn = j.tokenOut + ), + + calendar AS ( + SELECT + date_sequence AS day + FROM unnest(sequence(date('2024-12-01'), date(now()), interval '1' day)) as t(date_sequence) + ) + + SELECT + c.day, + l.pool_type, + '{{version}}' as version, + '{{blockchain}}' as blockchain, + b.token AS token_address, + COALESCE(SUM(b.supply + COALESCE(adelta, 0)),0) AS supply + FROM calendar c + LEFT JOIN balances b ON b.day <= c.day AND c.day < b.day_of_next_change + LEFT JOIN joins_and_exits j ON c.day = j.block_date AND b.token = j.bpt + LEFT JOIN pool_labels l ON b.token = l.address + GROUP BY 1, 2, 3, 4, 5 + HAVING SUM(b.supply + COALESCE(adelta, 0)) >= 0 --simple filter to remove outliers + +{% endmacro %} \ No newline at end of file diff --git a/dbt_macros/shared/balancer/balancer_liquidity_macro.sql b/dbt_macros/shared/balancer/balancer_liquidity_macro.sql index f4d4704028c..0f893a0f561 100644 --- a/dbt_macros/shared/balancer/balancer_liquidity_macro.sql +++ b/dbt_macros/shared/balancer/balancer_liquidity_macro.sql @@ -288,3 +288,333 @@ WITH pool_labels AS ( LEFT JOIN eth_prices e ON e.day = c.day LEFT JOIN pool_labels p ON p.pool_id = BYTEARRAY_SUBSTRING(c.pool_id, 1, 20) {% endmacro %} + +{# ######################################################################### #} + +{% macro + balancer_v3_compatible_liquidity_macro( + blockchain, version, project_decoded_as, base_spells_namespace, pool_labels_spell + ) +%} + +WITH pool_labels AS ( + SELECT + address AS pool_id, + name AS pool_symbol, + pool_type + FROM {{ pool_labels_spell }} + WHERE blockchain = '{{blockchain}}' + ), + + token_data AS ( + SELECT + pool, + ARRAY_AGG(FROM_HEX(json_extract_scalar(token, '$.token')) ORDER BY token_index) AS tokens + FROM ( + SELECT + pool, + tokenConfig, + SEQUENCE(1, CARDINALITY(tokenConfig)) AS token_index_array + FROM {{ source(project_decoded_as + '_' + blockchain, 'Vault_evt_PoolRegistered') }} + ) AS pool_data + CROSS JOIN UNNEST(tokenConfig, token_index_array) AS t(token, token_index) + GROUP BY 1 + ), + + prices AS ( + SELECT + date_trunc('day', minute) AS day, + contract_address AS token, + decimals, + APPROX_PERCENTILE(price, 0.5) AS price + FROM {{ source('prices', 'usd') }} + WHERE blockchain = '{{blockchain}}' + GROUP BY 1, 2, 3 + ), + + dex_prices_1 AS ( + SELECT + date_trunc('day', HOUR) AS DAY, + contract_address AS token, + approx_percentile(median_price, 0.5) AS price, + sum(sample_size) AS sample_size + FROM {{ source('dex', 'prices') }} + WHERE + ('{{blockchain}}' != 'fantom' OR + ('{{blockchain}}' = 'fantom' AND contract_address NOT IN (0xde1e704dae0b4051e80dabb26ab6ad6c12262da0, 0x5ddb92a5340fd0ead3987d3661afcd6104c3b757))) --broken price feeds + AND blockchain = '{{blockchain}}' + GROUP BY 1, 2 + HAVING sum(sample_size) > 3 + ), + + dex_prices_2 AS( + SELECT + day, + token, + price, + lag(price) OVER(PARTITION BY token ORDER BY day) AS previous_price + FROM dex_prices_1 + ), + + dex_prices AS ( + SELECT + day, + token, + price, + LEAD(DAY, 1, NOW()) OVER (PARTITION BY token ORDER BY DAY) AS day_of_next_change + FROM dex_prices_2 + WHERE (price < previous_price * 1e4 AND price > previous_price / 1e4) + ), + + bpt_prices AS( + SELECT DISTINCT + day, + contract_address AS token, + decimals, + bpt_price + FROM {{ ref(base_spells_namespace + '_bpt_prices') }} + WHERE blockchain = '{{blockchain}}' + AND version = '{{version}}' + ), + + eth_prices AS ( + SELECT + DATE_TRUNC('day', minute) as day, + AVG(price) as eth_price + FROM {{ source('prices', 'usd') }} + WHERE blockchain = 'ethereum' + AND contract_address = 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 + GROUP BY 1 + ), + + erc4626_prices AS( + SELECT + date_trunc('day', minute) AS day, + wrapped_token AS token, + decimals, + APPROX_PERCENTILE(median_price, 0.5) AS price, + DATE_TRUNC ('day', next_change) AS next_change + FROM {{ ref('balancer_v3_erc4626_token_prices') }} + WHERE blockchain = '{{blockchain}}' + GROUP BY 1, 2, 3, 5 + ), + + swaps_changes AS ( + SELECT + day, + pool_id, + token, + SUM(COALESCE(delta, INT256 '0')) AS delta + FROM + ( + SELECT + date_trunc('day', evt_block_time) AS day, + pool AS pool_id, + tokenIn AS token, + CAST(amountIn AS INT256) AS delta + FROM {{ source(project_decoded_as + '_' + blockchain, 'Vault_evt_Swap') }} + + UNION ALL + + SELECT + date_trunc('day', evt_block_time) AS day, + pool AS pool_id, + tokenOut AS token, + -CAST(amountOut AS INT256) AS delta + FROM {{ source(project_decoded_as + '_' + blockchain, 'Vault_evt_Swap') }} + ) swaps + GROUP BY 1, 2, 3 + ), + + balance_changes AS( + SELECT + evt_block_time, + pool_id, + category, + deltas, + swapFeeAmountsRaw + FROM + ( + SELECT + evt_block_time, + pool AS pool_id, + 'add' AS category, + amountsAddedRaw AS deltas, + swapFeeAmountsRaw + FROM {{ source(project_decoded_as + '_' + blockchain, 'Vault_evt_LiquidityAdded') }} + + UNION ALL + + SELECT + evt_block_time, + pool AS pool_id, + 'remove' AS category, + amountsRemovedRaw AS deltas, + swapFeeAmountsRaw + FROM {{ source(project_decoded_as + '_' + blockchain, 'Vault_evt_LiquidityRemoved') }} + ) adds_and_removes + ), + + zipped_balance_changes AS ( + SELECT + date_trunc('day', evt_block_time) AS day, + pool_id, + t.tokens, + CASE WHEN b.category = 'add' + THEN d.deltas + WHEN b.category = 'remove' + THEN -d.deltas + END AS deltas, + p.swapFeeAmountsRaw + FROM balance_changes b + JOIN token_data td ON b.pool_id = td.pool + CROSS JOIN UNNEST (td.tokens) WITH ORDINALITY as t(tokens,i) + CROSS JOIN UNNEST (b.deltas) WITH ORDINALITY as d(deltas,i) + CROSS JOIN UNNEST (b.swapFeeAmountsRaw) WITH ORDINALITY as p(swapFeeAmountsRaw,i) + WHERE t.i = d.i + AND d.i = p.i + ORDER BY 1,2,3 + ), + + balances_changes AS ( + SELECT + day, + pool_id, + tokens AS token, + deltas - CAST(swapFeeAmountsRaw as int256) AS delta + FROM zipped_balance_changes + ORDER BY 1, 2, 3 + ), + + daily_delta_balance AS ( + SELECT + day, + pool_id, + token, + SUM(COALESCE(amount, INT256 '0')) AS amount + FROM + ( + SELECT + day, + pool_id, + token, + SUM(COALESCE(delta, INT256 '0')) AS amount + FROM balances_changes + GROUP BY 1, 2, 3 + + UNION ALL + + SELECT + day, + pool_id, + token, + delta AS amount + FROM + swaps_changes + ) balance + GROUP BY 1, 2, 3 + ), + + cumulative_balance AS ( + SELECT + DAY, + pool_id, + token, + LEAD(DAY, 1, NOW()) OVER (PARTITION BY token, pool_id ORDER BY DAY) AS day_of_next_change, + SUM(amount) OVER (PARTITION BY pool_id, token ORDER BY DAY ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS cumulative_amount + FROM daily_delta_balance + ), + + calendar AS ( + SELECT date_sequence AS day + FROM unnest(sequence(date('2024-12-01'), date(now()), interval '1' day)) as t(date_sequence) + ), + + cumulative_usd_balance AS ( + SELECT + c.day, + '{{blockchain}}' as blockchain, + b.pool_id, + b.token, + symbol AS token_symbol, + cumulative_amount as token_balance_raw, + cumulative_amount / POWER(10, COALESCE(t.decimals, p1.decimals, p3.decimals, p4.decimals)) AS token_balance, + cumulative_amount / POWER(10, COALESCE(t.decimals, p1.decimals, p3.decimals, p4.decimals)) * COALESCE(p1.price, p2.price, p4.price, 0) AS protocol_liquidity_usd, + cumulative_amount / POWER(10, COALESCE(t.decimals, p1.decimals, p3.decimals, p4.decimals)) * COALESCE(p1.price, p2.price, p3.bpt_price, p4.price, 0) AS pool_liquidity_usd + FROM calendar c + LEFT JOIN cumulative_balance b ON b.day <= c.day + AND c.day < b.day_of_next_change + LEFT JOIN {{ source('tokens', 'erc20') }} t ON t.contract_address = b.token + AND blockchain = '{{blockchain}}' + LEFT JOIN prices p1 ON p1.day = b.day + AND p1.token = b.token + LEFT JOIN dex_prices p2 ON p2.day <= c.day + AND c.day < p2.day_of_next_change + AND p2.token = b.token + LEFT JOIN bpt_prices p3 ON p3.day = b.day + AND p3.token = b.token + LEFT JOIN erc4626_prices p4 ON p4.day <= c.day + AND c.day < p4.next_change + AND p4.token = b.token + WHERE b.token != BYTEARRAY_SUBSTRING(b.pool_id, 1, 20) + ), + + weighted_pool_liquidity_estimates AS ( + SELECT + b.day, + b.pool_id, + q.name, + pool_type, + ROW_NUMBER() OVER (partition by b.day, b.pool_id ORDER BY SUM(b.pool_liquidity_usd) ASC) AS pricing_count, --to avoid double count in pools with multiple pricing assets + SUM(b.protocol_liquidity_usd) / COALESCE(SUM(w.normalized_weight), 1) AS protocol_liquidity, + SUM(b.pool_liquidity_usd) / COALESCE(SUM(w.normalized_weight), 1) AS pool_liquidity + FROM cumulative_usd_balance b + LEFT JOIN {{ ref(base_spells_namespace + '_pools_tokens_weights') }} w ON b.pool_id = w.pool_id + AND b.token = w.token_address + AND b.pool_liquidity_usd > 0 + LEFT JOIN {{ source('balancer','token_whitelist') }} q ON b.token = q.address + AND b.blockchain = q.chain + LEFT JOIN pool_labels p ON p.pool_id = BYTEARRAY_SUBSTRING(b.pool_id, 1, 20) + WHERE q.name IS NOT NULL + AND p.pool_type IN ('weighted') -- filters for weighted pools with pricing assets + AND w.blockchain = '{{blockchain}}' + AND w.version = '{{version}}' + GROUP BY 1, 2, 3, 4 + ), + + weighted_pool_liquidity_estimates_2 AS( + SELECT e.day, + e.pool_id, + SUM(e.pool_liquidity) / MAX(e.pricing_count) AS pool_liquidity, + SUM(e.protocol_liquidity) / MAX(e.pricing_count) AS protocol_liquidity + FROM weighted_pool_liquidity_estimates e + GROUP BY 1,2 + ) + + SELECT + c.day, + c.pool_id, + BYTEARRAY_SUBSTRING(c.pool_id, 1, 20) AS pool_address, + p.pool_symbol, + '{{version}}' AS version, + '{{blockchain}}' AS blockchain, + p.pool_type, + c.token AS token_address, + c.token_symbol, + c.token_balance_raw, + c.token_balance, + COALESCE(b.protocol_liquidity * w.normalized_weight, c.protocol_liquidity_usd) AS protocol_liquidity_usd, + COALESCE(b.protocol_liquidity * w.normalized_weight, c.protocol_liquidity_usd)/e.eth_price AS protocol_liquidity_eth, + COALESCE(b.pool_liquidity * w.normalized_weight, c.pool_liquidity_usd) AS pool_liquidity_usd, + COALESCE(b.pool_liquidity * w.normalized_weight, c.pool_liquidity_usd)/e.eth_price AS pool_liquidity_eth + FROM cumulative_usd_balance c + FULL OUTER JOIN weighted_pool_liquidity_estimates_2 b ON c.day = b.day + AND c.pool_id = b.pool_id + LEFT JOIN {{ ref(base_spells_namespace + '_pools_tokens_weights') }} w ON b.pool_id = w.pool_id + AND w.blockchain = '{{blockchain}}' + AND w.version = '{{version}}' + AND w.token_address = c.token + LEFT JOIN eth_prices e ON e.day = c.day + LEFT JOIN pool_labels p ON p.pool_id = BYTEARRAY_SUBSTRING(c.pool_id, 1, 20) + + {% endmacro %} \ No newline at end of file diff --git a/dbt_macros/shared/balancer/balancer_pool_token_supply_changes_daily_agg_macro.sql b/dbt_macros/shared/balancer/balancer_pool_token_supply_changes_daily_agg_macro.sql index 510ebbe007e..35f850e3397 100644 --- a/dbt_macros/shared/balancer/balancer_pool_token_supply_changes_daily_agg_macro.sql +++ b/dbt_macros/shared/balancer/balancer_pool_token_supply_changes_daily_agg_macro.sql @@ -35,4 +35,47 @@ WITH LEFT JOIN daily_balance b ON b.block_date = c.day WHERE b.token_address IS NOT NULL AND b.pool_type IS NOT NULL - {% endmacro %} \ No newline at end of file + {% endmacro %} + +{# ######################################################################### #} + +{% macro + balancer_v3_compatible_bpt_supply_changes_daily_agg_macro( + blockchain, version, project_decoded_as, base_spells_namespace + ) +%} +WITH + daily_balance AS ( + SELECT + block_date, + blockchain, + pool_type, + pool_symbol, + token_address, + LEAD(block_date, 1, NOW()) OVER (PARTITION BY token_address ORDER BY block_date) AS day_of_next_change, + SUM(delta_amount) AS daily_amount + FROM {{ ref(base_spells_namespace + '_bpt_supply_changes') }} + WHERE blockchain = '{{blockchain}}' + AND version = '{{version}}' + GROUP BY 1, 2, 3, 4, 5 + ), + + calendar AS ( + SELECT date_sequence AS day + FROM unnest(sequence(date('2024-12-01'), date(now()), interval '1' day)) as t(date_sequence) + ) + + SELECT + c.day AS block_date, + '{{blockchain}}' as blockchain, + '{{version}}' AS version, + b.pool_type, + b.pool_symbol, + b.token_address, + b.daily_amount AS daily_delta + FROM calendar c + LEFT JOIN daily_balance b ON b.block_date = c.day + WHERE b.token_address IS NOT NULL + AND b.pool_type IS NOT NULL + + {% endmacro %} \ No newline at end of file diff --git a/dbt_macros/shared/balancer/balancer_pool_token_supply_changes_macro.sql b/dbt_macros/shared/balancer/balancer_pool_token_supply_changes_macro.sql index 71d9b78053e..90df02e7851 100644 --- a/dbt_macros/shared/balancer/balancer_pool_token_supply_changes_macro.sql +++ b/dbt_macros/shared/balancer/balancer_pool_token_supply_changes_macro.sql @@ -63,7 +63,7 @@ WITH pool_labels AS ( LEFT JOIN pool_labels l ON BYTEARRAY_SUBSTRING(s.poolId, 1, 20) = l.address WHERE tokenOut = BYTEARRAY_SUBSTRING(s.poolId, 1, 20) {% if is_incremental() %} - AND {{ incremental_predicate('s. evt_block_time') }} + AND {{ incremental_predicate('s.evt_block_time') }} {% endif %} ), @@ -86,7 +86,7 @@ WITH pool_labels AS ( LEFT JOIN pool_labels l ON BYTEARRAY_SUBSTRING(s.poolId, 1, 20) = l.address WHERE tokenIn = BYTEARRAY_SUBSTRING(s.poolId, 1, 20) {% if is_incremental() %} - AND {{ incremental_predicate('s. evt_block_time') }} + AND {{ incremental_predicate('s.evt_block_time') }} {% endif %} ) @@ -127,4 +127,131 @@ WITH pool_labels AS ( WHERE {{ incremental_predicate('evt_block_time') }} {% endif %} - {% endmacro %} \ No newline at end of file + {% endmacro %} + +{# ######################################################################### #} + +{% macro + balancer_v3_compatible_bpt_supply_changes_macro( + blockchain, version, project_decoded_as, base_spells_namespace, pool_labels_spell + ) +%} +WITH pool_labels AS ( + SELECT + address, + name, + pool_type + FROM {{ pool_labels_spell }} + WHERE blockchain = '{{blockchain}}' + ), + + -- Extract mints and burns from transfers + transfers AS ( + SELECT + t.evt_block_time, + t.evt_block_number, + t.evt_tx_hash, + t.evt_index, + t.contract_address AS token, + CASE + WHEN t."from" = 0x0000000000000000000000000000000000000000 + THEN 'mint' + WHEN t.to = 0x0000000000000000000000000000000000000000 + THEN 'burn' + END AS label, + l.pool_type, + l.name, + CASE + WHEN t."from" = 0x0000000000000000000000000000000000000000 + THEN value + WHEN t.to = 0x0000000000000000000000000000000000000000 + THEN - value + ELSE 0 + END AS amount + FROM {{ ref(base_spells_namespace + '_transfers_bpt') }} t + LEFT JOIN pool_labels l ON t.contract_address = l.address + WHERE t.blockchain = '{{blockchain}}' + AND t.version = '{{version}}' + {% if is_incremental() %} + AND {{ incremental_predicate('t.evt_block_time') }} + {% endif %} + ), + + -- Calculating Joins(mint) and Exits(burn) via Swap + joins AS ( + SELECT + s.evt_block_time, + s.evt_block_number, + s.evt_tx_hash, + s.evt_index, + s.tokenOut AS token, + 'join' AS label, + l.pool_type, + l.name, + s.amountOut AS amount + FROM {{ source(project_decoded_as + '_' + blockchain, 'Vault_evt_Swap') }} s + LEFT JOIN pool_labels l ON pool = l.address + WHERE tokenOut = pool + {% if is_incremental() %} + AND {{ incremental_predicate('s.evt_block_time') }} + {% endif %} + + ), + + exits AS ( + SELECT + s.evt_block_time, + s.evt_block_number, + s.evt_tx_hash, + s.evt_index, + s.tokenIn AS token, + 'exit' AS label, + l.pool_type, + l.name, + - s.amountIn AS amount + FROM {{ source(project_decoded_as + '_' + blockchain, 'Vault_evt_Swap') }} s + LEFT JOIN pool_labels l ON pool = l.address + WHERE tokenIn = pool + {% if is_incremental() %} + AND {{ incremental_predicate('s.evt_block_time') }} + {% endif %} + ) + + SELECT + date_trunc('day', evt_block_time) AS block_date, + evt_block_time, + evt_block_number, + '{{blockchain}}' AS blockchain, + evt_tx_hash, + evt_index, + pool_type, + name AS pool_symbol, + '{{version}}' AS version, + label, + token AS token_address, + amount AS delta_amount_raw, + amount / POWER (10, 18) AS delta_amount --18 decimals standard for BPTs + FROM + ( + SELECT + * + FROM joins + + UNION ALL + + SELECT + * + FROM exits + + UNION ALL + + SELECT + * + FROM transfers + WHERE label IS NOT NULL + ) + {% if is_incremental() %} + WHERE {{ incremental_predicate('evt_block_time') }} + {% endif %} + + {% endmacro %} \ No newline at end of file diff --git a/dbt_macros/shared/balancer/balancer_protocol_fee_macro.sql b/dbt_macros/shared/balancer/balancer_protocol_fee_macro.sql index 725c2cb76b8..eb5f72e13fb 100644 --- a/dbt_macros/shared/balancer/balancer_protocol_fee_macro.sql +++ b/dbt_macros/shared/balancer/balancer_protocol_fee_macro.sql @@ -120,7 +120,7 @@ WITH pool_labels AS ( d.token_address, t.symbol AS token_symbol, SUM(d.protocol_fee_amount_raw) AS token_amount_raw, - SUM(d.protocol_fee_amount_raw / power(10, COALESCE(t.decimals,p1.decimals, p3.decimals))) AS token_amount, + SUM(d.protocol_fee_amount_raw / POWER(10, COALESCE(t.decimals,p1.decimals, p3.decimals))) AS token_amount, SUM(COALESCE(p1.price, p2.price, p3.price) * protocol_fee_amount_raw / POWER(10, COALESCE(t.decimals,p1.decimals, p3.decimals))) AS protocol_fee_collected_usd FROM daily_protocol_fee_collected d LEFT JOIN prices p1 @@ -160,6 +160,7 @@ WITH pool_labels AS ( '{{version}}' as version, '{{blockchain}}' as blockchain, l.pool_type, + 'v2' AS fee_type, f.token_address, f.token_symbol, SUM(f.token_amount_raw) as token_amount_raw, @@ -172,6 +173,205 @@ WITH pool_labels AS ( ON r.day = f.day LEFT JOIN pool_labels l ON BYTEARRAY_SUBSTRING(f.pool_id,1,20) = l.address - GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 13 + GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 14 {% endmacro %} + +{# ######################################################################### #} + +{% macro + balancer_v3_compatible_protocol_fee_macro( + blockchain, version, project_decoded_as, base_spells_namespace, pool_labels_spell + ) +%} + +WITH pool_labels AS ( + SELECT * FROM ( + SELECT + address, + name, + pool_type, + ROW_NUMBER() OVER (PARTITION BY address ORDER BY MAX(updated_at) DESC) AS num + FROM {{ pool_labels_spell }} + WHERE blockchain = '{{blockchain}}' + GROUP BY 1, 2, 3) + WHERE num = 1 + ), + + prices AS ( + SELECT + date_trunc('day', minute) AS day, + contract_address AS token, + decimals, + AVG(price) AS price + FROM {{ source('prices', 'usd') }} + WHERE blockchain = '{{blockchain}}' + GROUP BY 1, 2, 3 + + ), + + dex_prices_1 AS ( + SELECT + date_trunc('day', hour) AS DAY, + contract_address AS token, + approx_percentile(median_price, 0.5) AS price, + sum(sample_size) AS sample_size + FROM {{ source('dex', 'prices') }} + WHERE blockchain = '{{blockchain}}' + GROUP BY 1, 2 + HAVING sum(sample_size) > 3 + ), + + dex_prices_2 AS( + SELECT + day, + token, + price, + lag(price) OVER(PARTITION BY token ORDER BY day) AS previous_price + FROM dex_prices_1 + ), + + dex_prices AS ( + SELECT + day, + token, + price, + LEAD(DAY, 1, NOW()) OVER (PARTITION BY token ORDER BY DAY) AS day_of_next_change + FROM dex_prices_2 + WHERE (price < previous_price * 1e4 AND price > previous_price / 1e4) + ), + + bpt_prices_1 AS ( --special calculation for this spell, in order to achieve completeness without relying on prices.usd + SELECT + l.day, + s.token_address AS token, + 18 AS decimals, + SUM(protocol_liquidity_usd / supply) AS price + FROM {{ ref(base_spells_namespace + '_liquidity') }} l + LEFT JOIN {{ ref(base_spells_namespace + '_bpt_supply') }} s ON s.token_address = l.pool_address + AND l.blockchain = s.blockchain AND s.day = l.day AND s.supply > 1e-4 + WHERE l.blockchain = '{{blockchain}}' + AND l.version = '{{version}}' + GROUP BY 1, 2, 3 + ), + + bpt_prices AS ( + SELECT + day, + token, + decimals, + price, + LEAD(DAY, 1, NOW()) OVER (PARTITION BY token ORDER BY DAY) AS day_of_next_change + FROM bpt_prices_1 + ), + + erc4626_prices AS( + SELECT + date_trunc('day', minute) AS day, + wrapped_token AS token, + decimals, + APPROX_PERCENTILE(median_price, 0.5) AS price, + DATE_TRUNC ('day', next_change) AS next_change + FROM {{ ref('balancer_v3_erc4626_token_prices') }} + WHERE blockchain = '{{blockchain}}' + GROUP BY 1, 2, 3, 5 + ), + + daily_protocol_fee_collected AS ( + SELECT + d.day, + d.pool_id, + d.token_address, + d.fee_type, + SUM(d.protocol_fee_amount_raw) AS token_amount_raw + FROM ( + SELECT + date_trunc('day', evt_block_time) AS day, + pool AS pool_id, + token AS token_address, + 'swap_fee' AS fee_type, + SUM(amount) AS protocol_fee_amount_raw + FROM {{ source(project_decoded_as + '_' + blockchain, 'ProtocolFeeController_evt_ProtocolSwapFeeCollected') }} + GROUP BY 1, 2, 3, 4 + + UNION ALL + + SELECT + date_trunc('day', evt_block_time) AS day, + pool AS pool_id, + token AS token_address, + 'yield_fee' AS fee_type, + SUM(amount) AS protocol_fee_amount_raw + FROM {{ source(project_decoded_as + '_' + blockchain, 'ProtocolFeeController_evt_ProtocolYieldFeeCollected') }} + GROUP BY 1, 2, 3, 4 + ) d + GROUP BY 1, 2, 3, 4 + ), + + decorated_protocol_fee AS ( + SELECT + d.day, + d.pool_id, + d.token_address, + t.symbol AS token_symbol, + d.fee_type, + SUM(d.token_amount_raw) AS token_amount_raw, + SUM(d.token_amount_raw / POWER(10, COALESCE(t.decimals,p1.decimals, p3.decimals, p4.decimals))) AS token_amount, + SUM(COALESCE(p1.price, p2.price, p3.price, p4.price) * token_amount_raw / POWER(10, COALESCE(t.decimals,p1.decimals, p3.decimals, p4.decimals))) AS protocol_fee_collected_usd + FROM daily_protocol_fee_collected d + LEFT JOIN prices p1 + ON p1.token = d.token_address + AND p1.day = d.day + LEFT JOIN dex_prices p2 + ON p2.token = d.token_address + AND p2.day = d.day + LEFT JOIN bpt_prices p3 + ON p3.token = d.token_address + AND p3.day <= d.day + AND d.day < p3.day_of_next_change + LEFT JOIN erc4626_prices p4 ON p4.day <= d.day + AND d.day < p4.next_change + AND p4.token = d.token_address + LEFT JOIN {{ source('tokens', 'erc20') }} t + ON t.contract_address = d.token_address + AND t.blockchain = '{{blockchain}}' + GROUP BY 1, 2, 3, 4, 5 + ), + + revenue_share as( + SELECT + day, + CASE + WHEN day < DATE '2022-07-03' THEN 0.25 -- veBAL release + WHEN day >= DATE '2022-07-03' AND day < DATE '2023-01-23' THEN 0.25 -- BIP 19 + WHEN day >= DATE '2023-01-23' AND day < DATE '2023-07-24' THEN 0.35 -- BIP 161 + WHEN day >= DATE '2023-07-24' THEN 0.175 -- BIP 371 + END AS treasury_share + FROM UNNEST(SEQUENCE(DATE '2022-03-01', CURRENT_DATE, INTERVAL '1' DAY)) AS date(day) + ) + + + SELECT + f.day, + f.pool_id, + BYTEARRAY_SUBSTRING(f.pool_id,1,20) as pool_address, + l.name AS pool_symbol, + '{{version}}' as version, + '{{blockchain}}' as blockchain, + l.pool_type, + f.fee_type, + f.token_address, + f.token_symbol, + SUM(f.token_amount_raw) as token_amount_raw, + SUM(f.token_amount) as token_amount, + SUM(f.protocol_fee_collected_usd) as protocol_fee_collected_usd, + r.treasury_share, + SUM(f.protocol_fee_collected_usd) * r.treasury_share as treasury_revenue_usd + FROM decorated_protocol_fee f + INNER JOIN revenue_share r + ON r.day = f.day + LEFT JOIN pool_labels l + ON BYTEARRAY_SUBSTRING(f.pool_id,1,20) = l.address + GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 14 + +{% endmacro %} \ No newline at end of file diff --git a/dbt_macros/shared/balancer/balancer_token_balance_changes_daily_agg_macro.sql b/dbt_macros/shared/balancer/balancer_token_balance_changes_daily_agg_macro.sql index 8930036313b..2d177e5d182 100644 --- a/dbt_macros/shared/balancer/balancer_token_balance_changes_daily_agg_macro.sql +++ b/dbt_macros/shared/balancer/balancer_token_balance_changes_daily_agg_macro.sql @@ -182,3 +182,198 @@ WITH AND w.token_address = c.token_address LEFT JOIN eth_prices e ON e.day = c.block_date {% endmacro %} + +{# ######################################################################### #} + +{% macro + balancer_v3_compatible_token_balance_changes_daily_agg_macro( + blockchain, version, project_decoded_as, base_spells_namespace + ) +%} +WITH + prices AS ( + SELECT + date_trunc('day', minute) AS day, + contract_address AS token, + decimals, + AVG(price) AS price + FROM {{ source('prices', 'usd') }} + WHERE blockchain = '{{blockchain}}' + {% if is_incremental() %} + WHERE {{ incremental_predicate('minute') }} + {% endif %} + GROUP BY 1, 2, 3 + ), + + dex_prices_1 AS ( + SELECT + date_trunc('day', HOUR) AS DAY, + contract_address AS token, + approx_percentile(median_price, 0.5) AS price, + sum(sample_size) AS sample_size + FROM {{ source('dex', 'prices') }} + {% if is_incremental() %} + WHERE {{ incremental_predicate('hour') }} + {% endif %} + GROUP BY 1, 2 + HAVING sum(sample_size) > 3 + ), + + dex_prices_2 AS( + SELECT + day, + token, + price, + lag(price) OVER(PARTITION BY token ORDER BY day) AS previous_price + FROM dex_prices_1 + ), + + dex_prices AS ( + SELECT + day, + token, + price, + LEAD(DAY, 1, NOW()) OVER (PARTITION BY token ORDER BY DAY) AS day_of_next_change + FROM dex_prices_2 + WHERE (price < previous_price * 1e4 AND price > previous_price / 1e4) + ), + + bpt_prices AS( + SELECT DISTINCT + day, + contract_address AS token, + decimals, + bpt_price + FROM {{ ref(base_spells_namespace + '_bpt_prices') }} + WHERE blockchain = '{{blockchain}}' + {% if is_incremental() %} + AND {{ incremental_predicate('day') }} + {% endif %} + AND version = '{{version}}' + ), + + eth_prices AS ( + SELECT + DATE_TRUNC('day', minute) as day, + AVG(price) as eth_price + FROM {{ source('prices', 'usd') }} + WHERE symbol = 'ETH' + {% if is_incremental() %} + WHERE {{ incremental_predicate('minute') }} + {% endif %} + GROUP BY 1 + ), + + erc4626_prices AS( + SELECT + date_trunc('day', minute) AS day, + wrapped_token AS token, + decimals, + APPROX_PERCENTILE(median_price, 0.5) AS price, + DATE_TRUNC ('day', next_change) AS next_change + FROM {{ ref('balancer_v3_erc4626_token_prices') }} + WHERE blockchain = '{{blockchain}}' + GROUP BY 1, 2, 3, 5 + ), + + daily_balance AS ( + SELECT + block_date, + pool_id, + pool_symbol, + pool_type, + token_address, + token_symbol, + LEAD(block_date, 1, NOW()) OVER (PARTITION BY token_address, pool_id ORDER BY block_date) AS day_of_next_change, + SUM(delta_amount) AS daily_amount + FROM {{ ref(base_spells_namespace + '_token_balance_changes') }} + WHERE blockchain = '{{blockchain}}' + AND version = '{{version}}' + GROUP BY 1, 2, 3, 4, 5, 6 + ), + + calendar AS ( + SELECT date_sequence AS day + FROM unnest(sequence(date('2024-12-01'), date(now()), interval '1' day)) as t(date_sequence) + ), + + daily_usd_balance AS ( + SELECT + c.day AS block_date, + '{{blockchain}}"' as blockchain, + b.pool_id, + b.pool_symbol, + b.pool_type, + b.token_address, + b.token_symbol, + daily_amount, + daily_amount * COALESCE(p1.price, p2.price, p3.bpt_price, p4.price, 0) AS daily_amount_usd + FROM calendar c + LEFT JOIN daily_balance b ON b.block_date <= c.day + AND c.day < b.day_of_next_change + LEFT JOIN prices p1 ON p1.day = b.block_date + AND p1.token = b.token_address + LEFT JOIN dex_prices p2 ON p2.day <= c.day + AND c.day < p2.day_of_next_change + AND p2.token = b.token_address + LEFT JOIN bpt_prices p3 ON p3.day = b.block_date + AND p3.token = b.token_address + LEFT JOIN erc4626_prices p4 ON p4.day <= c.day + AND c.day < p4.next_change + AND p4.token = b.token_address + WHERE b.token_address != BYTEARRAY_SUBSTRING(b.pool_id, 1, 20) + ), + + weighted_pool_amount_estimates AS ( + SELECT + b.block_date, + b.pool_id, + q.name, + pool_type, + ROW_NUMBER() OVER (PARTITION BY b.block_date, b.pool_id ORDER BY SUM(b.daily_amount_usd) ASC) AS pricing_count, --to avoid double count in pools with multiple pricing assets + SUM(b.daily_amount_usd) / COALESCE(SUM(w.normalized_weight), 1) AS weighted_daily_amount_usd + FROM daily_usd_balance b + LEFT JOIN {{ ref(base_spells_namespace + '_pools_tokens_weights') }} w ON b.pool_id = w.pool_id + AND b.token_address = w.token_address + AND b.daily_amount_usd > 0 + LEFT JOIN {{ source('balancer','token_whitelist') }} q ON b.token_address = q.address + AND b.blockchain = q.chain + WHERE q.name IS NOT NULL + AND b.pool_type = 'weighted' -- filters for weighted pools with pricing assets + AND w.blockchain = '{{blockchain}}' + AND w.version = '2' + GROUP BY 1, 2, 3, 4 + ), + + weighted_pool_amount_estimates_2 AS( + SELECT e.block_date, + e.pool_id, + SUM(e.weighted_daily_amount_usd) / MAX(e.pricing_count) AS weighted_daily_amount_usd + FROM weighted_pool_amount_estimates e + GROUP BY 1,2 + ) + + SELECT + c.block_date, + c.pool_id, + BYTEARRAY_SUBSTRING(c.pool_id, 1, 20) AS pool_address, + c.pool_symbol, + '2' AS version, + '{{blockchain}}' AS blockchain, + c.pool_type, + c.token_address, + c.token_symbol, + c.daily_amount AS daily_delta, + COALESCE(b.weighted_daily_amount_usd * w.normalized_weight, c.daily_amount_usd) AS daily_delta_usd, + COALESCE(b.weighted_daily_amount_usd * w.normalized_weight, c.daily_amount_usd)/e.eth_price AS daily_delta_eth + FROM daily_usd_balance c + FULL OUTER JOIN weighted_pool_amount_estimates_2 b ON c.block_date = b.block_date + AND c.pool_id = b.pool_id + LEFT JOIN {{ ref(base_spells_namespace + '_pools_tokens_weights') }} w ON b.pool_id = w.pool_id + AND w.blockchain = '{{blockchain}}' + AND w.version = '2' + AND w.token_address = c.token_address + LEFT JOIN eth_prices e ON e.day = c.block_date + {% endmacro %} + +{# ######################################################################### #} diff --git a/dbt_macros/shared/balancer/balancer_token_balance_changes_macro.sql b/dbt_macros/shared/balancer/balancer_token_balance_changes_macro.sql index 4e606ed955b..d22a7da1cb8 100644 --- a/dbt_macros/shared/balancer/balancer_token_balance_changes_macro.sql +++ b/dbt_macros/shared/balancer/balancer_token_balance_changes_macro.sql @@ -166,4 +166,200 @@ WITH pool_labels AS ( WHERE {{ incremental_predicate('evt_block_time') }} {% endif %} + {% endmacro %} + +{# ######################################################################### #} + +{% macro + balancer_v3_compatible_token_balance_changes_macro( + blockchain, version, project_decoded_as, base_spells_namespace, pool_labels_spell + ) +%} +WITH pool_labels AS ( + SELECT + address AS pool_id, + name AS pool_symbol, + pool_type + FROM {{ pool_labels_spell }} + WHERE blockchain = '{{blockchain}}' + ), + + token_data AS ( + SELECT + pool, + ARRAY_AGG(FROM_HEX(json_extract_scalar(token, '$.token')) ORDER BY token_index) AS tokens + FROM ( + SELECT + pool, + tokenConfig, + SEQUENCE(1, CARDINALITY(tokenConfig)) AS token_index_array + FROM {{ source(project_decoded_as + '_' + blockchain, 'Vault_evt_PoolRegistered') }} + ) AS pool_data + CROSS JOIN UNNEST(tokenConfig, token_index_array) AS t(token, token_index) + GROUP BY 1 + ), + + swaps_changes AS ( + SELECT + evt_block_time, + evt_block_number, + evt_tx_hash, + evt_index, + pool_id, + token, + SUM(COALESCE(delta, INT256 '0')) AS delta + FROM + ( + SELECT + evt_block_time, + evt_block_number, + evt_tx_hash, + evt_index, + pool AS pool_id, + tokenIn AS token, + CAST(amountIn as int256) AS delta + FROM {{ source(project_decoded_as + '_' + blockchain, 'Vault_evt_Swap') }} + + UNION ALL + + SELECT + evt_block_time, + evt_block_number, + evt_tx_hash, + evt_index, + pool AS pool_id, + tokenOut AS token, + -CAST(amountOut AS int256) AS delta + FROM {{ source(project_decoded_as + '_' + blockchain, 'Vault_evt_Swap') }} + ) swaps + GROUP BY 1, 2, 3, 4, 5, 6 + ), + + balance_changes AS( + SELECT + evt_block_time, + evt_block_number, + evt_tx_hash, + evt_index, + pool_id, + category, + deltas, + swapFeeAmountsRaw + FROM + ( + SELECT + evt_block_time, + evt_block_number, + evt_tx_hash, + evt_index, + pool AS pool_id, + 'add' AS category, + amountsAddedRaw AS deltas, + swapFeeAmountsRaw + FROM {{ source(project_decoded_as + '_' + blockchain, 'Vault_evt_LiquidityAdded') }} + + UNION ALL + + SELECT + evt_block_time, + evt_block_number, + evt_tx_hash, + evt_index, + pool AS pool_id, + 'remove' AS category, + amountsRemovedRaw AS deltas, + swapFeeAmountsRaw + FROM {{ source(project_decoded_as + '_' + blockchain, 'Vault_evt_LiquidityRemoved') }} + ) adds_and_removes + ), + + zipped_balance_changes AS ( + SELECT + evt_block_time, + evt_block_number, + evt_tx_hash, + evt_index, + pool_id, + t.tokens, + CASE WHEN b.category = 'add' + THEN d.deltas + WHEN b.category = 'remove' + THEN -d.deltas + END AS deltas, + p.swapFeeAmountsRaw + FROM balance_changes b + JOIN token_data td ON b.pool_id = td.pool + CROSS JOIN UNNEST (td.tokens) WITH ORDINALITY as t(tokens,i) + CROSS JOIN UNNEST (b.deltas) WITH ORDINALITY as d(deltas,i) + CROSS JOIN UNNEST (b.swapFeeAmountsRaw) WITH ORDINALITY as p(swapFeeAmountsRaw,i) + WHERE t.i = d.i + AND d.i = p.i + ORDER BY 1,2,3 + ), + + balances_changes AS ( + SELECT + evt_block_time, + evt_block_number, + evt_tx_hash, + evt_index, + pool_id, + tokens AS token, + deltas - CAST(swapFeeAmountsRaw as int256) AS delta + FROM zipped_balance_changes + ORDER BY 1, 2, 3 + ) + + + SELECT + date_trunc('day', b.evt_block_time) AS block_date, + b.evt_block_time, + b.evt_block_number, + '{{blockchain}}' AS blockchain, + b.evt_tx_hash, + b.evt_index, + b.pool_id, + BYTEARRAY_SUBSTRING(b.pool_id, 1, 20) AS pool_address, + p.pool_symbol, + p.pool_type, + '{{version}}' AS version, + b.token AS token_address, + t.symbol AS token_symbol, + b.amount AS delta_amount_raw, + CASE WHEN BYTEARRAY_SUBSTRING(b.pool_id, 1, 20) = b.token + THEN amount / POWER (10, 18) --for Balancer Pool Tokens + ELSE amount / POWER (10, COALESCE(t.decimals, 0)) + END AS delta_amount + FROM + ( + SELECT + evt_block_time, + evt_block_number, + evt_tx_hash, + evt_index, + pool_id, + token, + COALESCE(delta, INT256 '0') AS amount + FROM balances_changes + + UNION ALL + + SELECT + evt_block_time, + evt_block_number, + evt_tx_hash, + evt_index, + pool_id, + token, + delta AS amount + FROM + swaps_changes + ) b + LEFT JOIN {{ source('tokens', 'erc20') }} t ON t.contract_address = b.token + AND blockchain = '{{blockchain}}' + LEFT JOIN pool_labels p ON p.pool_id = BYTEARRAY_SUBSTRING(b.pool_id, 1, 20) + {% if is_incremental() %} + WHERE {{ incremental_predicate('evt_block_time') }} + {% endif %} + {% endmacro %} \ No newline at end of file diff --git a/dbt_macros/shared/balancer/balancer_transfers_bpt_macro.sql b/dbt_macros/shared/balancer/balancer_transfers_bpt_macro.sql index e7137266c70..bfe582be148 100644 --- a/dbt_macros/shared/balancer/balancer_transfers_bpt_macro.sql +++ b/dbt_macros/shared/balancer/balancer_transfers_bpt_macro.sql @@ -33,6 +33,44 @@ {% if is_incremental() %} WHERE {{ incremental_predicate('evt_block_time') }} {% endif %} ) transfers + {% endmacro %} + {# ######################################################################### #} + {% macro + balancer_v3_compatible_transfers_bpt_macro( + blockchain, version, project_decoded_as + ) +%} + + WITH registered_pools AS ( + SELECT + DISTINCT pool AS pool_address + FROM + {{ source(project_decoded_as + '_' + blockchain, 'Vault_evt_PoolRegistered') }} + ) + + SELECT DISTINCT * FROM ( + SELECT + '{{blockchain}}' AS blockchain, + '{{version}}' AS version, + transfer.contract_address, + transfer.evt_tx_hash, + transfer.evt_index, + transfer.evt_block_time, + TRY_CAST(date_trunc('DAY', transfer.evt_block_time) AS date) AS block_date, + TRY_CAST(date_trunc('MONTH', transfer.evt_block_time) AS date) AS block_month, + transfer.evt_block_number, + transfer."from", + transfer.to, + transfer.value + FROM {{ source('erc20_' + blockchain, 'evt_transfer') }} transfer + INNER JOIN registered_pools p ON p.pool_address = transfer.contract_address + {% if not is_incremental() %} + WHERE transfer.evt_block_time >= TIMESTAMP '2024-12-01' + {% endif %} + {% if is_incremental() %} + WHERE {{ incremental_predicate('evt_block_time') }} + {% endif %} ) transfers + {% endmacro %} \ No newline at end of file diff --git a/dbt_macros/shared/balances_incremental_subset_daily.sql b/dbt_macros/shared/balances_incremental_subset_daily.sql index 9e330747b25..a8566504dd6 100644 --- a/dbt_macros/shared/balances_incremental_subset_daily.sql +++ b/dbt_macros/shared/balances_incremental_subset_daily.sql @@ -2,6 +2,9 @@ @NOTICE this macro constructs the address level token balances table for given input table @NOTICE aka, you give lists of tokens and/or address, it generates table with daily balances of the address-token pair + + @WARN this macro has a dependancy on erc20.tokens. + @WARN if your token is not in the default list, manually add it via spellbook/dbt_subprojects/tokens/models/tokens//tokens__erc20.sql @PARAM blockchain -- blockchain name @PARAM address_list -- must have an address column, can be none if only filtering on tokens @@ -149,14 +152,18 @@ from( {% endif %} ) b -left join {{source('prices','usd')}} p - on (token_standard = 'erc20' +left join {{source('prices','usd_daily')}} p + on 1=1 + {% if is_incremental() %} + and {{ incremental_predicate('p.day') }} + {% endif %} + and ((token_standard = 'erc20' and p.blockchain = '{{blockchain}}' and b.token_address = p.contract_address - and b.day = p.minute) + and b.day = p.day) or (token_standard = 'native' and p.blockchain is null and p.contract_address is null and p.symbol = (select native_token_symbol from {{source('evms','info')}} where blockchain = '{{blockchain}}') - and b.day = p.minute) + and b.day = p.day)) {% endmacro %} diff --git a/dbt_subprojects/daily_spellbook/README.md b/dbt_subprojects/daily_spellbook/README.md index be76883e83d..284f462bfd6 100644 --- a/dbt_subprojects/daily_spellbook/README.md +++ b/dbt_subprojects/daily_spellbook/README.md @@ -1,3 +1,3 @@ ## Daily Spellbook -This is a DBT sub project for the the main models of Spellbook that runs on a daily candence. \ No newline at end of file +This is a DBT sub project for the the main models of Spellbook that runs on a daily candence. diff --git a/dbt_subprojects/daily_spellbook/dbt_project.yml b/dbt_subprojects/daily_spellbook/dbt_project.yml index 6b78c227a00..3de0a51a609 100644 --- a/dbt_subprojects/daily_spellbook/dbt_project.yml +++ b/dbt_subprojects/daily_spellbook/dbt_project.yml @@ -14,6 +14,9 @@ quoting: # profile: "spellbook-poc-tokens" profile: "spellbook-local" +flags: + require_certificate_validation: true + vars: DBT_ENV_CUSTOM_ENV_S3_BUCKET: "{{ env_var('DBT_ENV_CUSTOM_ENV_S3_BUCKET', 'local') }}" DBT_ENV_INCREMENTAL_TIME: "{{ env_var('DBT_ENV_INCREMENTAL_TIME', '3') }}" diff --git a/dbt_subprojects/daily_spellbook/macros/project/bungee/bungee_SocketBridge_macro.sql b/dbt_subprojects/daily_spellbook/macros/project/bungee/bungee_SocketBridge_macro.sql new file mode 100644 index 00000000000..93a0a13dbd5 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/macros/project/bungee/bungee_SocketBridge_macro.sql @@ -0,0 +1,23 @@ +{% macro bungee_SocketBridge(blockchain) %} + +select + contract_address, + evt_tx_hash, + evt_index, + evt_block_time, + evt_block_number, + amount, + token, + toChainId, + bridgeName, + sender, + receiver, + metadata, + '{{ blockchain }}' as source_chain, + {{ dbt_utils.generate_surrogate_key(['evt_tx_hash', 'evt_index']) }} as transfer_id +from {{ source('socket_v2_' ~ blockchain, 'SocketGateway_evt_SocketBridge') }} +{% if is_incremental() %} +where {{ incremental_predicate('evt_block_time') }} +{% endif %} + +{% endmacro %} diff --git a/dbt_subprojects/daily_spellbook/macros/project/lifi/lifi_extract_bridge_data_macro.sql b/dbt_subprojects/daily_spellbook/macros/project/lifi/lifi_extract_bridge_data_macro.sql new file mode 100644 index 00000000000..7210078cee3 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/macros/project/lifi/lifi_extract_bridge_data_macro.sql @@ -0,0 +1,37 @@ +{% macro lifi_extract_bridge_data(blockchain) %} + +{% set bridge_data_fields = [ + 'transactionId', + 'bridge', + 'integrator', + 'referrer', + 'sendingAssetId', + 'receiver', + 'minAmount', + 'destinationChainId' +] %} + +select + contract_address, + evt_tx_hash as tx_hash, + evt_index, + evt_block_time as block_time, + evt_block_number as block_number, + cast(date_trunc('day', evt_block_time) as date) as block_date, + {% for field in bridge_data_fields %} + {% if field in ['transactionId', 'referrer', 'sendingAssetId', 'receiver'] %} + from_hex(json_extract_scalar(bridgedata, '$.{{ field }}')) as {{ field }}, + {% elif field == 'minAmount' %} + cast(json_extract_scalar(bridgedata, '$.{{ field }}') as double) as {{ field }}, + {% else %} + json_extract_scalar(bridgedata, '$.{{ field }}') as {{ field }}, + {% endif %} + {% endfor %} + '{{ blockchain }}' as source_chain, + {{ dbt_utils.generate_surrogate_key(['evt_tx_hash', 'evt_index']) }} as transfer_id +from {{ source('lifi_' ~ blockchain, 'LiFiDiamond_v2_evt_LiFiTransferStarted') }} +{% if is_incremental() %} +where {{ incremental_predicate('evt_block_time') }} +{% endif %} + +{% endmacro %} diff --git a/dbt_subprojects/daily_spellbook/macros/project/oneinch/_meta/oneinch_mapped_contracts_macro.sql b/dbt_subprojects/daily_spellbook/macros/project/oneinch/_meta/oneinch_mapped_contracts_macro.sql index c41474053bc..51d242c34ab 100644 --- a/dbt_subprojects/daily_spellbook/macros/project/oneinch/_meta/oneinch_mapped_contracts_macro.sql +++ b/dbt_subprojects/daily_spellbook/macros/project/oneinch/_meta/oneinch_mapped_contracts_macro.sql @@ -79,7 +79,7 @@ , ('0xbf1fc29668e5f5eaa819948599c9ac1b1e03e75f', 'true', 'Cone' , 'ConeRouter01' , ['bnb']) , ('0x11984dc4465481512eb5b777e44061c158cf2259', 'true', 'Connext' , 'ConnextDiamond' , ['polygon']) , ('0xee9dec2712cce65174b561151701bf54b99c24c8', 'true', 'Connext' , 'ConnextDiamond' , ['arbitrum']) - , ('0x9008d19f58aabd9ed0d60971565aa8510560ab41', 'true', 'CoWSwap' , 'GPv2Settlement' , ['ethereum','gnosis','arbitrum']) + , ('0x9008d19f58aabd9ed0d60971565aa8510560ab41', 'true', 'CoWSwap' , 'GPv2Settlement' , ['ethereum','gnosis','arbitrum','base']) , ('0xfa43de785dd3cd0ef3dae0dd2b8be3f1b5112d1a', 'true', 'CrossCurve' , 'UnifiedRouterV2v1' , ['ethereum','bnb','polygon','gnosis','arbitrum','avalanche_c','optimism','base','fantom']) , ('0xa2a786ff9148f7c88ee93372db8cbe9e94585c74', 'true', 'CrossCurve' , 'UnifiedRouterV2v5' , ['ethereum','bnb','polygon','gnosis','arbitrum','avalanche_c','optimism','base','fantom','blast','linea','mantle']) , ('0xe7db62c7960183895190274f26925388db4a3be4', 'true', 'CrossCurve' , 'UnifiedRouterV2' , ['ethereum','bnb','polygon','gnosis','arbitrum','avalanche_c','optimism','base','fantom']) @@ -324,10 +324,10 @@ , ('0xb971ef87ede563556b2ed4b1c0b0019111dd85d2', 'true', 'Uniswap' , 'UNDEFINED' , ['bnb']) , ('0x2626664c2603336e57b271c5c0b26f421741e481', 'true', 'Uniswap' , 'UNDEFINED' , ['base']) , ('0x198ef79f1f515f02dfe9e3115ed9fc07183f02fc', 'true', 'Uniswap' , 'UNDEFINED' , ['base']) - , ('0xe80bf394d190851e215d5f67b67f8f5a52783f1e', 'true', 'Uniswap' , 'UniswapXV1' , ['ethereum']) - , ('0x6000da47483062a0d734ba3dc7576ce6a0b645c4', 'true', 'Uniswap' , 'UniswapXV1' , ['ethereum']) - , ('0x00000011f84b9aa48e5f8aa8b9897600006289be', 'true', 'Uniswap' , 'UniswapXV2' , ['ethereum']) - , ('0x1bd1aAdc9E230626C44a139d7E70d842749351eb', 'true', 'Uniswap' , 'UniswapXV2' , ['arbitrum']) + , ('0xe80bf394d190851e215d5f67b67f8f5a52783f1e', 'true', 'UniswapX' , 'UniswapXV1' , ['ethereum']) + , ('0x6000da47483062a0d734ba3dc7576ce6a0b645c4', 'true', 'UniswapX' , 'UniswapXV1' , ['ethereum']) + , ('0x00000011f84b9aa48e5f8aa8b9897600006289be', 'true', 'UniswapX' , 'UniswapXV2' , ['ethereum']) + , ('0x1bd1aAdc9E230626C44a139d7E70d842749351eb', 'true', 'UniswapX' , 'UniswapXV2' , ['arbitrum']) , ('0x9c12939390052919af3155f41bf4160fd3666a6f', 'true', 'Velodrome' , 'Router' , ['optimism']) , ('0xa132dab612db5cb9fc9ac426a0cc215a3423f9c9', 'true', 'Velodrome' , 'Router' , ['optimism']) , ('0x777777773fdd8b28bb03377d10fcea75ad9768da', 'true', 'Viarouter' , 'ViaRouter' , ['polygon','arbitrum','optimism']) diff --git a/dbt_subprojects/daily_spellbook/macros/project/oneinch/_meta/oneinch_project_swaps_exposed_blockchains_list.sql b/dbt_subprojects/daily_spellbook/macros/project/oneinch/_meta/oneinch_project_swaps_exposed_blockchains_list.sql index 7f0d322d55d..3d305d8d719 100644 --- a/dbt_subprojects/daily_spellbook/macros/project/oneinch/_meta/oneinch_project_swaps_exposed_blockchains_list.sql +++ b/dbt_subprojects/daily_spellbook/macros/project/oneinch/_meta/oneinch_project_swaps_exposed_blockchains_list.sql @@ -8,6 +8,7 @@ 'bnb', 'gnosis', 'fantom', - 'base', + 'base', + 'zksync', ]) }} {% endmacro %} \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/macros/project/oneinch/project/cfg/oneinch_project_orders_cfg_methods_macro.sql b/dbt_subprojects/daily_spellbook/macros/project/oneinch/project/cfg/oneinch_project_orders_cfg_methods_macro.sql index 9afcded3291..47938970284 100644 --- a/dbt_subprojects/daily_spellbook/macros/project/oneinch/project/cfg/oneinch_project_orders_cfg_methods_macro.sql +++ b/dbt_subprojects/daily_spellbook/macros/project/oneinch/project/cfg/oneinch_project_orders_cfg_methods_macro.sql @@ -475,7 +475,7 @@ {% set _taker_data = "4 + 32*4 + bytearray_to_bigint(substr(input, 4 + 32*13 + 24 + 1, 8))" %} {% set _recipients = "bytearray_to_bigint(substr(input, " ~ _taker_data ~ " + 32*1 + 24 + 1, 8))" %} {% set methods = methods + [{ - "project": "Uniswap", + "project": "UniswapX", "selector": "0x3f62192e", "tag": "'UniswapXV1'", "name": "execute", @@ -501,7 +501,7 @@ {% set _taker_data = "4 + 32*5 + bytearray_to_bigint(substr(input, 4 + 32*14 + 24 + 1, 8))" %} {% set _recipients = "bytearray_to_bigint(substr(input, " ~ _taker_data ~ " + 32*1 + 24 + 1, 8))" %} {% set methods = methods + [{ - "project": "Uniswap", + "project": "UniswapX", "selector": "0x0d335884", "tag": "'UniswapXV1'", "name": "executeWithCallback", @@ -528,7 +528,7 @@ {% set _taker_data = "bytearray_to_bigint(substr(input, " ~ _order_beginning ~ " + 32*12 + 24 + 1, 8))" %} {% set _recipients = "bytearray_to_bigint(substr(input, " ~ _order_beginning ~ " + " ~ _taker_data ~ " + 32*4 + 24 + 1, 8))" %} {% set methods = methods + [{ - "project": "Uniswap", + "project": "UniswapX", "selector": "0x0d7a16c3", "tag": "'UniswapXV1'", "name": "executeBatch", @@ -557,7 +557,7 @@ {% set _taker_data = "bytearray_to_bigint(substr(input, " ~ _order_beginning ~ " + 32*12 + 24 + 1, 8))" %} {% set _recipients = "bytearray_to_bigint(substr(input, " ~ _order_beginning ~ " + " ~ _taker_data ~ " + 32*4 + 24 + 1, 8))" %} {% set methods = methods + [{ - "project": "Uniswap", + "project": "UniswapX", "selector": "0x13fb72c7", "tag": "'UniswapXV1'", "name": "executeBatchWithCallback", @@ -584,7 +584,7 @@ {% set _taker_data = "4 + 32*1 + bytearray_to_bigint(substr(input, 4 + 32*10 + 24 + 1, 8))" %} {% set _recipients = "bytearray_to_bigint(substr(input, " ~ _taker_data ~ " + 32*4 + 24 + 1, 8))" %} {% set methods = methods + [{ - "project": "Uniswap", + "project": "UniswapX", "selector": "0x3f62192e", "tag": "'UniswapXV2'", "name": "execute", @@ -610,7 +610,7 @@ {% set _taker_data = "4 + 32*2 + bytearray_to_bigint(substr(input, 4 + 32*11 + 24 + 1, 8))" %} {% set _recipients = "bytearray_to_bigint(substr(input, " ~ _taker_data ~ " + 32*4 + 24 + 1, 8))" %} {% set methods = methods + [{ - "project": "Uniswap", + "project": "UniswapX", "selector": "0x0d335884", "tag": "'UniswapXV2'", "name": "executeWithCallback", @@ -638,7 +638,7 @@ {% set _taker_data = "bytearray_to_bigint(substr(input, " ~ _order_beginning ~ " + 32*9 + 24 + 1, 8))" %} {% set _recipients = "bytearray_to_bigint(substr(input, " ~ _order_beginning ~ " + " ~ _taker_data ~ " + 32*4 + 24 + 1, 8))" %} {% set methods = methods + [{ - "project": "Uniswap", + "project": "UniswapX", "selector": "0x13fb72c7", "tag": "'UniswapXV2'", "name": "executeBatchWithCallback", diff --git a/dbt_subprojects/daily_spellbook/macros/project/oneinch/project/oneinch_project_swaps_macro.sql b/dbt_subprojects/daily_spellbook/macros/project/oneinch/project/oneinch_project_swaps_macro.sql index b361c3c31f5..b4699961a0b 100644 --- a/dbt_subprojects/daily_spellbook/macros/project/oneinch/project/oneinch_project_swaps_macro.sql +++ b/dbt_subprojects/daily_spellbook/macros/project/oneinch/project/oneinch_project_swaps_macro.sql @@ -27,7 +27,7 @@ meta as ( block_number , tx_hash , call_trace_address - , project + , project as order_project , order_hash , maker , taker @@ -51,7 +51,7 @@ meta as ( block_number , tx_hash , call_trace_address - , '1inch' as project + , '1inch' as order_project , coalesce(order_hash, concat(tx_hash, to_big_endian_32(cast(counter as int)))) as order_hash , maker , receiver as taker @@ -81,7 +81,7 @@ meta as ( , tx_from , tx_to , call_trace_address - , project + , coalesce(order_project, project) as project , tag , flags , call_selector @@ -96,7 +96,7 @@ meta as ( , making_amount , replace(taker_asset, {{ zero_address }}, {{ native_address }}) as taker_asset , taking_amount - , array_agg(call_trace_address) over(partition by block_number, tx_hash, project) as call_trace_addresses -- to update the array after filtering nested calls of the project + , array_agg(call_trace_address) over(partition by block_number, tx_hash, coalesce(order_project, project)) as call_trace_addresses -- to update the array after filtering nested calls of the project , if(maker_asset in {{native_addresses}}, wrapped_native_token_address, maker_asset) as _maker_asset , if(taker_asset in {{native_addresses}}, wrapped_native_token_address, taker_asset) as _taker_asset , coalesce(order_hash, to_big_endian_64(counter)) as call_trade_id -- without call_trade for the correctness of the max transfer approach @@ -116,7 +116,7 @@ meta as ( and call_success and (flags['cross_chain'] or not flags['cross_chain_method']) -- without cross-chain methods calls in non cross-chain protocols ) - left join orders using(block_number, tx_hash, call_trace_address, project) + left join orders using(block_number, tx_hash, call_trace_address) join meta on true where reduce(call_trace_addresses, true, (r, x) -> if(r and x <> call_trace_address and slice(call_trace_address, 1, cardinality(x)) = x, false, r), r -> r) -- only not nested calls of the project in tx @@ -314,11 +314,36 @@ meta as ( select * , map_from_entries(array[ - ('classic: direct', flags['direct'] and order_hash is null and not auction and not cross_chain_swap or second_side) - , ('classic: external', not flags['direct'] and order_hash is null and not auction and not cross_chain_swap) - , ('intent: intra-chain auction', auction and not cross_chain_swap) - , ('intent: intra-chain user limit order', order_hash is not null and not auction and not cross_chain_swap and not contracts_only) - , ('intent: intra-chain contracts only', contracts_only) + ('intra-chain: classic: direct', + flags['direct'] + and order_hash is null + and not auction + and not cross_chain_swap + and not contracts_only + or second_side + ) + , ('intra-chain: classic: external', + not flags['direct'] + and order_hash is null + and not auction + and not contracts_only + and not cross_chain_swap + ) + , ('intra-chain: intents: auction', + auction + and not cross_chain_swap + ) + , ('intra-chain: intents: user limit order', + order_hash is not null + and not auction + and not cross_chain_swap + and not contracts_only + and not second_side + ) + , ('intra-chain: intents: contracts only', + contracts_only + and not second_side + ) , ('cross-chain', cross_chain_swap) ]) as modes from ( diff --git a/dbt_subprojects/daily_spellbook/macros/project/yield_yak/yield_yak_strategies.sql b/dbt_subprojects/daily_spellbook/macros/project/yield_yak/yield_yak_strategies.sql index 677d70269d8..cb58bcc6c86 100644 --- a/dbt_subprojects/daily_spellbook/macros/project/yield_yak/yield_yak_strategies.sql +++ b/dbt_subprojects/daily_spellbook/macros/project/yield_yak/yield_yak_strategies.sql @@ -107,6 +107,7 @@ 'PenguinStrategyForLPb', 'PlatypusStrategy', 'SonicStrategyForSA', + 'StableJackStrategy', 'StableVaultStrategyForS3D', 'StableVaultStrategyForS3F', 'StargateStrategyForLP', @@ -115,6 +116,7 @@ 'StormStrategyForSA', 'SuStrategyV2', 'SynapseStrategy', + 'TokenMillStrategy', 'UnipoolStrategyV1', 'UspPlatypusStrategy', 'Vault', diff --git a/dbt_subprojects/daily_spellbook/macros/project/yield_yak/yield_yak_user_yrt_balances.sql b/dbt_subprojects/daily_spellbook/macros/project/yield_yak/yield_yak_user_yrt_balances.sql index b9e4ed15e26..faf1f236a10 100644 --- a/dbt_subprojects/daily_spellbook/macros/project/yield_yak/yield_yak_user_yrt_balances.sql +++ b/dbt_subprojects/daily_spellbook/macros/project/yield_yak/yield_yak_user_yrt_balances.sql @@ -31,6 +31,13 @@ existing_contracts AS ( {% endif -%} new_transfers AS ( + SELECT + s.contract_address + , s.block_time + , s.block_number + , s.user_address + , s.net_transfer_amount + FROM ( {%- for strategy in yield_yak_strategies(blockchain) %} SELECT s.contract_address @@ -40,19 +47,8 @@ new_transfers AS ( , SUM(u.net_transfer_amount) AS net_transfer_amount FROM {{ source(namespace_blockchain, strategy + '_evt_Transfer') }} s CROSS JOIN UNNEST(ARRAY[s."from", s.to], ARRAY[-1 * CAST(s.value AS INT256), CAST(s.value AS INT256)]) AS u(user_address, net_transfer_amount) - {%- if is_incremental() %} - LEFT JOIN existing_contracts c - ON c.contract_address = s.contract_address - WHERE - (({{ incremental_predicate('s.evt_block_time') }} - AND s.evt_block_time > c.max_from_time) - OR c.contract_address IS NULL) -- This line allows for new contract_addresses being appended that were not already included in previous runs but also allows their entire historical data to be loaded - AND s."from" != s."to" - {%- endif %} - {%- if not is_incremental() %} WHERE s."from" != s."to" - {%- endif %} GROUP BY s.contract_address , s.evt_block_time @@ -63,6 +59,15 @@ new_transfers AS ( UNION ALL {%- endif -%} {%- endfor %} + ) s + {%- if is_incremental() %} + LEFT JOIN existing_contracts c + ON c.contract_address = s.contract_address + WHERE + ({{ incremental_predicate('s.block_time') }} + AND s.block_time > c.max_from_time) + OR c.contract_address IS NULL -- This line allows for new contract_addresses being appended that were not already included in previous runs but also allows their entire historical data to be loaded + {%- endif %} ), combined_table AS ( diff --git a/dbt_subprojects/daily_spellbook/macros/sector/metrics/metrics_fees_evm.sql b/dbt_subprojects/daily_spellbook/macros/sector/metrics/metrics_fees_evm.sql new file mode 100644 index 00000000000..412b4c7728d --- /dev/null +++ b/dbt_subprojects/daily_spellbook/macros/sector/metrics/metrics_fees_evm.sql @@ -0,0 +1,18 @@ +{% macro metrics_fees_evm(blockchain) %} + +select + blockchain + , block_date + , sum(tx_fee_usd) as gas_fees_usd +from + {{ source('gas', 'fees') }} +where blockchain = '{{blockchain}}' +{% if is_incremental() %} +and + {{ incremental_predicate('block_date') }} +{% endif %} +group by + blockchain + ,block_date + +{% endmacro %} diff --git a/dbt_subprojects/daily_spellbook/macros/sector/metrics/metrics_transactions_evm.sql b/dbt_subprojects/daily_spellbook/macros/sector/metrics/metrics_transactions_evm.sql new file mode 100644 index 00000000000..1ac65276fb3 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/macros/sector/metrics/metrics_transactions_evm.sql @@ -0,0 +1,19 @@ +{% macro metrics_transactions_evm(blockchain) %} + +select + blockchain + , block_date + , approx_distinct(tx_hash) as tx_count --max 2% error, which is fine +from + {{ source('tokens', 'transfers') }} +where + blockchain = '{{ blockchain }}' + and amount_usd >=1 + {% if is_incremental() %} + and {{ incremental_predicate('block_date') }} + {% endif %} +group by + blockchain + , block_date + +{% endmacro %} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transfers/metrics_net_transfers_daily.sql b/dbt_subprojects/daily_spellbook/macros/sector/metrics/metrics_transfers_evm.sql similarity index 88% rename from dbt_subprojects/daily_spellbook/models/_metrics/transfers/metrics_net_transfers_daily.sql rename to dbt_subprojects/daily_spellbook/macros/sector/metrics/metrics_transfers_evm.sql index 584a68edc7a..f96fdd425c8 100644 --- a/dbt_subprojects/daily_spellbook/models/_metrics/transfers/metrics_net_transfers_daily.sql +++ b/dbt_subprojects/daily_spellbook/macros/sector/metrics/metrics_transfers_evm.sql @@ -1,13 +1,4 @@ -{{ config( - schema = 'metrics' - , alias = 'net_transfers_daily' - , materialized = 'incremental' - , file_format = 'delta' - , incremental_strategy = 'merge' - , unique_key = ['blockchain', 'block_date'] - , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] - ) -}} +{% macro metrics_transfers_evm(blockchain) %} with raw_transfers as ( select @@ -19,7 +10,7 @@ with raw_transfers as ( from {{ source('tokens', 'transfers') }} where - 1 = 1 + blockchain = '{{blockchain}}' {% if is_incremental() %} and {{ incremental_predicate('block_date') }} {% endif %} @@ -40,7 +31,7 @@ with raw_transfers as ( from {{ source('tokens', 'transfers') }} where - 1 = 1 + blockchain = '{{blockchain}}' {% if is_incremental() %} and {{ incremental_predicate('block_date') }} {% endif %} @@ -60,6 +51,7 @@ with raw_transfers as ( inner join {{ source('labels', 'owner_details') }} as od on oa.owner_key = od.owner_key + where oa.blockchain = '{{blockchain}}' ), transfers_amount as ( select t.blockchain @@ -108,3 +100,5 @@ where group by blockchain , block_date + +{% endmacro %} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/dune_index/_schema.yml b/dbt_subprojects/daily_spellbook/models/_metrics/dune_index/_schema.yml index 0c19c70acf8..eed04ce6a8c 100644 --- a/dbt_subprojects/daily_spellbook/models/_metrics/dune_index/_schema.yml +++ b/dbt_subprojects/daily_spellbook/models/_metrics/dune_index/_schema.yml @@ -4,7 +4,7 @@ models: - name: metrics_dune_index_daily meta: sector: metrics - contributors: jeff-dude + contributors: jeff-dude, 0xRob config: tags: ['metrics', 'dune', 'index', 'daily'] description: "Combine transactions, transfers and fees index values to get a daily dune index value" @@ -13,10 +13,11 @@ models: combination_of_columns: - blockchain - block_date + - name: metrics_dune_index_stats meta: sector: metrics contributors: jeff-dude config: - tags: ['metrics', 'dune', 'index', 'daily'] - description: "View containing various time aggregations of the dune index" \ No newline at end of file + tags: [ 'metrics', 'dune', 'index', 'daily' ] + description: "View containing various time aggregations of the dune index" diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/dune_index/metrics_dune_index_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/dune_index/metrics_dune_index_daily.sql index e5f68fe3345..593d5136189 100644 --- a/dbt_subprojects/daily_spellbook/models/_metrics/dune_index/metrics_dune_index_daily.sql +++ b/dbt_subprojects/daily_spellbook/models/_metrics/dune_index/metrics_dune_index_daily.sql @@ -1,21 +1,71 @@ {{ config( schema = 'metrics' , alias = 'dune_index_daily' - , materialized = 'view' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] ) }} +{% set baseline_date = '2018-01-01' %} +{% set start_date = '2015-08-21' %} + +with +fees as ( + select + blockchain + , block_date + , gas_fees_usd + , (gas_fees_usd / (select sum(gas_fees_usd) from {{ ref('metrics_gas_fees_daily') }} where block_date = date '{{ baseline_date }}')) * 10 as fees_index + from + {{ ref('metrics_gas_fees_daily') }} + where + block_date >= date '{{ start_date }}' + {% if is_incremental() %} + and {{ incremental_predicate('block_date') }} + {% endif %} +), +transactions as ( + select + blockchain + , block_date + , tx_count + , (tx_count / cast((select sum(tx_count) from {{ ref('metrics_transactions_daily') }} where block_date = date '{{ baseline_date }}') as double)) * 10 as tx_index + from + {{ ref('metrics_transactions_daily') }} + where + block_date >= date '{{ start_date }}' + {% if is_incremental() %} + and {{ incremental_predicate('block_date') }} + {% endif %} +) +,transfers as ( + select + blockchain + , block_date + , net_transfer_amount_usd + , (net_transfer_amount_usd / cast((select sum(net_transfer_amount_usd) from {{ ref('metrics_transfers_daily') }} where block_date = date '{{ baseline_date }}') as double)) * 10 as transfers_index + from + {{ ref('metrics_transfers_daily') }} + where + block_date >= date '{{ start_date }}' + {% if is_incremental() %} + and {{ incremental_predicate('block_date') }} + {% endif %} +) + select blockchain , block_date - , coalesce(f.fees_index,0) as fees_index - , coalesce(tr.transfers_index,0) as transfers_index - , coalesce(tx.tx_index,0) as tx_index - , coalesce(f.fees_index,0)*0.45 + coalesce(tr.transfers_index,0)*0.45 + coalesce(tx.tx_index,0)*0.10 as dune_index -from {{ ref('metrics_fees_index_daily') }} as f -left join - {{ ref('metrics_transfers_index_daily') }} as tr - using (blockchain, block_date) -left join - {{ ref('metrics_transactions_index_daily') }} as tx - using (blockchain, block_date) \ No newline at end of file + , 0.45 * coalesce(fees_index,0) + 0.45 * coalesce(transfers_index,0) + 0.10 * coalesce(tx_index,0) as dune_index + , coalesce(fees_index,0) as fees_index + , coalesce(transfers_index,0) as transfers_index + , coalesce(tx_index,0) as tx_index + , gas_fees_usd + , tx_count + , net_transfer_amount_usd +from fees +left join transfers using (blockchain, block_date) +left join transactions using (blockchain, block_date) diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/dune_index/metrics_dune_index_stats.sql b/dbt_subprojects/daily_spellbook/models/_metrics/dune_index/metrics_dune_index_stats.sql index 7beb905d72b..c33a292b079 100644 --- a/dbt_subprojects/daily_spellbook/models/_metrics/dune_index/metrics_dune_index_stats.sql +++ b/dbt_subprojects/daily_spellbook/models/_metrics/dune_index/metrics_dune_index_stats.sql @@ -157,4 +157,4 @@ from inner join weekly_stats as w on d.blockchain = w.blockchain inner join monthly_stats as m - on d.blockchain = m.blockchain \ No newline at end of file + on d.blockchain = m.blockchain diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/fees/_schema.yml b/dbt_subprojects/daily_spellbook/models/_metrics/fees/_schema.yml index 19335852960..8a20c3dc635 100644 --- a/dbt_subprojects/daily_spellbook/models/_metrics/fees/_schema.yml +++ b/dbt_subprojects/daily_spellbook/models/_metrics/fees/_schema.yml @@ -8,27 +8,11 @@ models: config: tags: ['metrics', 'fees', 'gas', 'daily'] description: "Sum of total fees spent per day across all chains available in gas.fees and gas_solana.fees tables" - data_tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - blockchain - - block_date + - name: metrics_gas_fees_stats meta: sector: metrics contributors: jeff-dude config: tags: ['metrics', 'fees', 'gas'] - description: "View of gas fees per blockchain aggregated to various levels. The goal is to output one row per chain with stats availble for use in counter visuals." - - name: metrics_fees_index_daily - meta: - sector: metrics - contributors: jeff-dude - config: - tags: ['metrics', 'fees', 'gas', 'index', 'daily'] - description: "Each day, per chain, compare the adoption of activity based on total gas fees relative to the baseline expectation" - data_tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - blockchain - - block_date \ No newline at end of file + description: "View of gas fees per blockchain aggregated to various levels. The goal is to output one row per chain." diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/bitcoin/_schema.yml b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/bitcoin/_schema.yml new file mode 100644 index 00000000000..fa94e015cd8 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/bitcoin/_schema.yml @@ -0,0 +1,15 @@ +version: 2 + +models: + - name: metrics_bitcoin_gas_fees_daily + meta: + sector: metrics + contributors: jeff-dude + config: + tags: ['metrics', 'fees', 'gas', 'daily'] + description: "Sum of total fees spent per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/bitcoin/metrics_bitcoin_gas_fees_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/bitcoin/metrics_bitcoin_gas_fees_daily.sql new file mode 100644 index 00000000000..89cd4f55b75 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/bitcoin/metrics_bitcoin_gas_fees_daily.sql @@ -0,0 +1,46 @@ +{{ config( + schema = 'metrics_bitcoin' + , alias = 'gas_fees_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + +with prices as ( + select + day + , price + from + {{ source('prices', 'usd_daily') }} + where + symbol = 'BTC' + and blockchain is null + {% if is_incremental() %} + and {{ incremental_predicate('day') }} + {% endif %} +) +, bitcoin_fees as ( + select + date as block_date + , sum(total_fees) as daily_fee + from + {{ source('bitcoin', 'blocks') }} + where + date < cast(date_trunc('day', now()) as date) --exclude current day to match prices.usd_daily + {% if is_incremental() %} + and {{ incremental_predicate('date') }} + {% endif %} + group by + date +) +select + 'bitcoin' as blockchain + , block_date + , (daily_fee * price) as gas_fees_usd +from + bitcoin_fees +inner join prices + on block_date = day diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/_schema.yml b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/_schema.yml new file mode 100644 index 00000000000..90f3acd15d3 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/_schema.yml @@ -0,0 +1,249 @@ +version: 2 + +models: + - name: metrics_arbitrum_gas_fees_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'fees', 'gas', 'daily'] + description: "Sum of total fees spent per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_avalanche_c_gas_fees_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'fees', 'gas', 'daily'] + description: "Sum of total fees spent per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_base_gas_fees_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'fees', 'gas', 'daily'] + description: "Sum of total fees spent per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_blast_gas_fees_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'fees', 'gas', 'daily'] + description: "Sum of total fees spent per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_bnb_gas_fees_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'fees', 'gas', 'daily'] + description: "Sum of total fees spent per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_celo_gas_fees_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'fees', 'gas', 'daily'] + description: "Sum of total fees spent per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_ethereum_gas_fees_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'fees', 'gas', 'daily'] + description: "Sum of total fees spent per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_fantom_gas_fees_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'fees', 'gas', 'daily'] + description: "Sum of total fees spent per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_gnosis_gas_fees_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'fees', 'gas', 'daily'] + description: "Sum of total fees spent per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_linea_gas_fees_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'fees', 'gas', 'daily'] + description: "Sum of total fees spent per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_mantle_gas_fees_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'fees', 'gas', 'daily'] + description: "Sum of total fees spent per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_optimism_gas_fees_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'fees', 'gas', 'daily'] + description: "Sum of total fees spent per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_polygon_gas_fees_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'fees', 'gas', 'daily'] + description: "Sum of total fees spent per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_scroll_gas_fees_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'fees', 'gas', 'daily'] + description: "Sum of total fees spent per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_sei_gas_fees_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'fees', 'gas', 'daily'] + description: "Sum of total fees spent per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_zkevm_gas_fees_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'fees', 'gas', 'daily'] + description: "Sum of total fees spent per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_zksync_gas_fees_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'fees', 'gas', 'daily'] + description: "Sum of total fees spent per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_zora_gas_fees_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'fees', 'gas', 'daily'] + description: "Sum of total fees spent per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_ronin_gas_fees_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'fees', 'gas', 'daily'] + description: "Sum of total fees spent per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_arbitrum_gas_fees_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_arbitrum_gas_fees_daily.sql new file mode 100644 index 00000000000..2e939bf2771 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_arbitrum_gas_fees_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'arbitrum' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'gas_fees_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_fees_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_avalanche_c_gas_fees_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_avalanche_c_gas_fees_daily.sql new file mode 100644 index 00000000000..f83d076533c --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_avalanche_c_gas_fees_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'avalanche_c' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'gas_fees_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_fees_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_base_gas_fees_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_base_gas_fees_daily.sql new file mode 100644 index 00000000000..082759b8855 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_base_gas_fees_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'base' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'gas_fees_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_fees_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_blast_gas_fees_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_blast_gas_fees_daily.sql new file mode 100644 index 00000000000..632e8ebf4f4 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_blast_gas_fees_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'blast' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'gas_fees_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_fees_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_bnb_gas_fees_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_bnb_gas_fees_daily.sql new file mode 100644 index 00000000000..dec556a7b3c --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_bnb_gas_fees_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'bnb' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'gas_fees_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_fees_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_celo_gas_fees_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_celo_gas_fees_daily.sql new file mode 100644 index 00000000000..15da711d9f7 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_celo_gas_fees_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'celo' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'gas_fees_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_fees_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_ethereum_gas_fees_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_ethereum_gas_fees_daily.sql new file mode 100644 index 00000000000..b22fe1e34be --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_ethereum_gas_fees_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'ethereum' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'gas_fees_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_fees_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_fantom_gas_fees_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_fantom_gas_fees_daily.sql new file mode 100644 index 00000000000..92e6f7bb581 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_fantom_gas_fees_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'fantom' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'gas_fees_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_fees_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_gnosis_gas_fees_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_gnosis_gas_fees_daily.sql new file mode 100644 index 00000000000..8cfd81990d9 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_gnosis_gas_fees_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'gnosis' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'gas_fees_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_fees_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_linea_gas_fees_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_linea_gas_fees_daily.sql new file mode 100644 index 00000000000..a9c10dd0e13 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_linea_gas_fees_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'linea' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'gas_fees_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_fees_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_mantle_gas_fees_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_mantle_gas_fees_daily.sql new file mode 100644 index 00000000000..3743c06acc8 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_mantle_gas_fees_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'mantle' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'gas_fees_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_fees_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_optimism_gas_fees_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_optimism_gas_fees_daily.sql new file mode 100644 index 00000000000..b96b6f9d60b --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_optimism_gas_fees_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'optimism' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'gas_fees_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_fees_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_polygon_gas_fees_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_polygon_gas_fees_daily.sql new file mode 100644 index 00000000000..8bcf90f4b01 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_polygon_gas_fees_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'polygon' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'gas_fees_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_fees_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_ronin_gas_fees_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_ronin_gas_fees_daily.sql new file mode 100644 index 00000000000..5e4da1dffdc --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_ronin_gas_fees_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'ronin' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'gas_fees_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_fees_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_scroll_gas_fees_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_scroll_gas_fees_daily.sql new file mode 100644 index 00000000000..eb6fbbd25fe --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_scroll_gas_fees_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'scroll' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'gas_fees_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_fees_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_sei_gas_fees_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_sei_gas_fees_daily.sql new file mode 100644 index 00000000000..3df03b06885 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_sei_gas_fees_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'sei' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'gas_fees_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_fees_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_zkevm_gas_fees_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_zkevm_gas_fees_daily.sql new file mode 100644 index 00000000000..c946fdd4c47 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_zkevm_gas_fees_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'zkevm' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'gas_fees_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_fees_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_zksync_gas_fees_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_zksync_gas_fees_daily.sql new file mode 100644 index 00000000000..949e3ac28fb --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_zksync_gas_fees_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'zksync' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'gas_fees_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_fees_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_zora_gas_fees_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_zora_gas_fees_daily.sql new file mode 100644 index 00000000000..b22a703f410 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/evm/metrics_zora_gas_fees_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'zora' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'gas_fees_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_fees_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/solana/_schema.yml b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/solana/_schema.yml new file mode 100644 index 00000000000..44116ea0c4c --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/solana/_schema.yml @@ -0,0 +1,15 @@ +version: 2 + +models: + - name: metrics_solana_gas_fees_daily + meta: + sector: metrics + contributors: jeff-dude + config: + tags: ['metrics', 'fees', 'gas', 'daily'] + description: "Sum of total fees spent per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/solana/metrics_solana_gas_fees_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/solana/metrics_solana_gas_fees_daily.sql new file mode 100644 index 00000000000..1eb0afcb862 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/solana/metrics_solana_gas_fees_daily.sql @@ -0,0 +1,60 @@ +{{ config( + schema = 'metrics_solana' + , alias = 'gas_fees_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + +with fees as ( + select + blockchain + , block_date + , sum(tx_fee_usd) as gas_fees_usd + from + {{ source('gas', 'fees') }} + where blockchain = 'solana' + {% if is_incremental() %} + and + {{ incremental_predicate('block_date') }} + {% endif %} + group by + blockchain + , block_date +), solana_vote_fees as ( + -- solana vote fees are stored in a different spell due to data volume & lack of value-add for materializing the fee breakdown + select + blockchain + , block_date + , sum(tx_fee_usd) as gas_fees_usd + from + {{ source('gas_solana', 'vote_fees') }} + {% if is_incremental() %} + where + {{ incremental_predicate('block_date') }} + {% endif %} + group by + blockchain + , block_date +), combined_fees as ( + select + fees.blockchain + , fees.block_date + , fees.gas_fees_usd + coalesce(solana_vote_fees.gas_fees_usd, 0) as gas_fees_usd + from + fees + left join + solana_vote_fees + on + fees.blockchain = solana_vote_fees.blockchain + and fees.block_date = solana_vote_fees.block_date +) + +select + blockchain + ,block_date + ,gas_fees_usd +from combined_fees diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/tron/_schema.yml b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/tron/_schema.yml new file mode 100644 index 00000000000..30a48fd7599 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/tron/_schema.yml @@ -0,0 +1,24 @@ +version: 2 + +models: + - name: tron_fee_correction + meta: + sector: metrics + contributors: 0xRob + description: "correction needed to compensate for subsized energy fees" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - name: metrics_tron_gas_fees_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'fees', 'gas', 'daily'] + description: "Sum of total fees spent per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/tron/metrics_tron_gas_fees_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/tron/metrics_tron_gas_fees_daily.sql new file mode 100644 index 00000000000..1de205e2724 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/tron/metrics_tron_gas_fees_daily.sql @@ -0,0 +1,39 @@ +{{ config( + schema = 'metrics_tron' + , alias = 'gas_fees_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + +with fees as ( + select + blockchain + , block_date + , sum(tx_fee_usd) as gas_fees_usd + from + {{ source('gas', 'fees') }} + where blockchain = 'tron' + {% if is_incremental() %} + and + {{ incremental_predicate('block_date') }} + {% endif %} + group by + blockchain + , block_date +) + +select + blockchain + ,block_date + ,gas_fees_usd * coalesce(t.trx_fee_ratio,0.0) as gas_fees_usd -- apply correction to account for subsidized fees +from fees +left join {{ref('tron_fee_correction')}} t + on block_date = t.day + and blockchain = 'tron' + {% if is_incremental() %} + and {{ incremental_predicate('day') }} + {% endif %} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/fees/tron/tron_fee_correction.sql b/dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/tron/tron_fee_correction.sql similarity index 100% rename from dbt_subprojects/daily_spellbook/models/_metrics/fees/tron/tron_fee_correction.sql rename to dbt_subprojects/daily_spellbook/models/_metrics/fees/chains/tron/tron_fee_correction.sql diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/fees/metrics_fees_index_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/fees/metrics_fees_index_daily.sql deleted file mode 100644 index dd777d49048..00000000000 --- a/dbt_subprojects/daily_spellbook/models/_metrics/fees/metrics_fees_index_daily.sql +++ /dev/null @@ -1,38 +0,0 @@ -{{ config( - schema = 'metrics' - , alias = 'fees_index_daily' - , materialized = 'view' - ) -}} - -{% set baseline_date = '2018-01-01' %} -{% set start_date = '2015-08-21' %} - -with baseline as ( - select - sum(gas_fees_usd) as baseline_gas_fees_usd -- sum is required due to blockchain being second unique key in source - from - {{ ref('metrics_gas_fees_daily') }} - where - block_date = date '{{ baseline_date }}' -), daily as ( - select - blockchain - , block_date - , gas_fees_usd - from - {{ ref('metrics_gas_fees_daily') }} - where - block_date >= date '{{ start_date }}' -) -select - d.blockchain - , d.block_date - , d.gas_fees_usd - , b.baseline_gas_fees_usd - , (d.gas_fees_usd / b.baseline_gas_fees_usd) * 10 as fees_index -from - daily as d -left join - baseline as b - on 1 = 1 diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/fees/metrics_gas_fees_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/fees/metrics_gas_fees_daily.sql index 72c3c7ac935..4b661ed7545 100644 --- a/dbt_subprojects/daily_spellbook/models/_metrics/fees/metrics_gas_fees_daily.sql +++ b/dbt_subprojects/daily_spellbook/models/_metrics/fees/metrics_gas_fees_daily.sql @@ -1,112 +1,45 @@ {{ config( schema = 'metrics' , alias = 'gas_fees_daily' - , materialized = 'incremental' - , file_format = 'delta' - , incremental_strategy = 'merge' - , unique_key = ['blockchain', 'block_date'] - , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + , materialized = 'view' ) }} -with fees as ( - select - blockchain - , block_date - , sum(tx_fee_usd) as gas_fees_usd - from - {{ source('gas', 'fees') }} - {% if is_incremental() %} - where - {{ incremental_predicate('block_date') }} - {% endif %} - group by - blockchain - , block_date -), solana_vote_fees as ( - -- solana vote fees are stored in a different spell due to data volume & lack of value-add for materializing the fee breakdown - select - blockchain - , block_date - , sum(tx_fee_usd) as gas_fees_usd - from - {{ source('gas_solana', 'vote_fees') }} - {% if is_incremental() %} - where - {{ incremental_predicate('block_date') }} - {% endif %} - group by +{% set chains = [ + 'arbitrum' + , 'avalanche_c' + , 'base' + , 'bitcoin' + , 'blast' + , 'bnb' + , 'celo' + , 'ethereum' + , 'fantom' + , 'gnosis' + , 'linea' + , 'mantle' + , 'optimism' + , 'polygon' + , 'ronin' + , 'scroll' + , 'sei' + , 'solana' + , 'tron' + , 'zkevm' + , 'zksync' + , 'zora' +] %} + +SELECT * +FROM ( + {% for blockchain in chains %} + SELECT blockchain - , block_date -), combined_fees as ( - select - fees.blockchain - , fees.block_date - , fees.gas_fees_usd + coalesce(solana_vote_fees.gas_fees_usd, 0) as gas_fees_usd - from - fees - left join - solana_vote_fees - on - fees.blockchain = solana_vote_fees.blockchain - and fees.block_date = solana_vote_fees.block_date -), bitcoin_fees as ( - with prices as ( - select - day - , price - from - {{ source('prices', 'usd_daily') }} - where - symbol = 'BTC' - and blockchain is null - {% if is_incremental() %} - and {{ incremental_predicate('day') }} - {% endif %} - ), btc as ( - select - date as block_date - , sum(total_fees) as daily_fee - from - {{ source('bitcoin', 'blocks') }} - where - date < cast(date_trunc('day', now()) as date) --exclude current day to match prices.usd_daily - {% if is_incremental() %} - and {{ incremental_predicate('date') }} - {% endif %} - group by - date - ) - select - 'bitcoin' as blockchain - , btc.block_date - , btc.daily_fee as gas_fees_raw - , prices.price as daily_price - , (btc.daily_fee * prices.price) as gas_fees_usd - from - btc - inner join - prices - on btc.block_date = prices.day + ,block_date + ,gas_fees_usd + FROM {{ ref('metrics_' + blockchain + '_gas_fees_daily') }} + {% if not loop.last %} + UNION ALL + {% endif %} + {% endfor %} ) -select - blockchain - ,block_date - ,case when blockchain = 'tron' - then gas_fees_usd * coalesce(t.trx_fee_ratio,0.0) -- apply correction to account for subsidized fees - else gas_fees_usd end - as gas_fees_usd -from combined_fees -left join {{ref('tron_fee_correction')}} t - on block_date = t.day - and blockchain = 'tron' - {% if is_incremental() %} - and {{ incremental_predicate('day') }} - {% endif %} -union all -select - blockchain - , block_date - , gas_fees_usd -from - bitcoin_fees \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/fees/metrics_gas_fees_stats.sql b/dbt_subprojects/daily_spellbook/models/_metrics/fees/metrics_gas_fees_stats.sql index ded73862c35..c1a860c28f5 100644 --- a/dbt_subprojects/daily_spellbook/models/_metrics/fees/metrics_gas_fees_stats.sql +++ b/dbt_subprojects/daily_spellbook/models/_metrics/fees/metrics_gas_fees_stats.sql @@ -155,4 +155,4 @@ from inner join weekly_stats as w on d.blockchain = w.blockchain inner join monthly_stats as m - on d.blockchain = m.blockchain \ No newline at end of file + on d.blockchain = m.blockchain diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/fees/tron/_schema.yml b/dbt_subprojects/daily_spellbook/models/_metrics/fees/tron/_schema.yml deleted file mode 100644 index cc3aa2a265b..00000000000 --- a/dbt_subprojects/daily_spellbook/models/_metrics/fees/tron/_schema.yml +++ /dev/null @@ -1,12 +0,0 @@ -version: 2 - -models: - - name: tron_fee_correction - meta: - sector: metrics - contributors: 0xRob - description: "correction needed to compensate for subsized energy fees" - data_tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - day diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transactions/_schema.yml b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/_schema.yml index 5f6e1f051ca..82c58a98985 100644 --- a/dbt_subprojects/daily_spellbook/models/_metrics/transactions/_schema.yml +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/_schema.yml @@ -8,27 +8,11 @@ models: config: tags: ['metrics', 'transactions', 'daily'] description: "Sum of total tx's per day across all chains" - data_tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - blockchain - - block_date + - name: metrics_transactions_stats meta: sector: metrics contributors: jeff-dude config: - tags: ['metrics', 'transactions'] - description: "View of tx's per blockchain aggregated to various levels. The goal is to output one row per chain with stats availble for use in counter visuals." - - name: metrics_transactions_index_daily - meta: - sector: metrics - contributors: jeff-dude - config: - tags: ['metrics', 'transactions', 'index', 'daily'] - description: "Each day, per chain, compare the adoption of total transactions relative to the baseline expectation" - data_tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - blockchain - - block_date \ No newline at end of file + tags: [ 'metrics', 'transactions' ] + description: "View of tx's per blockchain aggregated to various levels. The goal is to output one row per chain." diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/bitcoin/_schema.yml b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/bitcoin/_schema.yml new file mode 100644 index 00000000000..aa54dcc9b6d --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/bitcoin/_schema.yml @@ -0,0 +1,15 @@ +version: 2 + +models: + - name: metrics_bitcoin_transactions_daily + meta: + sector: metrics + contributors: jeff-dude + config: + tags: ['metrics', 'transactions', 'daily'] + description: "Sum of total tx's per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/bitcoin/metrics_bitcoin_transactions_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/bitcoin/metrics_bitcoin_transactions_daily.sql new file mode 100644 index 00000000000..378c3e6b82d --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/bitcoin/metrics_bitcoin_transactions_daily.sql @@ -0,0 +1,26 @@ +{{ config( + schema = 'metrics_bitcoin' + , alias = 'transactions_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + +select + blockchain + , block_date + , approx_distinct(tx_id) as tx_count +from + {{ source('transfers_bitcoin', 'satoshi') }} +where + 1 = 1 + and amount_transfer_usd > 1 + {% if is_incremental() %} + and {{ incremental_predicate('block_date') }} + {% endif %} +group by + blockchain + , block_date diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/_schema.yml b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/_schema.yml new file mode 100644 index 00000000000..3df2dbfcae7 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/_schema.yml @@ -0,0 +1,262 @@ +version: 2 + +models: + - name: metrics_arbitrum_transactions_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'transactions', 'daily'] + description: "Sum of total tx's per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_avalanche_c_transactions_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'transactions', 'daily'] + description: "Sum of total tx's per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_base_transactions_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'transactions', 'daily'] + description: "Sum of total tx's per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_blast_transactions_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'transactions', 'daily'] + description: "Sum of total tx's per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_bnb_transactions_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'transactions', 'daily'] + description: "Sum of total tx's per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_celo_transactions_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'transactions', 'daily'] + description: "Sum of total tx's per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_ethereum_transactions_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'transactions', 'daily'] + description: "Sum of total tx's per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_fantom_transactions_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'transactions', 'daily'] + description: "Sum of total tx's per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_gnosis_transactions_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'transactions', 'daily'] + description: "Sum of total tx's per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_linea_transactions_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'transactions', 'daily'] + description: "Sum of total tx's per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_mantle_transactions_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'transactions', 'daily'] + description: "Sum of total tx's per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_optimism_transactions_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'transactions', 'daily'] + description: "Sum of total tx's per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_polygon_transactions_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'transactions', 'daily'] + description: "Sum of total tx's per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_scroll_transactions_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'transactions', 'daily'] + description: "Sum of total tx's per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_sei_transactions_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'transactions', 'daily'] + description: "Sum of total tx's per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_tron_transactions_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'transactions', 'daily'] + description: "Sum of total tx's per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_zkevm_transactions_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'transactions', 'daily'] + description: "Sum of total tx's per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_zksync_transactions_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'transactions', 'daily'] + description: "Sum of total tx's per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_zora_transactions_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'transactions', 'daily'] + description: "Sum of total tx's per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_ronin_transactions_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'transactions', 'daily'] + description: "Sum of total tx's per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_arbitrum_transactions_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_arbitrum_transactions_daily.sql new file mode 100644 index 00000000000..0293fd2b2c8 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_arbitrum_transactions_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'arbitrum' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transactions_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transactions_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_avalanche_c_transactions_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_avalanche_c_transactions_daily.sql new file mode 100644 index 00000000000..d2e90789069 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_avalanche_c_transactions_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'avalanche_c' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transactions_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transactions_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_base_transactions_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_base_transactions_daily.sql new file mode 100644 index 00000000000..9d3ee77d25b --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_base_transactions_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'base' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transactions_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transactions_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_blast_transactions_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_blast_transactions_daily.sql new file mode 100644 index 00000000000..7c5046ea9c2 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_blast_transactions_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'blast' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transactions_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transactions_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_bnb_transactions_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_bnb_transactions_daily.sql new file mode 100644 index 00000000000..c3feff1e770 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_bnb_transactions_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'bnb' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transactions_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transactions_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_celo_transactions_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_celo_transactions_daily.sql new file mode 100644 index 00000000000..94822b61bb1 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_celo_transactions_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'celo' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transactions_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transactions_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_ethereum_transactions_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_ethereum_transactions_daily.sql new file mode 100644 index 00000000000..6f053536b70 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_ethereum_transactions_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'ethereum' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transactions_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transactions_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_fantom_transactions_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_fantom_transactions_daily.sql new file mode 100644 index 00000000000..9d8043425fb --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_fantom_transactions_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'fantom' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transactions_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transactions_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_gnosis_transactions_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_gnosis_transactions_daily.sql new file mode 100644 index 00000000000..b9f6ba8a83a --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_gnosis_transactions_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'gnosis' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transactions_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transactions_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_linea_transactions_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_linea_transactions_daily.sql new file mode 100644 index 00000000000..05c80ad240a --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_linea_transactions_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'linea' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transactions_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transactions_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_mantle_transactions_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_mantle_transactions_daily.sql new file mode 100644 index 00000000000..6e98f940369 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_mantle_transactions_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'mantle' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transactions_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transactions_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_optimism_transactions_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_optimism_transactions_daily.sql new file mode 100644 index 00000000000..766ea462934 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_optimism_transactions_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'optimism' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transactions_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transactions_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_polygon_transactions_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_polygon_transactions_daily.sql new file mode 100644 index 00000000000..e3cebf43868 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_polygon_transactions_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'polygon' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transactions_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transactions_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_ronin_transactions_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_ronin_transactions_daily.sql new file mode 100644 index 00000000000..b85f21c8656 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_ronin_transactions_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'ronin' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transactions_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transactions_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_scroll_transactions_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_scroll_transactions_daily.sql new file mode 100644 index 00000000000..59d31f62ab9 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_scroll_transactions_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'scroll' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transactions_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transactions_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_sei_transactions_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_sei_transactions_daily.sql new file mode 100644 index 00000000000..4fde7ded5d5 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_sei_transactions_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'sei' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transactions_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transactions_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_tron_transactions_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_tron_transactions_daily.sql new file mode 100644 index 00000000000..7a56a34abfe --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_tron_transactions_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'tron' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transactions_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transactions_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_zkevm_transactions_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_zkevm_transactions_daily.sql new file mode 100644 index 00000000000..bc1b4c9ba6b --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_zkevm_transactions_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'zkevm' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transactions_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transactions_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_zksync_transactions_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_zksync_transactions_daily.sql new file mode 100644 index 00000000000..73bf7c01fc2 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_zksync_transactions_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'zksync' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transactions_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transactions_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_zora_transactions_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_zora_transactions_daily.sql new file mode 100644 index 00000000000..cf28eb3b1d1 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/evm/metrics_zora_transactions_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'zora' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transactions_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transactions_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/solana/_schema.yml b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/solana/_schema.yml new file mode 100644 index 00000000000..e314dcbfb2a --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/solana/_schema.yml @@ -0,0 +1,15 @@ +version: 2 + +models: + - name: metrics_solana_transactions_daily + meta: + sector: metrics + contributors: jeff-dude + config: + tags: ['metrics', 'transactions', 'daily'] + description: "Sum of total tx's per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/solana/metrics_solana_transactions_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/solana/metrics_solana_transactions_daily.sql new file mode 100644 index 00000000000..141f01f5824 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/chains/solana/metrics_solana_transactions_daily.sql @@ -0,0 +1,27 @@ +{{ config( + schema = 'metrics_solana' + , alias = 'transactions_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + +select + 'solana' as blockchain + , block_date + , approx_distinct(tx_id) as tx_count +from + {{ source('tokens_solana', 'transfers') }} +where + 1 = 1 + and action != 'wrap' + and amount_usd > 1 + {% if is_incremental() %} + and {{ incremental_predicate('block_date') }} + {% endif %} +group by + 'solana' + , block_date diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transactions/metrics_transactions_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/metrics_transactions_daily.sql index 62b6a2777aa..3357ab15032 100644 --- a/dbt_subprojects/daily_spellbook/models/_metrics/transactions/metrics_transactions_daily.sql +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/metrics_transactions_daily.sql @@ -1,83 +1,45 @@ {{ config( schema = 'metrics' , alias = 'transactions_daily' - , materialized = 'incremental' - , file_format = 'delta' - , incremental_strategy = 'merge' - , unique_key = ['blockchain', 'block_date'] - , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + , materialized = 'view' ) }} -with evm as ( - select - blockchain - , block_date - , approx_distinct(tx_hash) as tx_count --max 2% error, which is fine - from - {{ source('tokens', 'transfers') }} - where - 1 = 1 - and amount_usd >=1 - {% if is_incremental() %} - and {{ incremental_predicate('block_date') }} - {% endif %} - group by - blockchain - , block_date -) -, solana as ( - select - 'solana' as blockchain - , block_date - , approx_distinct(tx_id) as tx_count - from - {{ source('tokens_solana', 'transfers') }} - where - 1 = 1 - and action != 'wrap' - and amount_usd > 1 - {% if is_incremental() %} - and {{ incremental_predicate('block_date') }} - {% endif %} - group by - 'solana' - , block_date -) -, bitcoin as ( - select +{% set chains = [ + 'arbitrum' + , 'avalanche_c' + , 'base' + , 'bitcoin' + , 'blast' + , 'bnb' + , 'celo' + , 'ethereum' + , 'fantom' + , 'gnosis' + , 'linea' + , 'mantle' + , 'optimism' + , 'polygon' + , 'ronin' + , 'scroll' + , 'sei' + , 'solana' + , 'tron' + , 'zkevm' + , 'zksync' + , 'zora' +] %} + +SELECT * +FROM ( + {% for blockchain in chains %} + SELECT blockchain - , block_date - , approx_distinct(tx_id) as tx_count - from - {{ source('transfers_bitcoin', 'satoshi') }} - where - 1 = 1 - and amount_transfer_usd > 1 - {% if is_incremental() %} - and {{ incremental_predicate('block_date') }} + ,block_date + ,tx_count + FROM {{ ref('metrics_' + blockchain + '_transactions_daily') }} + {% if not loop.last %} + UNION ALL {% endif %} - group by - blockchain - , block_date + {% endfor %} ) -select - blockchain - , block_date - , tx_count -from - evm -union all -select - blockchain - , block_date - , tx_count -from - solana -union all -select - blockchain - , block_date - , tx_count -from - bitcoin \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transactions/metrics_transactions_index_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/metrics_transactions_index_daily.sql deleted file mode 100644 index 194eb76b218..00000000000 --- a/dbt_subprojects/daily_spellbook/models/_metrics/transactions/metrics_transactions_index_daily.sql +++ /dev/null @@ -1,38 +0,0 @@ -{{ config( - schema = 'metrics' - , alias = 'transactions_index_daily' - , materialized = 'view' - ) -}} - -{% set baseline_date = '2018-01-01' %} -{% set start_date = '2015-08-21' %} - -with baseline as ( - select - sum(tx_count) as baseline_tx_count -- sum is required due to blockchain being second unique key in source - from - {{ ref('metrics_transactions_daily') }} - where - block_date = date '{{ baseline_date }}' -), daily as ( - select - blockchain - , block_date - , tx_count - from - {{ ref('metrics_transactions_daily') }} - where - block_date >= date '{{ start_date }}' -) -select - d.blockchain - , d.block_date - , d.tx_count - , b.baseline_tx_count - , (cast(d.tx_count as double) / cast(b.baseline_tx_count as double)) * 10 as tx_index -from - daily as d -left join - baseline as b - on 1 = 1 diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transactions/metrics_transactions_stats.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/metrics_transactions_stats.sql index a03620af097..39063698f34 100644 --- a/dbt_subprojects/daily_spellbook/models/_metrics/transactions/metrics_transactions_stats.sql +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transactions/metrics_transactions_stats.sql @@ -155,4 +155,4 @@ from inner join weekly_stats as w on d.blockchain = w.blockchain inner join monthly_stats as m - on d.blockchain = m.blockchain \ No newline at end of file + on d.blockchain = m.blockchain diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transfers/_schema.yml b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/_schema.yml index e03f33be0d9..7330b573af4 100644 --- a/dbt_subprojects/daily_spellbook/models/_metrics/transfers/_schema.yml +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/_schema.yml @@ -1,7 +1,7 @@ version: 2 models: - - name: metrics_net_transfers_daily + - name: metrics_transfers_daily meta: sector: metrics contributors: jeff-dude @@ -18,62 +18,35 @@ models: with the positive net received (aka received) it adds up to 0 since the net sent should equal the net received. For example, if I give you $1 that's -1 sent (from me) and +1 received (by you) which adds to 0. This query counts the received to show that $1 was effectively transfered." - data_tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - blockchain - - block_date - - name: metrics_net_solana_transfers_daily + + - name: metrics_transfers_stats meta: sector: metrics contributors: jeff-dude config: - tags: ['metrics', 'net_transfers', 'solana'] - description: *net_transfers_description - data_tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - blockchain - - block_date - - name: metrics_net_bitcoin_transfers_daily + tags: ['metrics', 'transfers'] + description: "View of transfers per blockchain aggregated to various levels. The goal is to output one row per chain." + + - name: metrics_solana_transfers_daily meta: sector: metrics contributors: jeff-dude config: - tags: ['metrics', 'net_transfers', 'bitcoin'] + tags: ['metrics', 'net_transfers', 'solana'] description: *net_transfers_description data_tests: - dbt_utils.unique_combination_of_columns: combination_of_columns: - blockchain - block_date - - name: metrics_transfers_daily - meta: - sector: metrics - contributors: jeff-dude - config: - tags: ['metrics', 'transfers', 'daily'] - description: | - "Sum of total transfer amount per day across all chain." - data_tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - blockchain - - block_date - - name: metrics_transfers_stats - meta: - sector: metrics - contributors: jeff-dude - config: - tags: ['metrics', 'transfers'] - description: "View of transfers per blockchain aggregated to various levels. The goal is to output one row per chain with stats availble for use in counter visuals." - - name: metrics_transfers_index_daily + + - name: metrics_bitcoin_transfers_daily meta: sector: metrics contributors: jeff-dude config: - tags: ['metrics', 'transfers', 'index', 'daily'] - description: "Each day, per chain, compare the adoption of total transfers relative to the baseline expectation" + tags: ['metrics', 'net_transfers', 'bitcoin'] + description: *net_transfers_description data_tests: - dbt_utils.unique_combination_of_columns: combination_of_columns: diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transfers/metrics_net_bitcoin_transfers_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/bitcoin/metrics_bitcoin_transfers_daily.sql similarity index 97% rename from dbt_subprojects/daily_spellbook/models/_metrics/transfers/metrics_net_bitcoin_transfers_daily.sql rename to dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/bitcoin/metrics_bitcoin_transfers_daily.sql index f193edc8d53..711518ccf4b 100644 --- a/dbt_subprojects/daily_spellbook/models/_metrics/transfers/metrics_net_bitcoin_transfers_daily.sql +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/bitcoin/metrics_bitcoin_transfers_daily.sql @@ -1,6 +1,6 @@ {{ config( - schema = 'metrics' - , alias = 'net_bitcoin_transfers_daily' + schema = 'metrics_bitcoin' + , alias = 'transfers_daily' , materialized = 'incremental' , file_format = 'delta' , incremental_strategy = 'merge' @@ -110,4 +110,4 @@ where net_transfer_amount_usd > 0 group by blockchain - , block_date \ No newline at end of file + , block_date diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/_schema.yml b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/_schema.yml new file mode 100644 index 00000000000..0208f15cd8f --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/_schema.yml @@ -0,0 +1,262 @@ +version: 2 + +models: + - name: metrics_arbitrum_transfers_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'transfers', 'daily'] + description: "Total transfer amount per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_avalanche_c_transfers_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'transfers', 'daily'] + description: "Total transfer amount per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_base_transfers_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'transfers', 'daily'] + description: "Total transfer amount per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_blast_transfers_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'transfers', 'daily'] + description: "Total transfer amount per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_bnb_transfers_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'transfers', 'daily'] + description: "Total transfer amount per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_celo_transfers_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'transfers', 'daily'] + description: "Total transfer amount per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_ethereum_transfers_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'transfers', 'daily'] + description: "Total transfer amount per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_fantom_transfers_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'transfers', 'daily'] + description: "Total transfer amount per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_gnosis_transfers_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'transfers', 'daily'] + description: "Total transfer amount per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_linea_transfers_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'transfers', 'daily'] + description: "Total transfer amount per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_mantle_transfers_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'transfers', 'daily'] + description: "Total transfer amount per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_optimism_transfers_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'transfers', 'daily'] + description: "Total transfer amount per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_polygon_transfers_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'transfers', 'daily'] + description: "Total transfer amount per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_scroll_transfers_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'transfers', 'daily'] + description: "Total transfer amount per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_sei_transfers_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'transfers', 'daily'] + description: "Total transfer amount per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_tron_transfers_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'transfers', 'daily'] + description: "Total transfer amount per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_zkevm_transfers_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'transfers', 'daily'] + description: "Total transfer amount per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_zksync_transfers_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'transfers', 'daily'] + description: "Total transfer amount per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_zora_transfers_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: ['metrics', 'transfers', 'daily'] + description: "Total transfer amount per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date + + - name: metrics_ronin_transfers_daily + meta: + sector: metrics + contributors: jeff-dude, 0xRob + config: + tags: [ 'metrics', 'transfers', 'daily' ] + description: "Total transfer amount per day" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_date diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_arbitrum_transfers_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_arbitrum_transfers_daily.sql new file mode 100644 index 00000000000..272c9cf2fcd --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_arbitrum_transfers_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'arbitrum' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transfers_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transfers_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_avalanche_c_transfers_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_avalanche_c_transfers_daily.sql new file mode 100644 index 00000000000..5d768c36edc --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_avalanche_c_transfers_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'avalanche_c' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transfers_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transfers_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_base_transfers_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_base_transfers_daily.sql new file mode 100644 index 00000000000..8b9099a6035 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_base_transfers_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'base' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transfers_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transfers_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_blast_transfers_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_blast_transfers_daily.sql new file mode 100644 index 00000000000..c35a554a42a --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_blast_transfers_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'blast' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transfers_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transfers_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_bnb_transfers_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_bnb_transfers_daily.sql new file mode 100644 index 00000000000..0fd3b6a25b2 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_bnb_transfers_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'bnb' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transfers_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transfers_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_celo_transfers_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_celo_transfers_daily.sql new file mode 100644 index 00000000000..3e9b393ccce --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_celo_transfers_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'celo' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transfers_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transfers_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_ethereum_transfers_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_ethereum_transfers_daily.sql new file mode 100644 index 00000000000..f1b7aa5c1d8 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_ethereum_transfers_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'ethereum' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transfers_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transfers_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_fantom_transfers_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_fantom_transfers_daily.sql new file mode 100644 index 00000000000..6acd73adc56 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_fantom_transfers_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'fantom' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transfers_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transfers_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_gnosis_transfers_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_gnosis_transfers_daily.sql new file mode 100644 index 00000000000..9b916f51eaf --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_gnosis_transfers_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'gnosis' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transfers_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transfers_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_linea_transfers_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_linea_transfers_daily.sql new file mode 100644 index 00000000000..d7aa7dab9e2 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_linea_transfers_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'linea' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transfers_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transfers_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_mantle_transfers_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_mantle_transfers_daily.sql new file mode 100644 index 00000000000..035f2c1a820 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_mantle_transfers_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'mantle' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transfers_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transfers_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_optimism_transfers_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_optimism_transfers_daily.sql new file mode 100644 index 00000000000..7179d55e91a --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_optimism_transfers_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'optimism' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transfers_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transfers_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_polygon_transfers_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_polygon_transfers_daily.sql new file mode 100644 index 00000000000..725a9236cee --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_polygon_transfers_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'polygon' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transfers_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transfers_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_ronin_transfers_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_ronin_transfers_daily.sql new file mode 100644 index 00000000000..2276a133d6a --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_ronin_transfers_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'ronin' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transfers_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transfers_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_scroll_transfers_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_scroll_transfers_daily.sql new file mode 100644 index 00000000000..9c3f5418d5c --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_scroll_transfers_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'scroll' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transfers_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transfers_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_sei_transfers_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_sei_transfers_daily.sql new file mode 100644 index 00000000000..17d9ec4a367 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_sei_transfers_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'sei' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transfers_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transfers_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_tron_transfers_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_tron_transfers_daily.sql new file mode 100644 index 00000000000..035d9485a6c --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_tron_transfers_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'tron' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transfers_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transfers_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_zkevm_transfers_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_zkevm_transfers_daily.sql new file mode 100644 index 00000000000..a77bc732309 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_zkevm_transfers_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'zkevm' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transfers_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transfers_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_zksync_transfers_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_zksync_transfers_daily.sql new file mode 100644 index 00000000000..a941a3965e2 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_zksync_transfers_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'zksync' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transfers_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transfers_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_zora_transfers_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_zora_transfers_daily.sql new file mode 100644 index 00000000000..21bdfb3d180 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/evm/metrics_zora_transfers_daily.sql @@ -0,0 +1,15 @@ +{% set blockchain = 'zora' %} + +{{ config( + schema = 'metrics_' + blockchain + , alias = 'transfers_daily' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'block_date'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] + ) +}} + + +{{ metrics_transfers_evm(blockchain) }} diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transfers/metrics_net_solana_transfers_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/solana/metrics_solana_transfers_daily.sql similarity index 96% rename from dbt_subprojects/daily_spellbook/models/_metrics/transfers/metrics_net_solana_transfers_daily.sql rename to dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/solana/metrics_solana_transfers_daily.sql index 5a2472b35bb..88b7e629e8d 100644 --- a/dbt_subprojects/daily_spellbook/models/_metrics/transfers/metrics_net_solana_transfers_daily.sql +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/chains/solana/metrics_solana_transfers_daily.sql @@ -1,6 +1,6 @@ {{ config( - schema = 'metrics' - , alias = 'net_solana_transfers_daily' + schema = 'metrics_solana' + , alias = 'transfers_daily' , materialized = 'incremental' , file_format = 'delta' , incremental_strategy = 'merge' @@ -92,4 +92,4 @@ where net_transfer_amount_usd > 0 group by blockchain - , block_date \ No newline at end of file + , block_date diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transfers/metrics_transfers_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/metrics_transfers_daily.sql index 4a81fe41984..b0982950cc5 100644 --- a/dbt_subprojects/daily_spellbook/models/_metrics/transfers/metrics_transfers_daily.sql +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/metrics_transfers_daily.sql @@ -5,32 +5,44 @@ ) }} -select - blockchain - , block_date - , transfer_amount_usd_sent - , transfer_amount_usd_received - , transfer_amount_usd - , net_transfer_amount_usd -from - {{ ref('metrics_net_transfers_daily') }} -union all -select - blockchain - , block_date - , transfer_amount_usd_sent - , transfer_amount_usd_received - , transfer_amount_usd - , net_transfer_amount_usd -from - {{ ref('metrics_net_solana_transfers_daily') }} -union all -select - blockchain - , block_date - , transfer_amount_usd_sent - , transfer_amount_usd_received - , transfer_amount_usd - , net_transfer_amount_usd -from - {{ ref('metrics_net_bitcoin_transfers_daily') }} +{% set chains = [ + 'arbitrum' + , 'avalanche_c' + , 'base' + , 'bitcoin' + , 'blast' + , 'bnb' + , 'celo' + , 'ethereum' + , 'fantom' + , 'gnosis' + , 'linea' + , 'mantle' + , 'optimism' + , 'polygon' + , 'ronin' + , 'scroll' + , 'sei' + , 'solana' + , 'tron' + , 'zkevm' + , 'zksync' + , 'zora' +] %} + +SELECT * +FROM ( + {% for blockchain in chains %} + SELECT + blockchain + , block_date + , transfer_amount_usd_sent + , transfer_amount_usd_received + , transfer_amount_usd + , net_transfer_amount_usd + FROM {{ ref('metrics_' + blockchain + '_transfers_daily') }} + {% if not loop.last %} + UNION ALL + {% endif %} + {% endfor %} +) diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transfers/metrics_transfers_index_daily.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/metrics_transfers_index_daily.sql deleted file mode 100644 index f13e4e1648c..00000000000 --- a/dbt_subprojects/daily_spellbook/models/_metrics/transfers/metrics_transfers_index_daily.sql +++ /dev/null @@ -1,38 +0,0 @@ -{{ config( - schema = 'metrics' - , alias = 'transfers_index_daily' - , materialized = 'view' - ) -}} - -{% set baseline_date = '2018-01-01' %} -{% set start_date = '2015-08-21' %} - -with baseline as ( - select - sum(net_transfer_amount_usd) as baseline_net_transfer_amount_usd -- sum is required due to blockchain being second unique key in source - from - {{ ref('metrics_transfers_daily') }} - where - block_date = date '{{ baseline_date }}' -), daily as ( - select - blockchain - , block_date - , net_transfer_amount_usd - from - {{ ref('metrics_transfers_daily') }} - where - block_date >= date '{{ start_date }}' -) -select - d.blockchain - , d.block_date - , d.net_transfer_amount_usd - , b.baseline_net_transfer_amount_usd - , (d.net_transfer_amount_usd / b.baseline_net_transfer_amount_usd) * 10 as transfers_index -from - daily as d -left join - baseline as b - on 1 = 1 diff --git a/dbt_subprojects/daily_spellbook/models/_metrics/transfers/metrics_transfers_stats.sql b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/metrics_transfers_stats.sql index dfe6afb49b5..45d7124b597 100644 --- a/dbt_subprojects/daily_spellbook/models/_metrics/transfers/metrics_transfers_stats.sql +++ b/dbt_subprojects/daily_spellbook/models/_metrics/transfers/metrics_transfers_stats.sql @@ -155,4 +155,4 @@ from inner join weekly_stats as w on d.blockchain = w.blockchain inner join monthly_stats as m - on d.blockchain = m.blockchain \ No newline at end of file + on d.blockchain = m.blockchain diff --git a/dbt_subprojects/daily_spellbook/models/_projects/bungee/arbitrum/bungee_arbitrum_bridges.sql b/dbt_subprojects/daily_spellbook/models/_projects/bungee/arbitrum/bungee_arbitrum_bridges.sql new file mode 100644 index 00000000000..f8ca6d45091 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/bungee/arbitrum/bungee_arbitrum_bridges.sql @@ -0,0 +1,42 @@ +{{ + config( + schema = 'bungee_arbitrum', + alias = 'bridges', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transfer_id'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +with source_data as ( + {{ bungee_SocketBridge('arbitrum') }} +), + +tokens_mapped as ( + select + *, + case + when token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + then 0x82af49447d8a07e3bd95bd0d56f35241523fbab1 -- WETH on Arbitrum + else token + end as token_adjusted + from source_data +), + +price_data as ( + select + tokens_mapped.*, + p.price * amount / power(10, p.decimals) as amount_usd + from tokens_mapped + left join {{ source('prices', 'usd') }} p + on p.contract_address = tokens_mapped.token_adjusted + and p.blockchain = 'arbitrum' + and p.minute = date_trunc('minute', tokens_mapped.evt_block_time) + {% if is_incremental() %} + and {{ incremental_predicate('p.minute') }} + {% endif %} +) + +select * from price_data \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/bungee/avalanche_c/bungee_avalanche_c_bridges.sql b/dbt_subprojects/daily_spellbook/models/_projects/bungee/avalanche_c/bungee_avalanche_c_bridges.sql new file mode 100644 index 00000000000..ec26a230726 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/bungee/avalanche_c/bungee_avalanche_c_bridges.sql @@ -0,0 +1,42 @@ +{{ + config( + schema = 'bungee_avalanche_c', + alias = 'bridges', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transfer_id'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +with source_data as ( + {{ bungee_SocketBridge('avalanche_c') }} +), + +tokens_mapped as ( + select + *, + case + when token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + then 0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7 -- WAVAX + else token + end as token_adjusted + from source_data +), + +price_data as ( + select + tokens_mapped.*, + p.price * amount / power(10, p.decimals) as amount_usd + from tokens_mapped + left join {{ source('prices', 'usd') }} p + on p.contract_address = tokens_mapped.token_adjusted + and p.blockchain = 'avalanche_c' + and p.minute = date_trunc('minute', tokens_mapped.evt_block_time) + {% if is_incremental() %} + and {{ incremental_predicate('p.minute') }} + {% endif %} +) + +select * from price_data \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/bungee/base/bungee_base_bridges.sql b/dbt_subprojects/daily_spellbook/models/_projects/bungee/base/bungee_base_bridges.sql new file mode 100644 index 00000000000..7220bb9b57b --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/bungee/base/bungee_base_bridges.sql @@ -0,0 +1,42 @@ +{{ + config( + schema = 'bungee_base', + alias = 'bridges', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transfer_id'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +with source_data as ( + {{ bungee_SocketBridge('base') }} +), + +tokens_mapped as ( + select + *, + case + when token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + then 0x4200000000000000000000000000000000000006 -- WETH on Base + else token + end as token_adjusted + from source_data +), + +price_data as ( + select + tokens_mapped.*, + p.price * amount / power(10, p.decimals) as amount_usd + from tokens_mapped + left join {{ source('prices', 'usd') }} p + on p.contract_address = tokens_mapped.token_adjusted + and p.blockchain = 'base' + and p.minute = date_trunc('minute', tokens_mapped.evt_block_time) + {% if is_incremental() %} + and {{ incremental_predicate('p.minute') }} + {% endif %} +) + +select * from price_data \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/bungee/blast/bungee_blast_bridges.sql b/dbt_subprojects/daily_spellbook/models/_projects/bungee/blast/bungee_blast_bridges.sql new file mode 100644 index 00000000000..b19a68e3771 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/bungee/blast/bungee_blast_bridges.sql @@ -0,0 +1,42 @@ +{{ + config( + schema = 'bungee_blast', + alias = 'bridges', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transfer_id'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +with source_data as ( + {{ bungee_SocketBridge('blast') }} +), + +tokens_mapped as ( + select + *, + case + when token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + then 0x4300000000000000000000000000000000000004 -- WETH on Blast + else token + end as token_adjusted + from source_data +), + +price_data as ( + select + tokens_mapped.*, + p.price * amount / power(10, p.decimals) as amount_usd + from tokens_mapped + left join {{ source('prices', 'usd') }} p + on p.contract_address = tokens_mapped.token_adjusted + and p.blockchain = 'blast' + and p.minute = date_trunc('minute', tokens_mapped.evt_block_time) + {% if is_incremental() %} + and {{ incremental_predicate('p.minute') }} + {% endif %} +) + +select * from price_data \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/bungee/bnb/bungee_bnb_bridges.sql b/dbt_subprojects/daily_spellbook/models/_projects/bungee/bnb/bungee_bnb_bridges.sql new file mode 100644 index 00000000000..2feb8870be3 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/bungee/bnb/bungee_bnb_bridges.sql @@ -0,0 +1,42 @@ +{{ + config( + schema = 'bungee_bnb', + alias = 'bridges', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transfer_id'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +with source_data as ( + {{ bungee_SocketBridge('bnb') }} +), + +tokens_mapped as ( + select + *, + case + when token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + then 0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c -- WBNB + else token + end as token_adjusted + from source_data +), + +price_data as ( + select + tokens_mapped.*, + p.price * amount / power(10, p.decimals) as amount_usd + from tokens_mapped + left join {{ source('prices', 'usd') }} p + on p.contract_address = tokens_mapped.token_adjusted + and p.blockchain = 'bnb' + and p.minute = date_trunc('minute', tokens_mapped.evt_block_time) + {% if is_incremental() %} + and {{ incremental_predicate('p.minute') }} + {% endif %} +) + +select * from price_data \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/bungee/bungee_bridges.sql b/dbt_subprojects/daily_spellbook/models/_projects/bungee/bungee_bridges.sql new file mode 100644 index 00000000000..b2605abd834 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/bungee/bungee_bridges.sql @@ -0,0 +1,47 @@ +{{ + config( + schema = 'bungee', + alias = 'bridges', + materialized = 'view', + post_hook = '{{ expose_spells(\'[ + "ethereum", "zkevm", "scroll", "blast", "linea", "mantle", "optimism", + "gnosis", "arbitrum", "zksync", "base", "bnb", "polygon", + "avalanche_c", "fantom" + ]\', + "project", "bungee", \'["lequangphu"]\') }}' + ) +}} + +{% set chains = [ + 'ethereum', 'zkevm', 'scroll', 'blast', 'linea', 'mantle', 'optimism', + 'gnosis', 'arbitrum', 'zksync', 'base', 'bnb', 'polygon', + 'avalanche_c', 'fantom' +] %} + +with bungee_bridges as ( + {% for chain in chains %} + select + contract_address, + evt_tx_hash, + evt_index, + evt_block_time, + evt_block_number, + amount, + token, + toChainId, + bridgeName, + sender, + receiver, + metadata, + source_chain, + transfer_id, + amount_usd + from {{ ref( 'bungee_' ~ chain ~ '_bridges' ) }} + {% if not loop.last %} + union all + {% endif %} + {% endfor %} +) + +select * +from bungee_bridges \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/bungee/ethereum/bungee_ethereum_bridges.sql b/dbt_subprojects/daily_spellbook/models/_projects/bungee/ethereum/bungee_ethereum_bridges.sql new file mode 100644 index 00000000000..31b632b2ae7 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/bungee/ethereum/bungee_ethereum_bridges.sql @@ -0,0 +1,42 @@ +{{ + config( + schema = 'bungee_ethereum', + alias = 'bridges', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transfer_id'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +with source_data as ( + {{ bungee_SocketBridge('ethereum') }} +), + +tokens_mapped as ( + select + *, + case + when token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + then 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 -- WETH + else token + end as token_adjusted + from source_data +), + +price_data as ( + select + tokens_mapped.*, + p.price * amount / power(10, p.decimals) as amount_usd + from tokens_mapped + left join {{ source('prices', 'usd') }} p + on p.contract_address = tokens_mapped.token_adjusted + and p.blockchain = 'ethereum' + and p.minute = date_trunc('minute', tokens_mapped.evt_block_time) + {% if is_incremental() %} + and {{ incremental_predicate('p.minute') }} + {% endif %} +) + +select * from price_data \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/bungee/fantom/bungee_fantom_bridges.sql b/dbt_subprojects/daily_spellbook/models/_projects/bungee/fantom/bungee_fantom_bridges.sql new file mode 100644 index 00000000000..bb9698e6120 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/bungee/fantom/bungee_fantom_bridges.sql @@ -0,0 +1,42 @@ +{{ + config( + schema = 'bungee_fantom', + alias = 'bridges', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transfer_id'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +with source_data as ( + {{ bungee_SocketBridge('fantom') }} +), + +tokens_mapped as ( + select + *, + case + when token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + then 0x21be370d5312f44cb42ce377bc9b8a0cef1a4c83 -- WFTM + else token + end as token_adjusted + from source_data +), + +price_data as ( + select + tokens_mapped.*, + p.price * amount / power(10, p.decimals) as amount_usd + from tokens_mapped + left join {{ source('prices', 'usd') }} p + on p.contract_address = tokens_mapped.token_adjusted + and p.blockchain = 'fantom' + and p.minute = date_trunc('minute', tokens_mapped.evt_block_time) + {% if is_incremental() %} + and {{ incremental_predicate('p.minute') }} + {% endif %} +) + +select * from price_data \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/bungee/gnosis/bungee_gnosis_bridges.sql b/dbt_subprojects/daily_spellbook/models/_projects/bungee/gnosis/bungee_gnosis_bridges.sql new file mode 100644 index 00000000000..262891ca52a --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/bungee/gnosis/bungee_gnosis_bridges.sql @@ -0,0 +1,42 @@ +{{ + config( + schema = 'bungee_gnosis', + alias = 'bridges', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transfer_id'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +with source_data as ( + {{ bungee_SocketBridge('gnosis') }} +), + +tokens_mapped as ( + select + *, + case + when token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + then 0xe91d153e0b41518a2ce8dd3d7944fa863463a97d -- WXDAI + else token + end as token_adjusted + from source_data +), + +price_data as ( + select + tokens_mapped.*, + p.price * amount / power(10, p.decimals) as amount_usd + from tokens_mapped + left join {{ source('prices', 'usd') }} p + on p.contract_address = tokens_mapped.token_adjusted + and p.blockchain = 'gnosis' + and p.minute = date_trunc('minute', tokens_mapped.evt_block_time) + {% if is_incremental() %} + and {{ incremental_predicate('p.minute') }} + {% endif %} +) + +select * from price_data \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/bungee/linea/bungee_linea_bridges.sql b/dbt_subprojects/daily_spellbook/models/_projects/bungee/linea/bungee_linea_bridges.sql new file mode 100644 index 00000000000..4d22cc3b2ae --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/bungee/linea/bungee_linea_bridges.sql @@ -0,0 +1,42 @@ +{{ + config( + schema = 'bungee_linea', + alias = 'bridges', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transfer_id'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +with source_data as ( + {{ bungee_SocketBridge('linea') }} +), + +tokens_mapped as ( + select + *, + case + when token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + then 0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f -- WETH on Linea + else token + end as token_adjusted + from source_data +), + +price_data as ( + select + tokens_mapped.*, + p.price * amount / power(10, p.decimals) as amount_usd + from tokens_mapped + left join {{ source('prices', 'usd') }} p + on p.contract_address = tokens_mapped.token_adjusted + and p.blockchain = 'linea' + and p.minute = date_trunc('minute', tokens_mapped.evt_block_time) + {% if is_incremental() %} + and {{ incremental_predicate('p.minute') }} + {% endif %} +) + +select * from price_data \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/bungee/mantle/bungee_mantle_bridges.sql b/dbt_subprojects/daily_spellbook/models/_projects/bungee/mantle/bungee_mantle_bridges.sql new file mode 100644 index 00000000000..6f9cc1c609d --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/bungee/mantle/bungee_mantle_bridges.sql @@ -0,0 +1,42 @@ +{{ + config( + schema = 'bungee_mantle', + alias = 'bridges', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transfer_id'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +with source_data as ( + {{ bungee_SocketBridge('mantle') }} +), + +tokens_mapped as ( + select + *, + case + when token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + then 0x78c1b0c915c4faa5fffa6cabf0219da63d7f4cb8 -- WMNT + else token + end as token_adjusted + from source_data +), + +price_data as ( + select + tokens_mapped.*, + p.price * amount / power(10, p.decimals) as amount_usd + from tokens_mapped + left join {{ source('prices', 'usd') }} p + on p.contract_address = tokens_mapped.token_adjusted + and p.blockchain = 'mantle' + and p.minute = date_trunc('minute', tokens_mapped.evt_block_time) + {% if is_incremental() %} + and {{ incremental_predicate('p.minute') }} + {% endif %} +) + +select * from price_data \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/bungee/optimism/bungee_optimism_bridges.sql b/dbt_subprojects/daily_spellbook/models/_projects/bungee/optimism/bungee_optimism_bridges.sql new file mode 100644 index 00000000000..5fd6c070d90 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/bungee/optimism/bungee_optimism_bridges.sql @@ -0,0 +1,42 @@ +{{ + config( + schema = 'bungee_optimism', + alias = 'bridges', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transfer_id'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +with source_data as ( + {{ bungee_SocketBridge('optimism') }} +), + +tokens_mapped as ( + select + *, + case + when token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + then 0x4200000000000000000000000000000000000006 -- WETH on Optimism + else token + end as token_adjusted + from source_data +), + +price_data as ( + select + tokens_mapped.*, + p.price * amount / power(10, p.decimals) as amount_usd + from tokens_mapped + left join {{ source('prices', 'usd') }} p + on p.contract_address = tokens_mapped.token_adjusted + and p.blockchain = 'optimism' + and p.minute = date_trunc('minute', tokens_mapped.evt_block_time) + {% if is_incremental() %} + and {{ incremental_predicate('p.minute') }} + {% endif %} +) + +select * from price_data \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/bungee/polygon/bungee_polygon_bridges.sql b/dbt_subprojects/daily_spellbook/models/_projects/bungee/polygon/bungee_polygon_bridges.sql new file mode 100644 index 00000000000..e93d39768ee --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/bungee/polygon/bungee_polygon_bridges.sql @@ -0,0 +1,42 @@ +{{ + config( + schema = 'bungee_polygon', + alias = 'bridges', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transfer_id'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +with source_data as ( + {{ bungee_SocketBridge('polygon') }} +), + +tokens_mapped as ( + select + *, + case + when token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + then 0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270 -- WMATIC + else token + end as token_adjusted + from source_data +), + +price_data as ( + select + tokens_mapped.*, + p.price * amount / power(10, p.decimals) as amount_usd + from tokens_mapped + left join {{ source('prices', 'usd') }} p + on p.contract_address = tokens_mapped.token_adjusted + and p.blockchain = 'polygon' + and p.minute = date_trunc('minute', tokens_mapped.evt_block_time) + {% if is_incremental() %} + and {{ incremental_predicate('p.minute') }} + {% endif %} +) + +select * from price_data \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/bungee/schema.yml b/dbt_subprojects/daily_spellbook/models/_projects/bungee/schema.yml new file mode 100644 index 00000000000..9788cf2079a --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/bungee/schema.yml @@ -0,0 +1,101 @@ +version: 2 + +models: + - name: bungee_bridges + description: "Unified cross-chain bridges data from Bungee's Socket Bridge" + columns: &common_columns + - name: transfer_id + description: "Unique identifier for each transfer" + data_tests: + - unique + - not_null + - name: contract_address + description: "Address of the Socket Gateway contract" + - name: evt_tx_hash + description: "Transaction hash of the transfer event" + - name: evt_index + description: "Index of the event in the transaction" + - name: evt_block_time + description: "Timestamp of the block containing the transfer" + - name: evt_block_number + description: "Block number containing the transfer" + - name: amount + description: "Amount of tokens transferred" + - name: token + description: "Address of the transferred token" + - name: token_adjusted + description: "Adjusted token address (maps native token to wrapped version)" + - name: toChainId + description: "Destination chain ID" + - name: bridgeName + description: "Name of the bridge used" + - name: sender + description: "Address of the sender" + - name: receiver + description: "Address of the receiver" + - name: metadata + description: "Additional transfer metadata" + - name: source_chain + description: "Source blockchain of the transfer" + - name: amount_usd + description: "USD value of the transferred amount at the time of transfer" + + - name: bungee_ethereum_bridges + description: "Ethereum bridges data from Bungee's Socket Bridge" + columns: *common_columns + + - name: bungee_zkevm_bridges + description: "zkEVM bridges data from Bungee's Socket Bridge" + columns: *common_columns + + - name: bungee_scroll_bridges + description: "Scroll bridges data from Bungee's Socket Bridge" + columns: *common_columns + + - name: bungee_blast_bridges + description: "Blast bridges data from Bungee's Socket Bridge" + columns: *common_columns + + - name: bungee_linea_bridges + description: "Linea bridges data from Bungee's Socket Bridge" + columns: *common_columns + + - name: bungee_mantle_bridges + description: "Mantle bridges data from Bungee's Socket Bridge" + columns: *common_columns + + - name: bungee_optimism_bridges + description: "Optimism bridges data from Bungee's Socket Bridge" + columns: *common_columns + + - name: bungee_gnosis_bridges + description: "Gnosis bridges data from Bungee's Socket Bridge" + columns: *common_columns + + - name: bungee_arbitrum_bridges + description: "Arbitrum bridges data from Bungee's Socket Bridge" + columns: *common_columns + + - name: bungee_zksync_bridges + description: "zkSync bridges data from Bungee's Socket Bridge" + columns: *common_columns + + - name: bungee_base_bridges + description: "Base bridges data from Bungee's Socket Bridge" + columns: *common_columns + + - name: bungee_bnb_bridges + description: "BNB Chain bridges data from Bungee's Socket Bridge" + columns: *common_columns + + - name: bungee_polygon_bridges + description: "Polygon bridges data from Bungee's Socket Bridge" + columns: *common_columns + + - name: bungee_avalanche_c_bridges + description: "Avalanche C-Chain bridges data from Bungee's Socket Bridge" + columns: *common_columns + + - name: bungee_fantom_bridges + description: "Fantom bridges data from Bungee's Socket Bridge" + columns: *common_columns \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/bungee/scroll/bungee_scroll_bridges.sql b/dbt_subprojects/daily_spellbook/models/_projects/bungee/scroll/bungee_scroll_bridges.sql new file mode 100644 index 00000000000..9c3a4d3c1e3 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/bungee/scroll/bungee_scroll_bridges.sql @@ -0,0 +1,42 @@ +{{ + config( + schema = 'bungee_scroll', + alias = 'bridges', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transfer_id'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +with source_data as ( + {{ bungee_SocketBridge('scroll') }} +), + +tokens_mapped as ( + select + *, + case + when token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + then 0x5300000000000000000000000000000000000004 -- WETH on Scroll + else token + end as token_adjusted + from source_data +), + +price_data as ( + select + tokens_mapped.*, + p.price * amount / power(10, p.decimals) as amount_usd + from tokens_mapped + left join {{ source('prices', 'usd') }} p + on p.contract_address = tokens_mapped.token_adjusted + and p.blockchain = 'scroll' + and p.minute = date_trunc('minute', tokens_mapped.evt_block_time) + {% if is_incremental() %} + and {{ incremental_predicate('p.minute') }} + {% endif %} +) + +select * from price_data \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/bungee/zkevm/bungee_zkevm_bridges.sql b/dbt_subprojects/daily_spellbook/models/_projects/bungee/zkevm/bungee_zkevm_bridges.sql new file mode 100644 index 00000000000..2759ebb201d --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/bungee/zkevm/bungee_zkevm_bridges.sql @@ -0,0 +1,42 @@ +{{ + config( + schema = 'bungee_zkevm', + alias = 'bridges', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transfer_id'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +with source_data as ( + {{ bungee_SocketBridge('zkevm') }} +), + +tokens_mapped as ( + select + *, + case + when token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + then 0x4F9A0e7FD2Bf6067db6994CF12E4495Df938E6e9 -- WETH on zkEVM + else token + end as token_adjusted + from source_data +), + +price_data as ( + select + tokens_mapped.*, + p.price * amount / power(10, p.decimals) as amount_usd + from tokens_mapped + left join {{ source('prices', 'usd') }} p + on p.contract_address = tokens_mapped.token_adjusted + and p.blockchain = 'zkevm' + and p.minute = date_trunc('minute', tokens_mapped.evt_block_time) + {% if is_incremental() %} + and {{ incremental_predicate('p.minute') }} + {% endif %} +) + +select * from price_data \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/bungee/zksync/bungee_zksync_bridges.sql b/dbt_subprojects/daily_spellbook/models/_projects/bungee/zksync/bungee_zksync_bridges.sql new file mode 100644 index 00000000000..367a8cefcba --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/bungee/zksync/bungee_zksync_bridges.sql @@ -0,0 +1,42 @@ +{{ + config( + schema = 'bungee_zksync', + alias = 'bridges', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transfer_id'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +with source_data as ( + {{ bungee_SocketBridge('zksync') }} +), + +tokens_mapped as ( + select + *, + case + when token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + then 0x5aea5775959fbc2557cc8789bc1bf90a239d9a91 -- WETH on zkSync + else token + end as token_adjusted + from source_data +), + +price_data as ( + select + tokens_mapped.*, + p.price * amount / power(10, p.decimals) as amount_usd + from tokens_mapped + left join {{ source('prices', 'usd') }} p + on p.contract_address = tokens_mapped.token_adjusted + and p.blockchain = 'zksync' + and p.minute = date_trunc('minute', tokens_mapped.evt_block_time) + {% if is_incremental() %} + and {{ incremental_predicate('p.minute') }} + {% endif %} +) + +select * from price_data \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_claimable_funding_amount_per_size_updated.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_claimable_funding_amount_per_size_updated.sql new file mode 100644 index 00000000000..65468f09cf8 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_claimable_funding_amount_per_size_updated.sql @@ -0,0 +1,195 @@ +{{ + config( + schema = 'gmx_v2_arbitrum', + alias = 'claimable_funding_amount_per_size_updated', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'ClaimableFundingAmountPerSizeUpdated' -%} +{%- set blockchain_name = 'arbitrum' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items, + json_query(data, 'lax $.boolItems' OMIT QUOTES) AS bool_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bool_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bool_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed + UNION ALL + SELECT * + FROM bool_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'market' THEN value END) AS market, + MAX(CASE WHEN key_name = 'collateralToken' THEN value END) AS collateral_token, + MAX(CASE WHEN key_name = 'delta' THEN value END) AS delta, + MAX(CASE WHEN key_name = 'value' THEN value END) AS "value", + MAX(CASE WHEN key_name = 'isLong' THEN value END) AS is_long + + FROM + combined + GROUP BY tx_hash, index +) + +, event_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(market) AS market, + from_hex(collateral_token) AS collateral_token, + TRY_CAST(delta AS DOUBLE) delta, + TRY_CAST("value" AS DOUBLE) "value", + TRY_CAST(is_long AS BOOLEAN) AS is_long + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + tx_hash, + index, + contract_address, + event_name, + msg_sender, + + market, + ED.collateral_token, + delta / POWER(10, CTD.collateral_token_decimals + 15) AS delta, + "value" / POWER(10, CTD.collateral_token_decimals + 15) AS "value", + is_long + + FROM event_data AS ED + LEFT JOIN gmx_v2_arbitrum.collateral_tokens_data AS CTD + ON ED.collateral_token = CTD.collateral_token +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_deposit_cancelled.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_deposit_cancelled.sql new file mode 100644 index 00000000000..17988609734 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_deposit_cancelled.sql @@ -0,0 +1,187 @@ +{{ + config( + schema = 'gmx_v2_arbitrum', + alias = 'deposit_cancelled', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'DepositCancelled' -%} +{%- set blockchain_name = 'arbitrum' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items, + json_query(data, 'lax $.bytesItems' OMIT QUOTES) AS bytes_items, + json_query(data, 'lax $.stringItems' OMIT QUOTES) AS string_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, string_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(string_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM bytes32_items_parsed + UNION ALL + SELECT * + FROM bytes_items_parsed + UNION ALL + SELECT * + FROM string_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'account' THEN value END) AS account, + MAX(CASE WHEN key_name = 'key' THEN value END) AS "key", + MAX(CASE WHEN key_name = 'reasonBytes' THEN value END) AS reason_bytes, + MAX(CASE WHEN key_name = 'reason' THEN value END) AS reason + + FROM + combined + GROUP BY tx_hash, index +) + +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(account) AS account, + from_hex("key") AS "key", + from_hex(reason_bytes) AS reason_bytes, + reason + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_deposit_created.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_deposit_created.sql new file mode 100644 index 00000000000..44357cb1fbb --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_deposit_created.sql @@ -0,0 +1,258 @@ +{{ + config( + schema = 'gmx_v2_arbitrum', + alias = 'deposit_created', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'DepositCreated' -%} +{%- set blockchain_name = 'arbitrum' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items, + json_query(data, 'lax $.boolItems' OMIT QUOTES) AS bool_items, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bool_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bool_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed + UNION ALL + SELECT * + FROM bool_items_parsed + UNION ALL + SELECT * + FROM bytes32_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'account' THEN value END) AS account, + MAX(CASE WHEN key_name = 'receiver' THEN value END) AS receiver, + MAX(CASE WHEN key_name = 'callbackContract' THEN value END) AS callback_contract, + MAX(CASE WHEN key_name = 'market' THEN value END) AS market, + MAX(CASE WHEN key_name = 'initialLongToken' THEN value END) AS initial_long_token, + MAX(CASE WHEN key_name = 'initialShortToken' THEN value END) AS initial_short_token, + MAX(CASE WHEN key_name = 'longTokenSwapPath' THEN value END) AS long_token_swap_path, + MAX(CASE WHEN key_name = 'shortTokenSwapPath' THEN value END) AS short_token_swap_path, + + MAX(CASE WHEN key_name = 'initialLongTokenAmount' THEN value END) AS initial_long_token_amount, + MAX(CASE WHEN key_name = 'initialShortTokenAmount' THEN value END) AS initial_short_token_amount, + MAX(CASE WHEN key_name = 'minMarketTokens' THEN value END) AS min_market_tokens, + MAX(CASE WHEN key_name = 'updatedAtTime' THEN value END) AS updated_at_time, + MAX(CASE WHEN key_name = 'executionFee' THEN value END) AS execution_fee, + MAX(CASE WHEN key_name = 'callbackGasLimit' THEN value END) AS callback_gas_limit, + MAX(CASE WHEN key_name = 'depositType' THEN value END) AS deposit_type, + + MAX(CASE WHEN key_name = 'shouldUnwrapNativeToken' THEN value END) AS should_unwrap_native_token, + + MAX(CASE WHEN key_name = 'key' THEN value END) AS "key" + + FROM + combined + GROUP BY tx_hash, index +) + +, event_data AS ( + SELECT + blockchain, + block_time, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(account) AS account, + from_hex(receiver) AS receiver, + from_hex(callback_contract) AS callback_contract, + from_hex(market) AS market, + from_hex(initial_long_token) AS initial_long_token, + from_hex(initial_short_token) AS initial_short_token, + long_token_swap_path, + short_token_swap_path, + + TRY_CAST(initial_long_token_amount AS DOUBLE) initial_long_token_amount, + TRY_CAST(initial_short_token_amount AS DOUBLE) initial_short_token_amount, + TRY_CAST(min_market_tokens AS DOUBLE) min_market_tokens, + TRY_CAST(updated_at_time AS DOUBLE) AS updated_at_time, + TRY_CAST(execution_fee AS DOUBLE) AS execution_fee, + TRY_CAST(callback_gas_limit AS DOUBLE) AS callback_gas_limit, + TRY_CAST(deposit_type AS INTEGER) AS deposit_type, + + TRY_CAST(should_unwrap_native_token AS BOOLEAN) AS should_unwrap_native_token, + + from_hex("key") AS "key" + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + tx_hash, + index, + contract_address, + event_name, + msg_sender, + + account, + receiver, + callback_contract, + ED.market, + initial_long_token, + initial_short_token, + long_token_swap_path, + short_token_swap_path, + + initial_long_token_amount / POWER(10, MD.long_token_decimals) AS initial_long_token_amount, + initial_short_token_amount / POWER(10, MD.short_token_decimals) AS initial_short_token_amount, + min_market_tokens / POWER(10, 18) AS min_market_tokens, + CASE + WHEN updated_at_time = 0 THEN NULL + ELSE updated_at_time + END AS updated_at_time, + execution_fee / POWER(10, 18) AS execution_fee, + callback_gas_limit, + deposit_type, + + should_unwrap_native_token, + "key" + + FROM event_data AS ED + LEFT JOIN {{ ref('gmx_v2_arbitrum_markets_data') }} AS MD + ON ED.market = MD.market +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_deposit_executed.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_deposit_executed.sql new file mode 100644 index 00000000000..332c95169b7 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_deposit_executed.sql @@ -0,0 +1,199 @@ +{{ + config( + schema = 'gmx_v2_arbitrum', + alias = 'deposit_executed', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'DepositExecuted' -%} +{%- set blockchain_name = 'arbitrum' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed + UNION ALL + SELECT * + FROM bytes32_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'account' THEN value END) AS account, + MAX(CASE WHEN key_name = 'longTokenAmount' THEN value END) AS long_token_amount, + MAX(CASE WHEN key_name = 'shortTokenAmount' THEN value END) AS short_token_amount, + MAX(CASE WHEN key_name = 'receivedMarketTokens' THEN value END) AS received_market_tokens, + MAX(CASE WHEN key_name = 'swapPricingType' THEN value END) AS swap_pricing_type, + MAX(CASE WHEN key_name = 'key' THEN value END) AS "key" + + FROM + combined + GROUP BY tx_hash, index +) + +, event_data AS ( + SELECT + blockchain, + block_time, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(account) AS account, + TRY_CAST(long_token_amount AS DOUBLE) AS long_token_amount, + TRY_CAST(short_token_amount AS DOUBLE) AS short_token_amount, + TRY_CAST(received_market_tokens AS DOUBLE) AS received_market_tokens, + TRY_CAST(swap_pricing_type AS INTEGER) AS swap_pricing_type, + from_hex("key") AS "key" + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +, full_data AS ( + SELECT + ED.blockchain, + ED.block_time, + DATE(ED.block_time) AS block_date, + ED.block_number, + ED.tx_hash, + ED.index, + ED.contract_address, + ED.event_name, + ED.msg_sender, + + ED.account, + ED.long_token_amount / POWER(10, MD.long_token_decimals) AS long_token_amount, + ED.short_token_amount / POWER(10, MD.short_token_decimals) AS short_token_amount, + ED.received_market_tokens / POWER(10, 18) AS received_market_tokens, + ED.swap_pricing_type, + ED."key" + + FROM event_data AS ED + LEFT JOIN {{ ref('gmx_v2_arbitrum_deposit_created') }} AS DC + ON ED."key" = DC."key" + LEFT JOIN {{ ref('gmx_v2_arbitrum_markets_data') }} AS MD + ON DC.market = MD.market +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_event_schema.yml b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_event_schema.yml index d61b2d58e13..36a4e868118 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_event_schema.yml +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_event_schema.yml @@ -13,62 +13,44 @@ models: Extracts and decodes the `OrderCreated` event log data from the Arbitrum blockchain. This model processes log entries related to created orders, extracting key variables such as account addresses, event keys, and strings representing the reason for cancellation. - + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index columns: - &blockchain name: blockchain description: The blockchain network where the event occurred (Arbitrum) - data_tests: - - not_null - &block_time name: block_time description: The timestamp of the block when the event was recorded - data_tests: - - not_null - &block_date name: block_date - description: The date extracted from the block timestamp, representing the day the block was created - data_tests: - - not_null + description: The date extracted from the block timestamp, representing the day the block was created - &block_number name: block_number description: The block number where the event is included - data_tests: - - not_null - &tx_hash name: tx_hash description: The hash of the transaction where the event was logged - data_tests: - - not_null - &index name: index description: The position of the event within the transaction - data_tests: - - not_null - &contract_address name: contract_address - description: The contract address associated with the event - data_tests: - - not_null + description: The contract address associated with the event - &tx_from name: tx_from description: The originating address of the transaction, usually representing the sender - data_tests: - - not_null - &tx_to name: tx_to - description: The destination address of the transaction, representing the receiver - data_tests: - - not_null + description: The destination address of the transaction, representing the receiver - name: event_name description: The type of event recorded, always 'OrderCreated' for this model. - data_tests: - - not_null - &msg_sender name: msg_sender description: The address of the sender of the message or transaction. - data_tests: - - not_null - name: account description: The address associated with the order. - name: receiver @@ -152,12 +134,12 @@ models: data_tests: - not_null - name: updated_at_block - description: The block number at which the order was last updated. - data_tests: - - not_null + description: The block number at which the order was last updated. - &updated_at_time name: updated_at_time description: The timestamp when the order was last updated. + - name: valid_from_time + description: The time from which the order becomes valid for execution. - &is_long name: is_long description: A boolean indicating whether the position is long @@ -165,8 +147,8 @@ models: - not_null - name: should_unwrap_native_token description: Boolean indicating if the native token should be unwrapped. - - name: is_frozen - description: Boolean indicating if the order is frozen. + - name: auto_cancel + description: Boolean indicating whether the order will be automatically canceled under certain conditions. - &key name: key description: The unique identifier for the order, stored as a bytes32 value. @@ -187,7 +169,11 @@ models: Extracts and decodes the `OrderExecuted` event log data from the Arbitrum blockchain. This model processes log entries related to executed orders, extracting key variables such as account addresses, event keys, and integer values. - + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index columns: - *blockchain - *block_time @@ -230,7 +216,11 @@ models: Extracts and decodes the `OrderCancelled` event log data from the Arbitrum blockchain. This model processes log entries related to cancelled orders, extracting key variables such as account addresses, event keys, and strings representing the reason for cancellation. - + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index columns: - *blockchain - *block_time @@ -344,7 +334,11 @@ models: This model extracts and parses `PositionIncrease` events from the Arbitrum blockchain. It includes transaction details, addresses, and various metrics related to the event, such as market data, collateral amounts, price impacts, and more. - + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index columns: - *blockchain - *block_time @@ -477,7 +471,11 @@ models: This model extracts and parses `PositionDecrease` events from the Arbitrum blockchain. It includes transaction details, addresses, and various metrics related to the event, such as market data, collateral amounts, price impacts, and more. - + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index columns: - *blockchain - *block_time @@ -558,7 +556,11 @@ models: This model extracts and parses `PositionFeesCollected` events from the Arbitrum blockchain. It includes details about the transaction, addresses involved, and various metrics related to fees collected from positions, including fee amounts and related market data. - + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index columns: - *blockchain - *block_time @@ -604,31 +606,6 @@ models: description: The size of the trade in USD data_tests: - not_null - - &total_rebate_factor - name: total_rebate_factor - description: The total rebate factor for the position - data_tests: - - not_null - - &trader_discount_factor - name: trader_discount_factor - description: The discount factor applied to the trader - data_tests: - - not_null - - &total_rebate_amount - name: total_rebate_amount - description: The total amount of rebate given - data_tests: - - not_null - - &trader_discount_amount - name: trader_discount_amount - description: The amount of discount given to the trader - data_tests: - - not_null - - &affiliate_reward_amount - name: affiliate_reward_amount - description: The reward amount given to the affiliate - data_tests: - - not_null - &funding_fee_amount name: funding_fee_amount description: The amount of funding fee charged @@ -637,28 +614,18 @@ models: - &claimable_long_token_amount name: claimable_long_token_amount description: The amount of long tokens claimable - data_tests: - - not_null - &claimable_short_token_amount name: claimable_short_token_amount description: The amount of short tokens claimable - data_tests: - - not_null - &latest_funding_fee_amount_per_size name: latest_funding_fee_amount_per_size description: The latest funding fee amount per size - data_tests: - - not_null - &latest_long_token_claimable_funding_amount_per_size name: latest_long_token_claimable_funding_amount_per_size description: The latest claimable long token funding amount per size - data_tests: - - not_null - &latest_short_token_claimable_funding_amount_per_size name: latest_short_token_claimable_funding_amount_per_size description: The latest claimable short token funding amount per size - data_tests: - - not_null - &borrowing_fee_usd name: borrowing_fee_usd description: The borrowing fee amount in USD @@ -729,6 +696,61 @@ models: description: The total amount of UI fee collected data_tests: - not_null + - &referral_total_rebate_factor + name: referral_total_rebate_factor + description: The total rebate factor associated with referrals. + data_tests: + - not_null + - &referral_total_rebate_amount + name: referral_total_rebate_amount + description: The total rebate amount given for referrals. + data_tests: + - not_null + - &referral_trader_discount_factor + name: referral_trader_discount_factor + description: The discount factor applied to the trader through referrals. + data_tests: + - not_null + - &referral_adjusted_affiliate_reward_factor + name: referral_adjusted_affiliate_reward_factor + description: The adjusted affiliate reward factor based on referral criteria. + data_tests: + - not_null + - &referral_affiliate_reward_amount + name: referral_affiliate_reward_amount + description: The reward amount given to the affiliate for referrals. + data_tests: + - not_null + - &referral_trader_discount_amount + name: referral_trader_discount_amount + description: The discount amount given to the trader through referrals. + data_tests: + - not_null + - &pro_trader_discount_factor + name: pro_trader_discount_factor + description: The discount factor applied for pro traders. + data_tests: + - not_null + - &pro_trader_discount_amount + name: pro_trader_discount_amount + description: The discount amount given to pro traders. + data_tests: + - not_null + - &liquidation_fee_amount + name: liquidation_fee_amount + description: The amount of fees charged during liquidation. + data_tests: + - not_null + - &liquidation_fee_receiver_factor + name: liquidation_fee_receiver_factor + description: The factor used to calculate the liquidation fee allocated to the receiver. + data_tests: + - not_null + - &liquidation_fee_amount_for_fee_receiver + name: liquidation_fee_amount_for_fee_receiver + description: The amount of liquidation fee allocated to the fee receiver. + data_tests: + - not_null - &is_increase name: is_increase description: Indicates whether the position is increased (true) or decreased (false) @@ -755,7 +777,11 @@ models: This model extracts and parses `PositionFeesInfo` events from the Arbitrum blockchain. It includes details about the transaction, addresses involved, and various metrics related to position fees, including fee amounts and related market data. - + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index columns: - *blockchain - *block_time @@ -785,11 +811,6 @@ models: - *collateral_token_price_min - *collateral_token_price_max - *trade_size_usd - - *total_rebate_factor - - *trader_discount_factor - - *total_rebate_amount - - *trader_discount_amount - - *affiliate_reward_amount - *funding_fee_amount - *claimable_long_token_amount - *claimable_short_token_amount @@ -810,6 +831,17 @@ models: - *total_cost_amount - *ui_fee_receiver_factor - *ui_fee_amount + - *referral_total_rebate_factor + - *referral_total_rebate_amount + - *referral_trader_discount_factor + - *referral_adjusted_affiliate_reward_factor + - *referral_affiliate_reward_amount + - *referral_trader_discount_amount + - *pro_trader_discount_factor + - *pro_trader_discount_amount + - *liquidation_fee_amount + - *liquidation_fee_receiver_factor + - *liquidation_fee_amount_for_fee_receiver - *is_increase - *order_key - *position_key @@ -832,8 +864,7 @@ models: - dbt_utils.unique_combination_of_columns: combination_of_columns: - tx_hash - - key - + - index columns: - *blockchain - *block_time @@ -877,7 +908,11 @@ models: Extracts and decodes the `OrderUpdated` event log data from the Arbitrum blockchain. This model processes log entries related to updated orders, extracting key variables such as account addresses, event keys, and strings representing the reason for cancellation. - + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index columns: - *blockchain - *block_time @@ -898,9 +933,7 @@ models: data_tests: - not_null - name: market - description: The market in which the order was updated. - data_tests: - - not_null + description: The market in which the order was updated - name: account description: The address associated with the order. - *size_delta_usd @@ -909,4 +942,1336 @@ models: - *acceptable_price_raw - *acceptable_price - *min_output_amount_raw - - *updated_at_time \ No newline at end of file + - *updated_at_time + - name: valid_from_time + description: The time from which the order becomes valid for execution. + - name: auto_cancel + description: Boolean indicating whether the order will be automatically canceled under certain conditions. + + + - name: gmx_v2_arbitrum_open_interest_in_tokens_updated + meta: + blockchain: arbitrum + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'gmx', 'event', 'open_interest_in_tokens_updated'] + description: | + Combines and processes decoded event data to produce a normalized dataset of updated orders + on the GMX platform for the Arbitrum blockchain. + This model integrates data from the `open_interest_in_tokens_updated` table, enriching it with market-specific details. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: event_name + description: The type of event recorded, always 'OpenInterestInTokensUpdated' for this model + data_tests: + - not_null + - *msg_sender + - name: market + description: The market in which the order was updated, decoded from a hexadecimal value. + data_tests: + - not_null + - name: collateral_token + description: The token used as collateral for the order, decoded from a hexadecimal value. + data_tests: + - not_null + - name: is_long + description: A boolean flag indicating whether the order is a long position (true) or short position (false). + - name: next_value + description: | + Represents the updated open interest vlaue after the transaction. It is derived by normalizing + the raw value using index token decimals. + This ensures consistent scaling of the value across tokens with varying decimals. + - name: delta + description: | + Indicates the change in open interest. It is calculated by normalizing the raw delta value + using index token decimals. + This normalization accounts for token decimal differences and provides a standardized measure of change. + - name: tx_from + description: The address that initiated the transaction + - name: tx_to + description: The destination address of the transaction + - name: tx_index + description: Index value related to the transaction + + + - name: gmx_v2_arbitrum_open_interest_updated + meta: + blockchain: arbitrum + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'gmx', 'event', 'open_interest_updated'] + description: | + Extracts and processes decoded event data for open interest updates on the GMX platform, + specifically on the Arbitrum blockchain. This model normalizes data, including key metrics like + delta and next_value, ensuring consistent scaling based on token decimals. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: event_name + description: The type of event recorded, always 'OpenInterestUpdated' for this model + data_tests: + - not_null + - *msg_sender + - name: market + description: The market associated with the open interest update, decoded from a hexadecimal value. + data_tests: + - not_null + - name: collateral_token + description: The token used as collateral for the open interest, decoded from a hexadecimal value. + data_tests: + - not_null + - name: is_long + description: | + A boolean flag indicating whether the open interest update is for a long position (true) or short position (false). + data_type: boolean + - name: delta + description: | + Represents the change in open interest value, normalized by dividing the raw delta by `POWER(10, 30)`. + This ensures consistent scaling for values across tokens with varying decimals. + data_type: float + data_tests: + - not_null + - name: next_value + description: | + Indicates the updated open interest value after the transaction, normalized by dividing + the raw value by `POWER(10, 30)` to ensure consistent scaling across tokens. + data_type: float + data_tests: + - not_null + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: tx_index + description: The index value related to the transaction. + + + - name: gmx_v2_arbitrum_oracle_price_update + meta: + blockchain: arbitrum + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'gmx', 'event', 'oracle_price_update'] + description: | + Processes decoded event data for Oracle Price Updates on the GMX platform in the Arbitrum blockchain. + The model normalizes price data (min_price and max_price) using token-specific decimals and extracts + additional details such as the provider and token involved in the update. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: event_name + description: The type of event recorded, always 'OraclePriceUpdate' for this model + data_tests: + - not_null + - *msg_sender + - name: token + description: The token associated with the oracle price update, decoded from a hexadecimal value. + data_tests: + - not_null + - name: provider + description: The address of the price provider, decoded from a hexadecimal value. + - name: min_price + description: The minimum price reported by the oracle. + data_tests: + - not_null + - name: max_price + description: The maximum price reported by the oracle. + data_tests: + - not_null + - name: timestamp + description: The timestamp of the oracle price update. + data_type: timestamp + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: tx_index + description: The index value related to the transaction, used for unique identification. + + + - name: gmx_v2_arbitrum_pool_amount_updated + meta: + blockchain: arbitrum + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'gmx', 'event', 'pool_amount_updated'] + description: | + Processes decoded event data for Pool Amount Updates on the GMX platform in the Arbitrum blockchain. + This model normalizes token values (next_value and delta) based on token-specific decimals and extracts + additional details such as the market and token involved in the pool update. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: event_name + description: The type of event recorded, always 'PoolAmountUpdated' for this model + data_tests: + - not_null + - *msg_sender + - name: market + description: The market associated with the pool update, decoded from a hexadecimal value. + data_tests: + - not_null + - name: token + description: The token involved in the pool update, decoded from a hexadecimal value. + data_tests: + - not_null + - name: next_value + description: | + The amount in the pool for the specified token, normalized by dividing the raw value + by `POWER(10, token_decimals)`, where `token_decimals` is derived from ERC-20 token metadata. + data_tests: + - not_null + - name: delta + description: | + The change in the pool amount for the specified token, normalized by dividing the raw value + by `POWER(10, token_decimals)`, where `token_decimals` is derived from ERC-20 token metadata. + data_tests: + - not_null + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: tx_index + description: The index value related to the transaction, used for unique identification. + + + - name: gmx_v2_arbitrum_set_uint + meta: + blockchain: arbitrum + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'gmx', 'event', 'set_uint'] + description: | + Processes decoded event data for `SetUint` events on the GMX platform in the Arbitrum blockchain. + This model normalizes the value field and extracts additional details such as the base key and associated data, + ensuring compatibility with downstream analyses. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: event_name + description: The type of event recorded, always 'SetUint' for this model + data_tests: + - not_null + - *msg_sender + - name: base_key + description: The base key associated with the event, decoded from a hexadecimal value. + data_tests: + - not_null + - name: data + description: The associated data field, decoded from a hexadecimal value. + data_tests: + - not_null + - name: value_raw + description: | + The value associated with the event. + data_type: float + data_tests: + - not_null + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: tx_index + description: The index value related to the transaction, used for unique identification. + + + - name: gmx_v2_arbitrum_execution_fee_refund + meta: + blockchain: arbitrum + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'gmx', 'event', 'execution_fee_refund'] + description: | + Processes decoded event data for `ExecutionFeeRefund` events on the GMX platform in the Arbitrum blockchain. + This model extracts key details such as the refund amount, receiver, and transaction details to + enable analysis of refunded execution fees. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `ExecutionFeeRefund` for this model. + data_tests: + - not_null + - *msg_sender + - name: receiver + description: The address that received the refunded execution fee. + - name: refund_fee_amount + description: The amount of the refunded execution fee, denominated in the native token of the blockchain (e.g., ETH). + + + - name: gmx_v2_arbitrum_keeper_execution_fee + meta: + blockchain: arbitrum + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'gmx', 'event', 'keeper_execution_fee'] + description: | + Processes decoded event data for `KeeperExecutionFee` events on the GMX platform in the Arbitrum blockchain. + This model extracts key details such as the keeper's address, execution fee amount, and transaction details, enabling + analysis of fees associated with keeper-based executions. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `KeeperExecutionFee` for this model. + data_tests: + - not_null + - *msg_sender + - name: keeper + description: The address of the keeper responsible for executing the transaction. + - name: execution_fee_amount + description: The amount of the execution fee, denominated in the native token of the blockchain (e.g., ETH, AVAX). + + + - name: gmx_v2_arbitrum_deposit_cancelled + meta: + blockchain: arbitrum + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'gmx', 'event', 'deposit_cancelled'] + description: | + Processes decoded event data for `DepositCancelled` events on the GMX platform in the Arbitrum blockchain. + This model extracts key details such as the account address, cancellation reason, and transaction details, enabling + analysis of deposit cancellations on the platform. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `DepositCancelled` for this model. + - *msg_sender + - name: account + description: The account address associated with the cancelled deposit. + - name: key + description: A unique identifier for the cancelled deposit. + - name: reason_bytes + description: Encoded reason data for the deposit cancellation. + - name: reason + description: The decoded textual reason for the deposit cancellation. + + + - name: gmx_v2_arbitrum_deposit_created + meta: + blockchain: arbitrum + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'gmx', 'event', 'deposit_created'] + description: | + Processes decoded event data for `DepositCreated` events on the GMX platform in the Arbitrum blockchain. + This model extracts key details such as the account address, deposit details, and transaction specifics, enabling + analysis of deposits created on the platform. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `DepositCreated` for this model. + - *msg_sender + - name: account + description: The account address associated with the deposit. + - name: receiver + description: The receiver address specified for the deposit. + - name: callback_contract + description: The address of the callback contract associated with the deposit. + - name: market + description: The market for which the deposit was created. + - name: initial_long_token + description: The token used for the long position in the deposit. + - name: initial_short_token + description: The token used for the short position in the deposit. + - name: long_token_swap_path + description: The swap path for the long token. + - name: short_token_swap_path + description: The swap path for the short token. + - name: initial_long_token_amount + description: The initial amount of the long token in the deposit. + - name: initial_short_token_amount + description: The initial amount of the short token in the deposit. + - name: min_market_tokens + description: The minimum amount of market tokens expected from the deposit. + - name: updated_at_time + description: The timestamp when the deposit was last updated. + - name: execution_fee + description: The execution fee for processing the deposit. + - name: callback_gas_limit + description: The gas limit for the callback associated with the deposit. + - name: deposit_type + description: The type of deposit created. + - name: should_unwrap_native_token + description: Indicates whether the native token should be unwrapped. + - name: key + description: A unique identifier for the deposit. + + + - name: gmx_v2_arbitrum_deposit_executed + meta: + blockchain: arbitrum + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'gmx', 'event', 'deposit_executed'] + description: | + Processes decoded event data for `DepositExecuted` events on the GMX platform in the Arbitrum blockchain. + This model extracts key details such as the account address, execution details, and transaction specifics, enabling + analysis of deposits executed on the platform. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `DepositExecuted` for this model. + - *msg_sender + - name: account + description: The account address associated with the executed deposit. + - name: long_token_amount + description: The amount of the long token in the executed deposit. + - name: short_token_amount + description: The amount of the short token in the executed deposit. + - name: received_market_tokens + description: The number of market tokens received from the executed deposit. + - name: swap_pricing_type + description: The type of swap pricing applied during the execution. + - name: key + description: A unique identifier for the executed deposit. + + + - name: gmx_v2_arbitrum_glv_created + meta: + blockchain: arbitrum + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'gmx', 'event', 'glv_created'] + description: | + Processes decoded event data for `GLVCreated` events on the GMX platform in the Arbitrum blockchain. + This model extracts key details such as the GLV token, associated tokens, and transaction specifics, enabling + analysis of GLV creation events on the platform. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `GLVCreated` for this model. + - *msg_sender + - name: glv_token + description: The identifier of the GLV token created in the transaction. + - name: long_token + description: The long token associated with the GLV creation. + - name: short_token + description: The short token associated with the GLV creation. + - name: salt + description: A unique salt value used in the GLV creation. + - name: glv_type + description: The type of GLV created. + - name: market_token_symbol + description: The symbol of the market token involved in the GLV creation. + - name: market_token_decimals + description: The decimal precision of the market token involved in the GLV creation. + + + - name: gmx_v2_arbitrum_glv_deposit_cancelled + meta: + blockchain: arbitrum + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'gmx', 'event', 'glv_deposit_cancelled'] + description: | + Processes decoded event data for `GLVDepositCancelled` events on the GMX platform in the Arbitrum blockchain. + This model extracts key details such as the account address, cancellation reason, and transaction specifics, enabling + analysis of cancelled GLV deposits. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `GLVDepositCancelled` for this model. + - *msg_sender + - name: account + description: The account address associated with the cancelled deposit. + - name: key + description: A unique identifier for the cancelled deposit. + - name: reason_bytes + description: Encoded reason data for the deposit cancellation. + - name: reason + description: The decoded textual reason for the deposit cancellation. + + + - name: gmx_v2_arbitrum_glv_deposit_created + meta: + blockchain: arbitrum + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'gmx', 'event', 'glv_deposit_created'] + description: | + Processes decoded event data for `GLVDepositCreated` events on the GMX platform in the Arbitrum blockchain. + This model extracts key details such as the account address, deposit details, and transaction specifics, enabling + analysis of created GLV deposits. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `GLVDepositCreated` for this model. + - *msg_sender + - name: account + description: The account address associated with the deposit. + - name: receiver + description: The receiver address specified for the deposit. + - name: callback_contract + description: The address of the callback contract associated with the deposit. + - name: market + description: The market associated with the deposit. + - name: glv + description: The identifier of the GLV associated with the deposit. + - name: initial_long_token + description: The token used for the long position in the deposit. + - name: initial_short_token + description: The token used for the short position in the deposit. + - name: ui_fee_receiver + description: The address receiving the UI fee for the deposit. + - name: long_token_swap_path + description: The swap path for the long token. + - name: short_token_swap_path + description: The swap path for the short token. + - name: initial_long_token_amount + description: The initial amount of the long token in the deposit. + - name: initial_short_token_amount + description: The initial amount of the short token in the deposit. + - name: min_glv_tokens + description: The minimum amount of GLV tokens expected from the deposit. + - name: updated_at_time + description: The timestamp when the deposit was last updated. + - name: execution_fee + description: The execution fee for processing the deposit. + - name: callback_gas_limit + description: The gas limit for the callback associated with the deposit. + - name: market_token_amount + description: The amount of market tokens associated with the deposit. + - name: should_unwrap_native_token + description: Indicates whether the native token should be unwrapped. + - name: is_market_token_deposit + description: Indicates whether the deposit was made using market tokens. + - name: key + description: A unique identifier for the deposit. + + + - name: gmx_v2_arbitrum_glv_deposit_executed + meta: + blockchain: arbitrum + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'gmx', 'event', 'glv_deposit_executed'] + description: | + Processes decoded event data for `GLVDepositExecuted` events on the GMX platform in the Arbitrum blockchain. + This model extracts key details such as the account address, received GLV tokens, and transaction specifics, enabling + analysis of executed GLV deposits. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `GLVDepositExecuted` for this model. + data_tests: + - not_null + - *msg_sender + - name: account + description: The account address associated with the executed deposit. + - name: received_glv_tokens + description: The number of GLV tokens received from the executed deposit. + - name: key + description: A unique identifier for the executed deposit. + + + - name: gmx_v2_arbitrum_glv_shift_cancelled + meta: + blockchain: arbitrum + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'gmx', 'event', 'glv_shift_cancelled'] + description: | + Processes decoded event data for `GLVShiftCancelled` events on the GMX platform in the Arbitrum blockchain. + This model extracts key details such as the cancellation reason and transaction specifics, enabling + analysis of cancelled GLV shifts. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `GLVShiftCancelled` for this model. + - *msg_sender + - name: key + description: A unique identifier for the cancelled shift. + - name: reason_bytes + description: Encoded reason data for the shift cancellation. + - name: reason + description: The decoded textual reason for the shift cancellation. + + + - name: gmx_v2_arbitrum_glv_shift_created + meta: + blockchain: arbitrum + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'gmx', 'event', 'glv_shift_created'] + description: | + Processes decoded event data for `GLVShiftCreated` events on the GMX platform in the Arbitrum blockchain. + This model extracts key details such as the source and destination markets, GLV details, and transaction specifics, enabling + analysis of created GLV shifts. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `GLVShiftCreated` for this model. + - *msg_sender + - name: from_market + description: The source market for the GLV shift. + - name: to_market + description: The destination market for the GLV shift. + - name: glv + description: The identifier of the GLV being shifted. + - name: market_token_amount + description: The amount of market tokens involved in the shift. + - name: min_market_tokens + description: The minimum market tokens expected from the shift. + - name: updated_at_time + description: The timestamp when the shift was last updated. + - name: key + description: A unique identifier for the created shift. + + + - name: gmx_v2_arbitrum_glv_shift_executed + meta: + blockchain: arbitrum + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'gmx', 'event', 'glv_shift_executed'] + description: | + Processes decoded event data for `GLVShiftExecuted` events on the GMX platform in the Arbitrum blockchain. + This model extracts key details such as the received market tokens and transaction specifics, enabling + analysis of executed GLV shifts. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `GLVShiftExecuted` for this model. + - *msg_sender + - name: received_market_tokens + description: The number of market tokens received from the executed shift. + - name: key + description: A unique identifier for the executed shift. + + + - name: gmx_v2_arbitrum_glv_withdrawal_cancelled + meta: + blockchain: arbitrum + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'gmx', 'event', 'glv_withdrawal_cancelled'] + description: | + Processes decoded event data for `GLVWithdrawalCancelled` events on the GMX platform in the Arbitrum blockchain. + This model extracts key details such as the account address, cancellation reason, and transaction specifics, enabling + analysis of cancelled GLV withdrawals. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `GLVWithdrawalCancelled` for this model. + data_tests: + - not_null + - *msg_sender + - name: account + description: The account address associated with the cancelled withdrawal. + - name: key + description: A unique identifier for the cancelled withdrawal. + - name: reason_bytes + description: Encoded reason data for the withdrawal cancellation. + - name: reason + description: The decoded textual reason for the withdrawal cancellation. + + + - name: gmx_v2_arbitrum_glv_withdrawal_created + meta: + blockchain: arbitrum + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'gmx', 'event', 'glv_withdrawal_created'] + description: | + Processes decoded event data for `GLVWithdrawalCreated` events on the GMX platform in the Arbitrum blockchain. + This model extracts key details such as the account address, withdrawal details, and transaction specifics, enabling + analysis of created GLV withdrawals. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `GLVWithdrawalCreated` for this model. + data_tests: + - not_null + - *msg_sender + - name: account + description: The account address associated with the withdrawal. + - name: receiver + description: The receiver address specified for the withdrawal. + - name: callback_contract + description: The address of the callback contract associated with the withdrawal. + - name: market + description: The market associated with the withdrawal. + - name: glv + description: The identifier of the GLV associated with the withdrawal. + - name: ui_fee_receiver + description: The address receiving the UI fee for the withdrawal. + - name: long_token_swap_path + description: The swap path for the long token. + - name: short_token_swap_path + description: The swap path for the short token. + - name: glv_token_amount + description: The amount of GLV tokens involved in the withdrawal. + - name: min_long_token_amount + description: The minimum long token amount expected from the withdrawal. + - name: min_short_token_amount + description: The minimum short token amount expected from the withdrawal. + - name: updated_at_time + description: The timestamp when the withdrawal was last updated. + - name: execution_fee + description: The execution fee for processing the withdrawal. + - name: callback_gas_limit + description: The gas limit for the callback associated with the withdrawal. + - name: should_unwrap_native_token + description: Indicates whether the native token should be unwrapped. + - name: key + description: A unique identifier for the created withdrawal. + + + - name: gmx_v2_arbitrum_glv_withdrawal_executed + meta: + blockchain: arbitrum + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'gmx', 'event', 'glv_withdrawal_executed'] + description: | + Processes decoded event data for `GLVWithdrawalExecuted` events on the GMX platform in the Arbitrum blockchain. + This model extracts key details such as the account address and transaction specifics, enabling + analysis of executed GLV withdrawals. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `GLVWithdrawalExecuted` for this model. + data_tests: + - not_null + - *msg_sender + - name: account + description: The account address associated with the executed withdrawal. + - name: key + description: A unique identifier for the executed withdrawal. + + + - name: gmx_v2_arbitrum_shift_created + meta: + blockchain: arbitrum + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'gmx', 'event', 'shift_created'] + description: | + Processes decoded event data for `ShiftCreated` events on the GMX platform in the Arbitrum blockchain. + This model extracts key details such as the account address, market details, and transaction specifics, enabling + analysis of created shifts. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `ShiftCreated` for this model. + - *msg_sender + - name: account + description: The account address associated with the shift. + - name: receiver + description: The receiver address specified for the shift. + - name: callback_contract + description: The address of the callback contract associated with the shift. + - name: from_market + description: The source market for the shift. + - name: to_market + description: The destination market for the shift. + - name: market_token_amount + description: The amount of market tokens involved in the shift. + - name: min_market_tokens + description: The minimum market tokens expected from the shift. + - name: updated_at_time + description: The timestamp when the shift was last updated. + - name: execution_fee + description: The execution fee for processing the shift. + - name: callback_gas_limit + description: The gas limit for the callback associated with the shift. + - name: key + description: A unique identifier for the created shift. + + + - name: gmx_v2_arbitrum_shift_executed + meta: + blockchain: arbitrum + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'gmx', 'event', 'shift_executed'] + description: | + Processes decoded event data for `ShiftExecuted` events on the GMX platform in the Arbitrum blockchain. + This model extracts key details such as the account address, received market tokens, and transaction specifics, enabling + analysis of executed shifts. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `ShiftExecuted` for this model. + - *msg_sender + - name: account + description: The account address associated with the executed shift. + - name: received_market_tokens + description: The number of market tokens received from the executed shift. + - name: key + description: A unique identifier for the executed shift. + + + - name: gmx_v2_arbitrum_withdrawal_cancelled + meta: + blockchain: arbitrum + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'gmx', 'event', 'withdrawal_cancelled'] + description: | + Processes decoded event data for `WithdrawalCancelled` events on the GMX platform in the Arbitrum blockchain. + This model extracts key details such as the account address, cancellation reason, and transaction specifics, enabling + analysis of cancelled withdrawals. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `WithdrawalCancelled` for this model. + - *msg_sender + - name: account + description: The account address associated with the cancelled withdrawal. + - name: key + description: A unique identifier for the cancelled withdrawal. + - name: reason_bytes + description: Encoded reason data for the withdrawal cancellation. + - name: reason + description: The decoded textual reason for the withdrawal cancellation. + + + - name: gmx_v2_arbitrum_withdrawal_created + meta: + blockchain: arbitrum + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'gmx', 'event', 'withdrawal_created'] + description: | + Processes decoded event data for `WithdrawalCreated` events on the GMX platform in the Arbitrum blockchain. + This model extracts key details such as the account address, withdrawal details, and transaction specifics, enabling + analysis of created withdrawals. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `WithdrawalCreated` for this model. + - *msg_sender + - name: account + description: The account address associated with the withdrawal. + - name: receiver + description: The receiver address specified for the withdrawal. + - name: callback_contract + description: The address of the callback contract associated with the withdrawal. + - name: market + description: The market associated with the withdrawal. + - name: market_token_amount + description: The amount of market tokens involved in the withdrawal. + - name: min_long_token_amount + description: The minimum long token amount expected from the withdrawal. + - name: min_short_token_amount + description: The minimum short token amount expected from the withdrawal. + - name: updated_at_time + description: The timestamp when the withdrawal was last updated. + - name: execution_fee + description: The execution fee for processing the withdrawal. + - name: callback_gas_limit + description: The gas limit for the callback associated with the withdrawal. + - name: should_unwrap_native_token + description: Indicates whether the native token should be unwrapped. + - name: key + description: A unique identifier for the created withdrawal. + + + - name: gmx_v2_arbitrum_withdrawal_executed + meta: + blockchain: arbitrum + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'gmx', 'event', 'withdrawal_executed'] + description: | + Processes decoded event data for `WithdrawalExecuted` events on the GMX platform in the Arbitrum blockchain. + This model extracts key details such as the account address, pricing type, and transaction specifics, enabling + analysis of executed withdrawals. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `WithdrawalExecuted` for this model. + - *msg_sender + - name: account + description: The account address associated with the executed withdrawal. + - name: swap_pricing_type + description: The pricing type applied during the withdrawal. + - name: key + description: A unique identifier for the executed withdrawal. + + + - name: gmx_v2_arbitrum_claimable_funding_amount_per_size_updated + meta: + blockchain: arbitrum + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'gmx', 'event', 'claimable_funding'] + description: | + Processes decoded event data for `ClaimableFundingAmountPerSizeUpdated` events on the GMX platform across the Arbitrum blockchain. + This model extracts key details such as funding updates, collateral information, and market direction to support funding analysis. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address initiating the transaction. + - name: tx_to + description: The recipient address of the transaction. + - name: event_name + description: The name of the event emitted, always `ClaimableFundingAmountPerSizeUpdated`. + - *msg_sender + - name: market + description: The specific GMX market where the funding amount was updated. + - name: collateral_token + description: The token used as collateral in the funding event. + - name: delta + description: The change in the funding amount. + - name: value + description: The funding amount value associated with the update. + - name: is_long + description: A boolean indicating if the position is a long position (`true` for long, `false` for short). + + - name: gmx_v2_arbitrum_funding_fee_amount_per_size_updated + meta: + blockchain: arbitrum + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'gmx', 'event', 'funding_fee'] + description: | + Processes decoded event data for `FundingFeeAmountPerSizeUpdated` events on the GMX platform across the Arbitrum blockchain. + This model extracts key details such as funding fees, collateral details, and market direction to enable funding fee analysis. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address initiating the transaction. + - name: tx_to + description: The recipient address of the transaction. + - name: event_name + description: The name of the event emitted, always `FundingFeeAmountPerSizeUpdated`. + - *msg_sender + - name: market + description: The specific GMX market where the funding fee was updated. + - name: collateral_token + description: The token used as collateral in the funding event. + - name: delta + description: The change in the funding fee amount. + - name: value + description: The funding fee amount associated with the update. + - name: is_long + description: A boolean indicating if the position is a long position (`True` for long, `False` for short). diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_execution_fee_refund.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_execution_fee_refund.sql new file mode 100644 index 00000000000..62b61274227 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_execution_fee_refund.sql @@ -0,0 +1,147 @@ +{{ + config( + schema = 'gmx_v2_arbitrum', + alias = 'execution_fee_refund', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'ExecutionFeeRefund' -%} +{%- set blockchain_name = 'arbitrum' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + MAX(CASE WHEN key_name = 'receiver' THEN value END) AS receiver, + MAX(CASE WHEN key_name = 'refundFeeAmount' THEN value END) AS refund_fee_amount + FROM + combined + GROUP BY tx_hash, index +) + +-- full data +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(EDP.receiver) AS receiver, + CAST(EDP.refund_fee_amount AS DOUBLE) / POWER(10, 18) AS refund_fee_amount + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_funding_fee_amount_per_size_updated.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_funding_fee_amount_per_size_updated.sql new file mode 100644 index 00000000000..48aef2055c4 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_funding_fee_amount_per_size_updated.sql @@ -0,0 +1,195 @@ +{{ + config( + schema = 'gmx_v2_arbitrum', + alias = 'funding_fee_amount_per_size_updated', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'FundingFeeAmountPerSizeUpdated' -%} +{%- set blockchain_name = 'arbitrum' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items, + json_query(data, 'lax $.boolItems' OMIT QUOTES) AS bool_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bool_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bool_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed + UNION ALL + SELECT * + FROM bool_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'market' THEN value END) AS market, + MAX(CASE WHEN key_name = 'collateralToken' THEN value END) AS collateral_token, + MAX(CASE WHEN key_name = 'delta' THEN value END) AS delta, + MAX(CASE WHEN key_name = 'value' THEN value END) AS "value", + MAX(CASE WHEN key_name = 'isLong' THEN value END) AS is_long + + FROM + combined + GROUP BY tx_hash, index +) + +, event_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(market) AS market, + from_hex(collateral_token) AS collateral_token, + TRY_CAST(delta AS DOUBLE) delta, + TRY_CAST("value" AS DOUBLE) "value", + TRY_CAST(is_long AS BOOLEAN) AS is_long + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + tx_hash, + index, + contract_address, + event_name, + msg_sender, + + market, + ED.collateral_token, + delta / POWER(10, CTD.collateral_token_decimals + 15) AS delta, + "value" / POWER(10, CTD.collateral_token_decimals + 15) AS "value", + is_long + + FROM event_data AS ED + LEFT JOIN gmx_v2_arbitrum.collateral_tokens_data AS CTD + ON ED.collateral_token = CTD.collateral_token +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_glv_created.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_glv_created.sql new file mode 100644 index 00000000000..efa07928cd6 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_glv_created.sql @@ -0,0 +1,157 @@ +{{ + config( + schema = 'gmx_v2_arbitrum', + alias = 'glv_created', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'GlvCreated' -%} +{%- set blockchain_name = 'arbitrum' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM bytes32_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'glvToken' THEN value END) AS glv_token, + MAX(CASE WHEN key_name = 'longToken' THEN value END) AS long_token, + MAX(CASE WHEN key_name = 'shortToken' THEN value END) AS short_token, + MAX(CASE WHEN key_name = 'salt' THEN value END) AS salt, + MAX(CASE WHEN key_name = 'glvType' THEN value END) AS glv_type + + FROM + combined + GROUP BY tx_hash, index +) + +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(glv_token) AS glv_token, + from_hex(long_token) AS long_token, + from_hex(short_token) AS short_token, + from_hex(salt) AS salt, + from_hex(glv_type) AS glv_type, + 'GM' AS market_token_symbol, + 18 AS market_token_decimals + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_glv_deposit_cancelled.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_glv_deposit_cancelled.sql new file mode 100644 index 00000000000..347667e0461 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_glv_deposit_cancelled.sql @@ -0,0 +1,187 @@ +{{ + config( + schema = 'gmx_v2_arbitrum', + alias = 'glv_deposit_cancelled', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'GlvDepositCancelled' -%} +{%- set blockchain_name = 'arbitrum' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items, + json_query(data, 'lax $.bytesItems' OMIT QUOTES) AS bytes_items, + json_query(data, 'lax $.stringItems' OMIT QUOTES) AS string_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, string_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(string_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM bytes32_items_parsed + UNION ALL + SELECT * + FROM bytes_items_parsed + UNION ALL + SELECT * + FROM string_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'account' THEN value END) AS account, + MAX(CASE WHEN key_name = 'key' THEN value END) AS "key", + MAX(CASE WHEN key_name = 'reasonBytes' THEN value END) AS reason_bytes, + MAX(CASE WHEN key_name = 'reason' THEN value END) AS reason + + FROM + combined + GROUP BY tx_hash, index +) + +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(account) AS account, + from_hex("key") AS "key", + from_hex(reason_bytes) AS reason_bytes, + reason + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_glv_deposit_created.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_glv_deposit_created.sql new file mode 100644 index 00000000000..ea34140f4fc --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_glv_deposit_created.sql @@ -0,0 +1,269 @@ +{{ + config( + schema = 'gmx_v2_arbitrum', + alias = 'glv_deposit_created', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'GlvDepositCreated' -%} +{%- set blockchain_name = 'arbitrum' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items, + json_query(data, 'lax $.boolItems' OMIT QUOTES) AS bool_items, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bool_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bool_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed + UNION ALL + SELECT * + FROM bool_items_parsed + UNION ALL + SELECT * + FROM bytes32_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'account' THEN value END) AS account, + MAX(CASE WHEN key_name = 'receiver' THEN value END) AS receiver, + MAX(CASE WHEN key_name = 'callbackContract' THEN value END) AS callback_contract, + MAX(CASE WHEN key_name = 'market' THEN value END) AS market, + MAX(CASE WHEN key_name = 'glv' THEN value END) AS glv, + MAX(CASE WHEN key_name = 'initialLongToken' THEN value END) AS initial_long_token, + MAX(CASE WHEN key_name = 'initialShortToken' THEN value END) AS initial_short_token, + MAX(CASE WHEN key_name = 'uiFeeReceiver' THEN value END) AS ui_fee_receiver, + MAX(CASE WHEN key_name = 'longTokenSwapPath' THEN value END) AS long_token_swap_path, + MAX(CASE WHEN key_name = 'shortTokenSwapPath' THEN value END) AS short_token_swap_path, + + MAX(CASE WHEN key_name = 'initialLongTokenAmount' THEN value END) AS initial_long_token_amount, + MAX(CASE WHEN key_name = 'initialShortTokenAmount' THEN value END) AS initial_short_token_amount, + MAX(CASE WHEN key_name = 'minGlvTokens' THEN value END) AS min_glv_tokens, + MAX(CASE WHEN key_name = 'updatedAtTime' THEN value END) AS updated_at_time, + MAX(CASE WHEN key_name = 'executionFee' THEN value END) AS execution_fee, + MAX(CASE WHEN key_name = 'callbackGasLimit' THEN value END) AS callback_gas_limit, + MAX(CASE WHEN key_name = 'marketTokenAmount' THEN value END) AS market_token_amount, + + MAX(CASE WHEN key_name = 'shouldUnwrapNativeToken' THEN value END) AS should_unwrap_native_token, + MAX(CASE WHEN key_name = 'isMarketTokenDeposit' THEN value END) AS is_market_token_deposit, + + MAX(CASE WHEN key_name = 'key' THEN value END) AS "key" + + FROM + combined + GROUP BY tx_hash, index +) + +, event_data AS ( + SELECT + blockchain, + block_time, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(account) AS account, + from_hex(receiver) AS receiver, + from_hex(callback_contract) AS callback_contract, + from_hex(market) AS market, + from_hex(glv) AS glv, + from_hex(initial_long_token) AS initial_long_token, + from_hex(initial_short_token) AS initial_short_token, + from_hex(ui_fee_receiver) AS ui_fee_receiver, + long_token_swap_path, + short_token_swap_path, + + TRY_CAST(initial_long_token_amount AS DOUBLE) initial_long_token_amount, -- long_token_decimals + TRY_CAST(initial_short_token_amount AS DOUBLE) initial_short_token_amount, -- short_token_decimals + TRY_CAST(min_glv_tokens AS DOUBLE) min_glv_tokens, -- index_token_decimals (glv or market?) + TRY_CAST(updated_at_time AS DOUBLE) AS updated_at_time, + TRY_CAST(execution_fee AS DOUBLE) AS execution_fee, -- POWER(10, 18) + TRY_CAST(callback_gas_limit AS DOUBLE) AS callback_gas_limit, -- no decimals, keep as raw values + TRY_CAST(market_token_amount AS DOUBLE) market_token_amount, -- index_token_decimals (glv or market?) + + TRY_CAST(should_unwrap_native_token AS BOOLEAN) AS should_unwrap_native_token, + TRY_CAST(is_market_token_deposit AS BOOLEAN) AS is_market_token_deposit, + + from_hex("key") AS "key" + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + tx_hash, + index, + contract_address, + event_name, + msg_sender, + + account, + receiver, + callback_contract, + ED.market, + glv, + initial_long_token, + initial_short_token, + ui_fee_receiver, + long_token_swap_path, + short_token_swap_path, + + initial_long_token_amount / POWER(10, MD.long_token_decimals) AS initial_long_token_amount, + initial_short_token_amount / POWER(10, MD.short_token_decimals) AS initial_short_token_amount, + min_glv_tokens / POWER(10, 18) AS min_glv_tokens, + CASE + WHEN updated_at_time = 0 THEN NULL + ELSE updated_at_time + END AS updated_at_time, + execution_fee / POWER(10, 18) AS execution_fee, + callback_gas_limit, + market_token_amount / POWER(10, 18) AS market_token_amount, + + should_unwrap_native_token, + is_market_token_deposit, + + "key" + + FROM event_data AS ED + LEFT JOIN {{ ref('gmx_v2_arbitrum_markets_data') }} AS MD + ON ED.market = MD.market +) + + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_glv_deposit_executed.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_glv_deposit_executed.sql new file mode 100644 index 00000000000..3302d0cbe00 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_glv_deposit_executed.sql @@ -0,0 +1,186 @@ +{{ + config( + schema = 'gmx_v2_arbitrum', + alias = 'glv_deposit_executed', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'GlvDepositExecuted' -%} +{%- set blockchain_name = 'arbitrum' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed + UNION ALL + SELECT * + FROM bytes32_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'account' THEN value END) AS account, + MAX(CASE WHEN key_name = 'receivedGlvTokens' THEN value END) AS received_glv_tokens, + MAX(CASE WHEN key_name = 'key' THEN value END) AS "key" + + FROM + combined + GROUP BY tx_hash, index +) + +, event_data AS ( + SELECT + blockchain, + block_time, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(account) AS account, + TRY_CAST(received_glv_tokens AS DOUBLE) received_glv_tokens, + from_hex("key") AS "key" + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + tx_hash, + index, + contract_address, + event_name, + msg_sender, + + account, + received_glv_tokens / POWER(10,18) AS received_glv_tokens, + "key" + + FROM event_data AS ED +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_glv_shift_cancelled.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_glv_shift_cancelled.sql new file mode 100644 index 00000000000..eb06ffd6817 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_glv_shift_cancelled.sql @@ -0,0 +1,167 @@ +{{ + config( + schema = 'gmx_v2_arbitrum', + alias = 'glv_shift_cancelled', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'GlvShiftCancelled' -%} +{%- set blockchain_name = 'arbitrum' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items, + json_query(data, 'lax $.bytesItems' OMIT QUOTES) AS bytes_items, + json_query(data, 'lax $.stringItems' OMIT QUOTES) AS string_items + FROM + evt_data +) +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, string_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(string_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM bytes32_items_parsed + UNION ALL + SELECT * + FROM bytes_items_parsed + UNION ALL + SELECT * + FROM string_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'key' THEN value END) AS "key", + MAX(CASE WHEN key_name = 'reasonBytes' THEN value END) AS reason_bytes, + MAX(CASE WHEN key_name = 'reason' THEN value END) AS reason + FROM + combined + GROUP BY tx_hash, index +) + +-- full data +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex("key") AS "key", + from_hex(reason_bytes) AS reason_bytes, + reason + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_glv_shift_created.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_glv_shift_created.sql new file mode 100644 index 00000000000..3352d8cbe46 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_glv_shift_created.sql @@ -0,0 +1,200 @@ +{{ + config( + schema = 'gmx_v2_arbitrum', + alias = 'glv_shift_created', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'GlvShiftCreated' -%} +{%- set blockchain_name = 'arbitrum' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed + UNION ALL + SELECT * + FROM bytes32_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'fromMarket' THEN value END) AS from_market, + MAX(CASE WHEN key_name = 'toMarket' THEN value END) AS to_market, + MAX(CASE WHEN key_name = 'glv' THEN value END) AS glv, + MAX(CASE WHEN key_name = 'marketTokenAmount' THEN value END) AS market_token_amount, + MAX(CASE WHEN key_name = 'minMarketTokens' THEN value END) AS min_market_tokens, + MAX(CASE WHEN key_name = 'updatedAtTime' THEN value END) AS updated_at_time, + MAX(CASE WHEN key_name = 'key' THEN value END) AS "key" + + FROM + combined + GROUP BY tx_hash, index +) + +, event_data AS ( + SELECT + blockchain, + block_time, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(from_market) AS from_market, + from_hex(to_market) AS to_market, + from_hex(glv) AS glv, + TRY_CAST(market_token_amount AS DOUBLE) AS market_token_amount, + TRY_CAST(min_market_tokens AS DOUBLE) AS min_market_tokens, + TRY_CAST(updated_at_time AS DOUBLE) updated_at_time, + from_hex("key") AS "key" + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + tx_hash, + index, + contract_address, + event_name, + msg_sender, + + from_market, + to_market, + glv, + market_token_amount / POWER(10, 18) AS market_token_amount, + min_market_tokens / POWER(10, 18) AS min_market_tokens, + CASE + WHEN updated_at_time = 0 THEN NULL + ELSE updated_at_time + END AS updated_at_time, + "key" + FROM event_data AS ED +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_glv_shift_executed.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_glv_shift_executed.sql new file mode 100644 index 00000000000..106f89913c2 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_glv_shift_executed.sql @@ -0,0 +1,165 @@ +{{ + config( + schema = 'gmx_v2_arbitrum', + alias = 'glv_shift_executed', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'GlvShiftExecuted' -%} +{%- set blockchain_name = 'arbitrum' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items + FROM + evt_data +) + +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM uint_items_parsed + UNION ALL + SELECT * + FROM bytes32_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'receivedMarketTokens' THEN value END) AS received_market_tokens, + MAX(CASE WHEN key_name = 'key' THEN value END) AS "key" + + FROM + combined + GROUP BY tx_hash, index +) + +, event_data AS ( + SELECT + blockchain, + block_time, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + TRY_CAST(received_market_tokens AS DOUBLE) received_market_tokens, + from_hex("key") AS "key" + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + tx_hash, + index, + contract_address, + event_name, + msg_sender, + + received_market_tokens / POWER(10, 18) AS received_market_tokens, + "key" + FROM event_data AS ED +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_glv_withdrawal_cancelled.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_glv_withdrawal_cancelled.sql new file mode 100644 index 00000000000..e07944f51c7 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_glv_withdrawal_cancelled.sql @@ -0,0 +1,187 @@ +{{ + config( + schema = 'gmx_v2_arbitrum', + alias = 'glv_withdrawal_cancelled', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'GlvWithdrawalCancelled' -%} +{%- set blockchain_name = 'arbitrum' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items, + json_query(data, 'lax $.bytesItems' OMIT QUOTES) AS bytes_items, + json_query(data, 'lax $.stringItems' OMIT QUOTES) AS string_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, string_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(string_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM bytes32_items_parsed + UNION ALL + SELECT * + FROM bytes_items_parsed + UNION ALL + SELECT * + FROM string_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'account' THEN value END) AS account, + MAX(CASE WHEN key_name = 'key' THEN value END) AS "key", + MAX(CASE WHEN key_name = 'reasonBytes' THEN value END) AS reason_bytes, + MAX(CASE WHEN key_name = 'reason' THEN value END) AS reason + + FROM + combined + GROUP BY tx_hash, index +) + +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(account) AS account, + from_hex("key") AS "key", + from_hex(reason_bytes) AS reason_bytes, + reason + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_glv_withdrawal_created.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_glv_withdrawal_created.sql new file mode 100644 index 00000000000..3aa3f886a57 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_glv_withdrawal_created.sql @@ -0,0 +1,255 @@ +{{ + config( + schema = 'gmx_v2_arbitrum', + alias = 'glv_withdrawal_created', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'GlvWithdrawalCreated' -%} +{%- set blockchain_name = 'arbitrum' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items, + json_query(data, 'lax $.boolItems' OMIT QUOTES) AS bool_items, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bool_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bool_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed + UNION ALL + SELECT * + FROM bool_items_parsed + UNION ALL + SELECT * + FROM bytes32_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'account' THEN value END) AS account, + MAX(CASE WHEN key_name = 'receiver' THEN value END) AS receiver, + MAX(CASE WHEN key_name = 'callbackContract' THEN value END) AS callback_contract, + MAX(CASE WHEN key_name = 'market' THEN value END) AS market, + MAX(CASE WHEN key_name = 'glv' THEN value END) AS glv, + MAX(CASE WHEN key_name = 'uiFeeReceiver' THEN value END) AS ui_fee_receiver, + MAX(CASE WHEN key_name = 'longTokenSwapPath' THEN value END) AS long_token_swap_path, + MAX(CASE WHEN key_name = 'shortTokenSwapPath' THEN value END) AS short_token_swap_path, + + MAX(CASE WHEN key_name = 'glvTokenAmount' THEN value END) AS glv_token_amount, + MAX(CASE WHEN key_name = 'minLongTokenAmount' THEN value END) AS min_long_token_amount, + MAX(CASE WHEN key_name = 'minShortTokenAmount' THEN value END) AS min_short_token_amount, + MAX(CASE WHEN key_name = 'updatedAtTime' THEN value END) AS updated_at_time, + MAX(CASE WHEN key_name = 'executionFee' THEN value END) AS execution_fee, + MAX(CASE WHEN key_name = 'callbackGasLimit' THEN value END) AS callback_gas_limit, + + MAX(CASE WHEN key_name = 'shouldUnwrapNativeToken' THEN value END) AS should_unwrap_native_token, + + MAX(CASE WHEN key_name = 'key' THEN value END) AS "key" + + FROM + combined + GROUP BY tx_hash, index +) + +, event_data AS ( + SELECT + blockchain, + block_time, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(account) AS account, + from_hex(receiver) AS receiver, + from_hex(callback_contract) AS callback_contract, + from_hex(market) AS market, + from_hex(glv) AS glv, + from_hex(ui_fee_receiver) AS ui_fee_receiver, + long_token_swap_path, + short_token_swap_path, + + TRY_CAST(glv_token_amount AS DOUBLE) glv_token_amount, -- index_token_decimals (glv or market?) + TRY_CAST(min_long_token_amount AS DOUBLE) min_long_token_amount, -- long_token_decimals + TRY_CAST(min_short_token_amount AS DOUBLE) min_short_token_amount, -- short_token_decimals + TRY_CAST(updated_at_time AS DOUBLE) AS updated_at_time, + TRY_CAST(execution_fee AS DOUBLE) AS execution_fee, -- POWER(10, 18) + TRY_CAST(callback_gas_limit AS DOUBLE) AS callback_gas_limit, -- no decimals, keep as raw values + + TRY_CAST(should_unwrap_native_token AS BOOLEAN) AS should_unwrap_native_token, + + from_hex("key") AS "key" + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + tx_hash, + index, + contract_address, + event_name, + msg_sender, + + account, + receiver, + callback_contract, + ED.market, + glv, + ui_fee_receiver, + long_token_swap_path, + short_token_swap_path, + + glv_token_amount / POWER(10, 18) AS glv_token_amount, + min_long_token_amount / POWER(10, MD.long_token_decimals) AS min_long_token_amount, + min_short_token_amount / POWER(10, MD.short_token_decimals) AS min_short_token_amount, + CASE + WHEN updated_at_time = 0 THEN NULL + ELSE updated_at_time + END AS updated_at_time, + execution_fee / POWER(10, 18) AS execution_fee, + callback_gas_limit, + + should_unwrap_native_token, + "key" + + FROM event_data AS ED + LEFT JOIN {{ ref('gmx_v2_arbitrum_markets_data') }} AS MD + ON ED.market = MD.market +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_glv_withdrawal_executed.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_glv_withdrawal_executed.sql new file mode 100644 index 00000000000..80574bfc7c7 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_glv_withdrawal_executed.sql @@ -0,0 +1,149 @@ +{{ + config( + schema = 'gmx_v2_arbitrum', + alias = 'glv_withdrawal_executed', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'GlvWithdrawalExecuted' -%} +{%- set blockchain_name = 'arbitrum' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM bytes32_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'account' THEN value END) AS account, + MAX(CASE WHEN key_name = 'key' THEN value END) AS "key" + + FROM + combined + GROUP BY tx_hash, index +) + +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(account) AS account, + from_hex("key") AS "key" + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_keeper_execution_fee.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_keeper_execution_fee.sql new file mode 100644 index 00000000000..c10578e4da4 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_keeper_execution_fee.sql @@ -0,0 +1,147 @@ +{{ + config( + schema = 'gmx_v2_arbitrum', + alias = 'keeper_execution_fee', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'KeeperExecutionFee' -%} +{%- set blockchain_name = 'arbitrum' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + MAX(CASE WHEN key_name = 'keeper' THEN value END) AS keeper, + MAX(CASE WHEN key_name = 'executionFeeAmount' THEN value END) AS execution_fee_amount + FROM + combined + GROUP BY tx_hash, index +) + +-- full data +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(EDP.keeper) AS keeper, + CAST(EDP.execution_fee_amount AS DOUBLE) / POWER(10, 18) AS execution_fee_amount + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_market_created.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_market_created.sql index 58a6f6bcb5e..77ebbce58c1 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_market_created.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_market_created.sql @@ -49,7 +49,7 @@ WITH evt_data_1 AS ( , evt_data AS ( SELECT * FROM evt_data_1 - UNION + UNION ALL SELECT * FROM evt_data_2 ) diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_open_interest_in_tokens_updated.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_open_interest_in_tokens_updated.sql new file mode 100644 index 00000000000..e783d229c36 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_open_interest_in_tokens_updated.sql @@ -0,0 +1,187 @@ +{{ + config( + schema = 'gmx_v2_arbitrum', + alias = 'open_interest_in_tokens_updated', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'OpenInterestInTokensUpdated' -%} +{%- set blockchain_name = 'arbitrum' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items, + json_query(data, 'lax $.intItems' OMIT QUOTES) AS int_items, + json_query(data, 'lax $.boolItems' OMIT QUOTES) AS bool_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, int_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(int_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bool_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bool_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed + UNION ALL + SELECT * + FROM int_items_parsed + UNION ALL + SELECT * + FROM bool_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + MAX(CASE WHEN key_name = 'isLong' THEN value END) AS is_long, + MAX(CASE WHEN key_name = 'nextValue' THEN value END) AS next_value, + MAX(CASE WHEN key_name = 'market' THEN value END) AS market, + MAX(CASE WHEN key_name = 'collateralToken' THEN value END) AS collateral_token, + MAX(CASE WHEN key_name = 'delta' THEN value END) AS delta + FROM + combined + GROUP BY tx_hash, index +) + +-- full data +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(EDP.market) AS market, + from_hex(EDP.collateral_token) AS collateral_token, + CAST(EDP.is_long AS BOOLEAN) AS is_long, + CAST(EDP.next_value AS DOUBLE) / POWER(10, MD.index_token_decimals) AS next_value, + CAST(EDP.delta AS DOUBLE) / POWER(10, MD.index_token_decimals) AS delta + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index + LEFT JOIN {{ ref('gmx_v2_arbitrum_markets_data') }} AS MD + ON from_hex(EDP.market) = MD.market +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to', 'index'] + ) +}} diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_open_interest_updated.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_open_interest_updated.sql new file mode 100644 index 00000000000..2bfd18b0817 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_open_interest_updated.sql @@ -0,0 +1,186 @@ +{{ + config( + schema = 'gmx_v2_arbitrum', + alias = 'open_interest_updated', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'OpenInterestUpdated' -%} +{%- set blockchain_name = 'arbitrum' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items, + json_query(data, 'lax $.intItems' OMIT QUOTES) AS int_items, + json_query(data, 'lax $.boolItems' OMIT QUOTES) AS bool_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, int_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(int_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bool_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bool_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed + UNION ALL + SELECT * + FROM int_items_parsed + UNION ALL + SELECT * + FROM bool_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + MAX(CASE WHEN key_name = 'market' THEN value END) AS market, + MAX(CASE WHEN key_name = 'collateralToken' THEN value END) AS collateral_token, + MAX(CASE WHEN key_name = 'isLong' THEN value END) AS is_long, + MAX(CASE WHEN key_name = 'delta' THEN value END) AS delta, + MAX(CASE WHEN key_name = 'nextValue' THEN value END) AS next_value + FROM + combined + GROUP BY tx_hash, index +) + +-- full data +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(market) AS market, + from_hex(collateral_token) AS collateral_token, + TRY_CAST(is_long AS BOOLEAN) AS is_long, + TRY_CAST(delta AS DOUBLE) / POWER(10, 30) AS delta, + TRY_CAST(next_value AS DOUBLE) / POWER(10, 30) AS next_value + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to', 'index'] + ) +}} diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_oracle_price_update.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_oracle_price_update.sql new file mode 100644 index 00000000000..3f21c89db83 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_oracle_price_update.sql @@ -0,0 +1,157 @@ +{{ + config( + schema = 'gmx_v2_arbitrum', + alias = 'oracle_price_update', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'OraclePriceUpdate' -%} +{%- set blockchain_name = 'arbitrum' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% else %} + AND evt_block_time > DATE '2023-08-01' + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% else %} + AND evt_block_time > DATE '2023-08-01' + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items + FROM + evt_data +) +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed +) +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + MAX(CASE WHEN key_name = 'token' THEN value END) AS token, + MAX(CASE WHEN key_name = 'provider' THEN value END) AS provider, + MAX(CASE WHEN key_name = 'minPrice' THEN value END) AS min_price, + MAX(CASE WHEN key_name = 'maxPrice' THEN value END) AS max_price, + MAX(CASE WHEN key_name = 'timestamp' THEN value END) AS "timestamp" + FROM + combined + GROUP BY tx_hash, index +) + +-- full data +, full_data AS ( + SELECT + ED.blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + ED.tx_hash, + ED.index, + ED.contract_address, + event_name, + msg_sender, + + from_hex(token) AS token, + from_hex(provider) AS provider, + TRY_CAST(min_price AS DOUBLE) / POWER(10, 30 - ERC20.decimals) AS min_price, + TRY_CAST(max_price AS DOUBLE) / POWER(10, 30 - ERC20.decimals) AS max_price, + CASE + WHEN TRY_CAST("timestamp" AS DOUBLE) = 0 THEN NULL + ELSE TRY_CAST("timestamp" AS DOUBLE) + END AS "timestamp" + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index + LEFT JOIN {{ ref('gmx_v2_arbitrum_erc20') }} AS ERC20 + ON from_hex(EDP.token) = ERC20.contract_address +) + +-- can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to', 'index'] + ) +}} + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_cancelled.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_cancelled.sql index 84fe7f7b326..c7444cacce2 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_cancelled.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_cancelled.sql @@ -2,7 +2,9 @@ config( schema = 'gmx_v2_arbitrum', alias = 'order_cancelled', - materialized = 'table' + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' ) }} @@ -23,7 +25,9 @@ WITH evt_data_1 AS ( msgSender AS msg_sender FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog1')}} WHERE eventName = '{{ event_name }}' - ORDER BY evt_block_time ASC + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} ) , evt_data_2 AS ( @@ -40,14 +44,16 @@ WITH evt_data_1 AS ( msgSender AS msg_sender FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog2')}} WHERE eventName = '{{ event_name }}' - ORDER BY evt_block_time ASC + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} ) -- unite 2 tables , evt_data AS ( SELECT * FROM evt_data_1 - UNION + UNION ALL SELECT * FROM evt_data_2 ) diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_created.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_created.sql index 4339e211083..12f38efb078 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_created.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_created.sql @@ -2,7 +2,9 @@ config( schema = 'gmx_v2_arbitrum', alias = 'order_created', - materialized = 'table' + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' ) }} @@ -23,7 +25,9 @@ WITH evt_data_1 AS ( msgSender AS msg_sender FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog1')}} WHERE eventName = '{{ event_name }}' - ORDER BY evt_block_time ASC + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} ) , evt_data_2 AS ( @@ -40,7 +44,9 @@ WITH evt_data_1 AS ( msgSender AS msg_sender FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog2')}} WHERE eventName = '{{ event_name }}' - ORDER BY evt_block_time ASC + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} ) -- unite 2 tables @@ -171,10 +177,11 @@ WITH evt_data_1 AS ( MAX(CASE WHEN key_name = 'updatedAtBlock' THEN value END) AS updated_at_block, MAX(CASE WHEN key_name = 'updatedAtTime' THEN value END) AS updated_at_time, + MAX(CASE WHEN key_name = 'validFromTime' THEN value END) AS valid_from_time, MAX(CASE WHEN key_name = 'isLong' THEN value END) AS is_long, MAX(CASE WHEN key_name = 'shouldUnwrapNativeToken' THEN value END) AS should_unwrap_native_token, - MAX(CASE WHEN key_name = 'isFrozen' THEN value END) AS is_frozen, + MAX(CASE WHEN key_name = 'autoCancel' THEN value END) AS auto_cancel, MAX(CASE WHEN key_name = 'key' THEN value END) AS key FROM @@ -213,9 +220,10 @@ WITH evt_data_1 AS ( TRY_CAST(min_output_amount AS DOUBLE) AS min_output_amount, TRY_CAST(updated_at_block AS BIGINT) AS updated_at_block, TRY_CAST(updated_at_time AS DOUBLE) AS updated_at_time, + TRY_CAST(valid_from_time AS DOUBLE) AS valid_from_time, TRY_CAST(is_long AS BOOLEAN) AS is_long, TRY_CAST(should_unwrap_native_token AS BOOLEAN) AS should_unwrap_native_token, - TRY_CAST(is_frozen AS BOOLEAN) AS is_frozen, + TRY_CAST(auto_cancel AS BOOLEAN) AS auto_cancel, from_hex(key) AS key FROM evt_data AS ED @@ -284,9 +292,14 @@ WITH evt_data_1 AS ( WHEN updated_at_time = 0 THEN NULL ELSE updated_at_time END AS updated_at_time, + valid_from_time, is_long, should_unwrap_native_token, - is_frozen, + + CASE + WHEN auto_cancel IS NULL THEN false + ELSE auto_cancel + END AS auto_cancel, key FROM event_data AS ED diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_executed.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_executed.sql index b373d356708..366dc5709e9 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_executed.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_executed.sql @@ -2,7 +2,9 @@ config( schema = 'gmx_v2_arbitrum', alias = 'order_executed', - materialized = 'table' + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' ) }} @@ -23,7 +25,9 @@ WITH evt_data_1 AS ( msgSender AS msg_sender FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog1')}} WHERE eventName = '{{ event_name }}' - ORDER BY evt_block_time ASC + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} ) , evt_data_2 AS ( @@ -40,14 +44,16 @@ WITH evt_data_1 AS ( msgSender AS msg_sender FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog2')}} WHERE eventName = '{{ event_name }}' - ORDER BY evt_block_time ASC + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} ) -- unite 2 tables , evt_data AS ( SELECT * FROM evt_data_1 - UNION + UNION ALL SELECT * FROM evt_data_2 ) diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_frozen.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_frozen.sql index b0cc9d09f62..132477a7d8e 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_frozen.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_frozen.sql @@ -2,7 +2,9 @@ config( schema = 'gmx_v2_arbitrum', alias = 'order_frozen', - materialized = 'table' + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' ) }} @@ -23,7 +25,9 @@ WITH evt_data_1 AS ( msgSender AS msg_sender FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog1')}} WHERE eventName = '{{ event_name }}' - ORDER BY evt_block_time ASC + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} ) , evt_data_2 AS ( @@ -40,14 +44,16 @@ WITH evt_data_1 AS ( msgSender AS msg_sender FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog2')}} WHERE eventName = '{{ event_name }}' - ORDER BY evt_block_time ASC + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} ) -- unite 2 tables , evt_data AS ( SELECT * FROM evt_data_1 - UNION + UNION ALL SELECT * FROM evt_data_2 ) diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_updated.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_updated.sql index 4fe2a489b05..38d6a895854 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_updated.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_updated.sql @@ -2,7 +2,9 @@ config( schema = 'gmx_v2_arbitrum', alias = 'order_updated', - materialized = 'table' + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' ) }} @@ -23,7 +25,9 @@ WITH evt_data_1 AS ( msgSender AS msg_sender FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog1')}} WHERE eventName = '{{ event_name }}' - ORDER BY evt_block_time ASC + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} ) , evt_data_2 AS ( @@ -40,7 +44,9 @@ WITH evt_data_1 AS ( msgSender AS msg_sender FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog2')}} WHERE eventName = '{{ event_name }}' - ORDER BY evt_block_time ASC + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} ) -- unite 2 tables @@ -58,7 +64,8 @@ WITH evt_data_1 AS ( index, json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items, json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, - json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items, + json_query(data, 'lax $.boolItems' OMIT QUOTES) AS bool_items FROM evt_data ) @@ -102,6 +109,19 @@ WITH evt_data_1 AS ( ) AS t(item) ) +, bool_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bool_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + , combined AS ( SELECT * FROM bytes32_items_parsed @@ -111,6 +131,9 @@ WITH evt_data_1 AS ( UNION ALL SELECT * FROM uint_items_parsed + UNION ALL + SELECT * + FROM bool_items_parsed ) , evt_data_parsed AS ( @@ -123,7 +146,9 @@ WITH evt_data_1 AS ( MAX(CASE WHEN key_name = 'acceptablePrice' THEN value END) AS acceptable_price, MAX(CASE WHEN key_name = 'triggerPrice' THEN value END) AS trigger_price, MAX(CASE WHEN key_name = 'minOutputAmount' THEN value END) AS min_output_amount, - MAX(CASE WHEN key_name = 'updatedAtTime' THEN value END) AS updated_at_time + MAX(CASE WHEN key_name = 'updatedAtTime' THEN value END) AS updated_at_time, + MAX(CASE WHEN key_name = 'validFromTime' THEN value END) AS valid_from_time, + MAX(CASE WHEN key_name = 'autoCancel' THEN value END) AS auto_cancel FROM combined GROUP BY tx_hash, index @@ -147,7 +172,9 @@ WITH evt_data_1 AS ( TRY_CAST(acceptable_price AS DOUBLE) AS acceptable_price, TRY_CAST(trigger_price AS DOUBLE) AS trigger_price, TRY_CAST(min_output_amount AS DOUBLE) AS min_output_amount, - TRY_CAST(updated_at_time AS DOUBLE) AS updated_at_time + TRY_CAST(updated_at_time AS DOUBLE) AS updated_at_time, + TRY_CAST(valid_from_time AS DOUBLE) AS valid_from_time, + TRY_CAST(auto_cancel AS BOOLEAN) AS auto_cancel FROM evt_data AS ED LEFT JOIN evt_data_parsed AS EDP @@ -186,7 +213,9 @@ WITH evt_data_1 AS ( CASE WHEN ED.updated_at_time = 0 THEN NULL ELSE ED.updated_at_time - END AS updated_at_time + END AS updated_at_time, + ED.valid_from_time, + ED.auto_cancel FROM event_data AS ED LEFT JOIN {{ ref('gmx_v2_arbitrum_order_created') }} AS OC diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_pool_amount_updated.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_pool_amount_updated.sql new file mode 100644 index 00000000000..947eef0660f --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_pool_amount_updated.sql @@ -0,0 +1,165 @@ +{{ + config( + schema = 'gmx_v2_arbitrum', + alias = 'pool_amount_updated', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'PoolAmountUpdated' -%} +{%- set blockchain_name = 'arbitrum' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items, + json_query(data, 'lax $.intItems' OMIT QUOTES) AS int_items + FROM + evt_data +) +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) +, int_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(int_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed + UNION ALL + SELECT * + FROM int_items_parsed +) +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + MAX(CASE WHEN key_name = 'market' THEN value END) AS market, + MAX(CASE WHEN key_name = 'token' THEN value END) AS token, + MAX(CASE WHEN key_name = 'delta' THEN value END) AS delta, + MAX(CASE WHEN key_name = 'nextValue' THEN value END) AS next_value + FROM + combined + GROUP BY tx_hash, index +) + +-- full data +, full_data AS ( + SELECT + ED.blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + ED.tx_hash, + ED.index, + ED.contract_address, + event_name, + msg_sender, + + from_hex(market) AS market, + from_hex(token) AS token, + TRY_CAST(next_value AS DOUBLE) / POWER(10, ERC20.decimals) AS next_value, + TRY_CAST(delta AS DOUBLE) / POWER(10, ERC20.decimals) AS delta + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index + LEFT JOIN {{ ref('gmx_v2_arbitrum_erc20') }} AS ERC20 + ON from_hex(EDP.token) = ERC20.contract_address +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to', 'index'] + ) +}} + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_position_decrease.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_position_decrease.sql index d5cfa5c134e..b41395df4a1 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_position_decrease.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_position_decrease.sql @@ -2,7 +2,9 @@ config( schema = 'gmx_v2_arbitrum', alias = 'position_decrease', - materialized = 'table' + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' ) }} @@ -23,7 +25,9 @@ WITH evt_data_1 AS ( msgSender AS msg_sender FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog1')}} WHERE eventName = '{{ event_name }}' - ORDER BY evt_block_time ASC + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} ) , evt_data_2 AS ( @@ -40,14 +44,16 @@ WITH evt_data_1 AS ( msgSender AS msg_sender FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog2')}} WHERE eventName = '{{ event_name }}' - ORDER BY evt_block_time ASC + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} ) -- unite 2 tables , evt_data AS ( SELECT * FROM evt_data_1 - UNION + UNION ALL SELECT * FROM evt_data_2 ) diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_position_fees_collected.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_position_fees_collected.sql index fa7d065f5fa..7ef09cf95a9 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_position_fees_collected.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_position_fees_collected.sql @@ -2,7 +2,9 @@ config( schema = 'gmx_v2_arbitrum', alias = 'position_fees_collected', - materialized = 'table' + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' ) }} @@ -23,7 +25,9 @@ WITH evt_data_1 AS ( msgSender AS msg_sender FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog1')}} WHERE eventName = '{{ event_name }}' - ORDER BY evt_block_time ASC + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} ) , evt_data_2 AS ( @@ -40,14 +44,16 @@ WITH evt_data_1 AS ( msgSender AS msg_sender FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog2')}} WHERE eventName = '{{ event_name }}' - ORDER BY evt_block_time ASC + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} ) -- unite 2 tables , evt_data AS ( SELECT * FROM evt_data_1 - UNION + UNION ALL SELECT * FROM evt_data_2 ) @@ -135,19 +141,19 @@ WITH evt_data_1 AS ( tx_hash, index, + MAX(CASE WHEN key_name = 'orderKey' THEN value END) AS order_key, + MAX(CASE WHEN key_name = 'positionKey' THEN value END) AS position_key, + MAX(CASE WHEN key_name = 'referralCode' THEN value END) AS referral_code, + MAX(CASE WHEN key_name = 'market' THEN value END) AS market, MAX(CASE WHEN key_name = 'collateralToken' THEN value END) AS collateral_token, MAX(CASE WHEN key_name = 'affiliate' THEN value END) AS affiliate, MAX(CASE WHEN key_name = 'trader' THEN value END) AS trader, MAX(CASE WHEN key_name = 'uiFeeReceiver' THEN value END) AS ui_fee_receiver, + MAX(CASE WHEN key_name = 'collateralTokenPrice.min' THEN value END) AS collateral_token_price_min, MAX(CASE WHEN key_name = 'collateralTokenPrice.max' THEN value END) AS collateral_token_price_max, MAX(CASE WHEN key_name = 'tradeSizeUsd' THEN value END) AS trade_size_usd, - MAX(CASE WHEN key_name = 'totalRebateFactor' THEN value END) AS total_rebate_factor, - MAX(CASE WHEN key_name = 'traderDiscountFactor' THEN value END) AS trader_discount_factor, - MAX(CASE WHEN key_name = 'totalRebateAmount' THEN value END) AS total_rebate_amount, - MAX(CASE WHEN key_name = 'traderDiscountAmount' THEN value END) AS trader_discount_amount, - MAX(CASE WHEN key_name = 'affiliateRewardAmount' THEN value END) AS affiliate_reward_amount, MAX(CASE WHEN key_name = 'fundingFeeAmount' THEN value END) AS funding_fee_amount, MAX(CASE WHEN key_name = 'claimableLongTokenAmount' THEN value END) AS claimable_long_token_amount, MAX(CASE WHEN key_name = 'claimableShortTokenAmount' THEN value END) AS claimable_short_token_amount, @@ -168,10 +174,28 @@ WITH evt_data_1 AS ( MAX(CASE WHEN key_name = 'totalCostAmount' THEN value END) AS total_cost_amount, MAX(CASE WHEN key_name = 'uiFeeReceiverFactor' THEN value END) AS ui_fee_receiver_factor, MAX(CASE WHEN key_name = 'uiFeeAmount' THEN value END) AS ui_fee_amount, - MAX(CASE WHEN key_name = 'isIncrease' THEN value END) AS is_increase, - MAX(CASE WHEN key_name = 'orderKey' THEN value END) AS order_key, - MAX(CASE WHEN key_name = 'positionKey' THEN value END) AS position_key, - MAX(CASE WHEN key_name = 'referralCode' THEN value END) AS referral_code + + MAX(CASE WHEN key_name = 'totalRebateFactor' THEN value END) AS total_rebate_factor, + MAX(CASE WHEN key_name = 'traderDiscountFactor' THEN value END) AS trader_discount_factor, + MAX(CASE WHEN key_name = 'totalRebateAmount' THEN value END) AS total_rebate_amount, + MAX(CASE WHEN key_name = 'traderDiscountAmount' THEN value END) AS trader_discount_amount, + MAX(CASE WHEN key_name = 'affiliateRewardAmount' THEN value END) AS affiliate_reward_amount, + + MAX(CASE WHEN key_name = 'referral.totalRebateFactor' THEN value END) AS referral_total_rebate_factor, + MAX(CASE WHEN key_name = 'referral.adjustedAffiliateRewardFactor' THEN value END) AS referral_adjusted_affiliate_reward_factor, + MAX(CASE WHEN key_name = 'referral.traderDiscountFactor' THEN value END) AS referral_trader_discount_factor, + MAX(CASE WHEN key_name = 'referral.totalRebateAmount' THEN value END) AS referral_total_rebate_amount, + MAX(CASE WHEN key_name = 'referral.traderDiscountAmount' THEN value END) AS referral_trader_discount_amount, + MAX(CASE WHEN key_name = 'referral.affiliateRewardAmount' THEN value END) AS referral_affiliate_reward_amount, + + MAX(CASE WHEN key_name = 'pro.traderDiscountFactor' THEN value END) AS pro_trader_discount_factor, + MAX(CASE WHEN key_name = 'pro.traderDiscountAmount' THEN value END) AS pro_trader_discount_amount, + + MAX(CASE WHEN key_name = 'liquidationFeeAmount' THEN value END) AS liquidation_fee_amount, + MAX(CASE WHEN key_name = 'liquidationFeeReceiverFactor' THEN value END) AS liquidation_fee_receiver_factor, + MAX(CASE WHEN key_name = 'liquidationFeeAmountForFeeReceiver' THEN value END) AS liquidation_fee_amount_for_fee_receiver, + + MAX(CASE WHEN key_name = 'isIncrease' THEN value END) AS is_increase FROM combined @@ -190,19 +214,19 @@ WITH evt_data_1 AS ( event_name, msg_sender, + from_hex(order_key) AS order_key, + from_hex(position_key) AS position_key, + from_hex(referral_code) AS referral_code, + from_hex(market) AS market, from_hex(collateral_token) AS collateral_token, from_hex(affiliate) AS affiliate, from_hex(trader) AS trader, from_hex(ui_fee_receiver) AS ui_fee_receiver, + TRY_CAST(collateral_token_price_min AS DOUBLE) AS collateral_token_price_min, TRY_CAST(collateral_token_price_max AS DOUBLE) AS collateral_token_price_max, TRY_CAST(trade_size_usd AS DOUBLE) AS trade_size_usd, - TRY_CAST(total_rebate_factor AS DOUBLE) AS total_rebate_factor, - TRY_CAST(trader_discount_factor AS DOUBLE) AS trader_discount_factor, - TRY_CAST(total_rebate_amount AS DOUBLE) AS total_rebate_amount, - TRY_CAST(trader_discount_amount AS DOUBLE) AS trader_discount_amount, - TRY_CAST(affiliate_reward_amount AS DOUBLE) AS affiliate_reward_amount, TRY_CAST(funding_fee_amount AS DOUBLE) AS funding_fee_amount, TRY_CAST(claimable_long_token_amount AS DOUBLE) AS claimable_long_token_amount, TRY_CAST(claimable_short_token_amount AS DOUBLE) AS claimable_short_token_amount, @@ -223,11 +247,29 @@ WITH evt_data_1 AS ( TRY_CAST(total_cost_amount AS DOUBLE) AS total_cost_amount, TRY_CAST(ui_fee_receiver_factor AS DOUBLE) AS ui_fee_receiver_factor, TRY_CAST(ui_fee_amount AS DOUBLE) AS ui_fee_amount, - TRY_CAST(is_increase AS BOOLEAN) AS is_increase, - from_hex(order_key) AS order_key, - from_hex(position_key) AS position_key, - from_hex(referral_code) AS referral_code - + + TRY_CAST(total_rebate_factor AS DOUBLE) AS total_rebate_factor, + TRY_CAST(trader_discount_factor AS DOUBLE) AS trader_discount_factor, + TRY_CAST(total_rebate_amount AS DOUBLE) AS total_rebate_amount, + TRY_CAST(trader_discount_amount AS DOUBLE) AS trader_discount_amount, + TRY_CAST(affiliate_reward_amount AS DOUBLE) AS affiliate_reward_amount, + + TRY_CAST(referral_total_rebate_factor AS DOUBLE) AS referral_total_rebate_factor, + TRY_CAST(referral_adjusted_affiliate_reward_factor AS DOUBLE) AS referral_adjusted_affiliate_reward_factor, + TRY_CAST(referral_trader_discount_factor AS DOUBLE) AS referral_trader_discount_factor, + TRY_CAST(referral_total_rebate_amount AS DOUBLE) AS referral_total_rebate_amount, + TRY_CAST(referral_trader_discount_amount AS DOUBLE) AS referral_trader_discount_amount, + TRY_CAST(referral_affiliate_reward_amount AS DOUBLE) AS referral_affiliate_reward_amount, + + TRY_CAST(pro_trader_discount_factor AS DOUBLE) AS pro_trader_discount_factor, + TRY_CAST(pro_trader_discount_amount AS DOUBLE) AS pro_trader_discount_amount, + + TRY_CAST(liquidation_fee_amount AS DOUBLE) AS liquidation_fee_amount, + TRY_CAST(liquidation_fee_receiver_factor AS DOUBLE) AS liquidation_fee_receiver_factor, + TRY_CAST(liquidation_fee_amount_for_fee_receiver AS DOUBLE) AS liquidation_fee_amount_for_fee_receiver, + + TRY_CAST(is_increase AS BOOLEAN) AS is_increase + FROM evt_data AS ED LEFT JOIN evt_data_parsed AS EDP ON ED.tx_hash = EDP.tx_hash @@ -247,6 +289,10 @@ WITH evt_data_1 AS ( event_name, msg_sender, + order_key, + position_key, + referral_code, + ED.market AS market, ED.collateral_token, affiliate, @@ -255,12 +301,7 @@ WITH evt_data_1 AS ( collateral_token_price_min / POWER(10, 30 - collateral_token_decimals) AS collateral_token_price_min, collateral_token_price_max / POWER(10, 30 - collateral_token_decimals) AS collateral_token_price_max, - trade_size_usd / POWER(10, 30) AS trade_size_usd, - total_rebate_factor / POWER(10, 30) AS total_rebate_factor, - trader_discount_factor / POWER(10, 30) AS trader_discount_factor, - total_rebate_amount / POWER(10, collateral_token_decimals) AS total_rebate_amount, - trader_discount_amount / POWER(10, collateral_token_decimals) AS trader_discount_amount, - affiliate_reward_amount / POWER(10, collateral_token_decimals) AS affiliate_reward_amount, + trade_size_usd / POWER(10, 30) AS trade_size_usd, funding_fee_amount / POWER(10, collateral_token_decimals + 15) AS funding_fee_amount, claimable_long_token_amount / POWER(10, long_token_decimals + 15) AS claimable_long_token_amount, claimable_short_token_amount / POWER(10, short_token_decimals + 15) AS claimable_short_token_amount, @@ -281,11 +322,29 @@ WITH evt_data_1 AS ( total_cost_amount / POWER(10, collateral_token_decimals) AS total_cost_amount, ui_fee_receiver_factor / POWER(10, 30) AS ui_fee_receiver_factor, ui_fee_amount / POWER(10, collateral_token_decimals) AS ui_fee_amount, - is_increase, - order_key, - position_key, - referral_code + + total_rebate_factor / POWER(10, 30) AS total_rebate_factor, + trader_discount_factor / POWER(10, 30) AS trader_discount_factor, + total_rebate_amount / POWER(10, collateral_token_decimals) AS total_rebate_amount, + trader_discount_amount / POWER(10, collateral_token_decimals) AS trader_discount_amount, + affiliate_reward_amount / POWER(10, collateral_token_decimals) AS affiliate_reward_amount, + + referral_total_rebate_factor / POWER(10, 30) AS referral_total_rebate_factor, + referral_adjusted_affiliate_reward_factor / POWER(10, 30) AS referral_adjusted_affiliate_reward_factor, + referral_trader_discount_factor / POWER(10, 30) AS referral_trader_discount_factor, + referral_total_rebate_amount / POWER(10, collateral_token_decimals) AS referral_total_rebate_amount, + referral_trader_discount_amount / POWER(10, collateral_token_decimals) AS referral_trader_discount_amount, + referral_affiliate_reward_amount / POWER(10, collateral_token_decimals) AS referral_affiliate_reward_amount, + pro_trader_discount_factor / POWER(10, 30) AS pro_trader_discount_factor, + pro_trader_discount_amount / POWER(10, collateral_token_decimals) AS pro_trader_discount_amount, + + liquidation_fee_amount / POWER(10, collateral_token_decimals) AS liquidation_fee_amount, + liquidation_fee_receiver_factor / POWER(10, 30) AS liquidation_fee_receiver_factor, + liquidation_fee_amount_for_fee_receiver / POWER(10, collateral_token_decimals) AS liquidation_fee_amount_for_fee_receiver, + + is_increase + FROM event_data AS ED LEFT JOIN {{ ref('gmx_v2_arbitrum_markets_data') }} AS MD ON ED.market = MD.market @@ -293,10 +352,99 @@ WITH evt_data_1 AS ( ON ED.collateral_token = CTD.collateral_token ) +, full_data_2 AS ( + SELECT + blockchain, + block_time, + block_date, + block_number, + tx_hash, + index, + contract_address, + event_name, + msg_sender, + + order_key, + position_key, + referral_code, + + market, + collateral_token, + affiliate, + trader, + ui_fee_receiver, + + collateral_token_price_min, + collateral_token_price_max, + trade_size_usd, + funding_fee_amount, + claimable_long_token_amount, + claimable_short_token_amount, + latest_funding_fee_amount_per_size, + latest_long_token_claimable_funding_amount_per_size, + latest_short_token_claimable_funding_amount_per_size, + borrowing_fee_usd, + borrowing_fee_amount, + borrowing_fee_receiver_factor, + borrowing_fee_amount_for_fee_receiver, + position_fee_factor, + protocol_fee_amount, + position_fee_receiver_factor, + fee_receiver_amount, + fee_amount_for_pool, + position_fee_amount_for_pool, + position_fee_amount, + total_cost_amount, + ui_fee_receiver_factor, + ui_fee_amount, + + CASE + WHEN total_rebate_factor IS NOT NULL THEN total_rebate_factor + WHEN referral_total_rebate_factor IS NOT NULL THEN referral_total_rebate_factor + ELSE 0 + END AS referral_total_rebate_factor, + CASE + WHEN total_rebate_amount IS NOT NULL THEN total_rebate_amount + WHEN referral_total_rebate_amount IS NOT NULL THEN referral_total_rebate_amount + ELSE 0 + END AS referral_total_rebate_amount, + CASE + WHEN referral_trader_discount_factor IS NOT NULL THEN referral_trader_discount_factor + WHEN trader_discount_factor IS NOT NULL THEN trader_discount_factor * total_rebate_factor + ELSE 0 + END AS referral_trader_discount_factor, + CASE + WHEN referral_adjusted_affiliate_reward_factor IS NOT NULL THEN referral_adjusted_affiliate_reward_factor + WHEN affiliate_reward_amount IS NOT NULL THEN affiliate_reward_amount + ELSE 0 + END AS referral_adjusted_affiliate_reward_factor, + CASE + WHEN referral_affiliate_reward_amount IS NOT NULL THEN referral_affiliate_reward_amount + WHEN affiliate_reward_amount IS NOT NULL THEN affiliate_reward_amount + ELSE 0 + END AS referral_affiliate_reward_amount, + CASE + WHEN referral_trader_discount_amount IS NOT NULL THEN referral_trader_discount_amount + WHEN trader_discount_amount IS NOT NULL THEN trader_discount_amount + ELSE 0 + END AS referral_trader_discount_amount, + + COALESCE(pro_trader_discount_factor, 0) AS pro_trader_discount_factor, + COALESCE(pro_trader_discount_amount, 0) AS pro_trader_discount_amount, + + COALESCE(liquidation_fee_amount, 0) AS liquidation_fee_amount, + COALESCE(liquidation_fee_receiver_factor, 0) AS liquidation_fee_receiver_factor, + COALESCE(liquidation_fee_amount_for_fee_receiver, 0) AS liquidation_fee_amount_for_fee_receiver, + + is_increase + + FROM full_data +) + --can be removed once decoded tables are fully denormalized {{ add_tx_columns( - model_cte = 'full_data' + model_cte = 'full_data_2' , blockchain = blockchain_name , columns = ['from', 'to'] ) diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_position_fees_info.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_position_fees_info.sql index 4a7432cea9b..355dc8b647d 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_position_fees_info.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_position_fees_info.sql @@ -2,7 +2,9 @@ config( schema = 'gmx_v2_arbitrum', alias = 'position_fees_info', - materialized = 'table' + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' ) }} @@ -23,7 +25,9 @@ WITH evt_data_1 AS ( msgSender AS msg_sender FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog1')}} WHERE eventName = '{{ event_name }}' - ORDER BY evt_block_time ASC + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} ) , evt_data_2 AS ( @@ -40,14 +44,16 @@ WITH evt_data_1 AS ( msgSender AS msg_sender FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog2')}} WHERE eventName = '{{ event_name }}' - ORDER BY evt_block_time ASC + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} ) -- unite 2 tables , evt_data AS ( SELECT * FROM evt_data_1 - UNION + UNION ALL SELECT * FROM evt_data_2 ) @@ -135,19 +141,20 @@ WITH evt_data_1 AS ( tx_hash, index, + MAX(CASE WHEN key_name = 'orderKey' THEN value END) AS order_key, + MAX(CASE WHEN key_name = 'positionKey' THEN value END) AS position_key, + MAX(CASE WHEN key_name = 'referralCode' THEN value END) AS referral_code, + MAX(CASE WHEN key_name = 'market' THEN value END) AS market, MAX(CASE WHEN key_name = 'collateralToken' THEN value END) AS collateral_token, MAX(CASE WHEN key_name = 'affiliate' THEN value END) AS affiliate, MAX(CASE WHEN key_name = 'trader' THEN value END) AS trader, MAX(CASE WHEN key_name = 'uiFeeReceiver' THEN value END) AS ui_fee_receiver, + MAX(CASE WHEN key_name = 'collateralTokenPrice.min' THEN value END) AS collateral_token_price_min, MAX(CASE WHEN key_name = 'collateralTokenPrice.max' THEN value END) AS collateral_token_price_max, MAX(CASE WHEN key_name = 'tradeSizeUsd' THEN value END) AS trade_size_usd, - MAX(CASE WHEN key_name = 'totalRebateFactor' THEN value END) AS total_rebate_factor, - MAX(CASE WHEN key_name = 'traderDiscountFactor' THEN value END) AS trader_discount_factor, - MAX(CASE WHEN key_name = 'totalRebateAmount' THEN value END) AS total_rebate_amount, - MAX(CASE WHEN key_name = 'traderDiscountAmount' THEN value END) AS trader_discount_amount, - MAX(CASE WHEN key_name = 'affiliateRewardAmount' THEN value END) AS affiliate_reward_amount, + MAX(CASE WHEN key_name = 'fundingFeeAmount' THEN value END) AS funding_fee_amount, MAX(CASE WHEN key_name = 'claimableLongTokenAmount' THEN value END) AS claimable_long_token_amount, MAX(CASE WHEN key_name = 'claimableShortTokenAmount' THEN value END) AS claimable_short_token_amount, @@ -168,10 +175,28 @@ WITH evt_data_1 AS ( MAX(CASE WHEN key_name = 'totalCostAmount' THEN value END) AS total_cost_amount, MAX(CASE WHEN key_name = 'uiFeeReceiverFactor' THEN value END) AS ui_fee_receiver_factor, MAX(CASE WHEN key_name = 'uiFeeAmount' THEN value END) AS ui_fee_amount, - MAX(CASE WHEN key_name = 'isIncrease' THEN value END) AS is_increase, - MAX(CASE WHEN key_name = 'orderKey' THEN value END) AS order_key, - MAX(CASE WHEN key_name = 'positionKey' THEN value END) AS position_key, - MAX(CASE WHEN key_name = 'referralCode' THEN value END) AS referral_code + + MAX(CASE WHEN key_name = 'totalRebateFactor' THEN value END) AS total_rebate_factor, + MAX(CASE WHEN key_name = 'traderDiscountFactor' THEN value END) AS trader_discount_factor, + MAX(CASE WHEN key_name = 'totalRebateAmount' THEN value END) AS total_rebate_amount, + MAX(CASE WHEN key_name = 'traderDiscountAmount' THEN value END) AS trader_discount_amount, + MAX(CASE WHEN key_name = 'affiliateRewardAmount' THEN value END) AS affiliate_reward_amount, + + MAX(CASE WHEN key_name = 'referral.totalRebateFactor' THEN value END) AS referral_total_rebate_factor, + MAX(CASE WHEN key_name = 'referral.adjustedAffiliateRewardFactor' THEN value END) AS referral_adjusted_affiliate_reward_factor, + MAX(CASE WHEN key_name = 'referral.traderDiscountFactor' THEN value END) AS referral_trader_discount_factor, + MAX(CASE WHEN key_name = 'referral.totalRebateAmount' THEN value END) AS referral_total_rebate_amount, + MAX(CASE WHEN key_name = 'referral.traderDiscountAmount' THEN value END) AS referral_trader_discount_amount, + MAX(CASE WHEN key_name = 'referral.affiliateRewardAmount' THEN value END) AS referral_affiliate_reward_amount, + + MAX(CASE WHEN key_name = 'pro.traderDiscountFactor' THEN value END) AS pro_trader_discount_factor, + MAX(CASE WHEN key_name = 'pro.traderDiscountAmount' THEN value END) AS pro_trader_discount_amount, + + MAX(CASE WHEN key_name = 'liquidationFeeAmount' THEN value END) AS liquidation_fee_amount, + MAX(CASE WHEN key_name = 'liquidationFeeReceiverFactor' THEN value END) AS liquidation_fee_receiver_factor, + MAX(CASE WHEN key_name = 'liquidationFeeAmountForFeeReceiver' THEN value END) AS liquidation_fee_amount_for_fee_receiver, + + MAX(CASE WHEN key_name = 'isIncrease' THEN value END) AS is_increase FROM combined @@ -190,19 +215,19 @@ WITH evt_data_1 AS ( event_name, msg_sender, + from_hex(order_key) AS order_key, + from_hex(position_key) AS position_key, + from_hex(referral_code) AS referral_code, + from_hex(market) AS market, from_hex(collateral_token) AS collateral_token, from_hex(affiliate) AS affiliate, from_hex(trader) AS trader, from_hex(ui_fee_receiver) AS ui_fee_receiver, + TRY_CAST(collateral_token_price_min AS DOUBLE) AS collateral_token_price_min, TRY_CAST(collateral_token_price_max AS DOUBLE) AS collateral_token_price_max, TRY_CAST(trade_size_usd AS DOUBLE) AS trade_size_usd, - TRY_CAST(total_rebate_factor AS DOUBLE) AS total_rebate_factor, - TRY_CAST(trader_discount_factor AS DOUBLE) AS trader_discount_factor, - TRY_CAST(total_rebate_amount AS DOUBLE) AS total_rebate_amount, - TRY_CAST(trader_discount_amount AS DOUBLE) AS trader_discount_amount, - TRY_CAST(affiliate_reward_amount AS DOUBLE) AS affiliate_reward_amount, TRY_CAST(funding_fee_amount AS DOUBLE) AS funding_fee_amount, TRY_CAST(claimable_long_token_amount AS DOUBLE) AS claimable_long_token_amount, TRY_CAST(claimable_short_token_amount AS DOUBLE) AS claimable_short_token_amount, @@ -223,11 +248,29 @@ WITH evt_data_1 AS ( TRY_CAST(total_cost_amount AS DOUBLE) AS total_cost_amount, TRY_CAST(ui_fee_receiver_factor AS DOUBLE) AS ui_fee_receiver_factor, TRY_CAST(ui_fee_amount AS DOUBLE) AS ui_fee_amount, - TRY_CAST(is_increase AS BOOLEAN) AS is_increase, - from_hex(order_key) AS order_key, - from_hex(position_key) AS position_key, - from_hex(referral_code) AS referral_code - + + TRY_CAST(total_rebate_factor AS DOUBLE) AS total_rebate_factor, + TRY_CAST(trader_discount_factor AS DOUBLE) AS trader_discount_factor, + TRY_CAST(total_rebate_amount AS DOUBLE) AS total_rebate_amount, + TRY_CAST(trader_discount_amount AS DOUBLE) AS trader_discount_amount, + TRY_CAST(affiliate_reward_amount AS DOUBLE) AS affiliate_reward_amount, + + TRY_CAST(referral_total_rebate_factor AS DOUBLE) AS referral_total_rebate_factor, + TRY_CAST(referral_adjusted_affiliate_reward_factor AS DOUBLE) AS referral_adjusted_affiliate_reward_factor, + TRY_CAST(referral_trader_discount_factor AS DOUBLE) AS referral_trader_discount_factor, + TRY_CAST(referral_total_rebate_amount AS DOUBLE) AS referral_total_rebate_amount, + TRY_CAST(referral_trader_discount_amount AS DOUBLE) AS referral_trader_discount_amount, + TRY_CAST(referral_affiliate_reward_amount AS DOUBLE) AS referral_affiliate_reward_amount, + + TRY_CAST(pro_trader_discount_factor AS DOUBLE) AS pro_trader_discount_factor, + TRY_CAST(pro_trader_discount_amount AS DOUBLE) AS pro_trader_discount_amount, + + TRY_CAST(liquidation_fee_amount AS DOUBLE) AS liquidation_fee_amount, + TRY_CAST(liquidation_fee_receiver_factor AS DOUBLE) AS liquidation_fee_receiver_factor, + TRY_CAST(liquidation_fee_amount_for_fee_receiver AS DOUBLE) AS liquidation_fee_amount_for_fee_receiver, + + TRY_CAST(is_increase AS BOOLEAN) AS is_increase + FROM evt_data AS ED LEFT JOIN evt_data_parsed AS EDP ON ED.tx_hash = EDP.tx_hash @@ -247,6 +290,10 @@ WITH evt_data_1 AS ( event_name, msg_sender, + order_key, + position_key, + referral_code, + ED.market AS market, ED.collateral_token, affiliate, @@ -255,12 +302,7 @@ WITH evt_data_1 AS ( collateral_token_price_min / POWER(10, 30 - collateral_token_decimals) AS collateral_token_price_min, collateral_token_price_max / POWER(10, 30 - collateral_token_decimals) AS collateral_token_price_max, - trade_size_usd / POWER(10, 30) AS trade_size_usd, - total_rebate_factor / POWER(10, 30) AS total_rebate_factor, - trader_discount_factor / POWER(10, 30) AS trader_discount_factor, - total_rebate_amount / POWER(10, collateral_token_decimals) AS total_rebate_amount, - trader_discount_amount / POWER(10, collateral_token_decimals) AS trader_discount_amount, - affiliate_reward_amount / POWER(10, collateral_token_decimals) AS affiliate_reward_amount, + trade_size_usd / POWER(10, 30) AS trade_size_usd, funding_fee_amount / POWER(10, collateral_token_decimals + 15) AS funding_fee_amount, claimable_long_token_amount / POWER(10, long_token_decimals + 15) AS claimable_long_token_amount, claimable_short_token_amount / POWER(10, short_token_decimals + 15) AS claimable_short_token_amount, @@ -281,10 +323,28 @@ WITH evt_data_1 AS ( total_cost_amount / POWER(10, collateral_token_decimals) AS total_cost_amount, ui_fee_receiver_factor / POWER(10, 30) AS ui_fee_receiver_factor, ui_fee_amount / POWER(10, collateral_token_decimals) AS ui_fee_amount, - is_increase, - order_key, - position_key, - referral_code + + total_rebate_factor / POWER(10, 30) AS total_rebate_factor, + trader_discount_factor / POWER(10, 30) AS trader_discount_factor, + total_rebate_amount / POWER(10, collateral_token_decimals) AS total_rebate_amount, + trader_discount_amount / POWER(10, collateral_token_decimals) AS trader_discount_amount, + affiliate_reward_amount / POWER(10, collateral_token_decimals) AS affiliate_reward_amount, + + referral_total_rebate_factor / POWER(10, 30) AS referral_total_rebate_factor, + referral_adjusted_affiliate_reward_factor / POWER(10, 30) AS referral_adjusted_affiliate_reward_factor, + referral_trader_discount_factor / POWER(10, 30) AS referral_trader_discount_factor, + referral_total_rebate_amount / POWER(10, collateral_token_decimals) AS referral_total_rebate_amount, + referral_trader_discount_amount / POWER(10, collateral_token_decimals) AS referral_trader_discount_amount, + referral_affiliate_reward_amount / POWER(10, collateral_token_decimals) AS referral_affiliate_reward_amount, + + pro_trader_discount_factor / POWER(10, 30) AS pro_trader_discount_factor, + pro_trader_discount_amount / POWER(10, collateral_token_decimals) AS pro_trader_discount_amount, + + liquidation_fee_amount / POWER(10, collateral_token_decimals) AS liquidation_fee_amount, + liquidation_fee_receiver_factor / POWER(10, 30) AS liquidation_fee_receiver_factor, + liquidation_fee_amount_for_fee_receiver / POWER(10, collateral_token_decimals) AS liquidation_fee_amount_for_fee_receiver, + + is_increase FROM event_data AS ED LEFT JOIN {{ ref('gmx_v2_arbitrum_markets_data') }} AS MD @@ -293,10 +353,99 @@ WITH evt_data_1 AS ( ON ED.collateral_token = CTD.collateral_token ) +, full_data_2 AS ( + SELECT + blockchain, + block_time, + block_date, + block_number, + tx_hash, + index, + contract_address, + event_name, + msg_sender, + + order_key, + position_key, + referral_code, + + market, + collateral_token, + affiliate, + trader, + ui_fee_receiver, + + collateral_token_price_min, + collateral_token_price_max, + trade_size_usd, + funding_fee_amount, + claimable_long_token_amount, + claimable_short_token_amount, + latest_funding_fee_amount_per_size, + latest_long_token_claimable_funding_amount_per_size, + latest_short_token_claimable_funding_amount_per_size, + borrowing_fee_usd, + borrowing_fee_amount, + borrowing_fee_receiver_factor, + borrowing_fee_amount_for_fee_receiver, + position_fee_factor, + protocol_fee_amount, + position_fee_receiver_factor, + fee_receiver_amount, + fee_amount_for_pool, + position_fee_amount_for_pool, + position_fee_amount, + total_cost_amount, + ui_fee_receiver_factor, + ui_fee_amount, + + CASE + WHEN total_rebate_factor IS NOT NULL THEN total_rebate_factor + WHEN referral_total_rebate_factor IS NOT NULL THEN referral_total_rebate_factor + ELSE 0 + END AS referral_total_rebate_factor, + CASE + WHEN total_rebate_amount IS NOT NULL THEN total_rebate_amount + WHEN referral_total_rebate_amount IS NOT NULL THEN referral_total_rebate_amount + ELSE 0 + END AS referral_total_rebate_amount, + CASE + WHEN referral_trader_discount_factor IS NOT NULL THEN referral_trader_discount_factor + WHEN trader_discount_factor IS NOT NULL THEN trader_discount_factor * total_rebate_factor + ELSE 0 + END AS referral_trader_discount_factor, + CASE + WHEN referral_adjusted_affiliate_reward_factor IS NOT NULL THEN referral_adjusted_affiliate_reward_factor + WHEN affiliate_reward_amount IS NOT NULL THEN affiliate_reward_amount + ELSE 0 + END AS referral_adjusted_affiliate_reward_factor, + CASE + WHEN referral_affiliate_reward_amount IS NOT NULL THEN referral_affiliate_reward_amount + WHEN affiliate_reward_amount IS NOT NULL THEN affiliate_reward_amount + ELSE 0 + END AS referral_affiliate_reward_amount, + CASE + WHEN referral_trader_discount_amount IS NOT NULL THEN referral_trader_discount_amount + WHEN trader_discount_amount IS NOT NULL THEN trader_discount_amount + ELSE 0 + END AS referral_trader_discount_amount, + + COALESCE(pro_trader_discount_factor, 0) AS pro_trader_discount_factor, + COALESCE(pro_trader_discount_amount, 0) AS pro_trader_discount_amount, + + COALESCE(liquidation_fee_amount, 0) AS liquidation_fee_amount, + COALESCE(liquidation_fee_receiver_factor, 0) AS liquidation_fee_receiver_factor, + COALESCE(liquidation_fee_amount_for_fee_receiver, 0) AS liquidation_fee_amount_for_fee_receiver, + + is_increase + + FROM full_data +) + --can be removed once decoded tables are fully denormalized {{ add_tx_columns( - model_cte = 'full_data' + model_cte = 'full_data_2' , blockchain = blockchain_name , columns = ['from', 'to'] ) diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_position_increase.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_position_increase.sql index bddd6f5c9f6..a0e6f4eaddf 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_position_increase.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_position_increase.sql @@ -2,7 +2,9 @@ config( schema = 'gmx_v2_arbitrum', alias = 'position_increase', - materialized = 'table' + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' ) }} @@ -23,7 +25,9 @@ WITH evt_data_1 AS ( msgSender AS msg_sender FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog1')}} WHERE eventName = '{{ event_name }}' - ORDER BY evt_block_time ASC + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} ) , evt_data_2 AS ( @@ -40,14 +44,16 @@ WITH evt_data_1 AS ( msgSender AS msg_sender FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog2')}} WHERE eventName = '{{ event_name }}' - ORDER BY evt_block_time ASC + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} ) -- unite 2 tables , evt_data AS ( SELECT * FROM evt_data_1 - UNION + UNION ALL SELECT * FROM evt_data_2 ) diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_set_uint.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_set_uint.sql new file mode 100644 index 00000000000..24939abe129 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_set_uint.sql @@ -0,0 +1,165 @@ +{{ + config( + schema = 'gmx_v2_arbitrum', + alias = 'set_uint', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'SetUint' -%} +{%- set blockchain_name = 'arbitrum' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items, + json_query(data, 'lax $.bytesItems' OMIT QUOTES) AS bytes_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items + FROM + evt_data +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM bytes32_items_parsed + UNION ALL + SELECT * + FROM bytes_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + MAX(CASE WHEN key_name = 'baseKey' THEN value END) AS base_key, + MAX(CASE WHEN key_name = 'data' THEN value END) AS "data", + MAX(CASE WHEN key_name = 'value' THEN value END) AS "value" + FROM + combined + GROUP BY tx_hash, index +) + +-- full data +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(EDP.base_key) AS base_key, + from_hex(EDP."data") AS "data", + TRY_CAST(EDP."value" AS DOUBLE) AS "value_raw" + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to', 'index'] + ) +}} + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_shift_created.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_shift_created.sql new file mode 100644 index 00000000000..18602bee501 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_shift_created.sql @@ -0,0 +1,218 @@ +{{ + config( + schema = 'gmx_v2_arbitrum', + alias = 'shift_created', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'ShiftCreated' -%} +{%- set blockchain_name = 'arbitrum' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed + UNION ALL + SELECT * + FROM bytes32_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'account' THEN value END) AS account, + MAX(CASE WHEN key_name = 'receiver' THEN value END) AS receiver, + MAX(CASE WHEN key_name = 'callbackContract' THEN value END) AS callback_contract, + MAX(CASE WHEN key_name = 'fromMarket' THEN value END) AS from_market, + MAX(CASE WHEN key_name = 'toMarket' THEN value END) AS to_market, + + MAX(CASE WHEN key_name = 'marketTokenAmount' THEN value END) AS market_token_amount, + MAX(CASE WHEN key_name = 'minMarketTokens' THEN value END) AS min_market_tokens, + MAX(CASE WHEN key_name = 'updatedAtTime' THEN value END) AS updated_at_time, + MAX(CASE WHEN key_name = 'executionFee' THEN value END) AS execution_fee, + MAX(CASE WHEN key_name = 'callbackGasLimit' THEN value END) AS callback_gas_limit, + + MAX(CASE WHEN key_name = 'key' THEN value END) AS "key" + + FROM + combined + GROUP BY tx_hash, index +) + +, event_data AS ( + SELECT + blockchain, + block_time, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(account) AS account, + from_hex(receiver) AS receiver, + from_hex(callback_contract) AS callback_contract, + from_hex(from_market) AS from_market, + from_hex(to_market) AS to_market, + + TRY_CAST(market_token_amount AS DOUBLE) market_token_amount, + TRY_CAST(min_market_tokens AS DOUBLE) min_market_tokens, + TRY_CAST(updated_at_time AS DOUBLE) AS updated_at_time, + TRY_CAST(execution_fee AS DOUBLE) AS execution_fee, + TRY_CAST(callback_gas_limit AS DOUBLE) AS callback_gas_limit, + + from_hex("key") AS "key" + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + tx_hash, + index, + contract_address, + event_name, + msg_sender, + + account, + receiver, + callback_contract, + from_market, + to_market, + + market_token_amount / POWER(10,18) AS market_token_amount, + min_market_tokens / POWER(10,18) AS min_market_tokens, + CASE + WHEN updated_at_time = 0 THEN NULL + ELSE updated_at_time + END AS updated_at_time, + execution_fee / POWER(10, 18) AS execution_fee, + callback_gas_limit, + "key" + + FROM event_data AS ED +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_shift_executed.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_shift_executed.sql new file mode 100644 index 00000000000..bfe660d6dbf --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_shift_executed.sql @@ -0,0 +1,168 @@ +{{ + config( + schema = 'gmx_v2_arbitrum', + alias = 'shift_executed', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'ShiftExecuted' -%} +{%- set blockchain_name = 'arbitrum' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed + UNION ALL + SELECT * + FROM bytes32_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'account' THEN value END) AS account, + MAX(CASE WHEN key_name = 'receivedMarketTokens' THEN value END) AS received_market_tokens, + MAX(CASE WHEN key_name = 'key' THEN value END) AS "key" + + FROM + combined + GROUP BY tx_hash, index +) + +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(account) AS account, + TRY_CAST(received_market_tokens AS DOUBLE) / POWER(10,18) AS received_market_tokens, + from_hex("key") AS "key" + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_withdrawal_cancelled.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_withdrawal_cancelled.sql new file mode 100644 index 00000000000..e7e5a292a44 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_withdrawal_cancelled.sql @@ -0,0 +1,187 @@ +{{ + config( + schema = 'gmx_v2_arbitrum', + alias = 'withdrawal_cancelled', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'WithdrawalCancelled' -%} +{%- set blockchain_name = 'arbitrum' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items, + json_query(data, 'lax $.bytesItems' OMIT QUOTES) AS bytes_items, + json_query(data, 'lax $.stringItems' OMIT QUOTES) AS string_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, string_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(string_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM bytes32_items_parsed + UNION ALL + SELECT * + FROM bytes_items_parsed + UNION ALL + SELECT * + FROM string_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'account' THEN value END) AS account, + MAX(CASE WHEN key_name = 'key' THEN value END) AS "key", + MAX(CASE WHEN key_name = 'reasonBytes' THEN value END) AS reason_bytes, + MAX(CASE WHEN key_name = 'reason' THEN value END) AS reason + + FROM + combined + GROUP BY tx_hash, index +) + +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(account) AS account, + from_hex("key") AS "key", + from_hex(reason_bytes) AS reason_bytes, + reason + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_withdrawal_created.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_withdrawal_created.sql new file mode 100644 index 00000000000..c97a0b78ad3 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_withdrawal_created.sql @@ -0,0 +1,243 @@ +{{ + config( + schema = 'gmx_v2_arbitrum', + alias = 'withdrawal_created', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'WithdrawalCreated' -%} +{%- set blockchain_name = 'arbitrum' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items, + json_query(data, 'lax $.boolItems' OMIT QUOTES) AS bool_items, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bool_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bool_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed + UNION ALL + SELECT * + FROM bool_items_parsed + UNION ALL + SELECT * + FROM bytes32_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'account' THEN value END) AS account, + MAX(CASE WHEN key_name = 'receiver' THEN value END) AS receiver, + MAX(CASE WHEN key_name = 'callbackContract' THEN value END) AS callback_contract, + MAX(CASE WHEN key_name = 'market' THEN value END) AS market, + + MAX(CASE WHEN key_name = 'marketTokenAmount' THEN value END) AS market_token_amount, + MAX(CASE WHEN key_name = 'minLongTokenAmount' THEN value END) AS min_long_token_amount, + MAX(CASE WHEN key_name = 'minShortTokenAmount' THEN value END) AS min_short_token_amount, + MAX(CASE WHEN key_name = 'updatedAtTime' THEN value END) AS updated_at_time, + MAX(CASE WHEN key_name = 'executionFee' THEN value END) AS execution_fee, + MAX(CASE WHEN key_name = 'callbackGasLimit' THEN value END) AS callback_gas_limit, + + MAX(CASE WHEN key_name = 'shouldUnwrapNativeToken' THEN value END) AS should_unwrap_native_token, + + MAX(CASE WHEN key_name = 'key' THEN value END) AS "key" + + FROM + combined + GROUP BY tx_hash, index +) + +, event_data AS ( + SELECT + blockchain, + block_time, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(account) AS account, + from_hex(receiver) AS receiver, + from_hex(callback_contract) AS callback_contract, + from_hex(market) AS market, + + TRY_CAST(market_token_amount AS DOUBLE) market_token_amount, -- index_token_decimals (market?) + TRY_CAST(min_long_token_amount AS DOUBLE) min_long_token_amount, -- long_token_decimals + TRY_CAST(min_short_token_amount AS DOUBLE) min_short_token_amount, -- short_token_decimals + TRY_CAST(updated_at_time AS DOUBLE) AS updated_at_time, + TRY_CAST(execution_fee AS DOUBLE) AS execution_fee, -- POWER(10, 18) + TRY_CAST(callback_gas_limit AS DOUBLE) AS callback_gas_limit, -- no decimals, keep as raw values + + TRY_CAST(should_unwrap_native_token AS BOOLEAN) AS should_unwrap_native_token, + + from_hex("key") AS "key" + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + tx_hash, + index, + contract_address, + event_name, + msg_sender, + + account, + receiver, + callback_contract, + ED.market, + + market_token_amount / POWER(10, 18) AS market_token_amount, + min_long_token_amount / POWER(10, MD.long_token_decimals) AS min_long_token_amount, + min_short_token_amount / POWER(10, MD.short_token_decimals) AS min_short_token_amount, + CASE + WHEN updated_at_time = 0 THEN NULL + ELSE updated_at_time + END AS updated_at_time, + execution_fee / POWER(10, 18) AS execution_fee, + callback_gas_limit, + + should_unwrap_native_token, + "key" + + FROM event_data AS ED + LEFT JOIN {{ ref('gmx_v2_arbitrum_markets_data') }} AS MD + ON ED.market = MD.market +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_withdrawal_executed.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_withdrawal_executed.sql new file mode 100644 index 00000000000..5456bbde74b --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_withdrawal_executed.sql @@ -0,0 +1,169 @@ +{{ + config( + schema = 'gmx_v2_arbitrum', + alias = 'withdrawal_executed', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'WithdrawalExecuted' -%} +{%- set blockchain_name = 'arbitrum' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items + FROM + evt_data +) + + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed + UNION ALL + SELECT * + FROM bytes32_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'account' THEN value END) AS account, + MAX(CASE WHEN key_name = 'swapPricingType' THEN value END) AS swap_pricing_type, + MAX(CASE WHEN key_name = 'key' THEN value END) AS "key" + + FROM + combined + GROUP BY tx_hash, index +) + +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(account) AS account, + TRY_CAST(swap_pricing_type AS INTEGER) AS swap_pricing_type, + from_hex("key") AS "key" + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_claimable_funding_amount_per_size_updated.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_claimable_funding_amount_per_size_updated.sql new file mode 100644 index 00000000000..e2456aeb0de --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_claimable_funding_amount_per_size_updated.sql @@ -0,0 +1,195 @@ +{{ + config( + schema = 'gmx_v2_avalanche_c', + alias = 'claimable_funding_amount_per_size_updated', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'ClaimableFundingAmountPerSizeUpdated' -%} +{%- set blockchain_name = 'avalanche_c' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items, + json_query(data, 'lax $.boolItems' OMIT QUOTES) AS bool_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bool_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bool_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed + UNION ALL + SELECT * + FROM bool_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'market' THEN value END) AS market, + MAX(CASE WHEN key_name = 'collateralToken' THEN value END) AS collateral_token, + MAX(CASE WHEN key_name = 'delta' THEN value END) AS delta, + MAX(CASE WHEN key_name = 'value' THEN value END) AS "value", + MAX(CASE WHEN key_name = 'isLong' THEN value END) AS is_long + + FROM + combined + GROUP BY tx_hash, index +) + +, event_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(market) AS market, + from_hex(collateral_token) AS collateral_token, + TRY_CAST(delta AS DOUBLE) delta, + TRY_CAST("value" AS DOUBLE) "value", + TRY_CAST(is_long AS BOOLEAN) AS is_long + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + tx_hash, + index, + contract_address, + event_name, + msg_sender, + + market, + ED.collateral_token, + delta / POWER(10, CTD.collateral_token_decimals + 15) AS delta, + "value" / POWER(10, CTD.collateral_token_decimals + 15) AS "value", + is_long + + FROM event_data AS ED + LEFT JOIN gmx_v2_avalanche_c.collateral_tokens_data AS CTD + ON ED.collateral_token = CTD.collateral_token +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_deposit_cancelled.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_deposit_cancelled.sql new file mode 100644 index 00000000000..41cce75f491 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_deposit_cancelled.sql @@ -0,0 +1,187 @@ +{{ + config( + schema = 'gmx_v2_avalanche_c', + alias = 'deposit_cancelled', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'DepositCancelled' -%} +{%- set blockchain_name = 'avalanche_c' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items, + json_query(data, 'lax $.bytesItems' OMIT QUOTES) AS bytes_items, + json_query(data, 'lax $.stringItems' OMIT QUOTES) AS string_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, string_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(string_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM bytes32_items_parsed + UNION ALL + SELECT * + FROM bytes_items_parsed + UNION ALL + SELECT * + FROM string_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'account' THEN value END) AS account, + MAX(CASE WHEN key_name = 'key' THEN value END) AS "key", + MAX(CASE WHEN key_name = 'reasonBytes' THEN value END) AS reason_bytes, + MAX(CASE WHEN key_name = 'reason' THEN value END) AS reason + + FROM + combined + GROUP BY tx_hash, index +) + +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(account) AS account, + from_hex("key") AS "key", + from_hex(reason_bytes) AS reason_bytes, + reason + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_deposit_created.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_deposit_created.sql new file mode 100644 index 00000000000..ce9567fda4b --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_deposit_created.sql @@ -0,0 +1,258 @@ +{{ + config( + schema = 'gmx_v2_avalanche_c', + alias = 'deposit_created', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'DepositCreated' -%} +{%- set blockchain_name = 'avalanche_c' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items, + json_query(data, 'lax $.boolItems' OMIT QUOTES) AS bool_items, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bool_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bool_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed + UNION ALL + SELECT * + FROM bool_items_parsed + UNION ALL + SELECT * + FROM bytes32_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'account' THEN value END) AS account, + MAX(CASE WHEN key_name = 'receiver' THEN value END) AS receiver, + MAX(CASE WHEN key_name = 'callbackContract' THEN value END) AS callback_contract, + MAX(CASE WHEN key_name = 'market' THEN value END) AS market, + MAX(CASE WHEN key_name = 'initialLongToken' THEN value END) AS initial_long_token, + MAX(CASE WHEN key_name = 'initialShortToken' THEN value END) AS initial_short_token, + MAX(CASE WHEN key_name = 'longTokenSwapPath' THEN value END) AS long_token_swap_path, + MAX(CASE WHEN key_name = 'shortTokenSwapPath' THEN value END) AS short_token_swap_path, + + MAX(CASE WHEN key_name = 'initialLongTokenAmount' THEN value END) AS initial_long_token_amount, + MAX(CASE WHEN key_name = 'initialShortTokenAmount' THEN value END) AS initial_short_token_amount, + MAX(CASE WHEN key_name = 'minMarketTokens' THEN value END) AS min_market_tokens, + MAX(CASE WHEN key_name = 'updatedAtTime' THEN value END) AS updated_at_time, + MAX(CASE WHEN key_name = 'executionFee' THEN value END) AS execution_fee, + MAX(CASE WHEN key_name = 'callbackGasLimit' THEN value END) AS callback_gas_limit, + MAX(CASE WHEN key_name = 'depositType' THEN value END) AS deposit_type, + + MAX(CASE WHEN key_name = 'shouldUnwrapNativeToken' THEN value END) AS should_unwrap_native_token, + + MAX(CASE WHEN key_name = 'key' THEN value END) AS "key" + + FROM + combined + GROUP BY tx_hash, index +) + +, event_data AS ( + SELECT + blockchain, + block_time, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(account) AS account, + from_hex(receiver) AS receiver, + from_hex(callback_contract) AS callback_contract, + from_hex(market) AS market, + from_hex(initial_long_token) AS initial_long_token, + from_hex(initial_short_token) AS initial_short_token, + long_token_swap_path, + short_token_swap_path, + + TRY_CAST(initial_long_token_amount AS DOUBLE) initial_long_token_amount, + TRY_CAST(initial_short_token_amount AS DOUBLE) initial_short_token_amount, + TRY_CAST(min_market_tokens AS DOUBLE) min_market_tokens, + TRY_CAST(updated_at_time AS DOUBLE) AS updated_at_time, + TRY_CAST(execution_fee AS DOUBLE) AS execution_fee, + TRY_CAST(callback_gas_limit AS DOUBLE) AS callback_gas_limit, + TRY_CAST(deposit_type AS INTEGER) AS deposit_type, + + TRY_CAST(should_unwrap_native_token AS BOOLEAN) AS should_unwrap_native_token, + + from_hex("key") AS "key" + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + tx_hash, + index, + contract_address, + event_name, + msg_sender, + + account, + receiver, + callback_contract, + ED.market, + initial_long_token, + initial_short_token, + long_token_swap_path, + short_token_swap_path, + + initial_long_token_amount / POWER(10, MD.long_token_decimals) AS initial_long_token_amount, + initial_short_token_amount / POWER(10, MD.short_token_decimals) AS initial_short_token_amount, + min_market_tokens / POWER(10, 18) AS min_market_tokens, + CASE + WHEN updated_at_time = 0 THEN NULL + ELSE updated_at_time + END AS updated_at_time, + execution_fee / POWER(10, 18) AS execution_fee, + callback_gas_limit, + deposit_type, + + should_unwrap_native_token, + "key" + + FROM event_data AS ED + LEFT JOIN {{ ref('gmx_v2_avalanche_c_markets_data') }} AS MD + ON ED.market = MD.market +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_deposit_executed.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_deposit_executed.sql new file mode 100644 index 00000000000..8271444fcf5 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_deposit_executed.sql @@ -0,0 +1,199 @@ +{{ + config( + schema = 'gmx_v2_avalanche_c', + alias = 'deposit_executed', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'DepositExecuted' -%} +{%- set blockchain_name = 'avalanche_c' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed + UNION ALL + SELECT * + FROM bytes32_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'account' THEN value END) AS account, + MAX(CASE WHEN key_name = 'longTokenAmount' THEN value END) AS long_token_amount, + MAX(CASE WHEN key_name = 'shortTokenAmount' THEN value END) AS short_token_amount, + MAX(CASE WHEN key_name = 'receivedMarketTokens' THEN value END) AS received_market_tokens, + MAX(CASE WHEN key_name = 'swapPricingType' THEN value END) AS swap_pricing_type, + MAX(CASE WHEN key_name = 'key' THEN value END) AS "key" + + FROM + combined + GROUP BY tx_hash, index +) + +, event_data AS ( + SELECT + blockchain, + block_time, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(account) AS account, + TRY_CAST(long_token_amount AS DOUBLE) AS long_token_amount, + TRY_CAST(short_token_amount AS DOUBLE) AS short_token_amount, + TRY_CAST(received_market_tokens AS DOUBLE) AS received_market_tokens, + TRY_CAST(swap_pricing_type AS INTEGER) AS swap_pricing_type, + from_hex("key") AS "key" + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +, full_data AS ( + SELECT + ED.blockchain, + ED.block_time, + DATE(ED.block_time) AS block_date, + ED.block_number, + ED.tx_hash, + ED.index, + ED.contract_address, + ED.event_name, + ED.msg_sender, + + ED.account, + ED.long_token_amount / POWER(10, MD.long_token_decimals) AS long_token_amount, + ED.short_token_amount / POWER(10, MD.short_token_decimals) AS short_token_amount, + ED.received_market_tokens / POWER(10, 18) AS received_market_tokens, + ED.swap_pricing_type, + ED."key" + + FROM event_data AS ED + LEFT JOIN {{ ref('gmx_v2_avalanche_c_deposit_created') }} AS DC + ON ED."key" = DC."key" + LEFT JOIN {{ ref('gmx_v2_avalanche_c_markets_data') }} AS MD + ON DC.market = MD.market +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_event_schema.yml b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_event_schema.yml index d43cb91644a..f8c25f3763c 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_event_schema.yml +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_event_schema.yml @@ -13,62 +13,44 @@ models: Extracts and decodes the `OrderCreated` event log data from the Avalanche blockchain. This model processes log entries related to created orders, extracting key variables such as account addresses, event keys, and strings representing the reason for cancellation. - + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index columns: - &blockchain name: blockchain description: The blockchain network where the event occurred (Avalanche) - data_tests: - - not_null - &block_time name: block_time description: The timestamp of the block when the event was recorded - data_tests: - - not_null - &block_date name: block_date - description: The date extracted from the block timestamp, representing the day the block was created - data_tests: - - not_null + description: The date extracted from the block timestamp, representing the day the block was created - &block_number name: block_number description: The block number where the event is included - data_tests: - - not_null - &tx_hash name: tx_hash description: The hash of the transaction where the event was logged - data_tests: - - not_null - &index name: index description: The position of the event within the transaction - data_tests: - - not_null - &contract_address name: contract_address description: The contract address associated with the event - data_tests: - - not_null - &tx_from name: tx_from description: The originating address of the transaction, usually representing the sender - data_tests: - - not_null - &tx_to name: tx_to - description: The destination address of the transaction, representing the receiver - data_tests: - - not_null + description: The destination address of the transaction, representing the receiver - name: event_name description: The type of event recorded, always 'OrderCreated' for this model. - data_tests: - - not_null - &msg_sender name: msg_sender description: The address of the sender of the message or transaction. - data_tests: - - not_null - name: account description: The address associated with the order. - name: receiver @@ -153,11 +135,11 @@ models: - not_null - name: updated_at_block description: The block number at which the order was last updated. - data_tests: - - not_null - - &updated_at_time + - &updated_at_time name: updated_at_time description: The timestamp when the order was last updated. + - name: valid_from_time + description: The time from which the order becomes valid for execution. - &is_long name: is_long description: A boolean indicating whether the position is long @@ -165,8 +147,8 @@ models: - not_null - name: should_unwrap_native_token description: Boolean indicating if the native token should be unwrapped. - - name: is_frozen - description: Boolean indicating if the order is frozen. + - name: auto_cancel + description: Boolean indicating whether the order will be automatically canceled under certain conditions. - &key name: key description: The unique identifier for the order, stored as a bytes32 value. @@ -187,7 +169,11 @@ models: Extracts and decodes the `OrderExecuted` event log data from the Avalanche blockchain. This model processes log entries related to executed orders, extracting key variables such as account addresses, event keys, and integer values. - + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index columns: - *blockchain - *block_time @@ -230,7 +216,11 @@ models: Extracts and decodes the `OrderCancelled` event log data from the Avalanche blockchain. This model processes log entries related to cancelled orders, extracting key variables such as account addresses, event keys, and strings representing the reason for cancellation. - + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index columns: - *blockchain - *block_time @@ -344,7 +334,11 @@ models: This model extracts and parses `PositionIncrease` events from the Avalanche blockchain. It includes transaction details, addresses, and various metrics related to the event, such as market data, collateral amounts, price impacts, and more. - + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index columns: - *blockchain - *block_time @@ -477,7 +471,11 @@ models: This model extracts and parses `PositionDecrease` events from the Avalanche blockchain. It includes transaction details, addresses, and various metrics related to the event, such as market data, collateral amounts, price impacts, and more. - + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index columns: - *blockchain - *block_time @@ -558,7 +556,11 @@ models: This model extracts and parses `PositionFeesCollected` events from the Avalanche blockchain. It includes details about the transaction, addresses involved, and various metrics related to fees collected from positions, including fee amounts and related market data. - + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index columns: - *blockchain - *block_time @@ -604,31 +606,6 @@ models: description: The size of the trade in USD data_tests: - not_null - - &total_rebate_factor - name: total_rebate_factor - description: The total rebate factor for the position - data_tests: - - not_null - - &trader_discount_factor - name: trader_discount_factor - description: The discount factor applied to the trader - data_tests: - - not_null - - &total_rebate_amount - name: total_rebate_amount - description: The total amount of rebate given - data_tests: - - not_null - - &trader_discount_amount - name: trader_discount_amount - description: The amount of discount given to the trader - data_tests: - - not_null - - &affiliate_reward_amount - name: affiliate_reward_amount - description: The reward amount given to the affiliate - data_tests: - - not_null - &funding_fee_amount name: funding_fee_amount description: The amount of funding fee charged @@ -637,28 +614,18 @@ models: - &claimable_long_token_amount name: claimable_long_token_amount description: The amount of long tokens claimable - data_tests: - - not_null - &claimable_short_token_amount name: claimable_short_token_amount description: The amount of short tokens claimable - data_tests: - - not_null - &latest_funding_fee_amount_per_size name: latest_funding_fee_amount_per_size description: The latest funding fee amount per size - data_tests: - - not_null - &latest_long_token_claimable_funding_amount_per_size name: latest_long_token_claimable_funding_amount_per_size description: The latest claimable long token funding amount per size - data_tests: - - not_null - &latest_short_token_claimable_funding_amount_per_size name: latest_short_token_claimable_funding_amount_per_size description: The latest claimable short token funding amount per size - data_tests: - - not_null - &borrowing_fee_usd name: borrowing_fee_usd description: The borrowing fee amount in USD @@ -729,6 +696,61 @@ models: description: The total amount of UI fee collected data_tests: - not_null + - &referral_total_rebate_factor + name: referral_total_rebate_factor + description: The total rebate factor associated with referrals. + data_tests: + - not_null + - &referral_total_rebate_amount + name: referral_total_rebate_amount + description: The total rebate amount given for referrals. + data_tests: + - not_null + - &referral_trader_discount_factor + name: referral_trader_discount_factor + description: The discount factor applied to the trader through referrals. + data_tests: + - not_null + - &referral_adjusted_affiliate_reward_factor + name: referral_adjusted_affiliate_reward_factor + description: The adjusted affiliate reward factor based on referral criteria. + data_tests: + - not_null + - &referral_affiliate_reward_amount + name: referral_affiliate_reward_amount + description: The reward amount given to the affiliate for referrals. + data_tests: + - not_null + - &referral_trader_discount_amount + name: referral_trader_discount_amount + description: The discount amount given to the trader through referrals. + data_tests: + - not_null + - &pro_trader_discount_factor + name: pro_trader_discount_factor + description: The discount factor applied for pro traders. + data_tests: + - not_null + - &pro_trader_discount_amount + name: pro_trader_discount_amount + description: The discount amount given to pro traders. + data_tests: + - not_null + - &liquidation_fee_amount + name: liquidation_fee_amount + description: The amount of fees charged during liquidation. + data_tests: + - not_null + - &liquidation_fee_receiver_factor + name: liquidation_fee_receiver_factor + description: The factor used to calculate the liquidation fee allocated to the receiver. + data_tests: + - not_null + - &liquidation_fee_amount_for_fee_receiver + name: liquidation_fee_amount_for_fee_receiver + description: The amount of liquidation fee allocated to the fee receiver. + data_tests: + - not_null - &is_increase name: is_increase description: Indicates whether the position is increased (true) or decreased (false) @@ -755,7 +777,11 @@ models: This model extracts and parses `PositionFeesInfo` events from the Avalanche blockchain. It includes details about the transaction, addresses involved, and various metrics related to position fees, including fee amounts and related market data. - + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index columns: - *blockchain - *block_time @@ -785,11 +811,6 @@ models: - *collateral_token_price_min - *collateral_token_price_max - *trade_size_usd - - *total_rebate_factor - - *trader_discount_factor - - *total_rebate_amount - - *trader_discount_amount - - *affiliate_reward_amount - *funding_fee_amount - *claimable_long_token_amount - *claimable_short_token_amount @@ -810,6 +831,17 @@ models: - *total_cost_amount - *ui_fee_receiver_factor - *ui_fee_amount + - *referral_total_rebate_factor + - *referral_total_rebate_amount + - *referral_trader_discount_factor + - *referral_adjusted_affiliate_reward_factor + - *referral_affiliate_reward_amount + - *referral_trader_discount_amount + - *pro_trader_discount_factor + - *pro_trader_discount_amount + - *liquidation_fee_amount + - *liquidation_fee_receiver_factor + - *liquidation_fee_amount_for_fee_receiver - *is_increase - *order_key - *position_key @@ -832,7 +864,7 @@ models: - dbt_utils.unique_combination_of_columns: combination_of_columns: - tx_hash - - key + - index columns: - *blockchain @@ -877,7 +909,11 @@ models: Extracts and decodes the `OrderUpdated` event log data from the Avalanche blockchain. This model processes log entries related to updated orders, extracting key variables such as account addresses, event keys, and strings representing the reason for cancellation. - + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index columns: - *blockchain - *block_time @@ -899,8 +935,6 @@ models: - not_null - name: market description: The market in which the order was updated. - data_tests: - - not_null - name: account description: The address associated with the order. - *size_delta_usd @@ -909,4 +943,1335 @@ models: - *acceptable_price_raw - *acceptable_price - *min_output_amount_raw - - *updated_at_time \ No newline at end of file + - *updated_at_time + - name: valid_from_time + description: The time from which the order becomes valid for execution. + - name: auto_cancel + description: Boolean indicating whether the order will be automatically canceled under certain conditions. + + + - name: gmx_v2_avalanche_c_open_interest_in_tokens_updated + meta: + blockchain: avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['avalanche_c', 'gmx', 'event', 'open_interest_in_tokens_updated'] + description: | + Combines and processes decoded event data to produce a normalized dataset of updated orders + on the GMX platform for the Avalanche blockchain. + This model integrates data from the `open_interest_in_tokens_updated` table, enriching it with market-specific details. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: event_name + description: The type of event recorded, always 'OpenInterestInTokensUpdated' for this model + data_tests: + - not_null + - *msg_sender + - name: market + description: The market in which the order was updated, decoded from a hexadecimal value. + data_tests: + - not_null + - name: collateral_token + description: The token used as collateral for the order, decoded from a hexadecimal value. + data_tests: + - not_null + - name: is_long + description: A boolean flag indicating whether the order is a long position (true) or short position (false). + - name: next_value + description: | + Represents the updated open interest vlaue after the transaction. It is derived by normalizing + the raw value using index token decimals. + This ensures consistent scaling of the value across tokens with varying decimals. + - name: delta + description: | + Indicates the change in open interest. It is calculated by normalizing the raw delta value + using index token decimals. + This normalization accounts for token decimal differences and provides a standardized measure of change. + - name: tx_from + description: The address that initiated the transaction + - name: tx_to + description: The destination address of the transaction + - name: tx_index + description: Index value related to the transaction + + + - name: gmx_v2_avalanche_c_open_interest_updated + meta: + blockchain: avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['avalanche_c', 'gmx', 'event', 'open_interest_updated'] + description: | + Extracts and processes decoded event data for open interest updates on the GMX platform, + specifically on the Avalanche blockchain. This model normalizes data, including key metrics like + delta and next_value, ensuring consistent scaling based on token decimals. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: event_name + description: The type of event recorded, always 'OpenInterestUpdated' for this model + data_tests: + - not_null + - *msg_sender + - name: market + description: The market associated with the open interest update, decoded from a hexadecimal value. + data_tests: + - not_null + - name: collateral_token + description: The token used as collateral for the open interest, decoded from a hexadecimal value. + data_tests: + - not_null + - name: is_long + description: | + A boolean flag indicating whether the open interest update is for a long position (true) or short position (false). + data_type: boolean + - name: delta + description: | + Represents the change in open interest value, normalized by dividing the raw delta by `POWER(10, 30)`. + This ensures consistent scaling for values across tokens with varying decimals. + data_type: float + data_tests: + - not_null + - name: next_value + description: | + Indicates the updated open interest value after the transaction, normalized by dividing + the raw value by `POWER(10, 30)` to ensure consistent scaling across tokens. + data_type: float + data_tests: + - not_null + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: tx_index + description: The index value related to the transaction. + + + - name: gmx_v2_avalanche_c_oracle_price_update + meta: + blockchain: avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['avalanche_c', 'gmx', 'event', 'oracle_price_update'] + description: | + Processes decoded event data for Oracle Price Updates on the GMX platform in the Avalanche blockchain. + The model normalizes price data (min_price and max_price) using token-specific decimals and extracts + additional details such as the provider and token involved in the update. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: event_name + description: The type of event recorded, always 'OraclePriceUpdate' for this model + data_tests: + - not_null + - *msg_sender + - name: token + description: The token associated with the oracle price update, decoded from a hexadecimal value. + data_tests: + - not_null + - name: provider + description: The address of the price provider, decoded from a hexadecimal value. + - name: min_price + description: The minimum price reported by the oracle. + data_tests: + - not_null + - name: max_price + description: The maximum price reported by the oracle. + data_tests: + - not_null + - name: timestamp + description: The timestamp of the oracle price update. + data_type: timestamp + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: tx_index + description: The index value related to the transaction, used for unique identification. + + + - name: gmx_v2_avalanche_c_pool_amount_updated + meta: + blockchain: avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['avalanche_c', 'gmx', 'event', 'pool_amount_updated'] + description: | + Processes decoded event data for Pool Amount Updates on the GMX platform in the Avalanche blockchain. + This model normalizes token values (next_value and delta) based on token-specific decimals and extracts + additional details such as the market and token involved in the pool update. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: event_name + description: The type of event recorded, always 'PoolAmountUpdated' for this model + data_tests: + - not_null + - *msg_sender + - name: market + description: The market associated with the pool update, decoded from a hexadecimal value. + data_tests: + - not_null + - name: token + description: The token involved in the pool update, decoded from a hexadecimal value. + data_tests: + - not_null + - name: next_value + description: | + The amount in the pool for the specified token, normalized by dividing the raw value + by `POWER(10, token_decimals)`, where `token_decimals` is derived from ERC-20 token metadata. + data_tests: + - not_null + - name: delta + description: | + The change in the pool amount for the specified token, normalized by dividing the raw value + by `POWER(10, token_decimals)`, where `token_decimals` is derived from ERC-20 token metadata. + data_tests: + - not_null + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: tx_index + description: The index value related to the transaction, used for unique identification. + + + - name: gmx_v2_avalanche_c_set_uint + meta: + blockchain: avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['avalanche_c', 'gmx', 'event', 'set_uint'] + description: | + Processes decoded event data for `SetUint` events on the GMX platform in the Avalanche blockchain. + This model normalizes the value field and extracts additional details such as the base key and associated data, + ensuring compatibility with downstream analyses. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: event_name + description: The type of event recorded, always 'SetUint' for this model + data_tests: + - not_null + - *msg_sender + - name: base_key + description: The base key associated with the event, decoded from a hexadecimal value. + data_tests: + - not_null + - name: data + description: The associated data field, decoded from a hexadecimal value. + data_tests: + - not_null + - name: value_raw + description: | + The value associated with the event. + data_type: float + data_tests: + - not_null + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: tx_index + description: The index value related to the transaction, used for unique identification. + + + - name: gmx_v2_avalanche_c_execution_fee_refund + meta: + blockchain: avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['avalanche_c', 'gmx', 'event', 'execution_fee_refund'] + description: | + Processes decoded event data for `ExecutionFeeRefund` events on the GMX platform in the Avalanche blockchain. + This model extracts key details such as the refund amount, receiver, and transaction details to + enable analysis of refunded execution fees. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `ExecutionFeeRefund` for this model. + data_tests: + - not_null + - *msg_sender + - name: receiver + description: The address that received the refunded execution fee. + - name: refund_fee_amount + description: The amount of the refunded execution fee, denominated in the native token of the blockchain (e.g., ETH). + + + - name: gmx_v2_avalanche_c_keeper_execution_fee + meta: + blockchain: avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['avalanche_c', 'gmx', 'event', 'keeper_execution_fee'] + description: | + Processes decoded event data for `KeeperExecutionFee` events on the GMX platform in the Avalanche blockchain. + This model extracts key details such as the keeper's address, execution fee amount, and transaction details, enabling + analysis of fees associated with keeper-based executions. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `KeeperExecutionFee` for this model. + data_tests: + - not_null + - *msg_sender + - name: keeper + description: The address of the keeper responsible for executing the transaction. + - name: execution_fee_amount + description: The amount of the execution fee, denominated in the native token of the blockchain (e.g., ETH, AVAX). + + + - name: gmx_v2_avalanche_c_deposit_cancelled + meta: + blockchain: avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['avalanche_c', 'gmx', 'event', 'deposit_cancelled'] + description: | + Processes decoded event data for `DepositCancelled` events on the GMX platform in the Avalanche blockchain. + This model extracts key details such as the account address, cancellation reason, and transaction details, enabling + analysis of deposit cancellations on the platform. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `DepositCancelled` for this model. + - *msg_sender + - name: account + description: The account address associated with the cancelled deposit. + - name: key + description: A unique identifier for the cancelled deposit. + - name: reason_bytes + description: Encoded reason data for the deposit cancellation. + - name: reason + description: The decoded textual reason for the deposit cancellation. + + + - name: gmx_v2_avalanche_c_deposit_created + meta: + blockchain: avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['avalanche_c', 'gmx', 'event', 'deposit_created'] + description: | + Processes decoded event data for `DepositCreated` events on the GMX platform in the Avalanche blockchain. + This model extracts key details such as the account address, deposit details, and transaction specifics, enabling + analysis of deposits created on the platform. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `DepositCreated` for this model. + - *msg_sender + - name: account + description: The account address associated with the deposit. + - name: receiver + description: The receiver address specified for the deposit. + - name: callback_contract + description: The address of the callback contract associated with the deposit. + - name: market + description: The market for which the deposit was created. + - name: initial_long_token + description: The token used for the long position in the deposit. + - name: initial_short_token + description: The token used for the short position in the deposit. + - name: long_token_swap_path + description: The swap path for the long token. + - name: short_token_swap_path + description: The swap path for the short token. + - name: initial_long_token_amount + description: The initial amount of the long token in the deposit. + - name: initial_short_token_amount + description: The initial amount of the short token in the deposit. + - name: min_market_tokens + description: The minimum amount of market tokens expected from the deposit. + - name: updated_at_time + description: The timestamp when the deposit was last updated. + - name: execution_fee + description: The execution fee for processing the deposit. + - name: callback_gas_limit + description: The gas limit for the callback associated with the deposit. + - name: deposit_type + description: The type of deposit created. + - name: should_unwrap_native_token + description: Indicates whether the native token should be unwrapped. + - name: key + description: A unique identifier for the deposit. + + + - name: gmx_v2_avalanche_c_deposit_executed + meta: + blockchain: avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['avalanche_c', 'gmx', 'event', 'deposit_executed'] + description: | + Processes decoded event data for `DepositExecuted` events on the GMX platform in the Avalanche blockchain. + This model extracts key details such as the account address, execution details, and transaction specifics, enabling + analysis of deposits executed on the platform. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `DepositExecuted` for this model. + - *msg_sender + - name: account + description: The account address associated with the executed deposit. + - name: long_token_amount + description: The amount of the long token in the executed deposit. + - name: short_token_amount + description: The amount of the short token in the executed deposit. + - name: received_market_tokens + description: The number of market tokens received from the executed deposit. + - name: swap_pricing_type + description: The type of swap pricing applied during the execution. + - name: key + description: A unique identifier for the executed deposit. + + + - name: gmx_v2_avalanche_c_glv_created + meta: + blockchain: avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['avalanche_c', 'gmx', 'event', 'glv_created'] + description: | + Processes decoded event data for `GLVCreated` events on the GMX platform in the Avalanche blockchain. + This model extracts key details such as the GLV token, associated tokens, and transaction specifics, enabling + analysis of GLV creation events on the platform. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `GLVCreated` for this model. + - *msg_sender + - name: glv_token + description: The identifier of the GLV token created in the transaction. + - name: long_token + description: The long token associated with the GLV creation. + - name: short_token + description: The short token associated with the GLV creation. + - name: salt + description: A unique salt value used in the GLV creation. + - name: glv_type + description: The type of GLV created. + - name: market_token_symbol + description: The symbol of the market token involved in the GLV creation. + - name: market_token_decimals + description: The decimal precision of the market token involved in the GLV creation. + + + - name: gmx_v2_avalanche_c_glv_deposit_cancelled + meta: + blockchain: avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['avalanche_c', 'gmx', 'event', 'glv_deposit_cancelled'] + description: | + Processes decoded event data for `GLVDepositCancelled` events on the GMX platform in the Avalanche blockchain. + This model extracts key details such as the account address, cancellation reason, and transaction specifics, enabling + analysis of cancelled GLV deposits. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `GLVDepositCancelled` for this model. + - *msg_sender + - name: account + description: The account address associated with the cancelled deposit. + - name: key + description: A unique identifier for the cancelled deposit. + - name: reason_bytes + description: Encoded reason data for the deposit cancellation. + - name: reason + description: The decoded textual reason for the deposit cancellation. + + + - name: gmx_v2_avalanche_c_glv_deposit_created + meta: + blockchain: avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['avalanche_c', 'gmx', 'event', 'glv_deposit_created'] + description: | + Processes decoded event data for `GLVDepositCreated` events on the GMX platform in the Avalanche blockchain. + This model extracts key details such as the account address, deposit details, and transaction specifics, enabling + analysis of created GLV deposits. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `GLVDepositCreated` for this model. + - *msg_sender + - name: account + description: The account address associated with the deposit. + - name: receiver + description: The receiver address specified for the deposit. + - name: callback_contract + description: The address of the callback contract associated with the deposit. + - name: market + description: The market associated with the deposit. + - name: glv + description: The identifier of the GLV associated with the deposit. + - name: initial_long_token + description: The token used for the long position in the deposit. + - name: initial_short_token + description: The token used for the short position in the deposit. + - name: ui_fee_receiver + description: The address receiving the UI fee for the deposit. + - name: long_token_swap_path + description: The swap path for the long token. + - name: short_token_swap_path + description: The swap path for the short token. + - name: initial_long_token_amount + description: The initial amount of the long token in the deposit. + - name: initial_short_token_amount + description: The initial amount of the short token in the deposit. + - name: min_glv_tokens + description: The minimum amount of GLV tokens expected from the deposit. + - name: updated_at_time + description: The timestamp when the deposit was last updated. + - name: execution_fee + description: The execution fee for processing the deposit. + - name: callback_gas_limit + description: The gas limit for the callback associated with the deposit. + - name: market_token_amount + description: The amount of market tokens associated with the deposit. + - name: should_unwrap_native_token + description: Indicates whether the native token should be unwrapped. + - name: is_market_token_deposit + description: Indicates whether the deposit was made using market tokens. + - name: key + description: A unique identifier for the deposit. + + + - name: gmx_v2_avalanche_c_glv_deposit_executed + meta: + blockchain: avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['avalanche_c', 'gmx', 'event', 'glv_deposit_executed'] + description: | + Processes decoded event data for `GLVDepositExecuted` events on the GMX platform in the Avalanche blockchain. + This model extracts key details such as the account address, received GLV tokens, and transaction specifics, enabling + analysis of executed GLV deposits. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `GLVDepositExecuted` for this model. + data_tests: + - not_null + - *msg_sender + - name: account + description: The account address associated with the executed deposit. + - name: received_glv_tokens + description: The number of GLV tokens received from the executed deposit. + - name: key + description: A unique identifier for the executed deposit. + + + - name: gmx_v2_avalanche_c_glv_shift_cancelled + meta: + blockchain: avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['avalanche_c', 'gmx', 'event', 'glv_shift_cancelled'] + description: | + Processes decoded event data for `GLVShiftCancelled` events on the GMX platform in the Avalanche blockchain. + This model extracts key details such as the cancellation reason and transaction specifics, enabling + analysis of cancelled GLV shifts. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `GLVShiftCancelled` for this model. + - *msg_sender + - name: key + description: A unique identifier for the cancelled shift. + - name: reason_bytes + description: Encoded reason data for the shift cancellation. + - name: reason + description: The decoded textual reason for the shift cancellation. + + + - name: gmx_v2_avalanche_c_glv_shift_created + meta: + blockchain: avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['avalanche_c', 'gmx', 'event', 'glv_shift_created'] + description: | + Processes decoded event data for `GLVShiftCreated` events on the GMX platform in the Avalanche blockchain. + This model extracts key details such as the source and destination markets, GLV details, and transaction specifics, enabling + analysis of created GLV shifts. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `GLVShiftCreated` for this model. + - *msg_sender + - name: from_market + description: The source market for the GLV shift. + - name: to_market + description: The destination market for the GLV shift. + - name: glv + description: The identifier of the GLV being shifted. + - name: market_token_amount + description: The amount of market tokens involved in the shift. + - name: min_market_tokens + description: The minimum market tokens expected from the shift. + - name: updated_at_time + description: The timestamp when the shift was last updated. + - name: key + description: A unique identifier for the created shift. + + + - name: gmx_v2_avalanche_c_glv_shift_executed + meta: + blockchain: avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['avalanche_c', 'gmx', 'event', 'glv_shift_executed'] + description: | + Processes decoded event data for `GLVShiftExecuted` events on the GMX platform in the Avalanche blockchain. + This model extracts key details such as the received market tokens and transaction specifics, enabling + analysis of executed GLV shifts. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `GLVShiftExecuted` for this model. + - *msg_sender + - name: received_market_tokens + description: The number of market tokens received from the executed shift. + - name: key + description: A unique identifier for the executed shift. + + + - name: gmx_v2_avalanche_c_glv_withdrawal_cancelled + meta: + blockchain: avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['avalanche_c', 'gmx', 'event', 'glv_withdrawal_cancelled'] + description: | + Processes decoded event data for `GLVWithdrawalCancelled` events on the GMX platform in the Avalanche blockchain. + This model extracts key details such as the account address, cancellation reason, and transaction specifics, enabling + analysis of cancelled GLV withdrawals. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `GLVWithdrawalCancelled` for this model. + data_tests: + - not_null + - *msg_sender + - name: account + description: The account address associated with the cancelled withdrawal. + - name: key + description: A unique identifier for the cancelled withdrawal. + - name: reason_bytes + description: Encoded reason data for the withdrawal cancellation. + - name: reason + description: The decoded textual reason for the withdrawal cancellation. + + + - name: gmx_v2_avalanche_c_glv_withdrawal_created + meta: + blockchain: avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['avalanche_c', 'gmx', 'event', 'glv_withdrawal_created'] + description: | + Processes decoded event data for `GLVWithdrawalCreated` events on the GMX platform in the Avalanche blockchain. + This model extracts key details such as the account address, withdrawal details, and transaction specifics, enabling + analysis of created GLV withdrawals. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `GLVWithdrawalCreated` for this model. + data_tests: + - not_null + - *msg_sender + - name: account + description: The account address associated with the withdrawal. + - name: receiver + description: The receiver address specified for the withdrawal. + - name: callback_contract + description: The address of the callback contract associated with the withdrawal. + - name: market + description: The market associated with the withdrawal. + - name: glv + description: The identifier of the GLV associated with the withdrawal. + - name: ui_fee_receiver + description: The address receiving the UI fee for the withdrawal. + - name: long_token_swap_path + description: The swap path for the long token. + - name: short_token_swap_path + description: The swap path for the short token. + - name: glv_token_amount + description: The amount of GLV tokens involved in the withdrawal. + - name: min_long_token_amount + description: The minimum long token amount expected from the withdrawal. + - name: min_short_token_amount + description: The minimum short token amount expected from the withdrawal. + - name: updated_at_time + description: The timestamp when the withdrawal was last updated. + - name: execution_fee + description: The execution fee for processing the withdrawal. + - name: callback_gas_limit + description: The gas limit for the callback associated with the withdrawal. + - name: should_unwrap_native_token + description: Indicates whether the native token should be unwrapped. + - name: key + description: A unique identifier for the created withdrawal. + + + - name: gmx_v2_avalanche_c_glv_withdrawal_executed + meta: + blockchain: avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['avalanche_c', 'gmx', 'event', 'glv_withdrawal_executed'] + description: | + Processes decoded event data for `GLVWithdrawalExecuted` events on the GMX platform in the Avalanche blockchain. + This model extracts key details such as the account address and transaction specifics, enabling + analysis of executed GLV withdrawals. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `GLVWithdrawalExecuted` for this model. + data_tests: + - not_null + - *msg_sender + - name: account + description: The account address associated with the executed withdrawal. + - name: key + description: A unique identifier for the executed withdrawal. + + + - name: gmx_v2_avalanche_c_shift_created + meta: + blockchain: avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['avalanche_c', 'gmx', 'event', 'shift_created'] + description: | + Processes decoded event data for `ShiftCreated` events on the GMX platform in the Avalanche blockchain. + This model extracts key details such as the account address, market details, and transaction specifics, enabling + analysis of created shifts. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `ShiftCreated` for this model. + - *msg_sender + - name: account + description: The account address associated with the shift. + - name: receiver + description: The receiver address specified for the shift. + - name: callback_contract + description: The address of the callback contract associated with the shift. + - name: from_market + description: The source market for the shift. + - name: to_market + description: The destination market for the shift. + - name: market_token_amount + description: The amount of market tokens involved in the shift. + - name: min_market_tokens + description: The minimum market tokens expected from the shift. + - name: updated_at_time + description: The timestamp when the shift was last updated. + - name: execution_fee + description: The execution fee for processing the shift. + - name: callback_gas_limit + description: The gas limit for the callback associated with the shift. + - name: key + description: A unique identifier for the created shift. + + + - name: gmx_v2_avalanche_c_shift_executed + meta: + blockchain: avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['avalanche_c', 'gmx', 'event', 'shift_executed'] + description: | + Processes decoded event data for `ShiftExecuted` events on the GMX platform in the Avalanche blockchain. + This model extracts key details such as the account address, received market tokens, and transaction specifics, enabling + analysis of executed shifts. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `ShiftExecuted` for this model. + - *msg_sender + - name: account + description: The account address associated with the executed shift. + - name: received_market_tokens + description: The number of market tokens received from the executed shift. + - name: key + description: A unique identifier for the executed shift. + + + - name: gmx_v2_avalanche_c_withdrawal_cancelled + meta: + blockchain: avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['avalanche_c', 'gmx', 'event', 'withdrawal_cancelled'] + description: | + Processes decoded event data for `WithdrawalCancelled` events on the GMX platform in the Avalanche blockchain. + This model extracts key details such as the account address, cancellation reason, and transaction specifics, enabling + analysis of cancelled withdrawals. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `WithdrawalCancelled` for this model. + - *msg_sender + - name: account + description: The account address associated with the cancelled withdrawal. + - name: key + description: A unique identifier for the cancelled withdrawal. + - name: reason_bytes + description: Encoded reason data for the withdrawal cancellation. + - name: reason + description: The decoded textual reason for the withdrawal cancellation. + + + - name: gmx_v2_avalanche_c_withdrawal_created + meta: + blockchain: avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['avalanche_c', 'gmx', 'event', 'withdrawal_created'] + description: | + Processes decoded event data for `WithdrawalCreated` events on the GMX platform in the Avalanche blockchain. + This model extracts key details such as the account address, withdrawal details, and transaction specifics, enabling + analysis of created withdrawals. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `WithdrawalCreated` for this model. + - *msg_sender + - name: account + description: The account address associated with the withdrawal. + - name: receiver + description: The receiver address specified for the withdrawal. + - name: callback_contract + description: The address of the callback contract associated with the withdrawal. + - name: market + description: The market associated with the withdrawal. + - name: market_token_amount + description: The amount of market tokens involved in the withdrawal. + - name: min_long_token_amount + description: The minimum long token amount expected from the withdrawal. + - name: min_short_token_amount + description: The minimum short token amount expected from the withdrawal. + - name: updated_at_time + description: The timestamp when the withdrawal was last updated. + - name: execution_fee + description: The execution fee for processing the withdrawal. + - name: callback_gas_limit + description: The gas limit for the callback associated with the withdrawal. + - name: should_unwrap_native_token + description: Indicates whether the native token should be unwrapped. + - name: key + description: A unique identifier for the created withdrawal. + + + - name: gmx_v2_avalanche_c_withdrawal_executed + meta: + blockchain: avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['avalanche_c', 'gmx', 'event', 'withdrawal_executed'] + description: | + Processes decoded event data for `WithdrawalExecuted` events on the GMX platform in the Avalanche blockchain. + This model extracts key details such as the account address, pricing type, and transaction specifics, enabling + analysis of executed withdrawals. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `WithdrawalExecuted` for this model. + - *msg_sender + - name: account + description: The account address associated with the executed withdrawal. + - name: swap_pricing_type + description: The pricing type applied during the withdrawal. + - name: key + description: A unique identifier for the executed withdrawal. + + - name: gmx_v2_avalanche_c_claimable_funding_amount_per_size_updated + meta: + blockchain: avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['avalanche_c', 'gmx', 'event', 'claimable_funding'] + description: | + Processes decoded event data for `ClaimableFundingAmountPerSizeUpdated` events on the GMX platform across the Avalanche blockchain. + This model extracts key details such as funding updates, collateral information, and market direction to support funding analysis. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address initiating the transaction. + - name: tx_to + description: The recipient address of the transaction. + - name: event_name + description: The name of the event emitted, always `ClaimableFundingAmountPerSizeUpdated`. + - *msg_sender + - name: market + description: The specific GMX market where the funding amount was updated. + - name: collateral_token + description: The token used as collateral in the funding event. + - name: delta + description: The change in the funding amount. + - name: value + description: The funding amount value associated with the update. + - name: is_long + description: A boolean indicating if the position is a long position (`true` for long, `false` for short). + + - name: gmx_v2_avalanche_c_funding_fee_amount_per_size_updated + meta: + blockchain: avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['avalanche_c', 'gmx', 'event', 'funding_fee'] + description: | + Processes decoded event data for `FundingFeeAmountPerSizeUpdated` events on the GMX platform across the Avalanche blockchain. + This model extracts key details such as funding fees, collateral details, and market direction to enable funding fee analysis. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address initiating the transaction. + - name: tx_to + description: The recipient address of the transaction. + - name: event_name + description: The name of the event emitted, always `FundingFeeAmountPerSizeUpdated`. + - *msg_sender + - name: market + description: The specific GMX market where the funding fee was updated. + - name: collateral_token + description: The token used as collateral in the funding event. + - name: delta + description: The change in the funding fee amount. + - name: value + description: The funding fee amount associated with the update. + - name: is_long + description: A boolean indicating if the position is a long position (`True` for long, `False` for short). diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_execution_fee_refund.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_execution_fee_refund.sql new file mode 100644 index 00000000000..f685312857d --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_execution_fee_refund.sql @@ -0,0 +1,147 @@ +{{ + config( + schema = 'gmx_v2_avalanche_c', + alias = 'execution_fee_refund', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'ExecutionFeeRefund' -%} +{%- set blockchain_name = 'avalanche_c' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + MAX(CASE WHEN key_name = 'receiver' THEN value END) AS receiver, + MAX(CASE WHEN key_name = 'refundFeeAmount' THEN value END) AS refund_fee_amount + FROM + combined + GROUP BY tx_hash, index +) + +-- full data +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(EDP.receiver) AS receiver, + CAST(EDP.refund_fee_amount AS DOUBLE) / POWER(10, 18) AS refund_fee_amount + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_funding_fee_amount_per_size_updated.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_funding_fee_amount_per_size_updated.sql new file mode 100644 index 00000000000..a2f93f4f0f8 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_funding_fee_amount_per_size_updated.sql @@ -0,0 +1,195 @@ +{{ + config( + schema = 'gmx_v2_avalanche_c', + alias = 'funding_fee_amount_per_size_updated', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'FundingFeeAmountPerSizeUpdated' -%} +{%- set blockchain_name = 'avalanche_c' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items, + json_query(data, 'lax $.boolItems' OMIT QUOTES) AS bool_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bool_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bool_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed + UNION ALL + SELECT * + FROM bool_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'market' THEN value END) AS market, + MAX(CASE WHEN key_name = 'collateralToken' THEN value END) AS collateral_token, + MAX(CASE WHEN key_name = 'delta' THEN value END) AS delta, + MAX(CASE WHEN key_name = 'value' THEN value END) AS "value", + MAX(CASE WHEN key_name = 'isLong' THEN value END) AS is_long + + FROM + combined + GROUP BY tx_hash, index +) + +, event_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(market) AS market, + from_hex(collateral_token) AS collateral_token, + TRY_CAST(delta AS DOUBLE) delta, + TRY_CAST("value" AS DOUBLE) "value", + TRY_CAST(is_long AS BOOLEAN) AS is_long + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + tx_hash, + index, + contract_address, + event_name, + msg_sender, + + market, + ED.collateral_token, + delta / POWER(10, CTD.collateral_token_decimals + 15) AS delta, + "value" / POWER(10, CTD.collateral_token_decimals + 15) AS "value", + is_long + + FROM event_data AS ED + LEFT JOIN gmx_v2_avalanche_c.collateral_tokens_data AS CTD + ON ED.collateral_token = CTD.collateral_token +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_glv_created.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_glv_created.sql new file mode 100644 index 00000000000..1dc64b7568b --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_glv_created.sql @@ -0,0 +1,157 @@ +{{ + config( + schema = 'gmx_v2_avalanche_c', + alias = 'glv_created', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'GlvCreated' -%} +{%- set blockchain_name = 'avalanche_c' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM bytes32_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'glvToken' THEN value END) AS glv_token, + MAX(CASE WHEN key_name = 'longToken' THEN value END) AS long_token, + MAX(CASE WHEN key_name = 'shortToken' THEN value END) AS short_token, + MAX(CASE WHEN key_name = 'salt' THEN value END) AS salt, + MAX(CASE WHEN key_name = 'glvType' THEN value END) AS glv_type + + FROM + combined + GROUP BY tx_hash, index +) + +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(glv_token) AS glv_token, + from_hex(long_token) AS long_token, + from_hex(short_token) AS short_token, + from_hex(salt) AS salt, + from_hex(glv_type) AS glv_type, + 'GM' AS market_token_symbol, + 18 AS market_token_decimals + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_glv_deposit_cancelled.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_glv_deposit_cancelled.sql new file mode 100644 index 00000000000..863c2643169 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_glv_deposit_cancelled.sql @@ -0,0 +1,187 @@ +{{ + config( + schema = 'gmx_v2_avalanche_c', + alias = 'glv_deposit_cancelled', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'GlvDepositCancelled' -%} +{%- set blockchain_name = 'avalanche_c' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items, + json_query(data, 'lax $.bytesItems' OMIT QUOTES) AS bytes_items, + json_query(data, 'lax $.stringItems' OMIT QUOTES) AS string_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, string_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(string_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM bytes32_items_parsed + UNION ALL + SELECT * + FROM bytes_items_parsed + UNION ALL + SELECT * + FROM string_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'account' THEN value END) AS account, + MAX(CASE WHEN key_name = 'key' THEN value END) AS "key", + MAX(CASE WHEN key_name = 'reasonBytes' THEN value END) AS reason_bytes, + MAX(CASE WHEN key_name = 'reason' THEN value END) AS reason + + FROM + combined + GROUP BY tx_hash, index +) + +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(account) AS account, + from_hex("key") AS "key", + from_hex(reason_bytes) AS reason_bytes, + reason + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_glv_deposit_created.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_glv_deposit_created.sql new file mode 100644 index 00000000000..c5c9f968d07 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_glv_deposit_created.sql @@ -0,0 +1,269 @@ +{{ + config( + schema = 'gmx_v2_avalanche_c', + alias = 'glv_deposit_created', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'GlvDepositCreated' -%} +{%- set blockchain_name = 'avalanche_c' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items, + json_query(data, 'lax $.boolItems' OMIT QUOTES) AS bool_items, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bool_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bool_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed + UNION ALL + SELECT * + FROM bool_items_parsed + UNION ALL + SELECT * + FROM bytes32_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'account' THEN value END) AS account, + MAX(CASE WHEN key_name = 'receiver' THEN value END) AS receiver, + MAX(CASE WHEN key_name = 'callbackContract' THEN value END) AS callback_contract, + MAX(CASE WHEN key_name = 'market' THEN value END) AS market, + MAX(CASE WHEN key_name = 'glv' THEN value END) AS glv, + MAX(CASE WHEN key_name = 'initialLongToken' THEN value END) AS initial_long_token, + MAX(CASE WHEN key_name = 'initialShortToken' THEN value END) AS initial_short_token, + MAX(CASE WHEN key_name = 'uiFeeReceiver' THEN value END) AS ui_fee_receiver, + MAX(CASE WHEN key_name = 'longTokenSwapPath' THEN value END) AS long_token_swap_path, + MAX(CASE WHEN key_name = 'shortTokenSwapPath' THEN value END) AS short_token_swap_path, + + MAX(CASE WHEN key_name = 'initialLongTokenAmount' THEN value END) AS initial_long_token_amount, + MAX(CASE WHEN key_name = 'initialShortTokenAmount' THEN value END) AS initial_short_token_amount, + MAX(CASE WHEN key_name = 'minGlvTokens' THEN value END) AS min_glv_tokens, + MAX(CASE WHEN key_name = 'updatedAtTime' THEN value END) AS updated_at_time, + MAX(CASE WHEN key_name = 'executionFee' THEN value END) AS execution_fee, + MAX(CASE WHEN key_name = 'callbackGasLimit' THEN value END) AS callback_gas_limit, + MAX(CASE WHEN key_name = 'marketTokenAmount' THEN value END) AS market_token_amount, + + MAX(CASE WHEN key_name = 'shouldUnwrapNativeToken' THEN value END) AS should_unwrap_native_token, + MAX(CASE WHEN key_name = 'isMarketTokenDeposit' THEN value END) AS is_market_token_deposit, + + MAX(CASE WHEN key_name = 'key' THEN value END) AS "key" + + FROM + combined + GROUP BY tx_hash, index +) + +, event_data AS ( + SELECT + blockchain, + block_time, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(account) AS account, + from_hex(receiver) AS receiver, + from_hex(callback_contract) AS callback_contract, + from_hex(market) AS market, + from_hex(glv) AS glv, + from_hex(initial_long_token) AS initial_long_token, + from_hex(initial_short_token) AS initial_short_token, + from_hex(ui_fee_receiver) AS ui_fee_receiver, + long_token_swap_path, + short_token_swap_path, + + TRY_CAST(initial_long_token_amount AS DOUBLE) initial_long_token_amount, -- long_token_decimals + TRY_CAST(initial_short_token_amount AS DOUBLE) initial_short_token_amount, -- short_token_decimals + TRY_CAST(min_glv_tokens AS DOUBLE) min_glv_tokens, -- index_token_decimals (glv or market?) + TRY_CAST(updated_at_time AS DOUBLE) AS updated_at_time, + TRY_CAST(execution_fee AS DOUBLE) AS execution_fee, -- POWER(10, 18) + TRY_CAST(callback_gas_limit AS DOUBLE) AS callback_gas_limit, -- no decimals, keep as raw values + TRY_CAST(market_token_amount AS DOUBLE) market_token_amount, -- index_token_decimals (glv or market?) + + TRY_CAST(should_unwrap_native_token AS BOOLEAN) AS should_unwrap_native_token, + TRY_CAST(is_market_token_deposit AS BOOLEAN) AS is_market_token_deposit, + + from_hex("key") AS "key" + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + tx_hash, + index, + contract_address, + event_name, + msg_sender, + + account, + receiver, + callback_contract, + ED.market, + glv, + initial_long_token, + initial_short_token, + ui_fee_receiver, + long_token_swap_path, + short_token_swap_path, + + initial_long_token_amount / POWER(10, MD.long_token_decimals) AS initial_long_token_amount, + initial_short_token_amount / POWER(10, MD.short_token_decimals) AS initial_short_token_amount, + min_glv_tokens / POWER(10, 18) AS min_glv_tokens, + CASE + WHEN updated_at_time = 0 THEN NULL + ELSE updated_at_time + END AS updated_at_time, + execution_fee / POWER(10, 18) AS execution_fee, + callback_gas_limit, + market_token_amount / POWER(10, 18) AS market_token_amount, + + should_unwrap_native_token, + is_market_token_deposit, + + "key" + + FROM event_data AS ED + LEFT JOIN {{ ref('gmx_v2_avalanche_c_markets_data') }} AS MD + ON ED.market = MD.market +) + + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_glv_deposit_executed.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_glv_deposit_executed.sql new file mode 100644 index 00000000000..f24cd674f4c --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_glv_deposit_executed.sql @@ -0,0 +1,186 @@ +{{ + config( + schema = 'gmx_v2_avalanche_c', + alias = 'glv_deposit_executed', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'GlvDepositExecuted' -%} +{%- set blockchain_name = 'avalanche_c' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed + UNION ALL + SELECT * + FROM bytes32_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'account' THEN value END) AS account, + MAX(CASE WHEN key_name = 'receivedGlvTokens' THEN value END) AS received_glv_tokens, + MAX(CASE WHEN key_name = 'key' THEN value END) AS "key" + + FROM + combined + GROUP BY tx_hash, index +) + +, event_data AS ( + SELECT + blockchain, + block_time, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(account) AS account, + TRY_CAST(received_glv_tokens AS DOUBLE) received_glv_tokens, + from_hex("key") AS "key" + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + tx_hash, + index, + contract_address, + event_name, + msg_sender, + + account, + received_glv_tokens / POWER(10,18) AS received_glv_tokens, + "key" + + FROM event_data AS ED +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_glv_shift_cancelled.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_glv_shift_cancelled.sql new file mode 100644 index 00000000000..4a3c61e65e4 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_glv_shift_cancelled.sql @@ -0,0 +1,167 @@ +{{ + config( + schema = 'gmx_v2_avalanche_c', + alias = 'glv_shift_cancelled', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'GlvShiftCancelled' -%} +{%- set blockchain_name = 'avalanche_c' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items, + json_query(data, 'lax $.bytesItems' OMIT QUOTES) AS bytes_items, + json_query(data, 'lax $.stringItems' OMIT QUOTES) AS string_items + FROM + evt_data +) +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, string_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(string_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM bytes32_items_parsed + UNION ALL + SELECT * + FROM bytes_items_parsed + UNION ALL + SELECT * + FROM string_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'key' THEN value END) AS "key", + MAX(CASE WHEN key_name = 'reasonBytes' THEN value END) AS reason_bytes, + MAX(CASE WHEN key_name = 'reason' THEN value END) AS reason + FROM + combined + GROUP BY tx_hash, index +) + +-- full data +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex("key") AS "key", + from_hex(reason_bytes) AS reason_bytes, + reason + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_glv_shift_created.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_glv_shift_created.sql new file mode 100644 index 00000000000..397886221ad --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_glv_shift_created.sql @@ -0,0 +1,200 @@ +{{ + config( + schema = 'gmx_v2_avalanche_c', + alias = 'glv_shift_created', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'GlvShiftCreated' -%} +{%- set blockchain_name = 'avalanche_c' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed + UNION ALL + SELECT * + FROM bytes32_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'fromMarket' THEN value END) AS from_market, + MAX(CASE WHEN key_name = 'toMarket' THEN value END) AS to_market, + MAX(CASE WHEN key_name = 'glv' THEN value END) AS glv, + MAX(CASE WHEN key_name = 'marketTokenAmount' THEN value END) AS market_token_amount, + MAX(CASE WHEN key_name = 'minMarketTokens' THEN value END) AS min_market_tokens, + MAX(CASE WHEN key_name = 'updatedAtTime' THEN value END) AS updated_at_time, + MAX(CASE WHEN key_name = 'key' THEN value END) AS "key" + + FROM + combined + GROUP BY tx_hash, index +) + +, event_data AS ( + SELECT + blockchain, + block_time, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(from_market) AS from_market, + from_hex(to_market) AS to_market, + from_hex(glv) AS glv, + TRY_CAST(market_token_amount AS DOUBLE) AS market_token_amount, + TRY_CAST(min_market_tokens AS DOUBLE) AS min_market_tokens, + TRY_CAST(updated_at_time AS DOUBLE) updated_at_time, + from_hex("key") AS "key" + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + tx_hash, + index, + contract_address, + event_name, + msg_sender, + + from_market, + to_market, + glv, + market_token_amount / POWER(10, 18) AS market_token_amount, + min_market_tokens / POWER(10, 18) AS min_market_tokens, + CASE + WHEN updated_at_time = 0 THEN NULL + ELSE updated_at_time + END AS updated_at_time, + "key" + FROM event_data AS ED +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_glv_shift_executed.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_glv_shift_executed.sql new file mode 100644 index 00000000000..f07679676cb --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_glv_shift_executed.sql @@ -0,0 +1,165 @@ +{{ + config( + schema = 'gmx_v2_avalanche_c', + alias = 'glv_shift_executed', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'GlvShiftExecuted' -%} +{%- set blockchain_name = 'avalanche_c' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items + FROM + evt_data +) + +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM uint_items_parsed + UNION ALL + SELECT * + FROM bytes32_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'receivedMarketTokens' THEN value END) AS received_market_tokens, + MAX(CASE WHEN key_name = 'key' THEN value END) AS "key" + + FROM + combined + GROUP BY tx_hash, index +) + +, event_data AS ( + SELECT + blockchain, + block_time, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + TRY_CAST(received_market_tokens AS DOUBLE) received_market_tokens, + from_hex("key") AS "key" + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + tx_hash, + index, + contract_address, + event_name, + msg_sender, + + received_market_tokens / POWER(10, 18) AS received_market_tokens, + "key" + FROM event_data AS ED +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_glv_withdrawal_cancelled.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_glv_withdrawal_cancelled.sql new file mode 100644 index 00000000000..9c9a58a940f --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_glv_withdrawal_cancelled.sql @@ -0,0 +1,187 @@ +{{ + config( + schema = 'gmx_v2_avalanche_c', + alias = 'glv_withdrawal_cancelled', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'GlvWithdrawalCancelled' -%} +{%- set blockchain_name = 'avalanche_c' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items, + json_query(data, 'lax $.bytesItems' OMIT QUOTES) AS bytes_items, + json_query(data, 'lax $.stringItems' OMIT QUOTES) AS string_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, string_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(string_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM bytes32_items_parsed + UNION ALL + SELECT * + FROM bytes_items_parsed + UNION ALL + SELECT * + FROM string_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'account' THEN value END) AS account, + MAX(CASE WHEN key_name = 'key' THEN value END) AS "key", + MAX(CASE WHEN key_name = 'reasonBytes' THEN value END) AS reason_bytes, + MAX(CASE WHEN key_name = 'reason' THEN value END) AS reason + + FROM + combined + GROUP BY tx_hash, index +) + +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(account) AS account, + from_hex("key") AS "key", + from_hex(reason_bytes) AS reason_bytes, + reason + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_glv_withdrawal_created.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_glv_withdrawal_created.sql new file mode 100644 index 00000000000..ab1baf9bcd1 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_glv_withdrawal_created.sql @@ -0,0 +1,255 @@ +{{ + config( + schema = 'gmx_v2_avalanche_c', + alias = 'glv_withdrawal_created', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'GlvWithdrawalCreated' -%} +{%- set blockchain_name = 'avalanche_c' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items, + json_query(data, 'lax $.boolItems' OMIT QUOTES) AS bool_items, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bool_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bool_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed + UNION ALL + SELECT * + FROM bool_items_parsed + UNION ALL + SELECT * + FROM bytes32_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'account' THEN value END) AS account, + MAX(CASE WHEN key_name = 'receiver' THEN value END) AS receiver, + MAX(CASE WHEN key_name = 'callbackContract' THEN value END) AS callback_contract, + MAX(CASE WHEN key_name = 'market' THEN value END) AS market, + MAX(CASE WHEN key_name = 'glv' THEN value END) AS glv, + MAX(CASE WHEN key_name = 'uiFeeReceiver' THEN value END) AS ui_fee_receiver, + MAX(CASE WHEN key_name = 'longTokenSwapPath' THEN value END) AS long_token_swap_path, + MAX(CASE WHEN key_name = 'shortTokenSwapPath' THEN value END) AS short_token_swap_path, + + MAX(CASE WHEN key_name = 'glvTokenAmount' THEN value END) AS glv_token_amount, + MAX(CASE WHEN key_name = 'minLongTokenAmount' THEN value END) AS min_long_token_amount, + MAX(CASE WHEN key_name = 'minShortTokenAmount' THEN value END) AS min_short_token_amount, + MAX(CASE WHEN key_name = 'updatedAtTime' THEN value END) AS updated_at_time, + MAX(CASE WHEN key_name = 'executionFee' THEN value END) AS execution_fee, + MAX(CASE WHEN key_name = 'callbackGasLimit' THEN value END) AS callback_gas_limit, + + MAX(CASE WHEN key_name = 'shouldUnwrapNativeToken' THEN value END) AS should_unwrap_native_token, + + MAX(CASE WHEN key_name = 'key' THEN value END) AS "key" + + FROM + combined + GROUP BY tx_hash, index +) + +, event_data AS ( + SELECT + blockchain, + block_time, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(account) AS account, + from_hex(receiver) AS receiver, + from_hex(callback_contract) AS callback_contract, + from_hex(market) AS market, + from_hex(glv) AS glv, + from_hex(ui_fee_receiver) AS ui_fee_receiver, + long_token_swap_path, + short_token_swap_path, + + TRY_CAST(glv_token_amount AS DOUBLE) glv_token_amount, -- index_token_decimals (glv or market?) + TRY_CAST(min_long_token_amount AS DOUBLE) min_long_token_amount, -- long_token_decimals + TRY_CAST(min_short_token_amount AS DOUBLE) min_short_token_amount, -- short_token_decimals + TRY_CAST(updated_at_time AS DOUBLE) AS updated_at_time, + TRY_CAST(execution_fee AS DOUBLE) AS execution_fee, -- POWER(10, 18) + TRY_CAST(callback_gas_limit AS DOUBLE) AS callback_gas_limit, -- no decimals, keep as raw values + + TRY_CAST(should_unwrap_native_token AS BOOLEAN) AS should_unwrap_native_token, + + from_hex("key") AS "key" + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + tx_hash, + index, + contract_address, + event_name, + msg_sender, + + account, + receiver, + callback_contract, + ED.market, + glv, + ui_fee_receiver, + long_token_swap_path, + short_token_swap_path, + + glv_token_amount / POWER(10, 18) AS glv_token_amount, + min_long_token_amount / POWER(10, MD.long_token_decimals) AS min_long_token_amount, + min_short_token_amount / POWER(10, MD.short_token_decimals) AS min_short_token_amount, + CASE + WHEN updated_at_time = 0 THEN NULL + ELSE updated_at_time + END AS updated_at_time, + execution_fee / POWER(10, 18) AS execution_fee, + callback_gas_limit, + + should_unwrap_native_token, + "key" + + FROM event_data AS ED + LEFT JOIN {{ ref('gmx_v2_avalanche_c_markets_data') }} AS MD + ON ED.market = MD.market +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_glv_withdrawal_executed.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_glv_withdrawal_executed.sql new file mode 100644 index 00000000000..b1d43e8e510 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_glv_withdrawal_executed.sql @@ -0,0 +1,149 @@ +{{ + config( + schema = 'gmx_v2_avalanche_c', + alias = 'glv_withdrawal_executed', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'GlvWithdrawalExecuted' -%} +{%- set blockchain_name = 'avalanche_c' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM bytes32_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'account' THEN value END) AS account, + MAX(CASE WHEN key_name = 'key' THEN value END) AS "key" + + FROM + combined + GROUP BY tx_hash, index +) + +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(account) AS account, + from_hex("key") AS "key" + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_keeper_execution_fee.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_keeper_execution_fee.sql new file mode 100644 index 00000000000..69ea1e6771f --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_keeper_execution_fee.sql @@ -0,0 +1,147 @@ +{{ + config( + schema = 'gmx_v2_avalanche_c', + alias = 'keeper_execution_fee', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'KeeperExecutionFee' -%} +{%- set blockchain_name = 'avalanche_c' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + MAX(CASE WHEN key_name = 'keeper' THEN value END) AS keeper, + MAX(CASE WHEN key_name = 'executionFeeAmount' THEN value END) AS execution_fee_amount + FROM + combined + GROUP BY tx_hash, index +) + +-- full data +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(EDP.keeper) AS keeper, + CAST(EDP.execution_fee_amount AS DOUBLE) / POWER(10, 18) AS execution_fee_amount + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_market_created.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_market_created.sql index 9979092e3ef..93ac2def471 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_market_created.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_market_created.sql @@ -49,7 +49,7 @@ WITH evt_data_1 AS ( , evt_data AS ( SELECT * FROM evt_data_1 - UNION + UNION ALL SELECT * FROM evt_data_2 ) diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_open_interest_in_tokens_updated.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_open_interest_in_tokens_updated.sql new file mode 100644 index 00000000000..9f82c578bca --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_open_interest_in_tokens_updated.sql @@ -0,0 +1,187 @@ +{{ + config( + schema = 'gmx_v2_avalanche_c', + alias = 'open_interest_in_tokens_updated', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'OpenInterestInTokensUpdated' -%} +{%- set blockchain_name = 'avalanche_c' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items, + json_query(data, 'lax $.intItems' OMIT QUOTES) AS int_items, + json_query(data, 'lax $.boolItems' OMIT QUOTES) AS bool_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, int_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(int_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bool_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bool_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed + UNION ALL + SELECT * + FROM int_items_parsed + UNION ALL + SELECT * + FROM bool_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + MAX(CASE WHEN key_name = 'isLong' THEN value END) AS is_long, + MAX(CASE WHEN key_name = 'nextValue' THEN value END) AS next_value, + MAX(CASE WHEN key_name = 'market' THEN value END) AS market, + MAX(CASE WHEN key_name = 'collateralToken' THEN value END) AS collateral_token, + MAX(CASE WHEN key_name = 'delta' THEN value END) AS delta + FROM + combined + GROUP BY tx_hash, index +) + +-- full data +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(EDP.market) AS market, + from_hex(EDP.collateral_token) AS collateral_token, + CAST(EDP.is_long AS BOOLEAN) AS is_long, + CAST(EDP.next_value AS DOUBLE) / POWER(10, MD.index_token_decimals) AS next_value, + CAST(EDP.delta AS DOUBLE) / POWER(10, MD.index_token_decimals) AS delta + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index + LEFT JOIN {{ ref('gmx_v2_avalanche_c_markets_data') }} AS MD + ON from_hex(EDP.market) = MD.market +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to', 'index'] + ) +}} diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_open_interest_updated.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_open_interest_updated.sql new file mode 100644 index 00000000000..fbb392ff855 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_open_interest_updated.sql @@ -0,0 +1,187 @@ +{{ + config( + schema = 'gmx_v2_avalanche_c', + alias = 'open_interest_updated', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'OpenInterestUpdated' -%} +{%- set blockchain_name = 'avalanche_c' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items, + json_query(data, 'lax $.intItems' OMIT QUOTES) AS int_items, + json_query(data, 'lax $.boolItems' OMIT QUOTES) AS bool_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, int_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(int_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bool_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bool_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed + UNION ALL + SELECT * + FROM int_items_parsed + UNION ALL + SELECT * + FROM bool_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + MAX(CASE WHEN key_name = 'market' THEN value END) AS market, + MAX(CASE WHEN key_name = 'collateralToken' THEN value END) AS collateral_token, + MAX(CASE WHEN key_name = 'isLong' THEN value END) AS is_long, + MAX(CASE WHEN key_name = 'delta' THEN value END) AS delta, + MAX(CASE WHEN key_name = 'nextValue' THEN value END) AS next_value + FROM + combined + GROUP BY tx_hash, index +) + +-- full data +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(market) AS market, + from_hex(collateral_token) AS collateral_token, + TRY_CAST(is_long AS BOOLEAN) AS is_long, + TRY_CAST(delta AS DOUBLE) / POWER(10, 30) AS delta, + TRY_CAST(next_value AS DOUBLE) / POWER(10, 30) AS next_value + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to', 'index'] + ) +}} + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_oracle_price_update.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_oracle_price_update.sql new file mode 100644 index 00000000000..0c5d6121b68 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_oracle_price_update.sql @@ -0,0 +1,157 @@ +{{ + config( + schema = 'gmx_v2_avalanche_c', + alias = 'oracle_price_update', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'OraclePriceUpdate' -%} +{%- set blockchain_name = 'avalanche_c' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% else %} + AND evt_block_time > DATE '2023-08-01' + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% else %} + AND evt_block_time > DATE '2023-08-01' + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items + FROM + evt_data +) +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed +) +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + MAX(CASE WHEN key_name = 'token' THEN value END) AS token, + MAX(CASE WHEN key_name = 'provider' THEN value END) AS provider, + MAX(CASE WHEN key_name = 'minPrice' THEN value END) AS min_price, + MAX(CASE WHEN key_name = 'maxPrice' THEN value END) AS max_price, + MAX(CASE WHEN key_name = 'timestamp' THEN value END) AS "timestamp" + FROM + combined + GROUP BY tx_hash, index +) + +-- full data +, full_data AS ( + SELECT + ED.blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + ED.tx_hash, + ED.index, + ED.contract_address, + event_name, + msg_sender, + + from_hex(token) AS token, + from_hex(provider) AS provider, + TRY_CAST(min_price AS DOUBLE) / POWER(10, 30 - ERC20.decimals) AS min_price, + TRY_CAST(max_price AS DOUBLE) / POWER(10, 30 - ERC20.decimals) AS max_price, + CASE + WHEN TRY_CAST("timestamp" AS DOUBLE) = 0 THEN NULL + ELSE TRY_CAST("timestamp" AS DOUBLE) + END AS "timestamp" + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index + LEFT JOIN {{ ref('gmx_v2_avalanche_c_erc20') }} AS ERC20 + ON from_hex(EDP.token) = ERC20.contract_address +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to', 'index'] + ) +}} + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_cancelled.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_cancelled.sql index ce8206ba85c..b38eb38e5cc 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_cancelled.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_cancelled.sql @@ -2,7 +2,9 @@ config( schema = 'gmx_v2_avalanche_c', alias = 'order_cancelled', - materialized = 'table' + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' ) }} @@ -23,7 +25,9 @@ WITH evt_data_1 AS ( msgSender AS msg_sender FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog1')}} WHERE eventName = '{{ event_name }}' - ORDER BY evt_block_time ASC + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} ) , evt_data_2 AS ( @@ -40,14 +44,16 @@ WITH evt_data_1 AS ( msgSender AS msg_sender FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog2')}} WHERE eventName = '{{ event_name }}' - ORDER BY evt_block_time ASC + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} ) -- unite 2 tables , evt_data AS ( SELECT * FROM evt_data_1 - UNION + UNION ALL SELECT * FROM evt_data_2 ) diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_created.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_created.sql index cec7a4baf06..9822561b7bc 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_created.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_created.sql @@ -2,7 +2,9 @@ config( schema = 'gmx_v2_avalanche_c', alias = 'order_created', - materialized = 'table' + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' ) }} @@ -23,7 +25,9 @@ WITH evt_data_1 AS ( msgSender AS msg_sender FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog1')}} WHERE eventName = '{{ event_name }}' - ORDER BY evt_block_time ASC + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} ) , evt_data_2 AS ( @@ -40,7 +44,9 @@ WITH evt_data_1 AS ( msgSender AS msg_sender FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog2')}} WHERE eventName = '{{ event_name }}' - ORDER BY evt_block_time ASC + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} ) -- unite 2 tables @@ -171,10 +177,11 @@ WITH evt_data_1 AS ( MAX(CASE WHEN key_name = 'updatedAtBlock' THEN value END) AS updated_at_block, MAX(CASE WHEN key_name = 'updatedAtTime' THEN value END) AS updated_at_time, + MAX(CASE WHEN key_name = 'validFromTime' THEN value END) AS valid_from_time, MAX(CASE WHEN key_name = 'isLong' THEN value END) AS is_long, MAX(CASE WHEN key_name = 'shouldUnwrapNativeToken' THEN value END) AS should_unwrap_native_token, - MAX(CASE WHEN key_name = 'isFrozen' THEN value END) AS is_frozen, + MAX(CASE WHEN key_name = 'autoCancel' THEN value END) AS auto_cancel, MAX(CASE WHEN key_name = 'key' THEN value END) AS key FROM @@ -213,9 +220,10 @@ WITH evt_data_1 AS ( TRY_CAST(min_output_amount AS DOUBLE) AS min_output_amount, TRY_CAST(updated_at_block AS BIGINT) AS updated_at_block, TRY_CAST(updated_at_time AS DOUBLE) AS updated_at_time, + TRY_CAST(valid_from_time AS DOUBLE) AS valid_from_time, TRY_CAST(is_long AS BOOLEAN) AS is_long, TRY_CAST(should_unwrap_native_token AS BOOLEAN) AS should_unwrap_native_token, - TRY_CAST(is_frozen AS BOOLEAN) AS is_frozen, + TRY_CAST(auto_cancel AS BOOLEAN) AS auto_cancel, from_hex(key) AS key FROM evt_data AS ED @@ -272,7 +280,7 @@ WITH evt_data_1 AS ( END AS trigger_price, acceptable_price AS acceptable_price_raw, CASE - WHEN index_token_decimals IS NULL THEN NULL + WHEN index_token_decimals IS NULL THEN NULL ELSE acceptable_price / POWER(10, 30 - index_token_decimals) END AS acceptable_price, execution_fee / POWER(10, 18) AS execution_fee, @@ -284,9 +292,14 @@ WITH evt_data_1 AS ( WHEN updated_at_time = 0 THEN NULL ELSE updated_at_time END AS updated_at_time, + valid_from_time, is_long, should_unwrap_native_token, - is_frozen, + + CASE + WHEN auto_cancel IS NULL THEN false + ELSE auto_cancel + END AS auto_cancel, key FROM event_data AS ED diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_executed.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_executed.sql index 677afcce2bd..5a28248d8c1 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_executed.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_executed.sql @@ -2,7 +2,9 @@ config( schema = 'gmx_v2_avalanche_c', alias = 'order_executed', - materialized = 'table' + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' ) }} @@ -23,7 +25,9 @@ WITH evt_data_1 AS ( msgSender AS msg_sender FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog1')}} WHERE eventName = '{{ event_name }}' - ORDER BY evt_block_time ASC + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} ) , evt_data_2 AS ( @@ -40,14 +44,16 @@ WITH evt_data_1 AS ( msgSender AS msg_sender FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog2')}} WHERE eventName = '{{ event_name }}' - ORDER BY evt_block_time ASC + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} ) -- unite 2 tables , evt_data AS ( SELECT * FROM evt_data_1 - UNION + UNION ALL SELECT * FROM evt_data_2 ) diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_frozen.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_frozen.sql index 0de9538f4a7..9651369a61e 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_frozen.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_frozen.sql @@ -2,7 +2,9 @@ config( schema = 'gmx_v2_avalanche_c', alias = 'order_frozen', - materialized = 'table' + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' ) }} @@ -23,7 +25,9 @@ WITH evt_data_1 AS ( msgSender AS msg_sender FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog1')}} WHERE eventName = '{{ event_name }}' - ORDER BY evt_block_time ASC + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} ) , evt_data_2 AS ( @@ -40,14 +44,16 @@ WITH evt_data_1 AS ( msgSender AS msg_sender FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog2')}} WHERE eventName = '{{ event_name }}' - ORDER BY evt_block_time ASC + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} ) -- unite 2 tables , evt_data AS ( SELECT * FROM evt_data_1 - UNION + UNION ALL SELECT * FROM evt_data_2 ) diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_updated.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_updated.sql index 5f0b28869f7..76d244245ce 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_updated.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_updated.sql @@ -2,7 +2,9 @@ config( schema = 'gmx_v2_avalanche_c', alias = 'order_updated', - materialized = 'table' + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' ) }} @@ -23,7 +25,9 @@ WITH evt_data_1 AS ( msgSender AS msg_sender FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog1')}} WHERE eventName = '{{ event_name }}' - ORDER BY evt_block_time ASC + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} ) , evt_data_2 AS ( @@ -40,7 +44,9 @@ WITH evt_data_1 AS ( msgSender AS msg_sender FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog2')}} WHERE eventName = '{{ event_name }}' - ORDER BY evt_block_time ASC + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} ) -- unite 2 tables @@ -58,7 +64,8 @@ WITH evt_data_1 AS ( index, json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items, json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, - json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items, + json_query(data, 'lax $.boolItems' OMIT QUOTES) AS bool_items FROM evt_data ) @@ -102,6 +109,19 @@ WITH evt_data_1 AS ( ) AS t(item) ) +, bool_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bool_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + , combined AS ( SELECT * FROM bytes32_items_parsed @@ -111,6 +131,9 @@ WITH evt_data_1 AS ( UNION ALL SELECT * FROM uint_items_parsed + UNION ALL + SELECT * + FROM bool_items_parsed ) , evt_data_parsed AS ( @@ -123,7 +146,9 @@ WITH evt_data_1 AS ( MAX(CASE WHEN key_name = 'acceptablePrice' THEN value END) AS acceptable_price, MAX(CASE WHEN key_name = 'triggerPrice' THEN value END) AS trigger_price, MAX(CASE WHEN key_name = 'minOutputAmount' THEN value END) AS min_output_amount, - MAX(CASE WHEN key_name = 'updatedAtTime' THEN value END) AS updated_at_time + MAX(CASE WHEN key_name = 'updatedAtTime' THEN value END) AS updated_at_time, + MAX(CASE WHEN key_name = 'validFromTime' THEN value END) AS valid_from_time, + MAX(CASE WHEN key_name = 'autoCancel' THEN value END) AS auto_cancel FROM combined GROUP BY tx_hash, index @@ -147,7 +172,9 @@ WITH evt_data_1 AS ( TRY_CAST(acceptable_price AS DOUBLE) AS acceptable_price, TRY_CAST(trigger_price AS DOUBLE) AS trigger_price, TRY_CAST(min_output_amount AS DOUBLE) AS min_output_amount, - TRY_CAST(updated_at_time AS DOUBLE) AS updated_at_time + TRY_CAST(updated_at_time AS DOUBLE) AS updated_at_time, + TRY_CAST(valid_from_time AS DOUBLE) AS valid_from_time, + TRY_CAST(auto_cancel AS BOOLEAN) AS auto_cancel FROM evt_data AS ED LEFT JOIN evt_data_parsed AS EDP @@ -186,7 +213,9 @@ WITH evt_data_1 AS ( CASE WHEN ED.updated_at_time = 0 THEN NULL ELSE ED.updated_at_time - END AS updated_at_time + END AS updated_at_time, + ED.valid_from_time, + ED.auto_cancel FROM event_data AS ED LEFT JOIN {{ ref('gmx_v2_avalanche_c_order_created') }} AS OC diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_pool_amount_updated.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_pool_amount_updated.sql new file mode 100644 index 00000000000..8f2ee6167cd --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_pool_amount_updated.sql @@ -0,0 +1,165 @@ +{{ + config( + schema = 'gmx_v2_avalanche_c', + alias = 'pool_amount_updated', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'PoolAmountUpdated' -%} +{%- set blockchain_name = 'avalanche_c' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items, + json_query(data, 'lax $.intItems' OMIT QUOTES) AS int_items + FROM + evt_data +) +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) +, int_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(int_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed + UNION ALL + SELECT * + FROM int_items_parsed +) +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + MAX(CASE WHEN key_name = 'market' THEN value END) AS market, + MAX(CASE WHEN key_name = 'token' THEN value END) AS token, + MAX(CASE WHEN key_name = 'delta' THEN value END) AS delta, + MAX(CASE WHEN key_name = 'nextValue' THEN value END) AS next_value + FROM + combined + GROUP BY tx_hash, index +) + +-- full data +, full_data AS ( + SELECT + ED.blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + ED.tx_hash, + ED.index, + ED.contract_address, + event_name, + msg_sender, + + from_hex(market) AS market, + from_hex(token) AS token, + TRY_CAST(next_value AS DOUBLE) / POWER(10, ERC20.decimals) AS next_value, + TRY_CAST(delta AS DOUBLE) / POWER(10, ERC20.decimals) AS delta + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index + LEFT JOIN {{ ref('gmx_v2_avalanche_c_erc20') }} AS ERC20 + ON from_hex(EDP.token) = ERC20.contract_address +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to', 'index'] + ) +}} + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_position_decrease.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_position_decrease.sql index e82cce31001..9870ebd74fc 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_position_decrease.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_position_decrease.sql @@ -2,7 +2,9 @@ config( schema = 'gmx_v2_avalanche_c', alias = 'position_decrease', - materialized = 'table' + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' ) }} @@ -23,7 +25,9 @@ WITH evt_data_1 AS ( msgSender AS msg_sender FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog1')}} WHERE eventName = '{{ event_name }}' - ORDER BY evt_block_time ASC + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} ) , evt_data_2 AS ( @@ -40,14 +44,16 @@ WITH evt_data_1 AS ( msgSender AS msg_sender FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog2')}} WHERE eventName = '{{ event_name }}' - ORDER BY evt_block_time ASC + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} ) -- unite 2 tables , evt_data AS ( SELECT * FROM evt_data_1 - UNION + UNION ALL SELECT * FROM evt_data_2 ) diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_position_fees_collected.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_position_fees_collected.sql index 2241dfb0e56..d138becbf80 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_position_fees_collected.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_position_fees_collected.sql @@ -2,7 +2,9 @@ config( schema = 'gmx_v2_avalanche_c', alias = 'position_fees_collected', - materialized = 'table' + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' ) }} @@ -23,7 +25,9 @@ WITH evt_data_1 AS ( msgSender AS msg_sender FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog1')}} WHERE eventName = '{{ event_name }}' - ORDER BY evt_block_time ASC + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} ) , evt_data_2 AS ( @@ -40,14 +44,16 @@ WITH evt_data_1 AS ( msgSender AS msg_sender FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog2')}} WHERE eventName = '{{ event_name }}' - ORDER BY evt_block_time ASC + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} ) -- unite 2 tables , evt_data AS ( SELECT * FROM evt_data_1 - UNION + UNION ALL SELECT * FROM evt_data_2 ) @@ -135,19 +141,19 @@ WITH evt_data_1 AS ( tx_hash, index, + MAX(CASE WHEN key_name = 'orderKey' THEN value END) AS order_key, + MAX(CASE WHEN key_name = 'positionKey' THEN value END) AS position_key, + MAX(CASE WHEN key_name = 'referralCode' THEN value END) AS referral_code, + MAX(CASE WHEN key_name = 'market' THEN value END) AS market, MAX(CASE WHEN key_name = 'collateralToken' THEN value END) AS collateral_token, MAX(CASE WHEN key_name = 'affiliate' THEN value END) AS affiliate, MAX(CASE WHEN key_name = 'trader' THEN value END) AS trader, MAX(CASE WHEN key_name = 'uiFeeReceiver' THEN value END) AS ui_fee_receiver, + MAX(CASE WHEN key_name = 'collateralTokenPrice.min' THEN value END) AS collateral_token_price_min, MAX(CASE WHEN key_name = 'collateralTokenPrice.max' THEN value END) AS collateral_token_price_max, MAX(CASE WHEN key_name = 'tradeSizeUsd' THEN value END) AS trade_size_usd, - MAX(CASE WHEN key_name = 'totalRebateFactor' THEN value END) AS total_rebate_factor, - MAX(CASE WHEN key_name = 'traderDiscountFactor' THEN value END) AS trader_discount_factor, - MAX(CASE WHEN key_name = 'totalRebateAmount' THEN value END) AS total_rebate_amount, - MAX(CASE WHEN key_name = 'traderDiscountAmount' THEN value END) AS trader_discount_amount, - MAX(CASE WHEN key_name = 'affiliateRewardAmount' THEN value END) AS affiliate_reward_amount, MAX(CASE WHEN key_name = 'fundingFeeAmount' THEN value END) AS funding_fee_amount, MAX(CASE WHEN key_name = 'claimableLongTokenAmount' THEN value END) AS claimable_long_token_amount, MAX(CASE WHEN key_name = 'claimableShortTokenAmount' THEN value END) AS claimable_short_token_amount, @@ -168,10 +174,28 @@ WITH evt_data_1 AS ( MAX(CASE WHEN key_name = 'totalCostAmount' THEN value END) AS total_cost_amount, MAX(CASE WHEN key_name = 'uiFeeReceiverFactor' THEN value END) AS ui_fee_receiver_factor, MAX(CASE WHEN key_name = 'uiFeeAmount' THEN value END) AS ui_fee_amount, - MAX(CASE WHEN key_name = 'isIncrease' THEN value END) AS is_increase, - MAX(CASE WHEN key_name = 'orderKey' THEN value END) AS order_key, - MAX(CASE WHEN key_name = 'positionKey' THEN value END) AS position_key, - MAX(CASE WHEN key_name = 'referralCode' THEN value END) AS referral_code + + MAX(CASE WHEN key_name = 'totalRebateFactor' THEN value END) AS total_rebate_factor, + MAX(CASE WHEN key_name = 'traderDiscountFactor' THEN value END) AS trader_discount_factor, + MAX(CASE WHEN key_name = 'totalRebateAmount' THEN value END) AS total_rebate_amount, + MAX(CASE WHEN key_name = 'traderDiscountAmount' THEN value END) AS trader_discount_amount, + MAX(CASE WHEN key_name = 'affiliateRewardAmount' THEN value END) AS affiliate_reward_amount, + + MAX(CASE WHEN key_name = 'referral.totalRebateFactor' THEN value END) AS referral_total_rebate_factor, + MAX(CASE WHEN key_name = 'referral.adjustedAffiliateRewardFactor' THEN value END) AS referral_adjusted_affiliate_reward_factor, + MAX(CASE WHEN key_name = 'referral.traderDiscountFactor' THEN value END) AS referral_trader_discount_factor, + MAX(CASE WHEN key_name = 'referral.totalRebateAmount' THEN value END) AS referral_total_rebate_amount, + MAX(CASE WHEN key_name = 'referral.traderDiscountAmount' THEN value END) AS referral_trader_discount_amount, + MAX(CASE WHEN key_name = 'referral.affiliateRewardAmount' THEN value END) AS referral_affiliate_reward_amount, + + MAX(CASE WHEN key_name = 'pro.traderDiscountFactor' THEN value END) AS pro_trader_discount_factor, + MAX(CASE WHEN key_name = 'pro.traderDiscountAmount' THEN value END) AS pro_trader_discount_amount, + + MAX(CASE WHEN key_name = 'liquidationFeeAmount' THEN value END) AS liquidation_fee_amount, + MAX(CASE WHEN key_name = 'liquidationFeeReceiverFactor' THEN value END) AS liquidation_fee_receiver_factor, + MAX(CASE WHEN key_name = 'liquidationFeeAmountForFeeReceiver' THEN value END) AS liquidation_fee_amount_for_fee_receiver, + + MAX(CASE WHEN key_name = 'isIncrease' THEN value END) AS is_increase FROM combined @@ -190,19 +214,19 @@ WITH evt_data_1 AS ( event_name, msg_sender, + from_hex(order_key) AS order_key, + from_hex(position_key) AS position_key, + from_hex(referral_code) AS referral_code, + from_hex(market) AS market, from_hex(collateral_token) AS collateral_token, from_hex(affiliate) AS affiliate, from_hex(trader) AS trader, from_hex(ui_fee_receiver) AS ui_fee_receiver, + TRY_CAST(collateral_token_price_min AS DOUBLE) AS collateral_token_price_min, TRY_CAST(collateral_token_price_max AS DOUBLE) AS collateral_token_price_max, TRY_CAST(trade_size_usd AS DOUBLE) AS trade_size_usd, - TRY_CAST(total_rebate_factor AS DOUBLE) AS total_rebate_factor, - TRY_CAST(trader_discount_factor AS DOUBLE) AS trader_discount_factor, - TRY_CAST(total_rebate_amount AS DOUBLE) AS total_rebate_amount, - TRY_CAST(trader_discount_amount AS DOUBLE) AS trader_discount_amount, - TRY_CAST(affiliate_reward_amount AS DOUBLE) AS affiliate_reward_amount, TRY_CAST(funding_fee_amount AS DOUBLE) AS funding_fee_amount, TRY_CAST(claimable_long_token_amount AS DOUBLE) AS claimable_long_token_amount, TRY_CAST(claimable_short_token_amount AS DOUBLE) AS claimable_short_token_amount, @@ -223,11 +247,29 @@ WITH evt_data_1 AS ( TRY_CAST(total_cost_amount AS DOUBLE) AS total_cost_amount, TRY_CAST(ui_fee_receiver_factor AS DOUBLE) AS ui_fee_receiver_factor, TRY_CAST(ui_fee_amount AS DOUBLE) AS ui_fee_amount, - TRY_CAST(is_increase AS BOOLEAN) AS is_increase, - from_hex(order_key) AS order_key, - from_hex(position_key) AS position_key, - from_hex(referral_code) AS referral_code - + + TRY_CAST(total_rebate_factor AS DOUBLE) AS total_rebate_factor, + TRY_CAST(trader_discount_factor AS DOUBLE) AS trader_discount_factor, + TRY_CAST(total_rebate_amount AS DOUBLE) AS total_rebate_amount, + TRY_CAST(trader_discount_amount AS DOUBLE) AS trader_discount_amount, + TRY_CAST(affiliate_reward_amount AS DOUBLE) AS affiliate_reward_amount, + + TRY_CAST(referral_total_rebate_factor AS DOUBLE) AS referral_total_rebate_factor, + TRY_CAST(referral_adjusted_affiliate_reward_factor AS DOUBLE) AS referral_adjusted_affiliate_reward_factor, + TRY_CAST(referral_trader_discount_factor AS DOUBLE) AS referral_trader_discount_factor, + TRY_CAST(referral_total_rebate_amount AS DOUBLE) AS referral_total_rebate_amount, + TRY_CAST(referral_trader_discount_amount AS DOUBLE) AS referral_trader_discount_amount, + TRY_CAST(referral_affiliate_reward_amount AS DOUBLE) AS referral_affiliate_reward_amount, + + TRY_CAST(pro_trader_discount_factor AS DOUBLE) AS pro_trader_discount_factor, + TRY_CAST(pro_trader_discount_amount AS DOUBLE) AS pro_trader_discount_amount, + + TRY_CAST(liquidation_fee_amount AS DOUBLE) AS liquidation_fee_amount, + TRY_CAST(liquidation_fee_receiver_factor AS DOUBLE) AS liquidation_fee_receiver_factor, + TRY_CAST(liquidation_fee_amount_for_fee_receiver AS DOUBLE) AS liquidation_fee_amount_for_fee_receiver, + + TRY_CAST(is_increase AS BOOLEAN) AS is_increase + FROM evt_data AS ED LEFT JOIN evt_data_parsed AS EDP ON ED.tx_hash = EDP.tx_hash @@ -247,6 +289,10 @@ WITH evt_data_1 AS ( event_name, msg_sender, + order_key, + position_key, + referral_code, + ED.market AS market, ED.collateral_token, affiliate, @@ -255,12 +301,7 @@ WITH evt_data_1 AS ( collateral_token_price_min / POWER(10, 30 - collateral_token_decimals) AS collateral_token_price_min, collateral_token_price_max / POWER(10, 30 - collateral_token_decimals) AS collateral_token_price_max, - trade_size_usd / POWER(10, 30) AS trade_size_usd, - total_rebate_factor / POWER(10, 30) AS total_rebate_factor, - trader_discount_factor / POWER(10, 30) AS trader_discount_factor, - total_rebate_amount / POWER(10, collateral_token_decimals) AS total_rebate_amount, - trader_discount_amount / POWER(10, collateral_token_decimals) AS trader_discount_amount, - affiliate_reward_amount / POWER(10, collateral_token_decimals) AS affiliate_reward_amount, + trade_size_usd / POWER(10, 30) AS trade_size_usd, funding_fee_amount / POWER(10, collateral_token_decimals + 15) AS funding_fee_amount, claimable_long_token_amount / POWER(10, long_token_decimals + 15) AS claimable_long_token_amount, claimable_short_token_amount / POWER(10, short_token_decimals + 15) AS claimable_short_token_amount, @@ -281,11 +322,29 @@ WITH evt_data_1 AS ( total_cost_amount / POWER(10, collateral_token_decimals) AS total_cost_amount, ui_fee_receiver_factor / POWER(10, 30) AS ui_fee_receiver_factor, ui_fee_amount / POWER(10, collateral_token_decimals) AS ui_fee_amount, - is_increase, - order_key, - position_key, - referral_code + + total_rebate_factor / POWER(10, 30) AS total_rebate_factor, + trader_discount_factor / POWER(10, 30) AS trader_discount_factor, + total_rebate_amount / POWER(10, collateral_token_decimals) AS total_rebate_amount, + trader_discount_amount / POWER(10, collateral_token_decimals) AS trader_discount_amount, + affiliate_reward_amount / POWER(10, collateral_token_decimals) AS affiliate_reward_amount, + + referral_total_rebate_factor / POWER(10, 30) AS referral_total_rebate_factor, + referral_adjusted_affiliate_reward_factor / POWER(10, 30) AS referral_adjusted_affiliate_reward_factor, + referral_trader_discount_factor / POWER(10, 30) AS referral_trader_discount_factor, + referral_total_rebate_amount / POWER(10, collateral_token_decimals) AS referral_total_rebate_amount, + referral_trader_discount_amount / POWER(10, collateral_token_decimals) AS referral_trader_discount_amount, + referral_affiliate_reward_amount / POWER(10, collateral_token_decimals) AS referral_affiliate_reward_amount, + pro_trader_discount_factor / POWER(10, 30) AS pro_trader_discount_factor, + pro_trader_discount_amount / POWER(10, collateral_token_decimals) AS pro_trader_discount_amount, + + liquidation_fee_amount / POWER(10, collateral_token_decimals) AS liquidation_fee_amount, + liquidation_fee_receiver_factor / POWER(10, 30) AS liquidation_fee_receiver_factor, + liquidation_fee_amount_for_fee_receiver / POWER(10, collateral_token_decimals) AS liquidation_fee_amount_for_fee_receiver, + + is_increase + FROM event_data AS ED LEFT JOIN {{ ref('gmx_v2_avalanche_c_markets_data') }} AS MD ON ED.market = MD.market @@ -293,11 +352,100 @@ WITH evt_data_1 AS ( ON ED.collateral_token = CTD.collateral_token ) +, full_data_2 AS ( + SELECT + blockchain, + block_time, + block_date, + block_number, + tx_hash, + index, + contract_address, + event_name, + msg_sender, + + order_key, + position_key, + referral_code, + + market, + collateral_token, + affiliate, + trader, + ui_fee_receiver, + + collateral_token_price_min, + collateral_token_price_max, + trade_size_usd, + funding_fee_amount, + claimable_long_token_amount, + claimable_short_token_amount, + latest_funding_fee_amount_per_size, + latest_long_token_claimable_funding_amount_per_size, + latest_short_token_claimable_funding_amount_per_size, + borrowing_fee_usd, + borrowing_fee_amount, + borrowing_fee_receiver_factor, + borrowing_fee_amount_for_fee_receiver, + position_fee_factor, + protocol_fee_amount, + position_fee_receiver_factor, + fee_receiver_amount, + fee_amount_for_pool, + position_fee_amount_for_pool, + position_fee_amount, + total_cost_amount, + ui_fee_receiver_factor, + ui_fee_amount, + + CASE + WHEN total_rebate_factor IS NOT NULL THEN total_rebate_factor + WHEN referral_total_rebate_factor IS NOT NULL THEN referral_total_rebate_factor + ELSE 0 + END AS referral_total_rebate_factor, + CASE + WHEN total_rebate_amount IS NOT NULL THEN total_rebate_amount + WHEN referral_total_rebate_amount IS NOT NULL THEN referral_total_rebate_amount + ELSE 0 + END AS referral_total_rebate_amount, + CASE + WHEN referral_trader_discount_factor IS NOT NULL THEN referral_trader_discount_factor + WHEN trader_discount_factor IS NOT NULL THEN trader_discount_factor * total_rebate_factor + ELSE 0 + END AS referral_trader_discount_factor, + CASE + WHEN referral_adjusted_affiliate_reward_factor IS NOT NULL THEN referral_adjusted_affiliate_reward_factor + WHEN affiliate_reward_amount IS NOT NULL THEN affiliate_reward_amount + ELSE 0 + END AS referral_adjusted_affiliate_reward_factor, + CASE + WHEN referral_affiliate_reward_amount IS NOT NULL THEN referral_affiliate_reward_amount + WHEN affiliate_reward_amount IS NOT NULL THEN affiliate_reward_amount + ELSE 0 + END AS referral_affiliate_reward_amount, + CASE + WHEN referral_trader_discount_amount IS NOT NULL THEN referral_trader_discount_amount + WHEN trader_discount_amount IS NOT NULL THEN trader_discount_amount + ELSE 0 + END AS referral_trader_discount_amount, + + COALESCE(pro_trader_discount_factor, 0) AS pro_trader_discount_factor, + COALESCE(pro_trader_discount_amount, 0) AS pro_trader_discount_amount, + + COALESCE(liquidation_fee_amount, 0) AS liquidation_fee_amount, + COALESCE(liquidation_fee_receiver_factor, 0) AS liquidation_fee_receiver_factor, + COALESCE(liquidation_fee_amount_for_fee_receiver, 0) AS liquidation_fee_amount_for_fee_receiver, + + is_increase + + FROM full_data +) + --can be removed once decoded tables are fully denormalized {{ add_tx_columns( - model_cte = 'full_data' + model_cte = 'full_data_2' , blockchain = blockchain_name , columns = ['from', 'to'] ) -}} +}} \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_position_fees_info.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_position_fees_info.sql index 0e71e6ccfdf..092bf293fdf 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_position_fees_info.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_position_fees_info.sql @@ -2,7 +2,9 @@ config( schema = 'gmx_v2_avalanche_c', alias = 'position_fees_info', - materialized = 'table' + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' ) }} @@ -23,7 +25,9 @@ WITH evt_data_1 AS ( msgSender AS msg_sender FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog1')}} WHERE eventName = '{{ event_name }}' - ORDER BY evt_block_time ASC + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} ) , evt_data_2 AS ( @@ -40,14 +44,16 @@ WITH evt_data_1 AS ( msgSender AS msg_sender FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog2')}} WHERE eventName = '{{ event_name }}' - ORDER BY evt_block_time ASC + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} ) -- unite 2 tables , evt_data AS ( SELECT * FROM evt_data_1 - UNION + UNION ALL SELECT * FROM evt_data_2 ) @@ -135,19 +141,20 @@ WITH evt_data_1 AS ( tx_hash, index, + MAX(CASE WHEN key_name = 'orderKey' THEN value END) AS order_key, + MAX(CASE WHEN key_name = 'positionKey' THEN value END) AS position_key, + MAX(CASE WHEN key_name = 'referralCode' THEN value END) AS referral_code, + MAX(CASE WHEN key_name = 'market' THEN value END) AS market, MAX(CASE WHEN key_name = 'collateralToken' THEN value END) AS collateral_token, MAX(CASE WHEN key_name = 'affiliate' THEN value END) AS affiliate, MAX(CASE WHEN key_name = 'trader' THEN value END) AS trader, MAX(CASE WHEN key_name = 'uiFeeReceiver' THEN value END) AS ui_fee_receiver, + MAX(CASE WHEN key_name = 'collateralTokenPrice.min' THEN value END) AS collateral_token_price_min, MAX(CASE WHEN key_name = 'collateralTokenPrice.max' THEN value END) AS collateral_token_price_max, MAX(CASE WHEN key_name = 'tradeSizeUsd' THEN value END) AS trade_size_usd, - MAX(CASE WHEN key_name = 'totalRebateFactor' THEN value END) AS total_rebate_factor, - MAX(CASE WHEN key_name = 'traderDiscountFactor' THEN value END) AS trader_discount_factor, - MAX(CASE WHEN key_name = 'totalRebateAmount' THEN value END) AS total_rebate_amount, - MAX(CASE WHEN key_name = 'traderDiscountAmount' THEN value END) AS trader_discount_amount, - MAX(CASE WHEN key_name = 'affiliateRewardAmount' THEN value END) AS affiliate_reward_amount, + MAX(CASE WHEN key_name = 'fundingFeeAmount' THEN value END) AS funding_fee_amount, MAX(CASE WHEN key_name = 'claimableLongTokenAmount' THEN value END) AS claimable_long_token_amount, MAX(CASE WHEN key_name = 'claimableShortTokenAmount' THEN value END) AS claimable_short_token_amount, @@ -168,10 +175,28 @@ WITH evt_data_1 AS ( MAX(CASE WHEN key_name = 'totalCostAmount' THEN value END) AS total_cost_amount, MAX(CASE WHEN key_name = 'uiFeeReceiverFactor' THEN value END) AS ui_fee_receiver_factor, MAX(CASE WHEN key_name = 'uiFeeAmount' THEN value END) AS ui_fee_amount, - MAX(CASE WHEN key_name = 'isIncrease' THEN value END) AS is_increase, - MAX(CASE WHEN key_name = 'orderKey' THEN value END) AS order_key, - MAX(CASE WHEN key_name = 'positionKey' THEN value END) AS position_key, - MAX(CASE WHEN key_name = 'referralCode' THEN value END) AS referral_code + + MAX(CASE WHEN key_name = 'totalRebateFactor' THEN value END) AS total_rebate_factor, + MAX(CASE WHEN key_name = 'traderDiscountFactor' THEN value END) AS trader_discount_factor, + MAX(CASE WHEN key_name = 'totalRebateAmount' THEN value END) AS total_rebate_amount, + MAX(CASE WHEN key_name = 'traderDiscountAmount' THEN value END) AS trader_discount_amount, + MAX(CASE WHEN key_name = 'affiliateRewardAmount' THEN value END) AS affiliate_reward_amount, + + MAX(CASE WHEN key_name = 'referral.totalRebateFactor' THEN value END) AS referral_total_rebate_factor, + MAX(CASE WHEN key_name = 'referral.adjustedAffiliateRewardFactor' THEN value END) AS referral_adjusted_affiliate_reward_factor, + MAX(CASE WHEN key_name = 'referral.traderDiscountFactor' THEN value END) AS referral_trader_discount_factor, + MAX(CASE WHEN key_name = 'referral.totalRebateAmount' THEN value END) AS referral_total_rebate_amount, + MAX(CASE WHEN key_name = 'referral.traderDiscountAmount' THEN value END) AS referral_trader_discount_amount, + MAX(CASE WHEN key_name = 'referral.affiliateRewardAmount' THEN value END) AS referral_affiliate_reward_amount, + + MAX(CASE WHEN key_name = 'pro.traderDiscountFactor' THEN value END) AS pro_trader_discount_factor, + MAX(CASE WHEN key_name = 'pro.traderDiscountAmount' THEN value END) AS pro_trader_discount_amount, + + MAX(CASE WHEN key_name = 'liquidationFeeAmount' THEN value END) AS liquidation_fee_amount, + MAX(CASE WHEN key_name = 'liquidationFeeReceiverFactor' THEN value END) AS liquidation_fee_receiver_factor, + MAX(CASE WHEN key_name = 'liquidationFeeAmountForFeeReceiver' THEN value END) AS liquidation_fee_amount_for_fee_receiver, + + MAX(CASE WHEN key_name = 'isIncrease' THEN value END) AS is_increase FROM combined @@ -190,19 +215,19 @@ WITH evt_data_1 AS ( event_name, msg_sender, + from_hex(order_key) AS order_key, + from_hex(position_key) AS position_key, + from_hex(referral_code) AS referral_code, + from_hex(market) AS market, from_hex(collateral_token) AS collateral_token, from_hex(affiliate) AS affiliate, from_hex(trader) AS trader, from_hex(ui_fee_receiver) AS ui_fee_receiver, + TRY_CAST(collateral_token_price_min AS DOUBLE) AS collateral_token_price_min, TRY_CAST(collateral_token_price_max AS DOUBLE) AS collateral_token_price_max, TRY_CAST(trade_size_usd AS DOUBLE) AS trade_size_usd, - TRY_CAST(total_rebate_factor AS DOUBLE) AS total_rebate_factor, - TRY_CAST(trader_discount_factor AS DOUBLE) AS trader_discount_factor, - TRY_CAST(total_rebate_amount AS DOUBLE) AS total_rebate_amount, - TRY_CAST(trader_discount_amount AS DOUBLE) AS trader_discount_amount, - TRY_CAST(affiliate_reward_amount AS DOUBLE) AS affiliate_reward_amount, TRY_CAST(funding_fee_amount AS DOUBLE) AS funding_fee_amount, TRY_CAST(claimable_long_token_amount AS DOUBLE) AS claimable_long_token_amount, TRY_CAST(claimable_short_token_amount AS DOUBLE) AS claimable_short_token_amount, @@ -223,11 +248,29 @@ WITH evt_data_1 AS ( TRY_CAST(total_cost_amount AS DOUBLE) AS total_cost_amount, TRY_CAST(ui_fee_receiver_factor AS DOUBLE) AS ui_fee_receiver_factor, TRY_CAST(ui_fee_amount AS DOUBLE) AS ui_fee_amount, - TRY_CAST(is_increase AS BOOLEAN) AS is_increase, - from_hex(order_key) AS order_key, - from_hex(position_key) AS position_key, - from_hex(referral_code) AS referral_code - + + TRY_CAST(total_rebate_factor AS DOUBLE) AS total_rebate_factor, + TRY_CAST(trader_discount_factor AS DOUBLE) AS trader_discount_factor, + TRY_CAST(total_rebate_amount AS DOUBLE) AS total_rebate_amount, + TRY_CAST(trader_discount_amount AS DOUBLE) AS trader_discount_amount, + TRY_CAST(affiliate_reward_amount AS DOUBLE) AS affiliate_reward_amount, + + TRY_CAST(referral_total_rebate_factor AS DOUBLE) AS referral_total_rebate_factor, + TRY_CAST(referral_adjusted_affiliate_reward_factor AS DOUBLE) AS referral_adjusted_affiliate_reward_factor, + TRY_CAST(referral_trader_discount_factor AS DOUBLE) AS referral_trader_discount_factor, + TRY_CAST(referral_total_rebate_amount AS DOUBLE) AS referral_total_rebate_amount, + TRY_CAST(referral_trader_discount_amount AS DOUBLE) AS referral_trader_discount_amount, + TRY_CAST(referral_affiliate_reward_amount AS DOUBLE) AS referral_affiliate_reward_amount, + + TRY_CAST(pro_trader_discount_factor AS DOUBLE) AS pro_trader_discount_factor, + TRY_CAST(pro_trader_discount_amount AS DOUBLE) AS pro_trader_discount_amount, + + TRY_CAST(liquidation_fee_amount AS DOUBLE) AS liquidation_fee_amount, + TRY_CAST(liquidation_fee_receiver_factor AS DOUBLE) AS liquidation_fee_receiver_factor, + TRY_CAST(liquidation_fee_amount_for_fee_receiver AS DOUBLE) AS liquidation_fee_amount_for_fee_receiver, + + TRY_CAST(is_increase AS BOOLEAN) AS is_increase + FROM evt_data AS ED LEFT JOIN evt_data_parsed AS EDP ON ED.tx_hash = EDP.tx_hash @@ -247,6 +290,10 @@ WITH evt_data_1 AS ( event_name, msg_sender, + order_key, + position_key, + referral_code, + ED.market AS market, ED.collateral_token, affiliate, @@ -255,12 +302,7 @@ WITH evt_data_1 AS ( collateral_token_price_min / POWER(10, 30 - collateral_token_decimals) AS collateral_token_price_min, collateral_token_price_max / POWER(10, 30 - collateral_token_decimals) AS collateral_token_price_max, - trade_size_usd / POWER(10, 30) AS trade_size_usd, - total_rebate_factor / POWER(10, 30) AS total_rebate_factor, - trader_discount_factor / POWER(10, 30) AS trader_discount_factor, - total_rebate_amount / POWER(10, collateral_token_decimals) AS total_rebate_amount, - trader_discount_amount / POWER(10, collateral_token_decimals) AS trader_discount_amount, - affiliate_reward_amount / POWER(10, collateral_token_decimals) AS affiliate_reward_amount, + trade_size_usd / POWER(10, 30) AS trade_size_usd, funding_fee_amount / POWER(10, collateral_token_decimals + 15) AS funding_fee_amount, claimable_long_token_amount / POWER(10, long_token_decimals + 15) AS claimable_long_token_amount, claimable_short_token_amount / POWER(10, short_token_decimals + 15) AS claimable_short_token_amount, @@ -281,10 +323,28 @@ WITH evt_data_1 AS ( total_cost_amount / POWER(10, collateral_token_decimals) AS total_cost_amount, ui_fee_receiver_factor / POWER(10, 30) AS ui_fee_receiver_factor, ui_fee_amount / POWER(10, collateral_token_decimals) AS ui_fee_amount, - is_increase, - order_key, - position_key, - referral_code + + total_rebate_factor / POWER(10, 30) AS total_rebate_factor, + trader_discount_factor / POWER(10, 30) AS trader_discount_factor, + total_rebate_amount / POWER(10, collateral_token_decimals) AS total_rebate_amount, + trader_discount_amount / POWER(10, collateral_token_decimals) AS trader_discount_amount, + affiliate_reward_amount / POWER(10, collateral_token_decimals) AS affiliate_reward_amount, + + referral_total_rebate_factor / POWER(10, 30) AS referral_total_rebate_factor, + referral_adjusted_affiliate_reward_factor / POWER(10, 30) AS referral_adjusted_affiliate_reward_factor, + referral_trader_discount_factor / POWER(10, 30) AS referral_trader_discount_factor, + referral_total_rebate_amount / POWER(10, collateral_token_decimals) AS referral_total_rebate_amount, + referral_trader_discount_amount / POWER(10, collateral_token_decimals) AS referral_trader_discount_amount, + referral_affiliate_reward_amount / POWER(10, collateral_token_decimals) AS referral_affiliate_reward_amount, + + pro_trader_discount_factor / POWER(10, 30) AS pro_trader_discount_factor, + pro_trader_discount_amount / POWER(10, collateral_token_decimals) AS pro_trader_discount_amount, + + liquidation_fee_amount / POWER(10, collateral_token_decimals) AS liquidation_fee_amount, + liquidation_fee_receiver_factor / POWER(10, 30) AS liquidation_fee_receiver_factor, + liquidation_fee_amount_for_fee_receiver / POWER(10, collateral_token_decimals) AS liquidation_fee_amount_for_fee_receiver, + + is_increase FROM event_data AS ED LEFT JOIN {{ ref('gmx_v2_avalanche_c_markets_data') }} AS MD @@ -293,11 +353,100 @@ WITH evt_data_1 AS ( ON ED.collateral_token = CTD.collateral_token ) +, full_data_2 AS ( + SELECT + blockchain, + block_time, + block_date, + block_number, + tx_hash, + index, + contract_address, + event_name, + msg_sender, + + order_key, + position_key, + referral_code, + + market, + collateral_token, + affiliate, + trader, + ui_fee_receiver, + + collateral_token_price_min, + collateral_token_price_max, + trade_size_usd, + funding_fee_amount, + claimable_long_token_amount, + claimable_short_token_amount, + latest_funding_fee_amount_per_size, + latest_long_token_claimable_funding_amount_per_size, + latest_short_token_claimable_funding_amount_per_size, + borrowing_fee_usd, + borrowing_fee_amount, + borrowing_fee_receiver_factor, + borrowing_fee_amount_for_fee_receiver, + position_fee_factor, + protocol_fee_amount, + position_fee_receiver_factor, + fee_receiver_amount, + fee_amount_for_pool, + position_fee_amount_for_pool, + position_fee_amount, + total_cost_amount, + ui_fee_receiver_factor, + ui_fee_amount, + + CASE + WHEN total_rebate_factor IS NOT NULL THEN total_rebate_factor + WHEN referral_total_rebate_factor IS NOT NULL THEN referral_total_rebate_factor + ELSE 0 + END AS referral_total_rebate_factor, + CASE + WHEN total_rebate_amount IS NOT NULL THEN total_rebate_amount + WHEN referral_total_rebate_amount IS NOT NULL THEN referral_total_rebate_amount + ELSE 0 + END AS referral_total_rebate_amount, + CASE + WHEN referral_trader_discount_factor IS NOT NULL THEN referral_trader_discount_factor + WHEN trader_discount_factor IS NOT NULL THEN trader_discount_factor * total_rebate_factor + ELSE 0 + END AS referral_trader_discount_factor, + CASE + WHEN referral_adjusted_affiliate_reward_factor IS NOT NULL THEN referral_adjusted_affiliate_reward_factor + WHEN affiliate_reward_amount IS NOT NULL THEN affiliate_reward_amount + ELSE 0 + END AS referral_adjusted_affiliate_reward_factor, + CASE + WHEN referral_affiliate_reward_amount IS NOT NULL THEN referral_affiliate_reward_amount + WHEN affiliate_reward_amount IS NOT NULL THEN affiliate_reward_amount + ELSE 0 + END AS referral_affiliate_reward_amount, + CASE + WHEN referral_trader_discount_amount IS NOT NULL THEN referral_trader_discount_amount + WHEN trader_discount_amount IS NOT NULL THEN trader_discount_amount + ELSE 0 + END AS referral_trader_discount_amount, + + COALESCE(pro_trader_discount_factor, 0) AS pro_trader_discount_factor, + COALESCE(pro_trader_discount_amount, 0) AS pro_trader_discount_amount, + + COALESCE(liquidation_fee_amount, 0) AS liquidation_fee_amount, + COALESCE(liquidation_fee_receiver_factor, 0) AS liquidation_fee_receiver_factor, + COALESCE(liquidation_fee_amount_for_fee_receiver, 0) AS liquidation_fee_amount_for_fee_receiver, + + is_increase + + FROM full_data +) + --can be removed once decoded tables are fully denormalized {{ add_tx_columns( - model_cte = 'full_data' + model_cte = 'full_data_2' , blockchain = blockchain_name , columns = ['from', 'to'] ) -}} +}} \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_position_increase.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_position_increase.sql index a4b6b107a40..da0e3bde9b2 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_position_increase.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_position_increase.sql @@ -2,7 +2,9 @@ config( schema = 'gmx_v2_avalanche_c', alias = 'position_increase', - materialized = 'table' + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' ) }} @@ -23,7 +25,9 @@ WITH evt_data_1 AS ( msgSender AS msg_sender FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog1')}} WHERE eventName = '{{ event_name }}' - ORDER BY evt_block_time ASC + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} ) , evt_data_2 AS ( @@ -40,14 +44,16 @@ WITH evt_data_1 AS ( msgSender AS msg_sender FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog2')}} WHERE eventName = '{{ event_name }}' - ORDER BY evt_block_time ASC + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} ) -- unite 2 tables , evt_data AS ( SELECT * FROM evt_data_1 - UNION + UNION ALL SELECT * FROM evt_data_2 ) diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_set_uint.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_set_uint.sql new file mode 100644 index 00000000000..7d7b60cc0a9 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_set_uint.sql @@ -0,0 +1,165 @@ +{{ + config( + schema = 'gmx_v2_avalanche_c', + alias = 'set_uint', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'SetUint' -%} +{%- set blockchain_name = 'avalanche_c' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items, + json_query(data, 'lax $.bytesItems' OMIT QUOTES) AS bytes_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items + FROM + evt_data +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM bytes32_items_parsed + UNION ALL + SELECT * + FROM bytes_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + MAX(CASE WHEN key_name = 'baseKey' THEN value END) AS base_key, + MAX(CASE WHEN key_name = 'data' THEN value END) AS "data", + MAX(CASE WHEN key_name = 'value' THEN value END) AS "value" + FROM + combined + GROUP BY tx_hash, index +) + +-- full data +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(EDP.base_key) AS base_key, + from_hex(EDP."data") AS "data", + TRY_CAST(EDP."value" AS DOUBLE) AS "value_raw" + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to', 'index'] + ) +}} + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_shift_created.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_shift_created.sql new file mode 100644 index 00000000000..c0e8906b3c4 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_shift_created.sql @@ -0,0 +1,218 @@ +{{ + config( + schema = 'gmx_v2_avalanche_c', + alias = 'shift_created', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'ShiftCreated' -%} +{%- set blockchain_name = 'avalanche_c' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed + UNION ALL + SELECT * + FROM bytes32_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'account' THEN value END) AS account, + MAX(CASE WHEN key_name = 'receiver' THEN value END) AS receiver, + MAX(CASE WHEN key_name = 'callbackContract' THEN value END) AS callback_contract, + MAX(CASE WHEN key_name = 'fromMarket' THEN value END) AS from_market, + MAX(CASE WHEN key_name = 'toMarket' THEN value END) AS to_market, + + MAX(CASE WHEN key_name = 'marketTokenAmount' THEN value END) AS market_token_amount, + MAX(CASE WHEN key_name = 'minMarketTokens' THEN value END) AS min_market_tokens, + MAX(CASE WHEN key_name = 'updatedAtTime' THEN value END) AS updated_at_time, + MAX(CASE WHEN key_name = 'executionFee' THEN value END) AS execution_fee, + MAX(CASE WHEN key_name = 'callbackGasLimit' THEN value END) AS callback_gas_limit, + + MAX(CASE WHEN key_name = 'key' THEN value END) AS "key" + + FROM + combined + GROUP BY tx_hash, index +) + +, event_data AS ( + SELECT + blockchain, + block_time, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(account) AS account, + from_hex(receiver) AS receiver, + from_hex(callback_contract) AS callback_contract, + from_hex(from_market) AS from_market, + from_hex(to_market) AS to_market, + + TRY_CAST(market_token_amount AS DOUBLE) market_token_amount, + TRY_CAST(min_market_tokens AS DOUBLE) min_market_tokens, + TRY_CAST(updated_at_time AS DOUBLE) AS updated_at_time, + TRY_CAST(execution_fee AS DOUBLE) AS execution_fee, + TRY_CAST(callback_gas_limit AS DOUBLE) AS callback_gas_limit, + + from_hex("key") AS "key" + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + tx_hash, + index, + contract_address, + event_name, + msg_sender, + + account, + receiver, + callback_contract, + from_market, + to_market, + + market_token_amount / POWER(10,18) AS market_token_amount, + min_market_tokens / POWER(10,18) AS min_market_tokens, + CASE + WHEN updated_at_time = 0 THEN NULL + ELSE updated_at_time + END AS updated_at_time, + execution_fee / POWER(10, 18) AS execution_fee, + callback_gas_limit, + "key" + + FROM event_data AS ED +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_shift_executed.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_shift_executed.sql new file mode 100644 index 00000000000..7e5d1068301 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_shift_executed.sql @@ -0,0 +1,168 @@ +{{ + config( + schema = 'gmx_v2_avalanche_c', + alias = 'shift_executed', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'ShiftExecuted' -%} +{%- set blockchain_name = 'avalanche_c' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed + UNION ALL + SELECT * + FROM bytes32_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'account' THEN value END) AS account, + MAX(CASE WHEN key_name = 'receivedMarketTokens' THEN value END) AS received_market_tokens, + MAX(CASE WHEN key_name = 'key' THEN value END) AS "key" + + FROM + combined + GROUP BY tx_hash, index +) + +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(account) AS account, + TRY_CAST(received_market_tokens AS DOUBLE) / POWER(10,18) AS received_market_tokens, + from_hex("key") AS "key" + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_withdrawal_cancelled.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_withdrawal_cancelled.sql new file mode 100644 index 00000000000..5ec6ef12537 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_withdrawal_cancelled.sql @@ -0,0 +1,187 @@ +{{ + config( + schema = 'gmx_v2_avalanche_c', + alias = 'withdrawal_cancelled', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'WithdrawalCancelled' -%} +{%- set blockchain_name = 'avalanche_c' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items, + json_query(data, 'lax $.bytesItems' OMIT QUOTES) AS bytes_items, + json_query(data, 'lax $.stringItems' OMIT QUOTES) AS string_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, string_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(string_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM bytes32_items_parsed + UNION ALL + SELECT * + FROM bytes_items_parsed + UNION ALL + SELECT * + FROM string_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'account' THEN value END) AS account, + MAX(CASE WHEN key_name = 'key' THEN value END) AS "key", + MAX(CASE WHEN key_name = 'reasonBytes' THEN value END) AS reason_bytes, + MAX(CASE WHEN key_name = 'reason' THEN value END) AS reason + + FROM + combined + GROUP BY tx_hash, index +) + +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(account) AS account, + from_hex("key") AS "key", + from_hex(reason_bytes) AS reason_bytes, + reason + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_withdrawal_created.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_withdrawal_created.sql new file mode 100644 index 00000000000..f42e389f09c --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_withdrawal_created.sql @@ -0,0 +1,243 @@ +{{ + config( + schema = 'gmx_v2_avalanche_c', + alias = 'withdrawal_created', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'WithdrawalCreated' -%} +{%- set blockchain_name = 'avalanche_c' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items, + json_query(data, 'lax $.boolItems' OMIT QUOTES) AS bool_items, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items + FROM + evt_data +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bool_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bool_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed + UNION ALL + SELECT * + FROM bool_items_parsed + UNION ALL + SELECT * + FROM bytes32_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'account' THEN value END) AS account, + MAX(CASE WHEN key_name = 'receiver' THEN value END) AS receiver, + MAX(CASE WHEN key_name = 'callbackContract' THEN value END) AS callback_contract, + MAX(CASE WHEN key_name = 'market' THEN value END) AS market, + + MAX(CASE WHEN key_name = 'marketTokenAmount' THEN value END) AS market_token_amount, + MAX(CASE WHEN key_name = 'minLongTokenAmount' THEN value END) AS min_long_token_amount, + MAX(CASE WHEN key_name = 'minShortTokenAmount' THEN value END) AS min_short_token_amount, + MAX(CASE WHEN key_name = 'updatedAtTime' THEN value END) AS updated_at_time, + MAX(CASE WHEN key_name = 'executionFee' THEN value END) AS execution_fee, + MAX(CASE WHEN key_name = 'callbackGasLimit' THEN value END) AS callback_gas_limit, + + MAX(CASE WHEN key_name = 'shouldUnwrapNativeToken' THEN value END) AS should_unwrap_native_token, + + MAX(CASE WHEN key_name = 'key' THEN value END) AS "key" + + FROM + combined + GROUP BY tx_hash, index +) + +, event_data AS ( + SELECT + blockchain, + block_time, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(account) AS account, + from_hex(receiver) AS receiver, + from_hex(callback_contract) AS callback_contract, + from_hex(market) AS market, + + TRY_CAST(market_token_amount AS DOUBLE) market_token_amount, -- index_token_decimals (market?) + TRY_CAST(min_long_token_amount AS DOUBLE) min_long_token_amount, -- long_token_decimals + TRY_CAST(min_short_token_amount AS DOUBLE) min_short_token_amount, -- short_token_decimals + TRY_CAST(updated_at_time AS DOUBLE) AS updated_at_time, + TRY_CAST(execution_fee AS DOUBLE) AS execution_fee, -- POWER(10, 18) + TRY_CAST(callback_gas_limit AS DOUBLE) AS callback_gas_limit, -- no decimals, keep as raw values + + TRY_CAST(should_unwrap_native_token AS BOOLEAN) AS should_unwrap_native_token, + + from_hex("key") AS "key" + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + tx_hash, + index, + contract_address, + event_name, + msg_sender, + + account, + receiver, + callback_contract, + ED.market, + + market_token_amount / POWER(10, 18) AS market_token_amount, + min_long_token_amount / POWER(10, MD.long_token_decimals) AS min_long_token_amount, + min_short_token_amount / POWER(10, MD.short_token_decimals) AS min_short_token_amount, + CASE + WHEN updated_at_time = 0 THEN NULL + ELSE updated_at_time + END AS updated_at_time, + execution_fee / POWER(10, 18) AS execution_fee, + callback_gas_limit, + + should_unwrap_native_token, + "key" + + FROM event_data AS ED + LEFT JOIN {{ ref('gmx_v2_avalanche_c_markets_data') }} AS MD + ON ED.market = MD.market +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_withdrawal_executed.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_withdrawal_executed.sql new file mode 100644 index 00000000000..b7a17202a3d --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_withdrawal_executed.sql @@ -0,0 +1,169 @@ +{{ + config( + schema = 'gmx_v2_avalanche_c', + alias = 'withdrawal_executed', + materialized = 'incremental', + unique_key = ['tx_hash', 'index'], + incremental_strategy = 'merge' + ) +}} + +{%- set event_name = 'WithdrawalExecuted' -%} +{%- set blockchain_name = 'avalanche_c' -%} + + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION ALL + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items + FROM + evt_data +) + + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed + UNION ALL + SELECT * + FROM bytes32_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + + MAX(CASE WHEN key_name = 'account' THEN value END) AS account, + MAX(CASE WHEN key_name = 'swapPricingType' THEN value END) AS swap_pricing_type, + MAX(CASE WHEN key_name = 'key' THEN value END) AS "key" + + FROM + combined + GROUP BY tx_hash, index +) + +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(account) AS account, + TRY_CAST(swap_pricing_type AS INTEGER) AS swap_pricing_type, + from_hex("key") AS "key" + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_claimable_funding_amount_per_size_updated.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_claimable_funding_amount_per_size_updated.sql new file mode 100644 index 00000000000..234a369761b --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_claimable_funding_amount_per_size_updated.sql @@ -0,0 +1,41 @@ +{{ config( + schema='gmx_v2', + alias = 'claimable_funding_amount_per_size_updated', + post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c"]\', + "project", + "gmx", + \'["ai_data_master","gmx-io"]\') }}' + ) +}} + +{%- set chains = [ + 'arbitrum', + 'avalanche_c', +] -%} + +{%- for chain in chains -%} +SELECT + blockchain, + block_time, + block_date, + block_number, + tx_hash, + index, + contract_address, + tx_from, + tx_to, + event_name, + msg_sender, + market, + collateral_token, + delta, + "value", + is_long +FROM {{ ref('gmx_v2_' ~ chain ~ '_claimable_funding_amount_per_size_updated') }} +{% if not loop.last %} +UNION ALL +{% endif %} +{%- endfor -%} + + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_deposit_cancelled.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_deposit_cancelled.sql new file mode 100644 index 00000000000..f82c94e76db --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_deposit_cancelled.sql @@ -0,0 +1,39 @@ +{{ config( + schema='gmx_v2', + alias = 'deposit_cancelled', + post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c"]\', + "project", + "gmx", + \'["ai_data_master","gmx-io"]\') }}' + ) +}} + +{%- set chains = [ + 'arbitrum', + 'avalanche_c', +] -%} + +{%- for chain in chains -%} +SELECT + blockchain, + block_time, + block_date, + block_number, + tx_hash, + index, + contract_address, + tx_from, + tx_to, + event_name, + msg_sender, + account, + "key", + reason_bytes, + reason +FROM {{ ref('gmx_v2_' ~ chain ~ '_deposit_cancelled') }} +{% if not loop.last %} +UNION ALL +{% endif %} +{%- endfor -%} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_deposit_created.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_deposit_created.sql new file mode 100644 index 00000000000..4ee27fc9ff4 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_deposit_created.sql @@ -0,0 +1,51 @@ +{{ config( + schema='gmx_v2', + alias = 'deposit_created', + post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c"]\', + "project", + "gmx", + \'["ai_data_master","gmx-io"]\') }}' + ) +}} + +{%- set chains = [ + 'arbitrum', + 'avalanche_c', +] -%} + +{%- for chain in chains -%} +SELECT + blockchain, + block_time, + block_date, + block_number, + tx_hash, + index, + contract_address, + tx_from, + tx_to, + event_name, + msg_sender, + account, + receiver, + callback_contract, + market, + initial_long_token, + initial_short_token, + long_token_swap_path, + short_token_swap_path, + initial_long_token_amount, + initial_short_token_amount, + min_market_tokens, + updated_at_time, + execution_fee, + callback_gas_limit, + deposit_type, + should_unwrap_native_token, + "key" +FROM {{ ref('gmx_v2_' ~ chain ~ '_deposit_created') }} +{% if not loop.last %} +UNION ALL +{% endif %} +{%- endfor -%} + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_deposit_executed.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_deposit_executed.sql new file mode 100644 index 00000000000..57d159c87df --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_deposit_executed.sql @@ -0,0 +1,43 @@ +{{ config( + schema='gmx_v2', + alias = 'deposit_executed', + post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c"]\', + "project", + "gmx", + \'["ai_data_master","gmx-io"]\') }}' + ) +}} + +{%- set chains = [ + 'arbitrum', + 'avalanche_c', +] -%} + +{%- for chain in chains -%} +SELECT + blockchain, + block_time, + block_date, + block_number, + tx_hash, + index, + contract_address, + tx_from, + tx_to, + event_name, + msg_sender, + + account, + long_token_amount, + short_token_amount, + received_market_tokens, + swap_pricing_type, + "key" +FROM {{ ref('gmx_v2_' ~ chain ~ '_deposit_executed') }} +{% if not loop.last %} +UNION ALL +{% endif %} +{%- endfor -%} + + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_event_schema.yml b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_event_schema.yml index bbe86ebd151..f6783776688 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_event_schema.yml +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_event_schema.yml @@ -13,62 +13,45 @@ models: Extracts and decodes the `OrderCreated` event log data from the Arbitrum and Avalanche blockchains. This model processes log entries related to created orders, extracting key variables such as account addresses, event keys, and strings representing the reason for cancellation. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - index columns: - &blockchain name: blockchain description: The blockchain network where the event occurred - data_tests: - - not_null - &block_time name: block_time description: The timestamp of the block when the event was recorded - data_tests: - - not_null - &block_date name: block_date - description: The date extracted from the block timestamp, representing the day the block was created - data_tests: - - not_null + description: The date extracted from the block timestamp, representing the day the block was created - &block_number name: block_number description: The block number where the event is included - data_tests: - - not_null - &tx_hash name: tx_hash description: The hash of the transaction where the event was logged - data_tests: - - not_null - &index name: index description: The position of the event within the transaction - data_tests: - - not_null - &contract_address name: contract_address description: The contract address associated with the event - data_tests: - - not_null - &tx_from name: tx_from description: The originating address of the transaction, usually representing the sender - data_tests: - - not_null - &tx_to name: tx_to - description: The destination address of the transaction, representing the receiver - data_tests: - - not_null + description: The destination address of the transaction, representing the receiver - name: event_name description: The type of event recorded, always 'OrderCreated' for this model. - data_tests: - - not_null - &msg_sender name: msg_sender description: The address of the sender of the message or transaction. - data_tests: - - not_null - name: account description: The address associated with the order. - name: receiver @@ -153,11 +136,11 @@ models: - not_null - name: updated_at_block description: The block number at which the order was last updated. - data_tests: - - not_null - &updated_at_time name: updated_at_time description: The timestamp when the order was last updated. + - name: valid_from_time + description: The time from which the order becomes valid for execution. - &is_long name: is_long description: A boolean indicating whether the position is long @@ -165,8 +148,8 @@ models: - not_null - name: should_unwrap_native_token description: Boolean indicating if the native token should be unwrapped. - - name: is_frozen - description: Boolean indicating if the order is frozen. + - name: auto_cancel + description: Boolean indicating whether the order will be automatically canceled under certain conditions. - &key name: key description: The unique identifier for the order, stored as a bytes32 value. @@ -604,31 +587,6 @@ models: description: The size of the trade in USD data_tests: - not_null - - &total_rebate_factor - name: total_rebate_factor - description: The total rebate factor for the position - data_tests: - - not_null - - &trader_discount_factor - name: trader_discount_factor - description: The discount factor applied to the trader - data_tests: - - not_null - - &total_rebate_amount - name: total_rebate_amount - description: The total amount of rebate given - data_tests: - - not_null - - &trader_discount_amount - name: trader_discount_amount - description: The amount of discount given to the trader - data_tests: - - not_null - - &affiliate_reward_amount - name: affiliate_reward_amount - description: The reward amount given to the affiliate - data_tests: - - not_null - &funding_fee_amount name: funding_fee_amount description: The amount of funding fee charged @@ -637,28 +595,18 @@ models: - &claimable_long_token_amount name: claimable_long_token_amount description: The amount of long tokens claimable - data_tests: - - not_null - &claimable_short_token_amount name: claimable_short_token_amount description: The amount of short tokens claimable - data_tests: - - not_null - &latest_funding_fee_amount_per_size name: latest_funding_fee_amount_per_size description: The latest funding fee amount per size - data_tests: - - not_null - &latest_long_token_claimable_funding_amount_per_size name: latest_long_token_claimable_funding_amount_per_size description: The latest claimable long token funding amount per size - data_tests: - - not_null - &latest_short_token_claimable_funding_amount_per_size name: latest_short_token_claimable_funding_amount_per_size description: The latest claimable short token funding amount per size - data_tests: - - not_null - &borrowing_fee_usd name: borrowing_fee_usd description: The borrowing fee amount in USD @@ -729,6 +677,61 @@ models: description: The total amount of UI fee collected data_tests: - not_null + - &referral_total_rebate_factor + name: referral_total_rebate_factor + description: The total rebate factor associated with referrals. + data_tests: + - not_null + - &referral_total_rebate_amount + name: referral_total_rebate_amount + description: The total rebate amount given for referrals. + data_tests: + - not_null + - &referral_trader_discount_factor + name: referral_trader_discount_factor + description: The discount factor applied to the trader through referrals. + data_tests: + - not_null + - &referral_adjusted_affiliate_reward_factor + name: referral_adjusted_affiliate_reward_factor + description: The adjusted affiliate reward factor based on referral criteria. + data_tests: + - not_null + - &referral_affiliate_reward_amount + name: referral_affiliate_reward_amount + description: The reward amount given to the affiliate for referrals. + data_tests: + - not_null + - &referral_trader_discount_amount + name: referral_trader_discount_amount + description: The discount amount given to the trader through referrals. + data_tests: + - not_null + - &pro_trader_discount_factor + name: pro_trader_discount_factor + description: The discount factor applied for pro traders. + data_tests: + - not_null + - &pro_trader_discount_amount + name: pro_trader_discount_amount + description: The discount amount given to pro traders. + data_tests: + - not_null + - &liquidation_fee_amount + name: liquidation_fee_amount + description: The amount of fees charged during liquidation. + data_tests: + - not_null + - &liquidation_fee_receiver_factor + name: liquidation_fee_receiver_factor + description: The factor used to calculate the liquidation fee allocated to the receiver. + data_tests: + - not_null + - &liquidation_fee_amount_for_fee_receiver + name: liquidation_fee_amount_for_fee_receiver + description: The amount of liquidation fee allocated to the fee receiver. + data_tests: + - not_null - &is_increase name: is_increase description: Indicates whether the position is increased (true) or decreased (false) @@ -785,11 +788,6 @@ models: - *collateral_token_price_min - *collateral_token_price_max - *trade_size_usd - - *total_rebate_factor - - *trader_discount_factor - - *total_rebate_amount - - *trader_discount_amount - - *affiliate_reward_amount - *funding_fee_amount - *claimable_long_token_amount - *claimable_short_token_amount @@ -810,6 +808,17 @@ models: - *total_cost_amount - *ui_fee_receiver_factor - *ui_fee_amount + - *referral_total_rebate_factor + - *referral_total_rebate_amount + - *referral_trader_discount_factor + - *referral_adjusted_affiliate_reward_factor + - *referral_affiliate_reward_amount + - *referral_trader_discount_amount + - *pro_trader_discount_factor + - *pro_trader_discount_amount + - *liquidation_fee_amount + - *liquidation_fee_receiver_factor + - *liquidation_fee_amount_for_fee_receiver - *is_increase - *order_key - *position_key @@ -899,8 +908,6 @@ models: - not_null - name: market description: The market in which the order was updated. - data_tests: - - not_null - name: account description: The address associated with the order. - *size_delta_usd @@ -909,4 +916,1228 @@ models: - *acceptable_price_raw - *acceptable_price - *min_output_amount_raw - - *updated_at_time \ No newline at end of file + - *updated_at_time + - name: valid_from_time + description: The time from which the order becomes valid for execution. + - name: auto_cancel + description: Boolean indicating whether the order will be automatically canceled under certain conditions. + + + - name: gmx_v2_open_interest_in_tokens_updated + meta: + blockchain: arbitrum, avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'avalanche_c', 'gmx', 'event', 'open_interest_in_tokens_updated'] + description: | + Combines and processes decoded event data to produce a normalized dataset of updated orders + on the GMX platform for the Arbitrum and Avalanche blockchains. + This model integrates data from the `open_interest_in_tokens_updated` table, enriching it with market-specific details. + + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: event_name + description: The type of event recorded, always 'OpenInterestInTokensUpdated' for this model + data_tests: + - not_null + - *msg_sender + - name: market + description: The market in which the order was updated, decoded from a hexadecimal value. + data_tests: + - not_null + - name: collateral_token + description: The token used as collateral for the order, decoded from a hexadecimal value. + data_tests: + - not_null + - name: is_long + description: A boolean flag indicating whether the order is a long position (true) or short position (false). + - name: next_value + description: | + Represents the updated open interest vlaue after the transaction. It is derived by normalizing + the raw value using index token decimals. + This ensures consistent scaling of the value across tokens with varying decimals. + - name: delta + description: | + Indicates the change in open interest. It is calculated by normalizing the raw delta value + using index token decimals. + This normalization accounts for token decimal differences and provides a standardized measure of change. + - name: tx_from + description: The address that initiated the transaction + - name: tx_to + description: The destination address of the transaction + - name: tx_index + description: Index value related to the transaction + + + - name: gmx_v2_open_interest_updated + meta: + blockchain: arbitrum, avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'avalanche_c', 'gmx', 'event', 'open_interest_updated'] + description: | + Extracts and processes decoded event data for open interest updates on the GMX platform, + specifically on the Arbitrum and Avalanche blockchains. This model normalizes data, including key metrics like + delta and next_value, ensuring consistent scaling based on token decimals. + + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: event_name + description: The type of event recorded, always 'OpentInterestUpdated' for this model + data_tests: + - not_null + - *msg_sender + - name: market + description: The market associated with the open interest update, decoded from a hexadecimal value. + data_tests: + - not_null + - name: collateral_token + description: The token used as collateral for the open interest, decoded from a hexadecimal value. + data_tests: + - not_null + - name: is_long + description: | + A boolean flag indicating whether the open interest update is for a long position (true) or short position (false). + data_type: boolean + - name: delta + description: | + Represents the change in open interest value, normalized by dividing the raw delta by `POWER(10, 30)`. + This ensures consistent scaling for values across tokens with varying decimals. + data_type: float + data_tests: + - not_null + - name: next_value + description: | + Indicates the updated open interest value after the transaction, normalized by dividing + the raw value by `POWER(10, 30)` to ensure consistent scaling across tokens. + data_type: float + data_tests: + - not_null + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: tx_index + description: The index value related to the transaction. + + + - name: gmx_v2_oracle_price_update + meta: + blockchain: arbitrum, avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'avalanche_c', 'gmx', 'event', 'oracle_price_update'] + description: | + Processes decoded event data for Oracle Price Updates on the GMX platform in the Arbitrum and Avalanche blockchains. + The model normalizes price data (min_price and max_price) using token-specific decimals and extracts + additional details such as the provider and token involved in the update. + + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: event_name + description: The type of event recorded, always 'OraclePriceUpdate' for this model + data_tests: + - not_null + - *msg_sender + - name: token + description: The token associated with the oracle price update, decoded from a hexadecimal value. + data_tests: + - not_null + - name: provider + description: The address of the price provider, decoded from a hexadecimal value. + - name: min_price + description: The minimum price reported by the oracle. + data_tests: + - not_null + - name: max_price + description: The maximum price reported by the oracle. + data_tests: + - not_null + - name: timestamp + description: The timestamp of the oracle price update. + data_type: timestamp + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: tx_index + description: The index value related to the transaction, used for unique identification. + + + - name: gmx_v2_pool_amount_updated + meta: + blockchain: arbitrum, avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'avalanche_c', 'gmx', 'event', 'pool_amount_updated'] + description: | + Processes decoded event data for Pool Amount Updates on the GMX platform in the Arbitrum and Avalanche blockchains. + This model normalizes token values (next_value and delta) based on token-specific decimals and extracts + additional details such as the market and token involved in the pool update. + + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: event_name + description: The type of event recorded, always 'PoolAmountUpdated' for this model + data_tests: + - not_null + - *msg_sender + - name: market + description: The market associated with the pool update, decoded from a hexadecimal value. + data_tests: + - not_null + - name: token + description: The token involved in the pool update, decoded from a hexadecimal value. + data_tests: + - not_null + - name: next_value + description: | + The amount in the pool for the specified token, normalized by dividing the raw value + by `POWER(10, token_decimals)`, where `token_decimals` is derived from ERC-20 token metadata. + data_tests: + - not_null + - name: delta + description: | + The change in the pool amount for the specified token, normalized by dividing the raw value + by `POWER(10, token_decimals)`, where `token_decimals` is derived from ERC-20 token metadata. + data_tests: + - not_null + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: tx_index + description: The index value related to the transaction, used for unique identification. + + + - name: gmx_v2_set_uint + meta: + blockchain: arbitrum, avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'avalanche_c', 'gmx', 'event', 'set_uint'] + description: | + Processes decoded event data for `SetUint` events on the GMX platform in the Arbitrum and Avalanche blockchains. + This model normalizes the value field and extracts additional details such as the base key and associated data, + ensuring compatibility with downstream analyses. + + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: event_name + description: The type of event recorded, always 'SetUint' for this model + data_tests: + - not_null + - *msg_sender + - name: base_key + description: The base key associated with the event, decoded from a hexadecimal value. + data_tests: + - not_null + - name: data + description: The associated data field, decoded from a hexadecimal value. + data_tests: + - not_null + - name: value_raw + description: | + The value associated with the event. + data_type: float + data_tests: + - not_null + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: tx_index + description: The index value related to the transaction, used for unique identification. + + + - name: gmx_v2_execution_fee_refund + meta: + blockchain: arbitrum, avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'avalanche_c', 'gmx', 'event', 'execution_fee_refund'] + description: | + Processes decoded event data for `ExecutionFeeRefund` events on the GMX platform in the Arbitrum and Avalanche blockchains. + This model extracts key details such as the refund amount, receiver, and transaction details to + enable analysis of refunded execution fees. + + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `ExecutionFeeRefund` for this model. + data_tests: + - not_null + - *msg_sender + - name: receiver + description: The address that received the refunded execution fee. + - name: refund_fee_amount + description: The amount of the refunded execution fee, denominated in the native token of the blockchain (e.g., ETH). + + + - name: gmx_v2_keeper_execution_fee + meta: + blockchain: arbitrum, avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'avalanche_c', 'gmx', 'event', 'keeper_execution_fee'] + description: | + Processes decoded event data for `KeeperExecutionFee` events on the GMX platform in the Arbitrum and Avalanche blockchains. + This model extracts key details such as the keeper's address, execution fee amount, and transaction details, enabling + analysis of fees associated with keeper-based executions. + + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `KeeperExecutionFee` for this model. + data_tests: + - not_null + - *msg_sender + - name: keeper + description: The address of the keeper responsible for executing the transaction. + - name: execution_fee_amount + description: The amount of the execution fee, denominated in the native token of the blockchain (e.g., ETH, AVAX). + + + - name: gmx_v2_deposit_cancelled + meta: + blockchain: arbitrum, avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'avalanche_c', 'gmx', 'event', 'deposit_cancelled'] + description: | + Processes decoded event data for `DepositCancelled` events on the GMX platform in the Arbitrum and Avalanche blockchains. + This model extracts key details such as the account address, cancellation reason, and transaction details, enabling + analysis of deposit cancellations on the platform. + + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `DepositCancelled` for this model. + - *msg_sender + - name: account + description: The account address associated with the cancelled deposit. + - name: key + description: A unique identifier for the cancelled deposit. + - name: reason_bytes + description: Encoded reason data for the deposit cancellation. + - name: reason + description: The decoded textual reason for the deposit cancellation. + + + - name: gmx_v2_deposit_created + meta: + blockchain: arbitrum, avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'avalanche_c', 'gmx', 'event', 'deposit_created'] + description: | + Processes decoded event data for `DepositCreated` events on the GMX platform in the Arbitrum and Avalanche blockchains. + This model extracts key details such as the account address, deposit details, and transaction specifics, enabling + analysis of deposits created on the platform. + + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `DepositCreated` for this model. + - *msg_sender + - name: account + description: The account address associated with the deposit. + - name: receiver + description: The receiver address specified for the deposit. + - name: callback_contract + description: The address of the callback contract associated with the deposit. + - name: market + description: The market for which the deposit was created. + - name: initial_long_token + description: The token used for the long position in the deposit. + - name: initial_short_token + description: The token used for the short position in the deposit. + - name: long_token_swap_path + description: The swap path for the long token. + - name: short_token_swap_path + description: The swap path for the short token. + - name: initial_long_token_amount + description: The initial amount of the long token in the deposit. + - name: initial_short_token_amount + description: The initial amount of the short token in the deposit. + - name: min_market_tokens + description: The minimum amount of market tokens expected from the deposit. + - name: updated_at_time + description: The timestamp when the deposit was last updated. + - name: execution_fee + description: The execution fee for processing the deposit. + - name: callback_gas_limit + description: The gas limit for the callback associated with the deposit. + - name: deposit_type + description: The type of deposit created. + - name: should_unwrap_native_token + description: Indicates whether the native token should be unwrapped. + - name: key + description: A unique identifier for the deposit. + + + - name: gmx_v2_deposit_executed + meta: + blockchain: arbitrum, avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'avalanche_c', 'gmx', 'event', 'deposit_executed'] + description: | + Processes decoded event data for `DepositExecuted` events on the GMX platform in the Arbitrum and Avalanche blockchains. + This model extracts key details such as the account address, execution details, and transaction specifics, enabling + analysis of deposits executed on the platform. + + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `DepositExecuted` for this model. + - *msg_sender + - name: account + description: The account address associated with the executed deposit. + - name: long_token_amount + description: The amount of the long token in the executed deposit. + - name: short_token_amount + description: The amount of the short token in the executed deposit. + - name: received_market_tokens + description: The number of market tokens received from the executed deposit. + - name: swap_pricing_type + description: The type of swap pricing applied during the execution. + - name: key + description: A unique identifier for the executed deposit. + + + - name: gmx_v2_glv_created + meta: + blockchain: arbitrum, avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'avalanche_c', 'gmx', 'event', 'glv_created'] + description: | + Processes decoded event data for `GLVCreated` events on the GMX platform in the Arbitrum and Avalanche blockchains. + This model extracts key details such as the GLV token, associated tokens, and transaction specifics, enabling + analysis of GLV creation events on the platform. + + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `GLVCreated` for this model. + - *msg_sender + - name: glv_token + description: The identifier of the GLV token created in the transaction. + - name: long_token + description: The long token associated with the GLV creation. + - name: short_token + description: The short token associated with the GLV creation. + - name: salt + description: A unique salt value used in the GLV creation. + - name: glv_type + description: The type of GLV created. + - name: market_token_symbol + description: The symbol of the market token involved in the GLV creation. + - name: market_token_decimals + description: The decimal precision of the market token involved in the GLV creation. + + + - name: gmx_v2_glv_deposit_cancelled + meta: + blockchain: arbitrum, avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'avalanche_c', 'gmx', 'event', 'glv_deposit_cancelled'] + description: | + Processes decoded event data for `GLVDepositCancelled` events on the GMX platform in the Arbitrum and Avalanche blockchains. + This model extracts key details such as the account address, cancellation reason, and transaction specifics, enabling + analysis of cancelled GLV deposits. + + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `GLVDepositCancelled` for this model. + - *msg_sender + - name: account + description: The account address associated with the cancelled deposit. + - name: key + description: A unique identifier for the cancelled deposit. + - name: reason_bytes + description: Encoded reason data for the deposit cancellation. + - name: reason + description: The decoded textual reason for the deposit cancellation. + + + - name: gmx_v2_glv_deposit_created + meta: + blockchain: arbitrum, avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'avalanche_c', 'gmx', 'event', 'glv_deposit_created'] + description: | + Processes decoded event data for `GLVDepositCreated` events on the GMX platform in the Arbitrum and Avalanche blockchains. + This model extracts key details such as the account address, deposit details, and transaction specifics, enabling + analysis of created GLV deposits. + + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `GLVDepositCreated` for this model. + - *msg_sender + - name: account + description: The account address associated with the deposit. + - name: receiver + description: The receiver address specified for the deposit. + - name: callback_contract + description: The address of the callback contract associated with the deposit. + - name: market + description: The market associated with the deposit. + - name: glv + description: The identifier of the GLV associated with the deposit. + - name: initial_long_token + description: The token used for the long position in the deposit. + - name: initial_short_token + description: The token used for the short position in the deposit. + - name: ui_fee_receiver + description: The address receiving the UI fee for the deposit. + - name: long_token_swap_path + description: The swap path for the long token. + - name: short_token_swap_path + description: The swap path for the short token. + - name: initial_long_token_amount + description: The initial amount of the long token in the deposit. + - name: initial_short_token_amount + description: The initial amount of the short token in the deposit. + - name: min_glv_tokens + description: The minimum amount of GLV tokens expected from the deposit. + - name: updated_at_time + description: The timestamp when the deposit was last updated. + - name: execution_fee + description: The execution fee for processing the deposit. + - name: callback_gas_limit + description: The gas limit for the callback associated with the deposit. + - name: market_token_amount + description: The amount of market tokens associated with the deposit. + - name: should_unwrap_native_token + description: Indicates whether the native token should be unwrapped. + - name: is_market_token_deposit + description: Indicates whether the deposit was made using market tokens. + - name: key + description: A unique identifier for the deposit. + + + - name: gmx_v2_glv_deposit_executed + meta: + blockchain: arbitrum, avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'avalanche_c', 'gmx', 'event', 'glv_deposit_executed'] + description: | + Processes decoded event data for `GLVDepositExecuted` events on the GMX platform in the Arbitrum and Avalanche blockchains. + This model extracts key details such as the account address, received GLV tokens, and transaction specifics, enabling + analysis of executed GLV deposits. + + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `GLVDepositExecuted` for this model. + data_tests: + - not_null + - *msg_sender + - name: account + description: The account address associated with the executed deposit. + - name: received_glv_tokens + description: The number of GLV tokens received from the executed deposit. + - name: key + description: A unique identifier for the executed deposit. + + + - name: gmx_v2_glv_shift_cancelled + meta: + blockchain: arbitrum, avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'avalanche_c', 'gmx', 'event', 'glv_shift_cancelled'] + description: | + Processes decoded event data for `GLVShiftCancelled` events on the GMX platform in the Arbitrum and Avalanche blockchains. + This model extracts key details such as the cancellation reason and transaction specifics, enabling + analysis of cancelled GLV shifts. + + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `GLVShiftCancelled` for this model. + - *msg_sender + - name: key + description: A unique identifier for the cancelled shift. + - name: reason_bytes + description: Encoded reason data for the shift cancellation. + - name: reason + description: The decoded textual reason for the shift cancellation. + + + - name: gmx_v2_glv_shift_created + meta: + blockchain: arbitrum, avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'avalanche_c', 'gmx', 'event', 'glv_shift_created'] + description: | + Processes decoded event data for `GLVShiftCreated` events on the GMX platform in the Arbitrum and Avalanche blockchains. + This model extracts key details such as the source and destination markets, GLV details, and transaction specifics, enabling + analysis of created GLV shifts. + + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `GLVShiftCreated` for this model. + - *msg_sender + - name: from_market + description: The source market for the GLV shift. + - name: to_market + description: The destination market for the GLV shift. + - name: glv + description: The identifier of the GLV being shifted. + - name: market_token_amount + description: The amount of market tokens involved in the shift. + - name: min_market_tokens + description: The minimum market tokens expected from the shift. + - name: updated_at_time + description: The timestamp when the shift was last updated. + - name: key + description: A unique identifier for the created shift. + + + - name: gmx_v2_glv_shift_executed + meta: + blockchain: arbitrum, avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'avalanche_c', 'gmx', 'event', 'glv_shift_executed'] + description: | + Processes decoded event data for `GLVShiftExecuted` events on the GMX platform in the Arbitrum and Avalanche blockchains. + This model extracts key details such as the received market tokens and transaction specifics, enabling + analysis of executed GLV shifts. + + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `GLVShiftExecuted` for this model. + - *msg_sender + - name: received_market_tokens + description: The number of market tokens received from the executed shift. + - name: key + description: A unique identifier for the executed shift. + + + - name: gmx_v2_glv_withdrawal_cancelled + meta: + blockchain: arbitrum, avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'avalanche_c', 'gmx', 'event', 'glv_withdrawal_cancelled'] + description: | + Processes decoded event data for `GLVWithdrawalCancelled` events on the GMX platform in the Arbitrum and Avalanche blockchains. + This model extracts key details such as the account address, cancellation reason, and transaction specifics, enabling + analysis of cancelled GLV withdrawals. + + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `GLVWithdrawalCancelled` for this model. + data_tests: + - not_null + - *msg_sender + - name: account + description: The account address associated with the cancelled withdrawal. + - name: key + description: A unique identifier for the cancelled withdrawal. + - name: reason_bytes + description: Encoded reason data for the withdrawal cancellation. + - name: reason + description: The decoded textual reason for the withdrawal cancellation. + + + - name: gmx_v2_glv_withdrawal_created + meta: + blockchain: arbitrum, avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'avalanche_c', 'gmx', 'event', 'glv_withdrawal_created'] + description: | + Processes decoded event data for `GLVWithdrawalCreated` events on the GMX platform in the Arbitrum and Avalanche blockchains. + This model extracts key details such as the account address, withdrawal details, and transaction specifics, enabling + analysis of created GLV withdrawals. + + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `GLVWithdrawalCreated` for this model. + data_tests: + - not_null + - *msg_sender + - name: account + description: The account address associated with the withdrawal. + - name: receiver + description: The receiver address specified for the withdrawal. + - name: callback_contract + description: The address of the callback contract associated with the withdrawal. + - name: market + description: The market associated with the withdrawal. + - name: glv + description: The identifier of the GLV associated with the withdrawal. + - name: ui_fee_receiver + description: The address receiving the UI fee for the withdrawal. + - name: long_token_swap_path + description: The swap path for the long token. + - name: short_token_swap_path + description: The swap path for the short token. + - name: glv_token_amount + description: The amount of GLV tokens involved in the withdrawal. + - name: min_long_token_amount + description: The minimum long token amount expected from the withdrawal. + - name: min_short_token_amount + description: The minimum short token amount expected from the withdrawal. + - name: updated_at_time + description: The timestamp when the withdrawal was last updated. + - name: execution_fee + description: The execution fee for processing the withdrawal. + - name: callback_gas_limit + description: The gas limit for the callback associated with the withdrawal. + - name: should_unwrap_native_token + description: Indicates whether the native token should be unwrapped. + - name: key + description: A unique identifier for the created withdrawal. + + + - name: gmx_v2_glv_withdrawal_executed + meta: + blockchain: arbitrum, avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'avalanche_c', 'gmx', 'event', 'glv_withdrawal_executed'] + description: | + Processes decoded event data for `GLVWithdrawalExecuted` events on the GMX platform in the Arbitrum and Avalanche blockchains. + This model extracts key details such as the account address and transaction specifics, enabling + analysis of executed GLV withdrawals. + + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `GLVWithdrawalExecuted` for this model. + data_tests: + - not_null + - *msg_sender + - name: account + description: The account address associated with the executed withdrawal. + - name: key + description: A unique identifier for the executed withdrawal. + + + - name: gmx_v2_shift_created + meta: + blockchain: arbitrum, avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'avalanche_c', 'gmx', 'event', 'shift_created'] + description: | + Processes decoded event data for `ShiftCreated` events on the GMX platform in the Arbitrum and Avalanche blockchains. + This model extracts key details such as the account address, market details, and transaction specifics, enabling + analysis of created shifts. + + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `ShiftCreated` for this model. + - *msg_sender + - name: account + description: The account address associated with the shift. + - name: receiver + description: The receiver address specified for the shift. + - name: callback_contract + description: The address of the callback contract associated with the shift. + - name: from_market + description: The source market for the shift. + - name: to_market + description: The destination market for the shift. + - name: market_token_amount + description: The amount of market tokens involved in the shift. + - name: min_market_tokens + description: The minimum market tokens expected from the shift. + - name: updated_at_time + description: The timestamp when the shift was last updated. + - name: execution_fee + description: The execution fee for processing the shift. + - name: callback_gas_limit + description: The gas limit for the callback associated with the shift. + - name: key + description: A unique identifier for the created shift. + + + - name: gmx_v2_shift_executed + meta: + blockchain: arbitrum, avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'avalanche_c', 'gmx', 'event', 'shift_executed'] + description: | + Processes decoded event data for `ShiftExecuted` events on the GMX platform in the Arbitrum and Avalanche blockchains. + This model extracts key details such as the account address, received market tokens, and transaction specifics, enabling + analysis of executed shifts. + + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `ShiftExecuted` for this model. + - *msg_sender + - name: account + description: The account address associated with the executed shift. + - name: received_market_tokens + description: The number of market tokens received from the executed shift. + - name: key + description: A unique identifier for the executed shift. + + + - name: gmx_v2_withdrawal_cancelled + meta: + blockchain: arbitrum, avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'avalanche_c', 'gmx', 'event', 'withdrawal_cancelled'] + description: | + Processes decoded event data for `WithdrawalCancelled` events on the GMX platform in the Arbitrum and Avalanche blockchains. + This model extracts key details such as the account address, cancellation reason, and transaction specifics, enabling + analysis of cancelled withdrawals. + + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `WithdrawalCancelled` for this model. + - *msg_sender + - name: account + description: The account address associated with the cancelled withdrawal. + - name: key + description: A unique identifier for the cancelled withdrawal. + - name: reason_bytes + description: Encoded reason data for the withdrawal cancellation. + - name: reason + description: The decoded textual reason for the withdrawal cancellation. + + + - name: gmx_v2_withdrawal_created + meta: + blockchain: arbitrum, avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'avalanche_c', 'gmx', 'event', 'withdrawal_created'] + description: | + Processes decoded event data for `WithdrawalCreated` events on the GMX platform in the Arbitrum and Avalanche blockchains. + This model extracts key details such as the account address, withdrawal details, and transaction specifics, enabling + analysis of created withdrawals. + + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `WithdrawalCreated` for this model. + - *msg_sender + - name: account + description: The account address associated with the withdrawal. + - name: receiver + description: The receiver address specified for the withdrawal. + - name: callback_contract + description: The address of the callback contract associated with the withdrawal. + - name: market + description: The market associated with the withdrawal. + - name: market_token_amount + description: The amount of market tokens involved in the withdrawal. + - name: min_long_token_amount + description: The minimum long token amount expected from the withdrawal. + - name: min_short_token_amount + description: The minimum short token amount expected from the withdrawal. + - name: updated_at_time + description: The timestamp when the withdrawal was last updated. + - name: execution_fee + description: The execution fee for processing the withdrawal. + - name: callback_gas_limit + description: The gas limit for the callback associated with the withdrawal. + - name: should_unwrap_native_token + description: Indicates whether the native token should be unwrapped. + - name: key + description: A unique identifier for the created withdrawal. + + + - name: gmx_v2_withdrawal_executed + meta: + blockchain: arbitrum, avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'avalanche_c', 'gmx', 'event', 'withdrawal_executed'] + description: | + Processes decoded event data for `WithdrawalExecuted` events on the GMX platform in the Arbitrum and Avalanche blockchains. + This model extracts key details such as the account address, pricing type, and transaction specifics, enabling + analysis of executed withdrawals. + + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address that initiated the transaction. + - name: tx_to + description: The destination address of the transaction. + - name: event_name + description: The type of event recorded, always `WithdrawalExecuted` for this model. + - *msg_sender + - name: account + description: The account address associated with the executed withdrawal. + - name: swap_pricing_type + description: The pricing type applied during the withdrawal. + - name: key + description: A unique identifier for the executed withdrawal. + + + - name: gmx_v2_claimable_funding_amount_per_size_updated + meta: + blockchain: arbitrum, avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'avalanche_c', 'gmx', 'event', 'claimable_funding'] + description: | + Processes decoded event data for `ClaimableFundingAmountPerSizeUpdated` events on the GMX platform across the Arbitrum and Avalanche blockchains. + This model extracts key details such as funding updates, collateral information, and market direction to support funding analysis. + + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address initiating the transaction. + - name: tx_to + description: The recipient address of the transaction. + - name: event_name + description: The name of the event emitted, always `ClaimableFundingAmountPerSizeUpdated`. + - *msg_sender + - name: market + description: The specific GMX market where the funding amount was updated. + - name: collateral_token + description: The token used as collateral in the funding event. + - name: delta + description: The change in the funding amount. + - name: value + description: The funding amount value associated with the update. + - name: is_long + description: A boolean indicating if the position is a long position (`true` for long, `false` for short). + + - name: gmx_v2_funding_fee_amount_per_size_updated + meta: + blockchain: arbitrum, avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'avalanche_c', 'gmx', 'event', 'funding_fee'] + description: | + Processes decoded event data for `FundingFeeAmountPerSizeUpdated` events on the GMX platform across the Arbitrum and Avalanche blockchains. + This model extracts key details such as funding fees, collateral details, and market direction to enable funding fee analysis. + + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - name: tx_from + description: The address initiating the transaction. + - name: tx_to + description: The recipient address of the transaction. + - name: event_name + description: The name of the event emitted, always `FundingFeeAmountPerSizeUpdated`. + - *msg_sender + - name: market + description: The specific GMX market where the funding fee was updated. + - name: collateral_token + description: The token used as collateral in the funding event. + - name: delta + description: The change in the funding fee amount. + - name: value + description: The funding fee amount associated with the update. + - name: is_long + description: A boolean indicating if the position is a long position (`True` for long, `False` for short). diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_execution_fee_refund.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_execution_fee_refund.sql new file mode 100644 index 00000000000..a4f2675416f --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_execution_fee_refund.sql @@ -0,0 +1,36 @@ +{{ config( + schema='gmx_v2', + alias = 'execution_fee_refund', + post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c"]\', + "project", + "gmx", + \'["ai_data_master","gmx-io"]\') }}' + ) +}} + +{%- set chains = [ + 'arbitrum', + 'avalanche_c', +] -%} + +{%- for chain in chains -%} +SELECT + blockchain, + block_time, + block_date, + block_number, + tx_hash, + index, + contract_address, + tx_from, + tx_to, + event_name, + msg_sender, + receiver, + refund_fee_amount +FROM {{ ref('gmx_v2_' ~ chain ~ '_execution_fee_refund') }} +{% if not loop.last %} +UNION ALL +{% endif %} +{%- endfor -%} + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_funding_fee_amount_per_size_updated.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_funding_fee_amount_per_size_updated.sql new file mode 100644 index 00000000000..77db6dab786 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_funding_fee_amount_per_size_updated.sql @@ -0,0 +1,40 @@ +{{ config( + schema='gmx_v2', + alias = 'funding_fee_amount_per_size_updated', + post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c"]\', + "project", + "gmx", + \'["ai_data_master","gmx-io"]\') }}' + ) +}} + +{%- set chains = [ + 'arbitrum', + 'avalanche_c', +] -%} + +{%- for chain in chains -%} +SELECT + blockchain, + block_time, + block_date, + block_number, + tx_hash, + index, + contract_address, + tx_from, + tx_to, + event_name, + msg_sender, + market, + collateral_token, + delta, + "value", + is_long +FROM {{ ref('gmx_v2_' ~ chain ~ '_funding_fee_amount_per_size_updated') }} +{% if not loop.last %} +UNION ALL +{% endif %} +{%- endfor -%} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_glv_created.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_glv_created.sql new file mode 100644 index 00000000000..3ff0d276649 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_glv_created.sql @@ -0,0 +1,44 @@ +{{ config( + schema='gmx_v2', + alias = 'glv_created', + post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c"]\', + "project", + "gmx", + \'["ai_data_master","gmx-io"]\') }}' + ) +}} + +{%- set chains = [ + 'arbitrum', + 'avalanche_c', +] -%} + +{%- for chain in chains -%} +SELECT + blockchain, + block_time, + block_date, + block_number, + tx_hash, + index, + contract_address, + tx_from, + tx_to, + event_name, + msg_sender, + + glv_token, + long_token, + short_token, + salt, + glv_type, + market_token_symbol, + market_token_decimals + +FROM {{ ref('gmx_v2_' ~ chain ~ '_glv_created') }} +{% if not loop.last %} +UNION ALL +{% endif %} +{%- endfor -%} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_glv_deposit_cancelled.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_glv_deposit_cancelled.sql new file mode 100644 index 00000000000..a94e78ae3f1 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_glv_deposit_cancelled.sql @@ -0,0 +1,42 @@ +{{ config( + schema='gmx_v2', + alias = 'glv_deposit_cancelled', + post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c"]\', + "project", + "gmx", + \'["ai_data_master","gmx-io"]\') }}' + ) +}} + +{%- set chains = [ + 'arbitrum', + 'avalanche_c', +] -%} + +{%- for chain in chains -%} +SELECT + blockchain, + block_time, + block_date, + block_number, + tx_hash, + index, + contract_address, + tx_from, + tx_to, + event_name, + msg_sender, + + account, + "key", + reason_bytes, + reason + +FROM {{ ref('gmx_v2_' ~ chain ~ '_glv_deposit_cancelled') }} +{% if not loop.last %} +UNION ALL +{% endif %} +{%- endfor -%} + + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_glv_deposit_created.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_glv_deposit_created.sql new file mode 100644 index 00000000000..550dbdac8ff --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_glv_deposit_created.sql @@ -0,0 +1,56 @@ +{{ config( + schema='gmx_v2', + alias = 'glv_deposit_created', + post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c"]\', + "project", + "gmx", + \'["ai_data_master","gmx-io"]\') }}' + ) +}} + +{%- set chains = [ + 'arbitrum', + 'avalanche_c', +] -%} + +{%- for chain in chains -%} +SELECT + blockchain, + block_time, + block_date, + block_number, + tx_hash, + index, + contract_address, + tx_from, + tx_to, + event_name, + msg_sender, + + account, + receiver, + callback_contract, + market, + glv, + initial_long_token, + initial_short_token, + ui_fee_receiver, + long_token_swap_path, + short_token_swap_path, + initial_long_token_amount, + initial_short_token_amount, + min_glv_tokens, + updated_at_time, + execution_fee, + callback_gas_limit, + market_token_amount, + should_unwrap_native_token, + is_market_token_deposit, + "key" + +FROM {{ ref('gmx_v2_' ~ chain ~ '_glv_deposit_created') }} +{% if not loop.last %} +UNION ALL +{% endif %} +{%- endfor -%} + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_glv_deposit_executed.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_glv_deposit_executed.sql new file mode 100644 index 00000000000..2a8ffc7a0a7 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_glv_deposit_executed.sql @@ -0,0 +1,42 @@ +{{ config( + schema='gmx_v2', + alias = 'glv_deposit_executed', + post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c"]\', + "project", + "gmx", + \'["ai_data_master","gmx-io"]\') }}' + ) +}} + +{%- set chains = [ + 'arbitrum', + 'avalanche_c', +] -%} + +{%- for chain in chains -%} +SELECT + blockchain, + block_time, + block_date, + block_number, + tx_hash, + index, + contract_address, + tx_from, + tx_to, + event_name, + msg_sender, + + account, + received_glv_tokens, + "key" + +FROM {{ ref('gmx_v2_' ~ chain ~ '_glv_deposit_executed') }} +{% if not loop.last %} +UNION ALL +{% endif %} +{%- endfor -%} + + + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_glv_shift_cancelled.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_glv_shift_cancelled.sql new file mode 100644 index 00000000000..93b1164153e --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_glv_shift_cancelled.sql @@ -0,0 +1,41 @@ +{{ config( + schema='gmx_v2', + alias = 'glv_shift_cancelled', + post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c"]\', + "project", + "gmx", + \'["ai_data_master","gmx-io"]\') }}' + ) +}} + +{%- set chains = [ + 'arbitrum', + 'avalanche_c', +] -%} + +{%- for chain in chains -%} +SELECT + blockchain, + block_time, + block_date, + block_number, + tx_hash, + index, + contract_address, + tx_from, + tx_to, + event_name, + msg_sender, + + "key", + reason_bytes, + reason + +FROM {{ ref('gmx_v2_' ~ chain ~ '_glv_shift_cancelled') }} +{% if not loop.last %} +UNION ALL +{% endif %} +{%- endfor -%} + + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_glv_shift_created.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_glv_shift_created.sql new file mode 100644 index 00000000000..eb1a077a283 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_glv_shift_created.sql @@ -0,0 +1,44 @@ +{{ config( + schema='gmx_v2', + alias = 'glv_shift_created', + post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c"]\', + "project", + "gmx", + \'["ai_data_master","gmx-io"]\') }}' + ) +}} + +{%- set chains = [ + 'arbitrum', + 'avalanche_c', +] -%} + +{%- for chain in chains -%} +SELECT + blockchain, + block_time, + block_date, + block_number, + tx_hash, + index, + contract_address, + tx_from, + tx_to, + event_name, + msg_sender, + + from_market, + to_market, + glv, + market_token_amount, + min_market_tokens, + updated_at_time, + "key" + +FROM {{ ref('gmx_v2_' ~ chain ~ '_glv_shift_created') }} +{% if not loop.last %} +UNION ALL +{% endif %} +{%- endfor -%} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_glv_shift_executed.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_glv_shift_executed.sql new file mode 100644 index 00000000000..8b5098727a0 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_glv_shift_executed.sql @@ -0,0 +1,39 @@ +{{ config( + schema='gmx_v2', + alias = 'glv_shift_executed', + post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c"]\', + "project", + "gmx", + \'["ai_data_master","gmx-io"]\') }}' + ) +}} + +{%- set chains = [ + 'arbitrum', + 'avalanche_c', +] -%} + +{%- for chain in chains -%} +SELECT + blockchain, + block_time, + block_date, + block_number, + tx_hash, + index, + contract_address, + tx_from, + tx_to, + event_name, + msg_sender, + + received_market_tokens, + "key" + +FROM {{ ref('gmx_v2_' ~ chain ~ '_glv_shift_executed') }} +{% if not loop.last %} +UNION ALL +{% endif %} +{%- endfor -%} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_glv_withdrawal_cancelled.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_glv_withdrawal_cancelled.sql new file mode 100644 index 00000000000..e13c2bfe157 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_glv_withdrawal_cancelled.sql @@ -0,0 +1,42 @@ +{{ config( + schema='gmx_v2', + alias = 'glv_withdrawal_cancelled', + post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c"]\', + "project", + "gmx", + \'["ai_data_master","gmx-io"]\') }}' + ) +}} + +{%- set chains = [ + 'arbitrum', + 'avalanche_c', +] -%} + +{%- for chain in chains -%} +SELECT + blockchain, + block_time, + block_date, + block_number, + tx_hash, + index, + contract_address, + tx_from, + tx_to, + event_name, + msg_sender, + + account, + "key", + reason_bytes, + reason + +FROM {{ ref('gmx_v2_' ~ chain ~ '_glv_withdrawal_cancelled') }} +{% if not loop.last %} +UNION ALL +{% endif %} +{%- endfor -%} + + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_glv_withdrawal_created.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_glv_withdrawal_created.sql new file mode 100644 index 00000000000..85faee03b17 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_glv_withdrawal_created.sql @@ -0,0 +1,52 @@ +{{ config( + schema='gmx_v2', + alias = 'glv_withdrawal_created', + post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c"]\', + "project", + "gmx", + \'["ai_data_master","gmx-io"]\') }}' + ) +}} + +{%- set chains = [ + 'arbitrum', + 'avalanche_c', +] -%} + +{%- for chain in chains -%} +SELECT + blockchain, + block_time, + block_date, + block_number, + tx_hash, + index, + contract_address, + tx_from, + tx_to, + event_name, + msg_sender, + + account, + receiver, + callback_contract, + market, + glv, + ui_fee_receiver, + long_token_swap_path, + short_token_swap_path, + glv_token_amount, + min_long_token_amount, + min_short_token_amount, + updated_at_time, + execution_fee, + callback_gas_limit, + should_unwrap_native_token, + "key" + +FROM {{ ref('gmx_v2_' ~ chain ~ '_glv_withdrawal_created') }} +{% if not loop.last %} +UNION ALL +{% endif %} +{%- endfor -%} + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_glv_withdrawal_executed.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_glv_withdrawal_executed.sql new file mode 100644 index 00000000000..5fd5d1de1e2 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_glv_withdrawal_executed.sql @@ -0,0 +1,40 @@ +{{ config( + schema='gmx_v2', + alias = 'glv_withdrawal_executed', + post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c"]\', + "project", + "gmx", + \'["ai_data_master","gmx-io"]\') }}' + ) +}} + +{%- set chains = [ + 'arbitrum', + 'avalanche_c', +] -%} + +{%- for chain in chains -%} +SELECT + blockchain, + block_time, + block_date, + block_number, + tx_hash, + index, + contract_address, + tx_from, + tx_to, + event_name, + msg_sender, + + account, + "key" + +FROM {{ ref('gmx_v2_' ~ chain ~ '_glv_withdrawal_executed') }} +{% if not loop.last %} +UNION ALL +{% endif %} +{%- endfor -%} + + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_keeper_execution_fee.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_keeper_execution_fee.sql new file mode 100644 index 00000000000..a24684122d9 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_keeper_execution_fee.sql @@ -0,0 +1,36 @@ +{{ config( + schema='gmx_v2', + alias = 'keeper_execution_fee', + post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c"]\', + "project", + "gmx", + \'["ai_data_master","gmx-io"]\') }}' + ) +}} + +{%- set chains = [ + 'arbitrum', + 'avalanche_c', +] -%} + +{%- for chain in chains -%} +SELECT + blockchain, + block_time, + block_date, + block_number, + tx_hash, + index, + contract_address, + tx_from, + tx_to, + event_name, + msg_sender, + keeper, + execution_fee_amount +FROM {{ ref('gmx_v2_' ~ chain ~ '_keeper_execution_fee') }} +{% if not loop.last %} +UNION ALL +{% endif %} +{%- endfor -%} + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_open_interest_in_tokens_updated.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_open_interest_in_tokens_updated.sql new file mode 100644 index 00000000000..1bdd950e9a0 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_open_interest_in_tokens_updated.sql @@ -0,0 +1,40 @@ +{{ config( + schema='gmx_v2', + alias = 'open_interest_in_tokens_updated', + post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c"]\', + "project", + "gmx", + \'["ai_data_master","gmx-io"]\') }}' + ) +}} + +{%- set chains = [ + 'arbitrum', + 'avalanche_c', +] -%} + +{%- for chain in chains -%} +SELECT + blockchain, + block_time, + block_date, + block_number, + tx_hash, + index, + contract_address, + tx_index, + tx_from, + tx_to, + event_name, + msg_sender, + market, + collateral_token, + is_long, + next_value, + delta +FROM {{ ref('gmx_v2_' ~ chain ~ '_open_interest_in_tokens_updated') }} +{% if not loop.last %} +UNION ALL +{% endif %} +{%- endfor -%} + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_open_interest_updated.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_open_interest_updated.sql new file mode 100644 index 00000000000..60d0182af5c --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_open_interest_updated.sql @@ -0,0 +1,41 @@ +{{ config( + schema='gmx_v2', + alias = 'open_interest_updated', + post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c"]\', + "project", + "gmx", + \'["ai_data_master","gmx-io"]\') }}' + ) +}} + +{%- set chains = [ + 'arbitrum', + 'avalanche_c', +] -%} + +{%- for chain in chains -%} +SELECT + blockchain, + block_time, + block_date, + block_number, + tx_hash, + index, + contract_address, + tx_index, + tx_from, + tx_to, + event_name, + msg_sender, + market, + collateral_token, + is_long, + next_value, + delta +FROM {{ ref('gmx_v2_' ~ chain ~ '_open_interest_updated') }} +{% if not loop.last %} +UNION ALL +{% endif %} +{%- endfor -%} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_oracle_price_update.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_oracle_price_update.sql new file mode 100644 index 00000000000..5296ab83672 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_oracle_price_update.sql @@ -0,0 +1,40 @@ +{{ config( + schema='gmx_v2', + alias = 'oracle_price_update', + post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c"]\', + "project", + "gmx", + \'["ai_data_master","gmx-io"]\') }}' + ) +}} + +{%- set chains = [ + 'arbitrum', + 'avalanche_c', +] -%} + +{%- for chain in chains -%} +SELECT + blockchain, + block_time, + block_date, + block_number, + tx_hash, + index, + contract_address, + tx_index, + tx_from, + tx_to, + event_name, + msg_sender, + token, + "provider", + min_price, + max_price, + "timestamp" +FROM {{ ref('gmx_v2_' ~ chain ~ '_oracle_price_update') }} +{% if not loop.last %} +UNION ALL +{% endif %} +{%- endfor -%} + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_order_created.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_order_created.sql index 9f95d34ebbd..11d0a609f05 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_order_created.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_order_created.sql @@ -46,9 +46,10 @@ SELECT min_output_amount_raw, updated_at_block, updated_at_time, + valid_from_time, is_long, should_unwrap_native_token, - is_frozen, + auto_cancel, key FROM {{ ref('gmx_v2_' ~ chain ~ '_order_created') }} {% if not loop.last %} diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_order_updated.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_order_updated.sql index 9481e7bc1b6..c456c7dcc75 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_order_updated.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_order_updated.sql @@ -34,8 +34,9 @@ SELECT trigger_price, trigger_price_raw, min_output_amount_raw, - updated_at_time - + updated_at_time, + valid_from_time, + auto_cancel FROM {{ ref('gmx_v2_' ~ chain ~ '_order_updated') }} {% if not loop.last %} UNION ALL diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_pool_amount_updated.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_pool_amount_updated.sql new file mode 100644 index 00000000000..f55114c2cc6 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_pool_amount_updated.sql @@ -0,0 +1,39 @@ +{{ config( + schema='gmx_v2', + alias = 'pool_amount_updated', + post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c"]\', + "project", + "gmx", + \'["ai_data_master","gmx-io"]\') }}' + ) +}} + +{%- set chains = [ + 'arbitrum', + 'avalanche_c', +] -%} + +{%- for chain in chains -%} +SELECT + blockchain, + block_time, + block_date, + block_number, + tx_hash, + index, + contract_address, + tx_index, + tx_from, + tx_to, + event_name, + msg_sender, + market, + token, + next_value, + delta +FROM {{ ref('gmx_v2_' ~ chain ~ '_pool_amount_updated') }} +{% if not loop.last %} +UNION ALL +{% endif %} +{%- endfor -%} + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_position_decrease.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_position_decrease.sql index 1970473375e..30f8ebfff2b 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_position_decrease.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_position_decrease.sql @@ -57,4 +57,4 @@ FROM {{ ref('gmx_v2_' ~ chain ~ '_position_decrease') }} {% if not loop.last %} UNION ALL {% endif %} -{%- endfor -%} \ No newline at end of file +{%- endfor -%} diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_position_fees_collected.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_position_fees_collected.sql index 78e89d3a511..c54fcae240e 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_position_fees_collected.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_position_fees_collected.sql @@ -34,11 +34,6 @@ SELECT collateral_token_price_min, collateral_token_price_max, trade_size_usd, - total_rebate_factor, - trader_discount_factor, - total_rebate_amount, - trader_discount_amount, - affiliate_reward_amount, funding_fee_amount, claimable_long_token_amount, claimable_short_token_amount, @@ -59,6 +54,17 @@ SELECT total_cost_amount, ui_fee_receiver_factor, ui_fee_amount, + referral_total_rebate_factor, + referral_total_rebate_amount, + referral_trader_discount_factor, + referral_adjusted_affiliate_reward_factor, + referral_affiliate_reward_amount, + referral_trader_discount_amount, + pro_trader_discount_factor, + pro_trader_discount_amount, + liquidation_fee_amount, + liquidation_fee_receiver_factor, + liquidation_fee_amount_for_fee_receiver, is_increase, order_key, position_key, diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_position_fees_info.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_position_fees_info.sql index 917113693ac..9ae7458454b 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_position_fees_info.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_position_fees_info.sql @@ -34,11 +34,6 @@ SELECT collateral_token_price_min, collateral_token_price_max, trade_size_usd, - total_rebate_factor, - trader_discount_factor, - total_rebate_amount, - trader_discount_amount, - affiliate_reward_amount, funding_fee_amount, claimable_long_token_amount, claimable_short_token_amount, @@ -59,6 +54,17 @@ SELECT total_cost_amount, ui_fee_receiver_factor, ui_fee_amount, + referral_total_rebate_factor, + referral_total_rebate_amount, + referral_trader_discount_factor, + referral_adjusted_affiliate_reward_factor, + referral_affiliate_reward_amount, + referral_trader_discount_amount, + pro_trader_discount_factor, + pro_trader_discount_amount, + liquidation_fee_amount, + liquidation_fee_receiver_factor, + liquidation_fee_amount_for_fee_receiver, is_increase, order_key, position_key, @@ -67,4 +73,4 @@ FROM {{ ref('gmx_v2_' ~ chain ~ '_position_fees_info') }} {% if not loop.last %} UNION ALL {% endif %} -{%- endfor -%} \ No newline at end of file +{%- endfor -%} diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_set_uint.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_set_uint.sql new file mode 100644 index 00000000000..4dbe5e181f8 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_set_uint.sql @@ -0,0 +1,38 @@ +{{ config( + schema='gmx_v2', + alias = 'set_uint', + post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c"]\', + "project", + "gmx", + \'["ai_data_master","gmx-io"]\') }}' + ) +}} + +{%- set chains = [ + 'arbitrum', + 'avalanche_c', +] -%} + +{%- for chain in chains -%} +SELECT + blockchain, + block_time, + block_date, + block_number, + tx_hash, + index, + contract_address, + tx_index, + tx_from, + tx_to, + event_name, + msg_sender, + base_key, + "data", + "value_raw" +FROM {{ ref('gmx_v2_' ~ chain ~ '_set_uint') }} +{% if not loop.last %} +UNION ALL +{% endif %} +{%- endfor -%} + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_shift_created.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_shift_created.sql new file mode 100644 index 00000000000..e79bb2d2a80 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_shift_created.sql @@ -0,0 +1,49 @@ +{{ config( + schema='gmx_v2', + alias = 'shift_created', + post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c"]\', + "project", + "gmx", + \'["ai_data_master","gmx-io"]\') }}' + ) +}} + +{%- set chains = [ + 'arbitrum', + 'avalanche_c', +] -%} + +{%- for chain in chains -%} +SELECT + blockchain, + block_time, + block_date, + block_number, + tx_hash, + index, + contract_address, + tx_from, + tx_to, + event_name, + msg_sender, + + account, + receiver, + callback_contract, + from_market, + to_market, + market_token_amount, + min_market_tokens, + updated_at_time, + execution_fee, + callback_gas_limit, + "key" + +FROM {{ ref('gmx_v2_' ~ chain ~ '_shift_created') }} +{% if not loop.last %} +UNION ALL +{% endif %} +{%- endfor -%} + + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_shift_executed.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_shift_executed.sql new file mode 100644 index 00000000000..4407f016586 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_shift_executed.sql @@ -0,0 +1,41 @@ +{{ config( + schema='gmx_v2', + alias = 'shift_executed', + post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c"]\', + "project", + "gmx", + \'["ai_data_master","gmx-io"]\') }}' + ) +}} + +{%- set chains = [ + 'arbitrum', + 'avalanche_c', +] -%} + +{%- for chain in chains -%} +SELECT + blockchain, + block_time, + block_date, + block_number, + tx_hash, + index, + contract_address, + tx_from, + tx_to, + event_name, + msg_sender, + + account, + received_market_tokens, + "key" + +FROM {{ ref('gmx_v2_' ~ chain ~ '_shift_executed') }} +{% if not loop.last %} +UNION ALL +{% endif %} +{%- endfor -%} + + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_withdrawal_cancelled.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_withdrawal_cancelled.sql new file mode 100644 index 00000000000..a1199d59838 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_withdrawal_cancelled.sql @@ -0,0 +1,41 @@ +{{ config( + schema='gmx_v2', + alias = 'withdrawal_cancelled', + post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c"]\', + "project", + "gmx", + \'["ai_data_master","gmx-io"]\') }}' + ) +}} + +{%- set chains = [ + 'arbitrum', + 'avalanche_c', +] -%} + +{%- for chain in chains -%} +SELECT + blockchain, + block_time, + block_date, + block_number, + tx_hash, + index, + contract_address, + tx_from, + tx_to, + event_name, + msg_sender, + + account, + "key", + reason_bytes, + reason + +FROM {{ ref('gmx_v2_' ~ chain ~ '_withdrawal_cancelled') }} +{% if not loop.last %} +UNION ALL +{% endif %} +{%- endfor -%} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_withdrawal_created.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_withdrawal_created.sql new file mode 100644 index 00000000000..527870ac98b --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_withdrawal_created.sql @@ -0,0 +1,49 @@ +{{ config( + schema='gmx_v2', + alias = 'withdrawal_created', + post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c"]\', + "project", + "gmx", + \'["ai_data_master","gmx-io"]\') }}' + ) +}} + +{%- set chains = [ + 'arbitrum', + 'avalanche_c', +] -%} + +{%- for chain in chains -%} +SELECT + blockchain, + block_time, + block_date, + block_number, + tx_hash, + index, + contract_address, + tx_from, + tx_to, + event_name, + msg_sender, + + account, + receiver, + callback_contract, + market, + market_token_amount, + min_long_token_amount, + min_short_token_amount, + updated_at_time, + execution_fee, + callback_gas_limit, + should_unwrap_native_token, + "key" + +FROM {{ ref('gmx_v2_' ~ chain ~ '_withdrawal_created') }} +{% if not loop.last %} +UNION ALL +{% endif %} +{%- endfor -%} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_withdrawal_executed.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_withdrawal_executed.sql new file mode 100644 index 00000000000..be12acddb55 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_withdrawal_executed.sql @@ -0,0 +1,40 @@ +{{ config( + schema='gmx_v2', + alias = 'withdrawal_executed', + post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c"]\', + "project", + "gmx", + \'["ai_data_master","gmx-io"]\') }}' + ) +}} + +{%- set chains = [ + 'arbitrum', + 'avalanche_c', +] -%} + +{%- for chain in chains -%} +SELECT + blockchain, + block_time, + block_date, + block_number, + tx_hash, + index, + contract_address, + tx_from, + tx_to, + event_name, + msg_sender, + + account, + swap_pricing_type, + "key" + +FROM {{ ref('gmx_v2_' ~ chain ~ '_withdrawal_executed') }} +{% if not loop.last %} +UNION ALL +{% endif %} +{%- endfor -%} + + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/arbitrum/gmx_v2_arbitrum_glv_markets_data.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/arbitrum/gmx_v2_arbitrum_glv_markets_data.sql new file mode 100644 index 00000000000..16d2d77e07e --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/arbitrum/gmx_v2_arbitrum_glv_markets_data.sql @@ -0,0 +1,24 @@ +{{ + config( + schema = 'gmx_v2_arbitrum', + alias = 'glv_markets_data', + materialized = 'view' + ) +}} + +SELECT + GCE.glv_token AS glv, + CONCAT(ERC20_LT.symbol, '-', ERC20_ST.symbol) AS glv_market_name, + 'GM' AS market_token_symbol, + 18 AS market_token_decimals, + GCE.long_token, + ERC20_LT.symbol AS long_token_symbol, + ERC20_LT.decimals AS long_token_decimals, + GCE.short_token, + ERC20_ST.symbol AS short_token_symbol, + ERC20_ST.decimals AS short_token_decimals +FROM {{ ref('gmx_v2_arbitrum_glv_created') }} AS GCE +LEFT JOIN {{ ref('gmx_v2_arbitrum_erc20') }} AS ERC20_LT + ON ERC20_LT.contract_address = GCE.long_token +LEFT JOIN {{ ref('gmx_v2_arbitrum_erc20') }} AS ERC20_ST + ON ERC20_ST.contract_address = GCE.short_token \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/arbitrum/gmx_v2_arbitrum_markets_data.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/arbitrum/gmx_v2_arbitrum_markets_data.sql index 5c4682b2fe8..9ef54976e01 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/arbitrum/gmx_v2_arbitrum_markets_data.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/arbitrum/gmx_v2_arbitrum_markets_data.sql @@ -15,10 +15,13 @@ SELECT END AS market_name, 'GM' AS market_token_symbol, 18 AS market_token_decimals, + MCE.index_token, ERC20_IT.symbol AS index_token_symbol, ERC20_IT.decimals AS index_token_decimals, + MCE.long_token, ERC20_LT.symbol AS long_token_symbol, ERC20_LT.decimals AS long_token_decimals, + MCE.short_token, ERC20_ST.symbol AS short_token_symbol, ERC20_ST.decimals AS short_token_decimals FROM {{ ref('gmx_v2_arbitrum_market_created') }} AS MCE diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/arbitrum/gmx_v2_arbitrum_tokens_schema.yml b/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/arbitrum/gmx_v2_arbitrum_tokens_schema.yml index 5bea8c3ee7f..317ba7b82c7 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/arbitrum/gmx_v2_arbitrum_tokens_schema.yml +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/arbitrum/gmx_v2_arbitrum_tokens_schema.yml @@ -110,10 +110,14 @@ models: description: The number of decimal places for the market token. data_tests: - not_null + - name: index_token + description: The contract address of the index token. - name: index_token_symbol description: The symbol representing the index token in the market. - name: index_token_decimals description: The number of decimal places for the index token used in the market. + - name: long_token + description: The contract address of the long token. - name: long_token_symbol description: The symbol representing the long token in the market. data_tests: @@ -122,6 +126,8 @@ models: description: The number of decimal places for the long token used in the market. data_tests: - not_null + - name: short_token + description: The contract address of the short token. - name: short_token_symbol description: The symbol representing the short token in the market. data_tests: @@ -129,4 +135,40 @@ models: - name: short_token_decimals description: The number of decimal places for the short token used in the market. data_tests: - - not_null \ No newline at end of file + - not_null + + + - name: gmx_v2_arbitrum_glv_markets_data + meta: + blockchain: arbitrum + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'gmx', 'markets', 'glv_markets_data'] + description: | + Processes decoded market data for GLV markets on the GMX platform in the Arbitrum blockchain. + This model extracts key details such as market names, token symbols, and decimals, enabling + comprehensive analysis of GLV markets. + + columns: + - name: glv + description: The identifier of the GLV market. + - name: glv_market_name + description: The name of the GLV market. + - name: market_token_symbol + description: The symbol of the market token. + - name: market_token_decimals + description: The decimal precision of the market token. + - name: long_token + description: The contract address of the long token. + - name: long_token_symbol + description: The symbol of the long token in the market. + - name: long_token_decimals + description: The decimal precision of the long token. + - name: short_token + description: The contract address of the short token. + - name: short_token_symbol + description: The symbol of the short token in the market. + - name: short_token_decimals + description: The decimal precision of the short token. diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/avalanche_c/gmx_v2_avalanche_c_glv_markets_data.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/avalanche_c/gmx_v2_avalanche_c_glv_markets_data.sql new file mode 100644 index 00000000000..126a8adc6fb --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/avalanche_c/gmx_v2_avalanche_c_glv_markets_data.sql @@ -0,0 +1,24 @@ +{{ + config( + schema = 'gmx_v2_avalanche_c', + alias = 'glv_markets_data', + materialized = 'view' + ) +}} + +SELECT + GCE.glv_token AS glv, + CONCAT(ERC20_LT.symbol, '-', ERC20_ST.symbol) AS glv_market_name, + 'GM' AS market_token_symbol, + 18 AS market_token_decimals, + GCE.long_token, + ERC20_LT.symbol AS long_token_symbol, + ERC20_LT.decimals AS long_token_decimals, + GCE.short_token, + ERC20_ST.symbol AS short_token_symbol, + ERC20_ST.decimals AS short_token_decimals +FROM {{ ref('gmx_v2_avalanche_c_glv_created') }} AS GCE +LEFT JOIN {{ ref('gmx_v2_avalanche_c_erc20') }} AS ERC20_LT + ON ERC20_LT.contract_address = GCE.long_token +LEFT JOIN {{ ref('gmx_v2_avalanche_c_erc20') }} AS ERC20_ST + ON ERC20_ST.contract_address = GCE.short_token \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/avalanche_c/gmx_v2_avalanche_c_markets_data.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/avalanche_c/gmx_v2_avalanche_c_markets_data.sql index c8fda944fb9..61d4a394158 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/avalanche_c/gmx_v2_avalanche_c_markets_data.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/avalanche_c/gmx_v2_avalanche_c_markets_data.sql @@ -15,10 +15,13 @@ SELECT END AS market_name, 'GM' AS market_token_symbol, 18 AS market_token_decimals, + MCE.index_token, ERC20_IT.symbol AS index_token_symbol, ERC20_IT.decimals AS index_token_decimals, + MCE.long_token, ERC20_LT.symbol AS long_token_symbol, ERC20_LT.decimals AS long_token_decimals, + MCE.short_token, ERC20_ST.symbol AS short_token_symbol, ERC20_ST.decimals AS short_token_decimals FROM {{ ref('gmx_v2_avalanche_c_market_created') }} AS MCE diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/avalanche_c/gmx_v2_avalanche_c_tokens_schema.yml b/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/avalanche_c/gmx_v2_avalanche_c_tokens_schema.yml index 572164b7ae2..279bb25881c 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/avalanche_c/gmx_v2_avalanche_c_tokens_schema.yml +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/avalanche_c/gmx_v2_avalanche_c_tokens_schema.yml @@ -109,10 +109,14 @@ models: description: The number of decimal places for the market token. data_tests: - not_null + - name: index_token + description: The contract address of the index token. - name: index_token_symbol description: The symbol representing the index token in the market. - name: index_token_decimals description: The number of decimal places for the index token used in the market. + - name: long_token + description: The contract address of the long token. - name: long_token_symbol description: The symbol representing the long token in the market. data_tests: @@ -121,6 +125,8 @@ models: description: The number of decimal places for the long token used in the market. data_tests: - not_null + - name: short_token + description: The contract address of the short token. - name: short_token_symbol description: The symbol representing the short token in the market. data_tests: @@ -129,3 +135,39 @@ models: description: The number of decimal places for the short token used in the market. data_tests: - not_null + + + - name: gmx_v2_avalanche_c_glv_markets_data + meta: + blockchain: avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['avalanche_c', 'gmx', 'markets', 'glv_markets_data'] + description: | + Processes decoded market data for GLV markets on the GMX platform in the Avalanche blockchain. + This model extracts key details such as market names, token symbols, and decimals, enabling + comprehensive analysis of GLV markets. + + columns: + - name: glv + description: The identifier of the GLV market. + - name: glv_market_name + description: The name of the GLV market. + - name: market_token_symbol + description: The symbol of the market token. + - name: market_token_decimals + description: The decimal precision of the market token. + - name: long_token + description: The contract address of the long token. + - name: long_token_symbol + description: The symbol of the long token in the market. + - name: long_token_decimals + description: The decimal precision of the long token. + - name: short_token + description: The contract address of the short token. + - name: short_token_symbol + description: The symbol of the short token in the market. + - name: short_token_decimals + description: The decimal precision of the short token. diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/gmx_v2_glv_markets_data.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/gmx_v2_glv_markets_data.sql new file mode 100644 index 00000000000..b0e0b15ba91 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/gmx_v2_glv_markets_data.sql @@ -0,0 +1,34 @@ +{{ config( + schema='gmx_v2', + alias = 'glv_markets_data', + post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c"]\', + "project", + "gmx", + \'["ai_data_master","gmx-io"]\') }}' + ) +}} + +{%- set chains = [ + 'arbitrum', + 'avalanche_c', +] -%} + +{%- for chain in chains -%} +SELECT + '{{ chain }}' AS "blockchain", + glv, + glv_market_name, + market_token_symbol, + market_token_decimals, + long_token, + long_token_symbol, + long_token_decimals, + short_token, + short_token_symbol, + short_token_decimals +FROM {{ ref('gmx_v2_' ~ chain ~ '_glv_markets_data') }} +{% if not loop.last %} +UNION ALL +{% endif %} +{%- endfor -%} + diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/gmx_v2_markets_data.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/gmx_v2_markets_data.sql index 0c0951fee6f..60a22b01370 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/gmx_v2_markets_data.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/gmx_v2_markets_data.sql @@ -20,10 +20,13 @@ SELECT market_name, market_token_symbol, market_token_decimals, + index_token, index_token_symbol, index_token_decimals, + long_token, long_token_symbol, long_token_decimals, + short_token, short_token_symbol, short_token_decimals FROM {{ ref('gmx_v2_' ~ chain ~ '_markets_data') }} diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/gmx_v2_tokens_schema.yml b/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/gmx_v2_tokens_schema.yml index e1c9b389c18..601a5f113d1 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/gmx_v2_tokens_schema.yml +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/gmx_v2_tokens_schema.yml @@ -110,10 +110,14 @@ models: description: The number of decimal places for the market token. data_tests: - not_null + - name: index_token + description: The contract address of the index token. - name: index_token_symbol description: The symbol representing the index token in the market. - name: index_token_decimals description: The number of decimal places for the index token used in the market. + - name: long_token + description: The contract address of the long token. - name: long_token_symbol description: The symbol representing the long token in the market. data_tests: @@ -122,6 +126,8 @@ models: description: The number of decimal places for the long token used in the market. data_tests: - not_null + - name: short_token + description: The contract address of the short token. - name: short_token_symbol description: The symbol representing the short token in the market. data_tests: @@ -129,4 +135,41 @@ models: - name: short_token_decimals description: The number of decimal places for the short token used in the market. data_tests: - - not_null \ No newline at end of file + - not_null + + + - name: gmx_v2_glv_markets_data + meta: + blockchain: arbitrum, avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'avalanche_c', 'gmx', 'markets', 'glv_markets_data'] + description: | + Processes decoded market data for GLV markets on the GMX platform in the Arbitrum and Avalanche blockchains. + This model extracts key details such as market names, token symbols, and decimals, enabling + comprehensive analysis of GLV markets. + + columns: + - *blockchain + - name: glv + description: The identifier of the GLV market. + - name: glv_market_name + description: The name of the GLV market. + - name: market_token_symbol + description: The symbol of the market token. + - name: market_token_decimals + description: The decimal precision of the market token. + - name: long_token + description: The contract address of the long token. + - name: long_token_symbol + description: The symbol of the long token in the market. + - name: long_token_decimals + description: The decimal precision of the long token. + - name: short_token + description: The contract address of the short token. + - name: short_token_symbol + description: The symbol of the short token in the market. + - name: short_token_decimals + description: The decimal precision of the short token. diff --git a/dbt_subprojects/daily_spellbook/models/_projects/lifi/arbitrum/lifi_arbitrum_transfers.sql b/dbt_subprojects/daily_spellbook/models/_projects/lifi/arbitrum/lifi_arbitrum_transfers.sql new file mode 100644 index 00000000000..50c4011e59c --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/lifi/arbitrum/lifi_arbitrum_transfers.sql @@ -0,0 +1,49 @@ +{{ config( + schema = 'lifi_arbitrum', + alias = 'transfers', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transfer_id'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] + ) +}} + +with source_data as ( + {{ lifi_extract_bridge_data('arbitrum') }} +), + +tokens_mapped as ( + select + *, + case + when sendingAssetId = 0x0000000000000000000000000000000000000000 + then 0x82af49447d8a07e3bd95bd0d56f35241523fbab1 -- WETH + when sendingAssetId = 0x3405a1bd46b85c5c029483fbecf2f3e611026e45 + then 0xff970a61a04b1ca14834a43f5de4533ebddb5cc8 -- USDC + else sendingAssetId + end as sendingAssetId_adjusted + from source_data +), + +price_data as ( + select + tokens_mapped.*, + p.price * minAmount / power(10, p.decimals) as amount_usd + from tokens_mapped + left join {{ source('prices', 'usd') }} p + on p.contract_address = tokens_mapped.sendingAssetId_adjusted + and p.blockchain = 'arbitrum' + and p.minute = date_trunc('minute', tokens_mapped.block_time) + {% if is_incremental() %} + and {{ incremental_predicate('p.minute') }} + {% endif %} +) + +{{ + add_tx_columns( + model_cte = 'price_data' + , blockchain = 'arbitrum' + , columns = ['from'] + ) +}} diff --git a/dbt_subprojects/daily_spellbook/models/_projects/lifi/avalanche_c/lifi_avalanche_c_transfers.sql b/dbt_subprojects/daily_spellbook/models/_projects/lifi/avalanche_c/lifi_avalanche_c_transfers.sql new file mode 100644 index 00000000000..90f8be57686 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/lifi/avalanche_c/lifi_avalanche_c_transfers.sql @@ -0,0 +1,47 @@ +{{ config( + schema = 'lifi_avalanche_c', + alias = 'transfers', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transfer_id'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] + ) +}} + +with source_data as ( + {{ lifi_extract_bridge_data('avalanche_c') }} +), + +tokens_mapped as ( + select + *, + case + when sendingAssetId = 0x0000000000000000000000000000000000000000 + then 0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7 -- WAVAX + else sendingAssetId + end as sendingAssetId_adjusted + from source_data +), + +price_data as ( + select + tokens_mapped.*, + p.price * minAmount / power(10, p.decimals) as amount_usd + from tokens_mapped + left join {{ source('prices', 'usd') }} p + on p.contract_address = tokens_mapped.sendingAssetId_adjusted + and p.blockchain = 'avalanche_c' + and p.minute = date_trunc('minute', tokens_mapped.block_time) + {% if is_incremental() %} + and {{ incremental_predicate('p.minute') }} + {% endif %} +) + +{{ + add_tx_columns( + model_cte = 'price_data' + , blockchain = 'avalanche_c' + , columns = ['from'] + ) +}} diff --git a/dbt_subprojects/daily_spellbook/models/_projects/lifi/bnb/lifi_bnb_transfers.sql b/dbt_subprojects/daily_spellbook/models/_projects/lifi/bnb/lifi_bnb_transfers.sql new file mode 100644 index 00000000000..e0182da42f6 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/lifi/bnb/lifi_bnb_transfers.sql @@ -0,0 +1,47 @@ +{{ config( + schema = 'lifi_bnb', + alias = 'transfers', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transfer_id'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] + ) +}} + +with source_data as ( + {{ lifi_extract_bridge_data('bnb') }} +), + +tokens_mapped as ( + select + *, + case + when sendingAssetId = 0x0000000000000000000000000000000000000000 + then 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c -- WBNB + else sendingAssetId + end as sendingAssetId_adjusted + from source_data +), + +price_data as ( + select + tokens_mapped.*, + p.price * minAmount / power(10, p.decimals) as amount_usd + from tokens_mapped + left join {{ source('prices', 'usd') }} p + on p.contract_address = tokens_mapped.sendingAssetId_adjusted + and p.blockchain = 'bnb' + and p.minute = date_trunc('minute', tokens_mapped.block_time) + {% if is_incremental() %} + and {{ incremental_predicate('p.minute') }} + {% endif %} +) + +{{ + add_tx_columns( + model_cte = 'price_data' + , blockchain = 'bnb' + , columns = ['from'] + ) +}} diff --git a/dbt_subprojects/daily_spellbook/models/_projects/lifi/ethereum/lifi_ethereum_transfers.sql b/dbt_subprojects/daily_spellbook/models/_projects/lifi/ethereum/lifi_ethereum_transfers.sql new file mode 100644 index 00000000000..3b9e32d6055 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/lifi/ethereum/lifi_ethereum_transfers.sql @@ -0,0 +1,47 @@ +{{ config( + schema = 'lifi_ethereum', + alias = 'transfers', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transfer_id'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] + ) +}} + +with source_data as ( + {{ lifi_extract_bridge_data('ethereum') }} +), + +tokens_mapped as ( + select + *, + case + when sendingAssetId = 0x0000000000000000000000000000000000000000 + then 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 -- WETH + else sendingAssetId + end as sendingAssetId_adjusted + from source_data +), + +price_data as ( + select + tokens_mapped.*, + p.price * minAmount / power(10, p.decimals) as amount_usd + from tokens_mapped + left join {{ source('prices', 'usd') }} p + on p.contract_address = tokens_mapped.sendingAssetId_adjusted + and p.blockchain = 'ethereum' + and p.minute = date_trunc('minute', tokens_mapped.block_time) + {% if is_incremental() %} + and {{ incremental_predicate('p.minute') }} + {% endif %} +) + +{{ + add_tx_columns( + model_cte = 'price_data' + , blockchain = 'ethereum' + , columns = ['from'] + ) +}} \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/lifi/fantom/lifi_fantom_transfers.sql b/dbt_subprojects/daily_spellbook/models/_projects/lifi/fantom/lifi_fantom_transfers.sql new file mode 100644 index 00000000000..51660d5e855 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/lifi/fantom/lifi_fantom_transfers.sql @@ -0,0 +1,47 @@ +{{ config( + schema = 'lifi_fantom', + alias = 'transfers', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transfer_id'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] + ) +}} + +with source_data as ( + {{ lifi_extract_bridge_data('fantom') }} +), + +tokens_mapped as ( + select + *, + case + when sendingAssetId = 0x0000000000000000000000000000000000000000 + then 0x21be370d5312f44cb42ce377bc9b8a0cef1a4c83 -- WFTM + else sendingAssetId + end as sendingAssetId_adjusted + from source_data +), + +price_data as ( + select + tokens_mapped.*, + p.price * minAmount / power(10, p.decimals) as amount_usd + from tokens_mapped + left join {{ source('prices', 'usd') }} p + on p.contract_address = tokens_mapped.sendingAssetId_adjusted + and p.blockchain = 'fantom' + and p.minute = date_trunc('minute', tokens_mapped.block_time) + {% if is_incremental() %} + and {{ incremental_predicate('p.minute') }} + {% endif %} +) + +{{ + add_tx_columns( + model_cte = 'price_data' + , blockchain = 'fantom' + , columns = ['from'] + ) +}} diff --git a/dbt_subprojects/daily_spellbook/models/_projects/lifi/gnosis/lifi_gnosis_transfers.sql b/dbt_subprojects/daily_spellbook/models/_projects/lifi/gnosis/lifi_gnosis_transfers.sql new file mode 100644 index 00000000000..d52d1b9ec92 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/lifi/gnosis/lifi_gnosis_transfers.sql @@ -0,0 +1,47 @@ +{{ config( + schema = 'lifi_gnosis', + alias = 'transfers', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transfer_id'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] + ) +}} + +with source_data as ( + {{ lifi_extract_bridge_data('gnosis') }} +), + +tokens_mapped as ( + select + *, + case + when sendingAssetId = 0x0000000000000000000000000000000000000000 + then 0xe91d153e0b41518a2ce8dd3d7944fa863463a97d -- WXDAI + else sendingAssetId + end as sendingAssetId_adjusted + from source_data +), + +price_data as ( + select + tokens_mapped.*, + p.price * minAmount / power(10, p.decimals) as amount_usd + from tokens_mapped + left join {{ source('prices', 'usd') }} p + on p.contract_address = tokens_mapped.sendingAssetId_adjusted + and p.blockchain = 'gnosis' + and p.minute = date_trunc('minute', tokens_mapped.block_time) + {% if is_incremental() %} + and {{ incremental_predicate('p.minute') }} + {% endif %} +) + +{{ + add_tx_columns( + model_cte = 'price_data' + , blockchain = 'gnosis' + , columns = ['from'] + ) +}} diff --git a/dbt_subprojects/daily_spellbook/models/_projects/lifi/lifi_transfers.sql b/dbt_subprojects/daily_spellbook/models/_projects/lifi/lifi_transfers.sql new file mode 100644 index 00000000000..74c65ad2842 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/lifi/lifi_transfers.sql @@ -0,0 +1,61 @@ +{{ + config( + schema = 'lifi', + alias = 'transfers', + materialized = 'view', + post_hook='{{ expose_spells(\'[ + "arbitrum" + , "avalanche_c" + , "bnb" + , "ethereum" + , "fantom" + , "gnosis" + , "zksync" + ]\', + "project", + "lifi", + \'["lequangphu"]\') }}' + ) +}} + +{% set chains = [ + 'ethereum', + 'arbitrum', + 'avalanche_c', + 'bnb', + 'fantom', + 'gnosis', + 'zksync' +] %} + +with chain_transfers as ( + {% for chain in chains %} + select + contract_address, + tx_hash, + evt_index, + block_time, + block_number, + block_date, + transactionId, + bridge, + integrator, + referrer, + sendingAssetId, + receiver, + minAmount, + destinationChainId, + source_chain, + transfer_id, + sendingAssetId_adjusted, + amount_usd, + tx_from + from {{ ref('lifi_' ~ chain ~ '_transfers') }} + {% if not loop.last %} + union all + {% endif %} + {% endfor %} +) + +select * +from chain_transfers \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/lifi/schema.yml b/dbt_subprojects/daily_spellbook/models/_projects/lifi/schema.yml new file mode 100644 index 00000000000..b24cab85118 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/lifi/schema.yml @@ -0,0 +1,73 @@ +version: 2 + +models: + - name: lifi_ethereum_transfers + description: "Ethereum LiFi transfer events" + columns: &common_columns + - name: contract_address + description: "Contract address of LiFi Diamond" + - name: tx_hash + description: "Transaction hash" + - name: evt_index + description: "Event index" + - name: block_time + description: "Timestamp of the block" + - name: block_number + description: "Block number" + - name: transactionId + description: "Unique transaction ID from LiFi" + - name: bridge + description: "Bridge used for the transfer" + - name: integrator + description: "Integrator of the transfer" + - name: referrer + description: "Referrer of the transfer" + - name: sendingAssetId + description: "Asset being transferred" + - name: receiver + description: "Address receiving the transfer" + - name: minAmount + description: "Minimum amount to be received" + - name: destinationChainId + description: "Target chain ID for the transfer" + - name: source_chain + description: "Source blockchain" + - name: transfer_id + description: "Unique identifier for each transfer" + data_tests: + - unique + - not_null + - name: amount_usd + description: "USD value of the transfer amount at the time of transfer" + - name: sendingAssetId_adjusted + description: "Sending asset address adjusted for native token price lookup" + - name: tx_from + description: "Address that initiated the transaction" + + - name: lifi_arbitrum_transfers + description: "Arbitrum LiFi transfer events" + columns: *common_columns + + - name: lifi_avalanche_c_transfers + description: "Avalanche C-Chain LiFi transfer events" + columns: *common_columns + + - name: lifi_bnb_transfers + description: "BNB LiFi transfer events" + columns: *common_columns + + - name: lifi_fantom_transfers + description: "Fantom LiFi transfer events" + columns: *common_columns + + - name: lifi_gnosis_transfers + description: "Gnosis LiFi transfer events" + columns: *common_columns + + - name: lifi_zksync_transfers + description: "zkSync LiFi transfer events" + columns: *common_columns + + - name: lifi_transfers + description: "Combined LiFi transfer events across all supported chains" + columns: *common_columns \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/lifi/zksync/lifi_zksync_transfers.sql b/dbt_subprojects/daily_spellbook/models/_projects/lifi/zksync/lifi_zksync_transfers.sql new file mode 100644 index 00000000000..d1560138355 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/lifi/zksync/lifi_zksync_transfers.sql @@ -0,0 +1,47 @@ +{{ config( + schema = 'lifi_zksync', + alias = 'transfers', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transfer_id'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] + ) +}} + +with source_data as ( + {{ lifi_extract_bridge_data('zksync') }} +), + +tokens_mapped as ( + select + *, + case + when sendingAssetId = 0x0000000000000000000000000000000000000000 + then 0x000000000000000000000000000000000000800a -- WETH + else sendingAssetId + end as sendingAssetId_adjusted + from source_data +), + +price_data as ( + select + tokens_mapped.*, + p.price * minAmount / power(10, p.decimals) as amount_usd + from tokens_mapped + left join {{ source('prices', 'usd') }} p + on p.contract_address = tokens_mapped.sendingAssetId_adjusted + and p.blockchain = 'zksync' + and p.minute = date_trunc('minute', tokens_mapped.block_time) + {% if is_incremental() %} + and {{ incremental_predicate('p.minute') }} + {% endif %} +) + +{{ + add_tx_columns( + model_cte = 'price_data' + , blockchain = 'zksync' + , columns = ['from'] + ) +}} diff --git a/dbt_subprojects/daily_spellbook/models/_projects/oneinch/arbitrum/project/oneinch_arbitrum_project_swaps.sql b/dbt_subprojects/daily_spellbook/models/_projects/oneinch/arbitrum/project/oneinch_arbitrum_project_swaps.sql index 2eb1fe7a88b..5f77999fd1c 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/oneinch/arbitrum/project/oneinch_arbitrum_project_swaps.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/oneinch/arbitrum/project/oneinch_arbitrum_project_swaps.sql @@ -6,7 +6,7 @@ config( schema = 'oneinch_' + blockchain, alias = 'project_swaps', - partition_by = ['block_month'], + partition_by = ['block_month', 'project'], materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', diff --git a/dbt_subprojects/daily_spellbook/models/_projects/oneinch/avalanche_c/project/oneinch_avalanche_c_project_swaps.sql b/dbt_subprojects/daily_spellbook/models/_projects/oneinch/avalanche_c/project/oneinch_avalanche_c_project_swaps.sql index 2907e88ba5d..093d2639f73 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/oneinch/avalanche_c/project/oneinch_avalanche_c_project_swaps.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/oneinch/avalanche_c/project/oneinch_avalanche_c_project_swaps.sql @@ -6,7 +6,7 @@ config( schema = 'oneinch_' + blockchain, alias = 'project_swaps', - partition_by = ['block_month'], + partition_by = ['block_month', 'project'], materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', diff --git a/dbt_subprojects/daily_spellbook/models/_projects/oneinch/base/project/oneinch_base_project_swaps.sql b/dbt_subprojects/daily_spellbook/models/_projects/oneinch/base/project/oneinch_base_project_swaps.sql index e954d34e994..03801b0e475 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/oneinch/base/project/oneinch_base_project_swaps.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/oneinch/base/project/oneinch_base_project_swaps.sql @@ -6,7 +6,7 @@ config( schema = 'oneinch_' + blockchain, alias = 'project_swaps', - partition_by = ['block_month'], + partition_by = ['block_month', 'project'], materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', diff --git a/dbt_subprojects/daily_spellbook/models/_projects/oneinch/bnb/project/oneinch_bnb_project_swaps.sql b/dbt_subprojects/daily_spellbook/models/_projects/oneinch/bnb/project/oneinch_bnb_project_swaps.sql index cc7fb07f019..f82ebf6751b 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/oneinch/bnb/project/oneinch_bnb_project_swaps.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/oneinch/bnb/project/oneinch_bnb_project_swaps.sql @@ -6,7 +6,7 @@ config( schema = 'oneinch_' + blockchain, alias = 'project_swaps', - partition_by = ['block_month'], + partition_by = ['block_month', 'project'], materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', diff --git a/dbt_subprojects/daily_spellbook/models/_projects/oneinch/ethereum/project/oneinch_ethereum_project_swaps.sql b/dbt_subprojects/daily_spellbook/models/_projects/oneinch/ethereum/project/oneinch_ethereum_project_swaps.sql index 9d47240179a..a4c2e198af3 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/oneinch/ethereum/project/oneinch_ethereum_project_swaps.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/oneinch/ethereum/project/oneinch_ethereum_project_swaps.sql @@ -6,7 +6,7 @@ config( schema = 'oneinch_' + blockchain, alias = 'project_swaps', - partition_by = ['block_month'], + partition_by = ['block_month', 'project'], materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', diff --git a/dbt_subprojects/daily_spellbook/models/_projects/oneinch/fantom/project/oneinch_fantom_project_swaps.sql b/dbt_subprojects/daily_spellbook/models/_projects/oneinch/fantom/project/oneinch_fantom_project_swaps.sql index 0b1cd0356cc..3829f2abadd 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/oneinch/fantom/project/oneinch_fantom_project_swaps.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/oneinch/fantom/project/oneinch_fantom_project_swaps.sql @@ -6,7 +6,7 @@ config( schema = 'oneinch_' + blockchain, alias = 'project_swaps', - partition_by = ['block_month'], + partition_by = ['block_month', 'project'], materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', diff --git a/dbt_subprojects/daily_spellbook/models/_projects/oneinch/gnosis/project/oneinch_gnosis_project_swaps.sql b/dbt_subprojects/daily_spellbook/models/_projects/oneinch/gnosis/project/oneinch_gnosis_project_swaps.sql index 09149d17b28..7989d8ab3f4 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/oneinch/gnosis/project/oneinch_gnosis_project_swaps.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/oneinch/gnosis/project/oneinch_gnosis_project_swaps.sql @@ -6,7 +6,7 @@ config( schema = 'oneinch_' + blockchain, alias = 'project_swaps', - partition_by = ['block_month'], + partition_by = ['block_month', 'project'], materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', diff --git a/dbt_subprojects/daily_spellbook/models/_projects/oneinch/optimism/project/oneinch_optimism_project_swaps.sql b/dbt_subprojects/daily_spellbook/models/_projects/oneinch/optimism/project/oneinch_optimism_project_swaps.sql index b1d1415c487..11824e6478e 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/oneinch/optimism/project/oneinch_optimism_project_swaps.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/oneinch/optimism/project/oneinch_optimism_project_swaps.sql @@ -6,7 +6,7 @@ config( schema = 'oneinch_' + blockchain, alias = 'project_swaps', - partition_by = ['block_month'], + partition_by = ['block_month', 'project'], materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', diff --git a/dbt_subprojects/daily_spellbook/models/_projects/oneinch/polygon/project/oneinch_polygon_project_swaps.sql b/dbt_subprojects/daily_spellbook/models/_projects/oneinch/polygon/project/oneinch_polygon_project_swaps.sql index fdb95800436..8af9dd17c97 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/oneinch/polygon/project/oneinch_polygon_project_swaps.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/oneinch/polygon/project/oneinch_polygon_project_swaps.sql @@ -6,7 +6,7 @@ config( schema = 'oneinch_' + blockchain, alias = 'project_swaps', - partition_by = ['block_month'], + partition_by = ['block_month', 'project'], materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', diff --git a/dbt_subprojects/daily_spellbook/models/_projects/oneinch/zksync/project/oneinch_zksync_project_swaps.sql b/dbt_subprojects/daily_spellbook/models/_projects/oneinch/zksync/project/oneinch_zksync_project_swaps.sql index a365adc4658..34df6a770ba 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/oneinch/zksync/project/oneinch_zksync_project_swaps.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/oneinch/zksync/project/oneinch_zksync_project_swaps.sql @@ -6,7 +6,7 @@ config( schema = 'oneinch_' + blockchain, alias = 'project_swaps', - partition_by = ['block_month'], + partition_by = ['block_month', 'project'], materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', diff --git a/dbt_subprojects/daily_spellbook/models/_projects/safe/balances/_schema.yml b/dbt_subprojects/daily_spellbook/models/_projects/safe/balances/_schema.yml new file mode 100644 index 00000000000..26d00f99e5b --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/safe/balances/_schema.yml @@ -0,0 +1,123 @@ +version: 2 + +models: + - name: safe_arbitrum_balances + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - address + - token_address + meta: + blockchain: arbitrum + project: safe + contributors: safeintern + config: + tags: ['safe', 'arbitrum'] + description: “Safe addresses balances” + + - name: safe_avalanche_c_balances + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - address + - token_address + meta: + blockchain: avalanche_c + project: safe + contributors: safeintern + config: + tags: [ 'safe', 'avalanche_c' ] + description: “Safe addresses balances” + + - name: safe_base_balances + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - address + - token_address + meta: + blockchain: base + project: safe + contributors: safeintern + config: + tags: [ 'safe', 'base' ] + description: “Safe addresses balances” + + - name: safe_ethereum_balances + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - address + - token_address + meta: + blockchain: ethereum + project: safe + contributors: safeintern + config: + tags: [ 'safe', 'ethereum' ] + description: “Safe addresses balances” + + - name: safe_linea_balances + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - address + - token_address + meta: + blockchain: linea + project: safe + contributors: safeintern + config: + tags: [ 'safe', 'linea' ] + description: “Safe addresses balances” + + - name: safe_optimism_balances + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - address + - token_address + meta: + blockchain: optimism + project: safe + contributors: safeintern + config: + tags: [ 'safe', 'optimism' ] + description: “Safe addresses balances” + + - name: safe_polygon_balances + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - address + - token_address + meta: + blockchain: polygon + project: safe + contributors: safeintern + config: + tags: [ 'safe', 'polygon' ] + description: “Safe addresses balances” + + - name: safe_scroll_balances + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - address + - token_address + meta: + blockchain: scroll + project: safe + contributors: safeintern + config: + tags: [ 'safe', 'scroll' ] + description: “Safe addresses balances” + diff --git a/dbt_subprojects/hourly_spellbook/models/_project/safe/arbitrum/safe_arbitrum_balances.sql b/dbt_subprojects/daily_spellbook/models/_projects/safe/balances/safe_arbitrum_balances.sql similarity index 95% rename from dbt_subprojects/hourly_spellbook/models/_project/safe/arbitrum/safe_arbitrum_balances.sql rename to dbt_subprojects/daily_spellbook/models/_projects/safe/balances/safe_arbitrum_balances.sql index 56d1fe4895b..9c5b0f9816d 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/safe/arbitrum/safe_arbitrum_balances.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/safe/balances/safe_arbitrum_balances.sql @@ -15,7 +15,7 @@ with safes as ( select address, blockchain - from {{ ref('safe_arbitrum_safes') }} + from {{ source('safe_arbitrum','safes') }} where blockchain = 'arbitrum' ), diff --git a/dbt_subprojects/daily_spellbook/models/_projects/safe/balances/safe_avalanche_c_balances.sql b/dbt_subprojects/daily_spellbook/models/_projects/safe/balances/safe_avalanche_c_balances.sql new file mode 100644 index 00000000000..33279643d65 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/safe/balances/safe_avalanche_c_balances.sql @@ -0,0 +1,36 @@ +{{ + config( + schema = 'safe_avalanche_c', + alias = 'balances', + partition_by = ['day'], + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['day', 'address', 'token_address'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.day')] + ) + }} + +with safes as ( + select + address, + blockchain + from {{ source('safe_avalanche_c','safes') }} + where blockchain = 'avalanche_c' +), + +balances as ( + {{ + balances_incremental_subset_daily( + blockchain = 'avalanche_c', + address_list = 'safes', + start_date = '2021-07-01' + ) + }} +) + +select * from balances +where token_standard in ('native', 'erc20') +and token_address not in ( + 0xd74f5255d557944cf7dd0e45ff521520002d5748, --$9.8B were minted in a hack in 2023, all of which are stored in a Safe. Filtering out. + 0xe9689028ede16c2fdfe3d11855d28f8e3fc452a3 ) diff --git a/dbt_subprojects/daily_spellbook/models/_projects/safe/balances/safe_base_balances.sql b/dbt_subprojects/daily_spellbook/models/_projects/safe/balances/safe_base_balances.sql new file mode 100644 index 00000000000..44e45138e77 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/safe/balances/safe_base_balances.sql @@ -0,0 +1,36 @@ +{{ + config( + schema = 'safe_base', + alias = 'balances', + partition_by = ['day'], + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['day', 'address', 'token_address'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.day')] + ) + }} + +with safes as ( + select + address, + blockchain + from {{ source('safe_base','safes') }} + where blockchain = 'base' +), + +balances as ( + {{ + balances_incremental_subset_daily( + blockchain = 'base', + address_list = 'safes', + start_date = '2021-07-01' + ) + }} +) + +select * from balances +where token_standard in ('native', 'erc20') +and token_address not in ( + 0xd74f5255d557944cf7dd0e45ff521520002d5748, --$9.8B were minted in a hack in 2023, all of which are stored in a Safe. Filtering out. + 0xe9689028ede16c2fdfe3d11855d28f8e3fc452a3 ) diff --git a/dbt_subprojects/hourly_spellbook/models/_project/safe/ethereum/safe_ethereum_balances.sql b/dbt_subprojects/daily_spellbook/models/_projects/safe/balances/safe_ethereum_balances.sql similarity index 95% rename from dbt_subprojects/hourly_spellbook/models/_project/safe/ethereum/safe_ethereum_balances.sql rename to dbt_subprojects/daily_spellbook/models/_projects/safe/balances/safe_ethereum_balances.sql index ebc7a430771..e681bf730d2 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/safe/ethereum/safe_ethereum_balances.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/safe/balances/safe_ethereum_balances.sql @@ -14,7 +14,7 @@ with safes as ( select address, blockchain - from {{ ref('safe_ethereum_safes') }} + from {{ source('safe_ethereum','safes') }} where blockchain = 'ethereum' ), diff --git a/dbt_subprojects/daily_spellbook/models/_projects/safe/balances/safe_linea_balances.sql b/dbt_subprojects/daily_spellbook/models/_projects/safe/balances/safe_linea_balances.sql new file mode 100644 index 00000000000..de62451a1e4 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/safe/balances/safe_linea_balances.sql @@ -0,0 +1,36 @@ +{{ + config( + schema = 'safe_linea', + alias = 'balances', + partition_by = ['day'], + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['day', 'address', 'token_address'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.day')] + ) + }} + +with safes as ( + select + address, + blockchain + from {{ source('safe_linea','safes') }} + where blockchain = 'linea' +), + +balances as ( + {{ + balances_incremental_subset_daily( + blockchain = 'linea', + address_list = 'safes', + start_date = '2021-07-01' + ) + }} +) + +select * from balances +where token_standard in ('native', 'erc20') +and token_address not in ( + 0xd74f5255d557944cf7dd0e45ff521520002d5748, --$9.8B were minted in a hack in 2023, all of which are stored in a Safe. Filtering out. + 0xe9689028ede16c2fdfe3d11855d28f8e3fc452a3 ) diff --git a/dbt_subprojects/hourly_spellbook/models/_project/safe/optimism/safe_optimism_balances.sql b/dbt_subprojects/daily_spellbook/models/_projects/safe/balances/safe_optimism_balances.sql similarity index 96% rename from dbt_subprojects/hourly_spellbook/models/_project/safe/optimism/safe_optimism_balances.sql rename to dbt_subprojects/daily_spellbook/models/_projects/safe/balances/safe_optimism_balances.sql index 2465f2a8d65..8338b3be28c 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/safe/optimism/safe_optimism_balances.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/safe/balances/safe_optimism_balances.sql @@ -20,7 +20,7 @@ with safes as ( select address, blockchain - from {{ ref('safe_optimism_safes') }} + from {{ source('safe_optimism','safes') }} where blockchain = 'optimism' ), balances as ( diff --git a/dbt_subprojects/hourly_spellbook/models/_project/safe/polygon/safe_polygon_balances.sql b/dbt_subprojects/daily_spellbook/models/_projects/safe/balances/safe_polygon_balances.sql similarity index 95% rename from dbt_subprojects/hourly_spellbook/models/_project/safe/polygon/safe_polygon_balances.sql rename to dbt_subprojects/daily_spellbook/models/_projects/safe/balances/safe_polygon_balances.sql index 5c62beac340..de7eb4a6d7a 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/safe/polygon/safe_polygon_balances.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/safe/balances/safe_polygon_balances.sql @@ -15,7 +15,7 @@ with safes as ( select address, blockchain - from {{ ref('safe_polygon_safes') }} + from {{ source('safe_polygon','safes') }} where blockchain = 'polygon' ), diff --git a/dbt_subprojects/daily_spellbook/models/_projects/safe/balances/safe_scroll_balances.sql b/dbt_subprojects/daily_spellbook/models/_projects/safe/balances/safe_scroll_balances.sql new file mode 100644 index 00000000000..4cf40377e92 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/safe/balances/safe_scroll_balances.sql @@ -0,0 +1,36 @@ +{{ + config( + schema = 'safe_scroll', + alias = 'balances', + partition_by = ['day'], + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['day', 'address', 'token_address'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.day')] + ) + }} + +with safes as ( + select + address, + blockchain + from {{ source('safe_scroll','safes') }} + where blockchain = 'scroll' +), + +balances as ( + {{ + balances_incremental_subset_daily( + blockchain = 'scroll', + address_list = 'safes', + start_date = '2021-07-01' + ) + }} +) + +select * from balances +where token_standard in ('native', 'erc20') +and token_address not in ( + 0xd74f5255d557944cf7dd0e45ff521520002d5748, --$9.8B were minted in a hack in 2023, all of which are stored in a Safe. Filtering out. + 0xe9689028ede16c2fdfe3d11855d28f8e3fc452a3 ) diff --git a/dbt_subprojects/daily_spellbook/models/_sector/alm/README.md b/dbt_subprojects/daily_spellbook/models/_sector/alm/README.md index cd518f1c77c..dfd2a73445f 100644 --- a/dbt_subprojects/daily_spellbook/models/_sector/alm/README.md +++ b/dbt_subprojects/daily_spellbook/models/_sector/alm/README.md @@ -41,7 +41,7 @@ Because of that, the `alm.trades` design mimics the one used for `dex.trades`. ### Data Flow Architecture -As previously said, the architecture of `alm.trades` mimics the one of `dex.trades`. Because of that, [this diagram](https://github.com/duneanalytics/spellbook/blob/main/models/_sector/dex/readme.md#data-flow-architecture) can be taken as a reference. +As previously said, the architecture of `alm.trades` mimics the one of `dex.trades`. Because of that, [this diagram](https://github.com/duneanalytics/spellbook/blob/main/dbt_subprojects/dex/models/trades/readme.md) can be taken as a reference. In `alm.trades`, the 2 macros used are: - `arrakis_compatible_v2_trades`: which tracks all the Uniswap V3 LP positions (timestamp, liquidity, and tick information) minted by Arrakis Finance vaults, and then derives the volume served for each swap based on the price movement of the pool. - `add_pool_price_usd`: which uses `prices.usd` to populate the pool price in USD, so the volume served can be expressed in USD terms. diff --git a/dbt_subprojects/daily_spellbook/models/_sector/labels/addresses/__single_category_labels__/beets/labels_beets_pools_sonic.sql b/dbt_subprojects/daily_spellbook/models/_sector/labels/addresses/__single_category_labels__/beets/labels_beets_pools_sonic.sql new file mode 100644 index 00000000000..f1a8903fbcf --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_sector/labels/addresses/__single_category_labels__/beets/labels_beets_pools_sonic.sql @@ -0,0 +1,222 @@ +{{config( + alias = 'beets_pools_sonic', + post_hook = '{{ expose_spells(\'["sonic"]\', + "sector", + "labels", + \'["viniabussafi"]\') }}' +)}} + +WITH v2_pools AS( + WITH pools AS ( + SELECT + pool_id, + zip.tokens AS token_address, + zip.weights / pow(10, 18) AS normalized_weight, + symbol, + pool_type, + pool_name + FROM ( + SELECT + c.poolId AS pool_id, + t.tokens, + w.weights, + cc.symbol, + 'weighted' AS pool_type, + cc.name AS pool_name + FROM {{ source('beethoven_x_v2_sonic', 'Vault_evt_PoolRegistered') }} c + INNER JOIN {{ source('beethoven_x_v2_sonic', 'WeightedPoolFactory_call_create') }} cc + ON c.evt_tx_hash = cc.call_tx_hash + AND bytearray_substring(c.poolId, 1, 20) = cc.output_0 + CROSS JOIN UNNEST(cc.tokens) WITH ORDINALITY t(tokens, pos) + CROSS JOIN UNNEST(cc.normalizedWeights) WITH ORDINALITY w(weights, pos) + WHERE t.pos = w.pos + ) zip + + + UNION ALL + + SELECT + c.poolId AS pool_id, + t.tokens AS token_address, + 0 AS normalized_weight, + cc.symbol, + 'stable' AS pool_type, + cc.name AS pool_name + FROM {{ source('beethoven_x_v2_sonic', 'Vault_evt_PoolRegistered') }} c + INNER JOIN {{ source('beethoven_x_v2_sonic', 'ComposableStablePoolFactory_call_create') }} cc + ON c.evt_tx_hash = cc.call_tx_hash + AND bytearray_substring(c.poolId, 1, 20) = cc.output_0 + CROSS JOIN UNNEST(cc.tokens) AS t(tokens) +), + +settings AS ( + SELECT + pool_id, + coalesce(t.symbol, '?') AS token_symbol, + normalized_weight, + p.symbol AS pool_symbol, + p.pool_type, + p.pool_name + FROM pools p + LEFT JOIN {{ source('tokens', 'erc20') }} t ON p.token_address = t.contract_address + AND t.blockchain = 'sonic' +) + +SELECT + 'sonic' AS blockchain, + bytearray_substring(pool_id, 1, 20) AS address, + CASE WHEN pool_type IN ('stable') + THEN lower(pool_symbol) + ELSE lower(concat(array_join(array_agg(token_symbol ORDER BY token_symbol), '/'), ' ', + array_join(array_agg(cast(norm_weight AS varchar) ORDER BY token_symbol), '/'))) + END AS name, + pool_name AS poolname, + pool_type, + '2' AS version, + 'beets_v2_pool' AS category, + 'beets' AS contributor, + 'query' AS source, + TIMESTAMP'2024-12-15 00:00' AS created_at, + now() AS updated_at, + 'beets_pools_sonic' AS model_name, + 'identifier' AS label_type +FROM ( + SELECT + s1.pool_id, + token_symbol, + pool_symbol, + cast(100 * normalized_weight AS integer) AS norm_weight, + pool_type, + pool_name + FROM settings s1 + GROUP BY s1.pool_id, token_symbol, pool_symbol, normalized_weight, pool_type, pool_name +) s +GROUP BY pool_id, pool_symbol, pool_type, pool_name +ORDER BY 1), + +v3_pools AS( + WITH token_data AS ( + SELECT + pool, + ARRAY_AGG(FROM_HEX(json_extract_scalar(token, '$.token')) ORDER BY token_index) AS tokens + FROM ( + SELECT + pool, + tokenConfig, + SEQUENCE(1, CARDINALITY(tokenConfig)) AS token_index_array + FROM {{ source('beethoven_x_v3_sonic', 'Vault_evt_PoolRegistered') }} + ) AS pool_data + CROSS JOIN UNNEST(tokenConfig, token_index_array) AS t(token, token_index) + GROUP BY 1 + ), + + pools AS ( + SELECT + pool_id, + zip.tokens AS token_address, + zip.weights / POWER(10, 18) AS normalized_weight, + symbol, + pool_type + FROM ( + SELECT + c.pool AS pool_id, + t.tokens, + w.weights, + cc.symbol, + 'weighted' AS pool_type + FROM token_data c + INNER JOIN {{ source('beethoven_x_v3_sonic', 'WeightedPoolFactory_call_create') }} cc + ON c.pool = cc.output_pool + CROSS JOIN UNNEST(c.tokens) WITH ORDINALITY t(tokens, pos) + CROSS JOIN UNNEST(cc.normalizedWeights) WITH ORDINALITY w(weights, pos) + WHERE t.pos = w.pos + + UNION ALL + + SELECT + c.pool AS pool_id, + t.tokens, + 0 AS weights, + cc.symbol, + 'stable' AS pool_type + FROM token_data c + INNER JOIN {{ source('beethoven_x_v3_sonic', 'StablePoolFactory_call_create') }} cc + ON c.pool = cc.output_pool + CROSS JOIN UNNEST(c.tokens) AS t(tokens) + ) zip + ), + + settings AS ( + SELECT + pool_id, + coalesce(t.symbol, '?') AS token_symbol, + normalized_weight, + p.symbol AS pool_symbol, + p.pool_type + FROM pools p + LEFT JOIN {{ source('tokens', 'erc20') }} t ON p.token_address = t.contract_address + AND t.blockchain = 'sonic' + ) + +SELECT + 'sonic' AS blockchain, + bytearray_substring(pool_id, 1, 20) AS address, + CASE WHEN pool_type IN ('stable') + THEN lower(pool_symbol) + ELSE lower(concat(array_join(array_agg(token_symbol ORDER BY token_symbol), '/'), ' ', + array_join(array_agg(cast(norm_weight AS varchar) ORDER BY token_symbol), '/'))) + END AS name, + pool_type, + '3' AS version, + 'beets_v3_pool' AS category, + 'beets' AS contributor, + 'query' AS source, + TIMESTAMP'2024-12-15 00:00' AS created_at, + now() AS updated_at, + 'beets_pools_sonic' AS model_name, + 'identifier' AS label_type +FROM ( + SELECT + s1.pool_id, + token_symbol, + pool_symbol, + cast(100 * normalized_weight AS integer) AS norm_weight, + pool_type + FROM settings s1 + GROUP BY s1.pool_id, token_symbol, pool_symbol, normalized_weight, pool_type +) s +GROUP BY pool_id, pool_symbol, pool_type +ORDER BY 1 +) + +SELECT + blockchain, + address, + name, + pool_type, + version, + category, + contributor, + source, + created_at, + updated_at, + model_name, + label_type +FROM v2_pools + +UNION + +SELECT + blockchain, + address, + name, + pool_type, + version, + category, + contributor, + source, + created_at, + updated_at, + model_name, + label_type +FROM v3_pools \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_sector/labels/addresses/__single_category_labels__/beets/labels_beets_schema.yml b/dbt_subprojects/daily_spellbook/models/_sector/labels/addresses/__single_category_labels__/beets/labels_beets_schema.yml new file mode 100644 index 00000000000..b830022043c --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_sector/labels/addresses/__single_category_labels__/beets/labels_beets_schema.yml @@ -0,0 +1,54 @@ +version: 2 + +models: + - name: labels_beets_pools_sonic + meta: + blockchain: sonic + sector: labels + project: beets + contributors: viniabussafi + config: + tags: ['labels', 'fantom', 'balancer', 'pools'] + description: 'Beets liquidity pools created on Sonic.' + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - address + - name + - category + - model_name + - blockchain + columns: + - &blockchain + name: blockchain + description: 'Blockchain' + - &address + name: address + description: 'Address of liquidity pool' + - &name + name: name + description: 'Label name of pool containg the token symbols and their respective weights (if applicable)' + - &poolname + name: poolname + description: 'Label name of pool set at contract creation' + - &category + name: category + description: 'Label category' + - &contributor + name: contributor + description: 'Wizard(s) contributing to labels' + - &source + name: source + description: 'How were labels generated (could be static or query)' + - &created_at + name: created_at + description: 'When were labels created' + - &updated_at + name: updated_at + description: "When were labels updated for the last time" + - &model_name + name: model_name + description: "Name of the label model sourced from" + - &label_type + name: label_type + description: "Type of label (see labels overall readme)" \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_sector/labels/labels_addresses.sql b/dbt_subprojects/daily_spellbook/models/_sector/labels/labels_addresses.sql index e0afc67d250..3d3047c5079 100644 --- a/dbt_subprojects/daily_spellbook/models/_sector/labels/labels_addresses.sql +++ b/dbt_subprojects/daily_spellbook/models/_sector/labels/labels_addresses.sql @@ -6,7 +6,7 @@ post_hook='{{ expose_spells(\'["bitcoin", "ethereum", "solana", "arbitrum", "gnosis", "optimism", "bnb", "avalanche_c", "fantom"]\', "sector", "labels", - \'["soispoke", "hildobby", "ilemi", "hosuke", "kaiblade"]\') }}') + \'["soispoke", "hildobby", "ilemi", "hosuke", "kaiblade", "viniabussafi"]\') }}') }} -- single category labels (no subsets), needs label_type and model_name added still. @@ -14,6 +14,8 @@ ref('labels_aztec_v2_contracts_ethereum') , source('labels', 'labels_balancer_v1_pools') , source('labels', 'balancer_v2_pools') + , source('labels', 'balancer_v3_pools') + , source('labels', 'balancer_cowswap_amm_pools') , ref('labels_balancer_v2_gauges') , ref('labels_cex') , ref('labels_contracts') diff --git a/dbt_subprojects/daily_spellbook/models/_sector/rwa/arbitrum/rwa_arbitrum_schema.yml b/dbt_subprojects/daily_spellbook/models/_sector/rwa/arbitrum/rwa_arbitrum_schema.yml index 575bafe15c1..003910de111 100644 --- a/dbt_subprojects/daily_spellbook/models/_sector/rwa/arbitrum/rwa_arbitrum_schema.yml +++ b/dbt_subprojects/daily_spellbook/models/_sector/rwa/arbitrum/rwa_arbitrum_schema.yml @@ -30,6 +30,12 @@ models: - &type name: type description: "Type of Asset" + - &decimals + name: decimals + description: "Decimals of the asset" + - &category + name: category + description: "RWA category for the Asset" - name: rwa_arbitrum_dex_pools diff --git a/dbt_subprojects/daily_spellbook/models/_sector/rwa/arbitrum/rwa_arbitrum_tokens.sql b/dbt_subprojects/daily_spellbook/models/_sector/rwa/arbitrum/rwa_arbitrum_tokens.sql index 3e38fcc57aa..6bc56f2101d 100644 --- a/dbt_subprojects/daily_spellbook/models/_sector/rwa/arbitrum/rwa_arbitrum_tokens.sql +++ b/dbt_subprojects/daily_spellbook/models/_sector/rwa/arbitrum/rwa_arbitrum_tokens.sql @@ -15,14 +15,90 @@ select token_address, symbol, project, - type + type, + decimals, + category from (values - (0x59D9356E565Ab3A36dD77763Fc0d87fEaf85508C, 'USDM' , 'Mountain Protocol' , 'RWA' ), - (0xfc90518D5136585ba45e34ED5E1D108BD3950CFa, 'USD+' , 'Dinari' , 'RWA' ), - (0x9d2f299715d94d8a7e6f5eaa8e654e8c74a988a7, 'FXS' , 'Frax Finance' , 'Governance' ) + (0x59D9356E565Ab3A36dD77763Fc0d87fEaf85508C, 'USDM' , 'Mountain Protocol' , 'RWA' , 18, 'Stablecoin'), + (0xfc90518D5136585ba45e34ED5E1D108BD3950CFa, 'USD+' , 'Dinari' , 'RWA' , 6 , 'Stocks'), + (0x9d2f299715d94d8a7e6f5eaa8e654e8c74a988a7, 'FXS' , 'Frax Finance' , 'Governance' , 18, 'Stablecoin'), + (0x667fd83e24ca1d935d36717d305d54fa0cac991c, 'FRAX' , 'Frax Finance' , 'RWA' , 18, 'Stablecoin'), + (0xCe38e140fC3982a6bCEbc37b040913EF2Cd6C5a7, 'AAPL.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0xd8F728AdB72a46Ae2c92234AE8870D04907786C5, 'AMD.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0x8240aFFe697CdE618AD05c3c8963f5Bfe152650b, 'AMZN.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0x3619ca1e96c629f7D71C1b03dc0Ee56479356228, 'ARKB.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0x67BaD479F77488f0f427584e267e66086a7Da43A, 'ARM.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0x769fF50fD49900a6c53b2aF049eACB83dAD52Bdf, 'BITB.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0x2B7c643b42409F352B936BF07e0538ba20979Bff, 'BRRR.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0x2824eFE5CeDB3BC8730E412981997daC7C7640C2, 'BTCO.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0xc52915Fe75dc8db9fb6306f43AAef1344E0837AB, 'BTCW.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0x46b979440ac257151ee5a5bc9597b76386907fa1, 'COIN.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0xDD92f0723a7318e684A88532CAC2421E3cC9968e, 'DEFI.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0x3c9f23db4ddc5655f7be636358d319a3de1ff0c4, 'DIS.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0xa6f344abc6e2501b2b303fcbba99cd89f136b5fb, 'EZBC.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0x026fdf3024953cb2e8982bc11c67d336f37a5044, 'FBTC.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0xb1284f6b3e487e3f773e9ad40f337c3b3cda5c69, 'GBTC.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0x8e50d11a54cff859b202b7fe5225353be0646410, 'GOOGL.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0x0c59f6b96d3cac58240429c7659ec107f8b1efa7, 'HODL.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0xc1ba16afdcb3a41242944c9faaccd9fb6f2b428c, 'IBIT.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0x0c29891dc5060618c779e2a45fbe4808aa5ae6ad, 'MCD.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0x519062155b0591627c8a0c0958110a8c5639dca6, 'META.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0x77308f8b63a99b24b262d930e0218ed2f49f8475, 'MSFT.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0x3ad63b3c0ea6d7a093ff98fde040baddc389ecdc, 'NFLX.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0x14297be295ab922458277be046e89f73382bdf8e, 'NLY.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0x4dafffddea93ddf1e0e7b61e844331455053ce5c, 'NVDA.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0xf1f18f765f118c3598cc54dcac1d0e12066263fe, 'PFE.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0x118346c2bb9d24412ed58c53bf9bb6f61a20d7ec, 'PLD.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0x5b6424769823e82a1829b0a8bcaf501bffd90d25, 'PYPL.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0x0b5ac0d7dcf6964609a12af4f6c6f3c257070193, 'RIOT.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0xf4bd09b048248876e39fcf2e0cdf1aee1240a9d2, 'SPY.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0xd883bcf80b2b085fa40cc3e2416b4ab1cbca649e, 'SQ.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0x36d37b6cbca364cf1d843eff8c2f6824491bcf81, 'TSLA.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0x9c46e1b70d447b770dbfc8d450543a431af6df3a, 'USFR.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0xeb0d1360a14c3b162f2974daa5d218e0c1090146, 'YUM.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0x0a2919147b871a0fc90f04944e31fad56d9af666, 'SLX.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0xc20770116f2821d550574c2b9ce1b4baa7012377, 'WEAT.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0x13f950ee286a5be0254065d4b66420fc0e57adfc, 'WOOD.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0xad6a646c1b262586ef3a8b6c6304e7c9218ecac4, 'PHO.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0x97ec5dada8262bd922bffd54a93f5a11efe0b136, 'RDDT.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0xb415998a7bb6f11dc589e0eb20adf586ba32f12a, 'GME.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0x28bf1c9ee2eb746a2d61a0bec97a344028171d6c, 'AMC.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0xa0eefbba9c18925fb6bab26281806772398cca1f, 'UBER.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0x337842843512192b798a5592053ce8e2245651f8, 'CSCO.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0x289594b223ab31832726eb99871fa99adac583e5, 'ADBE.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0x7c5fed5e0f8d05748cc12ffe1ca400b07de0f983, 'AVGO.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0x315a2dca4b1b633d3a707c71d96243534c02f7c4, 'XOM.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0x0e929101c4fa7c91eaa64d7216161ba3eee387fe, 'CVX.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0x50e2b96f958133cbda56d1a62d156e812fe97828, 'JNJ.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0x44966bf47a494b36dfb407afb334a9226cdf90bc, 'AZN.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0x50f7b76a0b888e5d7196f1a472d2e567d425c761, 'TJX.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0xb90e1ee5f4194388e71c11dc2a4eea16da391ce4, 'PG.d' , 'Dinari' , 'RWA' , 18, 'Stocks'), + (0x79ECCE8E2D17603877Ff15BC29804CbCB590EC08, 'fBILL' , 'Fortunafi' , 'RWA' , 18, 'Treasury Bills'), + (0x45bafad5a6a531Bc18Cf6CE5B02C58eA4D20589b, 'ifBILL' , 'Fortunafi' , 'RWA' , 18, 'Treasury Bills'), + (0x20c64dee8fda5269a78f2d5bdba861ca1d83df7a, 'bHIGH' , 'BackedFi' , 'RWA' , 18, 'Bonds'), + (0xbbcb0356bB9e6B3Faa5CbF9E5F36185d53403Ac9, 'bCOIN' , 'BackedFi' , 'RWA' , 18, 'Bonds'), + (0x2f11EeeE0bf21E7661A22dbBbb9068F4ad191b86, 'bNIU' , 'BackedFi' , 'RWA' , 18, 'Bonds'), + (0xAde6057FcAfa57d6d51FFa341C64ce4814995995, 'bZPR1' , 'BackedFi' , 'RWA' , 18, 'Bonds'), + (0x2F123cF3F37CE3328CC9B5b8415f9EC5109b45e7, 'bC3M' , 'BackedFi' , 'RWA' , 18, 'Bonds'), + (0x0f76d32cdccdcbd602a55af23eaf58fd1ee17245, 'bERNA' , 'BackedFi' , 'RWA' , 18, 'Bonds'), + (0x3f95aa88ddbb7d9d484aa3d482bf0a80009c52c9, 'bERNX' , 'BackedFi' , 'RWA' , 18, 'Bonds'), + (0xF84D28A8D28292842dD73D1c5F99476A80b6666A, 'TBILL' , 'OpenEden' , 'RWA' , 6 , 'Treasury Bills'), + (0xB88a5Ac00917a02d82c7cd6CEBd73E2852d43574, 'SWEEP' , 'Sweep' , 'RWA' , 18, 'Stablecoin'), + (0x35e050d3C0eC2d29D269a8EcEa763a183bDF9A9D, 'USDY' , 'Ondo Finance' , 'RWA' , 18, 'Treasury Bonds'), + (0x9B6226dd0191a77d032F56A6d383044EE99944C3, 'flrEUR' , 'Florence Finance' , 'RWA' , 18, 'Stablecoin'), + (0x0BBF664D46becc28593368c97236FAa0fb397595, 'KNOX' , 'Reserve Protocol' , 'RWA' , 18, 'Stablecoin'), + (0x0000206329b97DB379d5E1Bf586BbDB969C63274, 'USDA' , 'Angle' , 'RWA' , 18, 'Stablecoin'), + (0xFA5Ed56A203466CbBC2430a43c66b9D8723528E7, 'agEUR' , 'Angle' , 'RWA' , 18, 'Stablecoin'), + (0x323665443cef804a3b5206103304bd4872ea4253, 'USDV' , 'Verified USD' , 'RWA' , 6 , 'Stablecoin'), + (0xB9e4765BCE2609bC1949592059B17Ea72fEe6C6A, 'BENJI' , 'FranklinTempleton' , 'RWA' , 18, 'U.S. govt Securities'), + (0x89B1e7068bF8E3232dD8f16c35cAc45bDA584f4E, 'SWEEPR' , 'Sweep' , 'Governance' , 18, 'Stablecoin'), + (0x3269a3C00AB86c753856fD135d97b87FACB0d848, 'FFM' , 'Florence Finance' , 'Governance' , 18, 'Stablecoin'), + (0xCa5Ca9083702c56b481D1eec86F1776FDbd2e594, 'RSR' , 'Reserve Protocol' , 'Governance' , 18, 'Stablecoin') ) as t( token_address, symbol, project, - type + type, + decimals, + category ) diff --git a/dbt_subprojects/daily_spellbook/models/boost/boost_deployed.sql b/dbt_subprojects/daily_spellbook/models/boost/boost_deployed.sql index 2b7e0c586ea..40be3f50a3b 100644 --- a/dbt_subprojects/daily_spellbook/models/boost/boost_deployed.sql +++ b/dbt_subprojects/daily_spellbook/models/boost/boost_deployed.sql @@ -1,7 +1,6 @@ {{ config( schema='boost', - tags = ['prod_exclude'], alias='deployed', materialized='incremental', file_format='delta', @@ -33,7 +32,7 @@ select TRY(from_unixtime(end_time)) as end_time, reward_amount_raw, reward_token_address, - cast(max_participants as int) as max_participants, + max_participants, creation_time, creator as creator_address from diff --git a/dbt_subprojects/daily_spellbook/models/chain_info/chain_info_chain_ids.sql b/dbt_subprojects/daily_spellbook/models/chain_info/chain_info_chain_ids.sql index 83a864dd8dd..a0df844e8e3 100644 --- a/dbt_subprojects/daily_spellbook/models/chain_info/chain_info_chain_ids.sql +++ b/dbt_subprojects/daily_spellbook/models/chain_info/chain_info_chain_ids.sql @@ -31,12 +31,12 @@ FROM ( values ,('Metadium Mainnet' ,'META' ,'META' ,'11' ,'11' ,'https://metadium.com' ,'') ,('Metadium Testnet' ,'META' ,'KAL' ,'12' ,'12' ,'https://metadium.com' ,'') ,('Diode Testnet Staging' ,'DIODE' ,'sDIODE' ,'13' ,'13' ,'https://diode.io/staging' ,'') -,('Flare Mainnet' ,'FLR' ,'FLR' ,'14' ,'14' ,'https://flare.xyz' ,'https://flare-explorer.flare.network') +,('Flare Mainnet', 'FLR', 'FLR', '14', '14', 'https://flare.network', 'https://flare-explorer.flare.network') ,('Diode Prenet' ,'DIODE' ,'DIODE' ,'15' ,'15' ,'https://diode.io/prenet' ,'') -,('Flare Testnet Coston' ,'FLR' ,'CFLR' ,'16' ,'16' ,'https://flare.xyz' ,'https://coston-explorer.flare.network') +,('Flare Testnet Coston', 'CFLR', 'CFLR', '16', '16', 'https://flare.network', 'https://coston-explorer.flare.network') ,('ThaiChain 2.0 ThaiFi' ,'TCH' ,'TFI' ,'17' ,'17' ,'https://exp.thaifi.com' ,'') ,('ThunderCore Testnet' ,'TST' ,'TST' ,'18' ,'18' ,'https://thundercore.com' ,'https://explorer-testnet.thundercore.com') -,('Songbird Canary-Network' ,'SGB' ,'SGB' ,'19' ,'19' ,'https://flare.xyz' ,'https://songbird-explorer.flare.network') +,('Songbird Canary-Network' ,'SGB' ,'SGB' ,'19' ,'19' ,'https://flare.network' ,'https://songbird-explorer.flare.network') ,('Elastos Smart Chain' ,'ETH' ,'ELA' ,'20' ,'20' ,'https://www.elastos.org/' ,'https://esc.elastos.io') ,('Elastos Smart Chain Testnet' ,'ETH' ,'tELA' ,'21' ,'21' ,'https://www.elastos.org/' ,'https://esc-testnet.elastos.io') ,('ELA-DID-Sidechain Mainnet' ,'ETH' ,'ELA' ,'22' ,'22' ,'https://www.elastos.org/' ,'') diff --git a/dbt_subprojects/daily_spellbook/models/chainswap/arbitrum/chain_swap_arbitrum_trades.sql b/dbt_subprojects/daily_spellbook/models/chainswap/arbitrum/chain_swap_arbitrum_trades.sql index c83e6121cf0..591bf524275 100644 --- a/dbt_subprojects/daily_spellbook/models/chainswap/arbitrum/chain_swap_arbitrum_trades.sql +++ b/dbt_subprojects/daily_spellbook/models/chainswap/arbitrum/chain_swap_arbitrum_trades.sql @@ -9,7 +9,7 @@ incremental_predicates=[ incremental_predicate('DBT_INTERNAL_DEST.block_time') ], - unique_key=['blockchain', 'tx_hash', 'evt_index'], + unique_key=['blockchain', 'tx_hash', 'evt_index', 'fee_token_address'], ) }} @@ -22,6 +22,8 @@ {% set deployer_5 = '0xb7b953e81612c57256ff0aebd62b6a2f0546f7da' %} {% set deployer_6 = '0xb252f0ab7bdf1be4d5bbf607eb5c220b2d902a2c' %} {% set deployer_7 = '0xa24e8cE77D4A7Ce869DA3730e6560BfB66553F94' %} +{% set deployer_8 = '0xc8378819fbB95130c34D62f520167F745B13C305' %} +{% set deployer_9 = '0xde7Cb3d58D4004ff0De70995C0604089cc945EAF' %} {% set weth_contract_address = '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1' %} {% set usdc_contract_address = '0xaf88d065e77c8cC2239327C5EDb3A432268e5831' %} {% set fee_recipient_1 = '0x415EEc63c95e944D544b3088bc682B759edB8548' %} @@ -40,6 +42,8 @@ with or "from" = {{ deployer_5 }} or "from" = {{ deployer_6 }} or "from" = {{ deployer_7 }} + or "from" = {{ deployer_8 }} + or "from" = {{ deployer_9 }} ) and block_time >= timestamp '{{project_start_date}}' ), @@ -102,7 +106,11 @@ with (to = {{ fee_recipient_1 }} or to = {{ fee_recipient_2 }}) and block_time >= timestamp '{{project_start_date}}' and value > 0 - + ), + aggregated_fee_deposits as ( + select evt_tx_hash, sum(fee_token_amount) as fee_token_amount, fee_token_address + from fee_deposits + group by evt_tx_hash, fee_token_address ) select distinct block_time, @@ -122,7 +130,7 @@ select distinct fee_token_amount / power(10, decimals) * price as fee_usd, fee_token_amount / power(10, decimals) as fee_token_amount, symbol as fee_token_symbol, - cast(fee_token_address as varchar) as fee_token_address, + coalesce(fee_token_address, {{weth_contract_address}}) as fee_token_address, -- Dex project, version, @@ -137,8 +145,7 @@ from bot_trades join highest_event_index_for_each_trade on bot_trades.tx_hash = highest_event_index_for_each_trade.tx_hash -/* Left Outer Join to support 0 fee trades */ -left join fee_deposits on bot_trades.tx_hash = fee_deposits.evt_tx_hash +left join aggregated_fee_deposits as fee_deposits on bot_trades.tx_hash = fee_deposits.evt_tx_hash left join {{ source('prices', 'usd') }} on ( diff --git a/dbt_subprojects/daily_spellbook/models/chainswap/avalanche_c/chain_swap_avalanche_c_trades.sql b/dbt_subprojects/daily_spellbook/models/chainswap/avalanche_c/chain_swap_avalanche_c_trades.sql index d66064471be..34d5ead3a0b 100644 --- a/dbt_subprojects/daily_spellbook/models/chainswap/avalanche_c/chain_swap_avalanche_c_trades.sql +++ b/dbt_subprojects/daily_spellbook/models/chainswap/avalanche_c/chain_swap_avalanche_c_trades.sql @@ -9,7 +9,7 @@ incremental_predicates=[ incremental_predicate('DBT_INTERNAL_DEST.block_time') ], - unique_key=['blockchain', 'tx_hash', 'evt_index'], + unique_key=['blockchain', 'tx_hash', 'evt_index', 'fee_token_address'], ) }} @@ -19,6 +19,8 @@ {% set deployer_2 = '0x415EEc63c95e944D544b3088bc682B759edB8548' %} {% set deployer_3 = '0xc1cc1a300Dcfe5359eBe37f2007A77d1F91533ba' %} {% set deployer_4 = '0xa24e8cE77D4A7Ce869DA3730e6560BfB66553F94' %} +{% set deployer_5 = '0xc8378819fbB95130c34D62f520167F745B13C305' %} +{% set deployer_6 = '0xde7Cb3d58D4004ff0De70995C0604089cc945EAF' %} {% set wavax_contract_address = '0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7' %} {% set usdc_contract_address = '0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E' %} {% set fee_recipient_1 = '0x415EEc63c95e944D544b3088bc682B759edB8548' %} @@ -34,6 +36,8 @@ with or "from" = {{ deployer_2 }} or "from" = {{ deployer_3 }} or "from" = {{ deployer_4 }} + or "from" = {{ deployer_5 }} + or "from" = {{ deployer_6 }} ) and block_time >= timestamp '{{project_start_date}}' ), @@ -104,6 +108,11 @@ with {% else %} and block_time >= timestamp '{{project_start_date}}' {% endif %} + ), + aggregated_fee_deposits as ( + select evt_tx_hash, sum(fee_token_amount) as fee_token_amount, fee_token_address + from fee_deposits + group by evt_tx_hash, fee_token_address ) select distinct block_time, @@ -123,7 +132,7 @@ select distinct fee_token_amount / power(10, decimals) * price as fee_usd, fee_token_amount / power(10, decimals) as fee_token_amount, symbol as fee_token_symbol, - cast(fee_token_address as varchar) as fee_token_address, + coalesce(fee_token_address, {{wavax_contract_address}}) as fee_token_address, -- Dex project, version, @@ -138,8 +147,7 @@ from bot_trades join highest_event_index_for_each_trade on bot_trades.tx_hash = highest_event_index_for_each_trade.tx_hash -/* Left Outer Join to support 0 fee trades */ -left join fee_deposits on bot_trades.tx_hash = fee_deposits.evt_tx_hash +left join aggregated_fee_deposits as fee_deposits on bot_trades.tx_hash = fee_deposits.evt_tx_hash left join {{ source('prices', 'usd') }} on ( diff --git a/dbt_subprojects/daily_spellbook/models/chainswap/base/chain_swap_base_trades.sql b/dbt_subprojects/daily_spellbook/models/chainswap/base/chain_swap_base_trades.sql index 32ba14c0fb4..4ad4612a9d9 100644 --- a/dbt_subprojects/daily_spellbook/models/chainswap/base/chain_swap_base_trades.sql +++ b/dbt_subprojects/daily_spellbook/models/chainswap/base/chain_swap_base_trades.sql @@ -9,7 +9,7 @@ incremental_predicates=[ incremental_predicate('DBT_INTERNAL_DEST.block_time') ], - unique_key=['blockchain', 'tx_hash', 'evt_index'], + unique_key=['blockchain', 'tx_hash', 'evt_index', 'fee_token_address'], ) }} @@ -21,6 +21,8 @@ {% set deployer_4 = '0x3A510C5a32bCb381c53704AED9c02b0c70041F7A' %} {% set deployer_5 = '0xb252f0ab7bdf1be4d5bbf607eb5c220b2d902a2c' %} {% set deployer_6 = '0xa24e8cE77D4A7Ce869DA3730e6560BfB66553F94' %} +{% set deployer_7 = "0xc8378819fbB95130c34D62f520167F745B13C305" %} +{% set deployer_8 = "0xde7Cb3d58D4004ff0De70995C0604089cc945EAF" %} {% set weth_contract_address = '0x4200000000000000000000000000000000000006' %} {% set usdc_contract_address = '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' %} {% set fee_recipient_1 = '0x415EEc63c95e944D544b3088bc682B759edB8548' %} @@ -38,6 +40,8 @@ with or "from" = {{ deployer_4 }} or "from" = {{ deployer_5 }} or "from" = {{ deployer_6 }} + or "from" = {{ deployer_7 }} + or "from" = {{ deployer_8 }} ) and block_time >= timestamp '{{project_start_date}}' ), @@ -108,6 +112,11 @@ with {% else %} and block_time >= timestamp '{{project_start_date}}' {% endif %} + ), + aggregated_fee_deposits as ( + select evt_tx_hash, sum(fee_token_amount) as fee_token_amount, fee_token_address + from fee_deposits + group by evt_tx_hash, fee_token_address ) select distinct block_time, @@ -127,7 +136,7 @@ select distinct fee_token_amount / power(10, decimals) * price as fee_usd, fee_token_amount / power(10, decimals) as fee_token_amount, symbol as fee_token_symbol, - cast(fee_token_address as varchar) as fee_token_address, + coalesce(fee_token_address, {{weth_contract_address}}) as fee_token_address, -- Dex project, version, @@ -142,8 +151,7 @@ from bot_trades join highest_event_index_for_each_trade on bot_trades.tx_hash = highest_event_index_for_each_trade.tx_hash -/* Left Outer Join to support 0 fee trades */ -left join fee_deposits on bot_trades.tx_hash = fee_deposits.evt_tx_hash +left join aggregated_fee_deposits as fee_deposits on bot_trades.tx_hash = fee_deposits.evt_tx_hash left join {{ source('prices', 'usd') }} on ( diff --git a/dbt_subprojects/daily_spellbook/models/chainswap/bnb/chain_swap_bnb_trades.sql b/dbt_subprojects/daily_spellbook/models/chainswap/bnb/chain_swap_bnb_trades.sql index ab069893eaf..ca2c8015251 100644 --- a/dbt_subprojects/daily_spellbook/models/chainswap/bnb/chain_swap_bnb_trades.sql +++ b/dbt_subprojects/daily_spellbook/models/chainswap/bnb/chain_swap_bnb_trades.sql @@ -9,7 +9,7 @@ incremental_predicates=[ incremental_predicate('DBT_INTERNAL_DEST.block_time') ], - unique_key=['blockchain', 'tx_hash', 'evt_index'], + unique_key=['blockchain', 'tx_hash', 'evt_index', 'fee_token_address'], ) }} @@ -18,6 +18,8 @@ {% set deployer_1 = '0x1d32cFeFd97de9D740714A31b2E8C7bc34825442' %} {% set deployer_2 = '0x3A510C5a32bCb381c53704AED9c02b0c70041F7A' %} {% set deployer_3 = '0xa24e8cE77D4A7Ce869DA3730e6560BfB66553F94' %} +{% set deployer_4 = '0xc8378819fbB95130c34D62f520167F745B13C305' %} +{% set deployer_5 = '0xde7Cb3d58D4004ff0De70995C0604089cc945EAF' %} {% set wbnb_contract_address = '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c' %} {% set usdc_contract_address = '0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d' %} {% set fee_recipient_1 = '0x415EEc63c95e944D544b3088bc682B759edB8548' %} @@ -32,6 +34,8 @@ with "from" = {{ deployer_1 }} or "from" = {{ deployer_2 }} or "from" = {{ deployer_3 }} + or "from" = {{ deployer_4 }} + or "from" = {{ deployer_5 }} ) and block_time >= timestamp '{{project_start_date}}' @@ -103,6 +107,11 @@ with {% else %} and block_time >= timestamp '{{project_start_date}}' {% endif %} + ), + aggregated_fee_deposits as ( + select evt_tx_hash, sum(fee_token_amount) as fee_token_amount, fee_token_address + from fee_deposits + group by evt_tx_hash, fee_token_address ) select distinct block_time, @@ -122,7 +131,7 @@ select distinct fee_token_amount / power(10, decimals) * price as fee_usd, fee_token_amount / power(10, decimals) as fee_token_amount, symbol as fee_token_symbol, - cast(fee_token_address as varchar) as fee_token_address, + coalesce(fee_token_address, {{wbnb_contract_address}}) as fee_token_address, -- Dex project, version, @@ -138,7 +147,7 @@ join highest_event_index_for_each_trade on bot_trades.tx_hash = highest_event_index_for_each_trade.tx_hash /* Left Outer Join to support 0 fee trades */ -left join fee_deposits on bot_trades.tx_hash = fee_deposits.evt_tx_hash +left join aggregated_fee_deposits as fee_deposits on bot_trades.tx_hash = fee_deposits.evt_tx_hash left join {{ source('prices', 'usd') }} on ( diff --git a/dbt_subprojects/daily_spellbook/models/chainswap/chain_swap_schema.yml b/dbt_subprojects/daily_spellbook/models/chainswap/chain_swap_schema.yml index fc91c877fab..5dfa1b400d0 100644 --- a/dbt_subprojects/daily_spellbook/models/chainswap/chain_swap_schema.yml +++ b/dbt_subprojects/daily_spellbook/models/chainswap/chain_swap_schema.yml @@ -100,6 +100,7 @@ models: - blockchain - tx_hash - evt_index + - fee_token_address columns: - *blockchain - *block_time @@ -142,6 +143,7 @@ models: - blockchain - tx_hash - evt_index + - fee_token_address columns: - *blockchain - *block_time @@ -184,6 +186,7 @@ models: - blockchain - tx_hash - evt_index + - fee_token_address columns: - *blockchain - *block_time @@ -226,6 +229,7 @@ models: - blockchain - tx_hash - evt_index + - fee_token_address columns: - *blockchain - *block_time @@ -268,6 +272,7 @@ models: - blockchain - tx_hash - evt_index + - fee_token_address columns: - *blockchain - *block_time @@ -310,6 +315,7 @@ models: - blockchain - tx_hash - evt_index + - fee_token_address columns: - *blockchain - *block_time @@ -352,6 +358,7 @@ models: - blockchain - tx_hash - evt_index + - fee_token_address columns: - *blockchain @@ -377,4 +384,4 @@ models: - *user - *tx_hash - *evt_index - - *is_last_trade_in_transaction \ No newline at end of file + - *is_last_trade_in_transaction diff --git a/dbt_subprojects/daily_spellbook/models/chainswap/ethereum/chain_swap_ethereum_trades.sql b/dbt_subprojects/daily_spellbook/models/chainswap/ethereum/chain_swap_ethereum_trades.sql index 073195a8c12..4ad0c4894ab 100644 --- a/dbt_subprojects/daily_spellbook/models/chainswap/ethereum/chain_swap_ethereum_trades.sql +++ b/dbt_subprojects/daily_spellbook/models/chainswap/ethereum/chain_swap_ethereum_trades.sql @@ -9,7 +9,7 @@ incremental_predicates=[ incremental_predicate("DBT_INTERNAL_DEST.block_time") ], - unique_key=["blockchain", "tx_hash", "evt_index"], + unique_key=['blockchain', 'tx_hash', 'evt_index', 'fee_token_address'], ) }} @@ -20,8 +20,12 @@ {% set deployer_3 = "0xc1cc1a300Dcfe5359eBe37f2007A77d1F91533ba" %} {% set deployer_4 = "0x3A510C5a32bCb381c53704AED9c02b0c70041F7A" %} {% set deployer_5 = "0xa24e8cE77D4A7Ce869DA3730e6560BfB66553F94" %} +{% set deployer_6 = "0x686c0072dF3Df7A13ef666a3b661803a48558A90" %} +{% set deployer_7 = "0xc8378819fbB95130c34D62f520167F745B13C305" %} +{% set deployer_8 = "0xde7Cb3d58D4004ff0De70995C0604089cc945EAF" %} {% set weth_contract_address = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2" %} {% set usdc_contract_address = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" %} +{% set usdt_contract_address = "0xdac17f958d2ee523a2206206994597c13d831ec7" %} {% set fee_recipient_1 = "0x415EEc63c95e944D544b3088bc682B759edB8548" %} {% set fee_recipient_2 = "0xe1ff5a4c489b11e094bfbb5d23c6d4597a3a79ad" %} @@ -36,6 +40,9 @@ with or "from" = {{ deployer_3 }} or "from" = {{ deployer_4 }} or "from" = {{ deployer_5 }} + or "from" = {{ deployer_6 }} + or "from" = {{ deployer_7 }} + or "from" = {{ deployer_8 }} ) and block_time >= timestamp '{{project_start_date}}' ), @@ -86,6 +93,7 @@ with and ( contract_address = {{ weth_contract_address }} or contract_address = {{ usdc_contract_address }} + or contract_address = {{ usdt_contract_address }} ) {% if is_incremental() %} and {{ incremental_predicate('evt_block_time') }} @@ -106,6 +114,11 @@ with {% else %} and block_time >= timestamp '{{project_start_date}}' {% endif %} + ), + aggregated_fee_deposits as ( + select evt_tx_hash, sum(fee_token_amount) as fee_token_amount, fee_token_address + from fee_deposits + group by evt_tx_hash, fee_token_address ) select distinct block_time, @@ -125,7 +138,7 @@ select distinct fee_token_amount / power(10, decimals) * price as fee_usd, fee_token_amount / power(10, decimals) as fee_token_amount, symbol as fee_token_symbol, - cast(fee_token_address as varchar) as fee_token_address, + coalesce(fee_token_address, {{weth_contract_address}}) as fee_token_address, -- Dex project, version, @@ -140,8 +153,7 @@ from bot_trades join highest_event_index_for_each_trade on bot_trades.tx_hash = highest_event_index_for_each_trade.tx_hash -/* Left Outer Join to support 0 fee trades */ -left join fee_deposits on bot_trades.tx_hash = fee_deposits.evt_tx_hash +left join aggregated_fee_deposits as fee_deposits on bot_trades.tx_hash = fee_deposits.evt_tx_hash left join {{ source("prices", "usd") }} on ( diff --git a/dbt_subprojects/daily_spellbook/models/chainswap/optimism/chain_swap_optimism_trades.sql b/dbt_subprojects/daily_spellbook/models/chainswap/optimism/chain_swap_optimism_trades.sql index db7bb3f0001..2a110861880 100644 --- a/dbt_subprojects/daily_spellbook/models/chainswap/optimism/chain_swap_optimism_trades.sql +++ b/dbt_subprojects/daily_spellbook/models/chainswap/optimism/chain_swap_optimism_trades.sql @@ -9,7 +9,7 @@ incremental_predicates=[ incremental_predicate('DBT_INTERNAL_DEST.block_time') ], - unique_key=['blockchain', 'tx_hash', 'evt_index'], + unique_key=['blockchain', 'tx_hash', 'evt_index', 'fee_token_address'], ) }} @@ -22,6 +22,8 @@ {% set deployer_5 = '0x9eC1ACAe39d07E1e8D8B3cEbe7022790D87D744A' %} {% set deployer_6 = '0x415EEc63c95e944D544b3088bc682B759edB8548' %} {% set deployer_7 = '0xa24e8cE77D4A7Ce869DA3730e6560BfB66553F94' %} +{% set deployer_8 = '0xc8378819fbB95130c34D62f520167F745B13C305' %} +{% set deployer_9 = '0xde7Cb3d58D4004ff0De70995C0604089cc945EAF' %} {% set weth_contract_address = '0x4200000000000000000000000000000000000006' %} {% set usdc_contract_address = '0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85' %} {% set fee_recipient_1 = '0x415EEc63c95e944D544b3088bc682B759edB8548' %} @@ -40,6 +42,8 @@ with or "from" = {{ deployer_5 }} or "from" = {{ deployer_6 }} or "from" = {{ deployer_7 }} + or "from" = {{ deployer_8 }} + or "from" = {{ deployer_9 }} ) and block_time >= timestamp '{{project_start_date}}' ), @@ -110,6 +114,11 @@ with {% else %} and block_time >= timestamp '{{project_start_date}}' {% endif %} + ), + aggregated_fee_deposits as ( + select evt_tx_hash, sum(fee_token_amount) as fee_token_amount, fee_token_address + from fee_deposits + group by evt_tx_hash, fee_token_address ) select distinct block_time, @@ -129,7 +138,7 @@ select distinct fee_token_amount / power(10, decimals) * price as fee_usd, fee_token_amount / power(10, decimals) as fee_token_amount, symbol as fee_token_symbol, - cast(fee_token_address as varchar) as fee_token_address, + coalesce(fee_token_address, {{weth_contract_address}}) as fee_token_address, -- Dex project, version, @@ -145,7 +154,7 @@ join highest_event_index_for_each_trade on bot_trades.tx_hash = highest_event_index_for_each_trade.tx_hash /* Left Outer Join to support 0 fee trades */ -left join fee_deposits on bot_trades.tx_hash = fee_deposits.evt_tx_hash +left join aggregated_fee_deposits as fee_deposits on bot_trades.tx_hash = fee_deposits.evt_tx_hash left join {{ source('prices', 'usd') }} on ( diff --git a/dbt_subprojects/daily_spellbook/models/chainswap/polygon/chain_swap_polygon_trades.sql b/dbt_subprojects/daily_spellbook/models/chainswap/polygon/chain_swap_polygon_trades.sql index 01556b7a6bf..5629a66a60d 100644 --- a/dbt_subprojects/daily_spellbook/models/chainswap/polygon/chain_swap_polygon_trades.sql +++ b/dbt_subprojects/daily_spellbook/models/chainswap/polygon/chain_swap_polygon_trades.sql @@ -9,7 +9,7 @@ incremental_predicates=[ incremental_predicate('DBT_INTERNAL_DEST.block_time') ], - unique_key=['blockchain', 'tx_hash', 'evt_index'], + unique_key=['blockchain', 'tx_hash', 'evt_index', 'fee_token_address'], ) }} @@ -21,8 +21,11 @@ {% set deployer_4 = '0x3A510C5a32bCb381c53704AED9c02b0c70041F7A' %} {% set deployer_5 = '0xB7B953e81612c57256fF0aebD62B6a2F0546F7dA' %} {% set deployer_6 = '0xa24e8cE77D4A7Ce869DA3730e6560BfB66553F94' %} +{% set deployer_7 = "0xc8378819fbB95130c34D62f520167F745B13C305" %} +{% set deployer_8 = "0xde7Cb3d58D4004ff0De70995C0604089cc945EAF" %} {% set wmatic_contract_address = '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270' %} {% set usdc_contract_address = '0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359' %} +{% set usdt_contract_address = '0xc2132d05d31c914a87c6611c10748aeb04b58e8f' %} {% set fee_recipient_1 = '0x415EEc63c95e944D544b3088bc682B759edB8548' %} {% set fee_recipient_2 = '0xe1ff5a4c489b11e094bfbb5d23c6d4597a3a79ad' %} @@ -38,6 +41,8 @@ with or "from" = {{ deployer_4 }} or "from" = {{ deployer_5 }} or "from" = {{ deployer_6 }} + or "from" = {{ deployer_7 }} + or "from" = {{ deployer_8 }} ) and block_time >= timestamp '{{project_start_date}}' ), @@ -88,6 +93,7 @@ with and ( contract_address = {{ wmatic_contract_address }} or contract_address = {{ usdc_contract_address }} + or contract_address = {{ usdt_contract_address }} ) {% if is_incremental() %} and {{ incremental_predicate('evt_block_time') }} @@ -108,9 +114,12 @@ with {% else %} and block_time >= timestamp '{{project_start_date}}' {% endif %} + ), + aggregated_fee_deposits as ( + select evt_tx_hash, sum(fee_token_amount) as fee_token_amount, fee_token_address + from fee_deposits + group by evt_tx_hash, fee_token_address ) - - select distinct block_time, date_trunc('day', block_time) as block_date, @@ -129,7 +138,7 @@ select distinct fee_token_amount / power(10, decimals) * price as fee_usd, fee_token_amount / power(10, decimals) as fee_token_amount, symbol as fee_token_symbol, - cast(fee_token_address as varchar) as fee_token_address, + coalesce(fee_token_address, {{wmatic_contract_address}}) as fee_token_address, -- Dex project, version, @@ -145,7 +154,7 @@ join highest_event_index_for_each_trade on bot_trades.tx_hash = highest_event_index_for_each_trade.tx_hash /* Left Outer Join to support 0 fee trades */ -left join fee_deposits on bot_trades.tx_hash = fee_deposits.evt_tx_hash +left join aggregated_fee_deposits as fee_deposits on bot_trades.tx_hash = fee_deposits.evt_tx_hash left join {{ source('prices', 'usd') }} on ( diff --git a/dbt_subprojects/daily_spellbook/models/evms/evms_blocks.sql b/dbt_subprojects/daily_spellbook/models/evms/evms_blocks.sql index 3a92735e74c..21108d85279 100644 --- a/dbt_subprojects/daily_spellbook/models/evms/evms_blocks.sql +++ b/dbt_subprojects/daily_spellbook/models/evms/evms_blocks.sql @@ -2,7 +2,7 @@ schema='evms', alias = 'blocks', unique_key=['blockchain', 'number'], - post_hook='{{ expose_spells(\'["ethereum", "polygon", "bnb", "avalanche_c", "gnosis", "fantom", "optimism", "arbitrum", "celo", "base", "zksync", "zora", "scroll", "linea", "zkevm", "blast", "mantle"]\', + post_hook='{{ expose_spells(\'["ethereum", "polygon", "bnb", "avalanche_c", "gnosis", "fantom", "optimism", "arbitrum", "celo", "base", "zksync", "zora", "scroll", "linea", "zkevm", "blast", "mantle", "ronin"]\', "sector", "evms", \'["hildobby"]\') }}' @@ -29,6 +29,7 @@ , ('mantle', source('mantle', 'blocks')) , ('mode', source('mode', 'blocks')) , ('sei', source('sei', 'blocks')) + , ('ronin', source('ronin', 'blocks')) ] %} SELECT * diff --git a/dbt_subprojects/daily_spellbook/models/evms/evms_contracts.sql b/dbt_subprojects/daily_spellbook/models/evms/evms_contracts.sql index 045c4ada3f8..c69543967f3 100644 --- a/dbt_subprojects/daily_spellbook/models/evms/evms_contracts.sql +++ b/dbt_subprojects/daily_spellbook/models/evms/evms_contracts.sql @@ -2,7 +2,7 @@ schema='evms', alias = 'contracts', unique_key=['blockchain', 'address'], - post_hook='{{ expose_spells(\'["ethereum", "polygon", "bnb", "avalanche_c", "gnosis", "fantom", "optimism", "arbitrum", "celo", "base", "zksync", "zora", "scroll", "linea", "zkevm", "blast", "mantle"]\', + post_hook='{{ expose_spells(\'["ethereum", "polygon", "bnb", "avalanche_c", "gnosis", "fantom", "optimism", "arbitrum", "celo", "base", "zksync", "zora", "scroll", "linea", "zkevm", "blast", "mantle", "ronin"]\', "sector", "evms", \'["hildobby"]\') }}' @@ -28,6 +28,7 @@ , ('blast', source('blast', 'contracts')) , ('mantle', source('mantle', 'contracts')) , ('sei', source('sei', 'contracts')) + , ('ronin', source('ronin', 'contracts')) ] %} SELECT * diff --git a/dbt_subprojects/daily_spellbook/models/evms/evms_creation_traces.sql b/dbt_subprojects/daily_spellbook/models/evms/evms_creation_traces.sql index f3612f8dc96..8abe3191d0a 100644 --- a/dbt_subprojects/daily_spellbook/models/evms/evms_creation_traces.sql +++ b/dbt_subprojects/daily_spellbook/models/evms/evms_creation_traces.sql @@ -2,7 +2,7 @@ schema='evms', alias = 'creation_traces', unique_key=['blockchain', 'tx_hash', 'evt_index'], - post_hook='{{ expose_spells(\'["ethereum", "polygon", "bnb", "avalanche_c", "gnosis", "fantom", "optimism", "arbitrum", "celo", "base", "zksync", "zora", "scroll", "linea", "zkevm", "blast", "mantle"]\', + post_hook='{{ expose_spells(\'["ethereum", "polygon", "bnb", "avalanche_c", "gnosis", "fantom", "optimism", "arbitrum", "celo", "base", "zksync", "zora", "scroll", "linea", "zkevm", "blast", "mantle", "ronin"]\', "sector", "evms", \'["hildobby"]\') }}' @@ -28,6 +28,7 @@ , ('blast', source('blast', 'creation_traces')) , ('mantle', source('mantle', 'creation_traces')) , ('sei', source('sei', 'creation_traces')) + , ('ronin', source('ronin', 'creation_traces')) ] %} SELECT * diff --git a/dbt_subprojects/daily_spellbook/models/evms/evms_erc1155_approvalsforall.sql b/dbt_subprojects/daily_spellbook/models/evms/evms_erc1155_approvalsforall.sql index 527ea9a7f15..fe6620fa1b0 100644 --- a/dbt_subprojects/daily_spellbook/models/evms/evms_erc1155_approvalsforall.sql +++ b/dbt_subprojects/daily_spellbook/models/evms/evms_erc1155_approvalsforall.sql @@ -2,7 +2,7 @@ schema='evms', alias = 'erc1155_approvalsforall', unique_key=['blockchain', 'tx_hash', 'evt_index'], - post_hook='{{ expose_spells(\'["ethereum", "polygon", "bnb", "avalanche_c", "gnosis", "fantom", "optimism", "arbitrum", "celo", "base", "zksync", "zora", "scroll", "linea", "zkevm", "blast", "mantle"]\', + post_hook='{{ expose_spells(\'["ethereum", "polygon", "bnb", "avalanche_c", "gnosis", "fantom", "optimism", "arbitrum", "celo", "base", "zksync", "zora", "scroll", "linea", "zkevm", "blast", "mantle", "ronin"]\', "sector", "evms", \'["hildobby"]\') }}' @@ -28,6 +28,7 @@ , ('blast', source('erc1155_blast', 'evt_ApprovalForAll')) , ('mantle', source('erc1155_mantle', 'evt_ApprovalForAll')) , ('sei', source('erc1155_sei', 'evt_ApprovalForAll')) + , ('ronin', source('erc1155_ronin', 'evt_ApprovalForAll')) ] %} SELECT * diff --git a/dbt_subprojects/daily_spellbook/models/evms/evms_erc1155_transfersbatch.sql b/dbt_subprojects/daily_spellbook/models/evms/evms_erc1155_transfersbatch.sql index 1247a672e85..1466e326b17 100644 --- a/dbt_subprojects/daily_spellbook/models/evms/evms_erc1155_transfersbatch.sql +++ b/dbt_subprojects/daily_spellbook/models/evms/evms_erc1155_transfersbatch.sql @@ -2,7 +2,7 @@ schema='evms', alias = 'erc1155_transfersbatch', unique_key=['blockchain', 'tx_hash', 'evt_index'], - post_hook='{{ expose_spells(\'["ethereum", "polygon", "bnb", "avalanche_c", "gnosis", "fantom", "optimism", "arbitrum", "celo", "base", "zksync", "zora", "scroll", "linea", "zkevm", "blast", "mantle"]\', + post_hook='{{ expose_spells(\'["ethereum", "polygon", "bnb", "avalanche_c", "gnosis", "fantom", "optimism", "arbitrum", "celo", "base", "zksync", "zora", "scroll", "linea", "zkevm", "blast", "mantle", "ronin"]\', "sector", "evms", \'["hildobby"]\') }}' @@ -28,6 +28,7 @@ , ('blast', source('erc1155_blast', 'evt_transferbatch')) , ('mantle', source('erc1155_mantle', 'evt_transferbatch')) , ('sei', source('erc1155_sei', 'evt_transferbatch')) + , ('ronin', source('erc1155_ronin', 'evt_transferbatch')) ] %} SELECT * diff --git a/dbt_subprojects/daily_spellbook/models/evms/evms_erc1155_transferssingle.sql b/dbt_subprojects/daily_spellbook/models/evms/evms_erc1155_transferssingle.sql index 39460816d35..da8b32c1d16 100644 --- a/dbt_subprojects/daily_spellbook/models/evms/evms_erc1155_transferssingle.sql +++ b/dbt_subprojects/daily_spellbook/models/evms/evms_erc1155_transferssingle.sql @@ -2,7 +2,7 @@ schema='evms', alias = 'erc1155_transferssingle', unique_key=['blockchain', 'tx_hash', 'evt_index'], - post_hook='{{ expose_spells(\'["ethereum", "polygon", "bnb", "avalanche_c", "gnosis", "fantom", "optimism", "arbitrum", "celo", "base", "zksync", "zora", "scroll", "linea", "zkevm", "blast", "mantle"]\', + post_hook='{{ expose_spells(\'["ethereum", "polygon", "bnb", "avalanche_c", "gnosis", "fantom", "optimism", "arbitrum", "celo", "base", "zksync", "zora", "scroll", "linea", "zkevm", "blast", "mantle", "ronin"]\', "sector", "evms", \'["hildobby"]\') }}' @@ -28,6 +28,7 @@ , ('blast', source('erc1155_blast', 'evt_transfersingle')) , ('mantle', source('erc1155_mantle', 'evt_transfersingle')) , ('sei', source('erc1155_sei', 'evt_transfersingle')) + , ('ronin', source('erc1155_ronin', 'evt_transfersingle')) ] %} SELECT * diff --git a/dbt_subprojects/daily_spellbook/models/evms/evms_erc20_approvals.sql b/dbt_subprojects/daily_spellbook/models/evms/evms_erc20_approvals.sql index ba1a56bf569..abf407951c5 100644 --- a/dbt_subprojects/daily_spellbook/models/evms/evms_erc20_approvals.sql +++ b/dbt_subprojects/daily_spellbook/models/evms/evms_erc20_approvals.sql @@ -2,7 +2,7 @@ schema='evms', alias = 'erc20_approvals', unique_key=['blockchain', 'tx_hash', 'evt_index'], - post_hook='{{ expose_spells(\'["ethereum", "polygon", "bnb", "avalanche_c", "gnosis", "fantom", "optimism", "arbitrum", "celo", "base", "zksync", "zora", "scroll", "linea", "zkevm", "blast", "mantle"]\', + post_hook='{{ expose_spells(\'["ethereum", "polygon", "bnb", "avalanche_c", "gnosis", "fantom", "optimism", "arbitrum", "celo", "base", "zksync", "zora", "scroll", "linea", "zkevm", "blast", "mantle", "ronin"]\', "sector", "evms", \'["hildobby"]\') }}' @@ -28,6 +28,7 @@ , ('blast', source('erc20_blast', 'evt_approval')) , ('mantle', source('erc20_mantle', 'evt_approval')) , ('sei', source('erc20_sei', 'evt_Approval')) + , ('ronin', source('erc20_ronin', 'evt_approval')) ] %} SELECT * diff --git a/dbt_subprojects/daily_spellbook/models/evms/evms_erc20_transfers.sql b/dbt_subprojects/daily_spellbook/models/evms/evms_erc20_transfers.sql index 9720d9346d4..b1da539a0a7 100644 --- a/dbt_subprojects/daily_spellbook/models/evms/evms_erc20_transfers.sql +++ b/dbt_subprojects/daily_spellbook/models/evms/evms_erc20_transfers.sql @@ -2,7 +2,7 @@ schema='evms', alias = 'erc20_transfers', unique_key=['blockchain', 'tx_hash', 'evt_index'], - post_hook='{{ expose_spells(\'["ethereum", "polygon", "bnb", "avalanche_c", "gnosis", "fantom", "optimism", "arbitrum", "celo", "base", "zksync", "zora", "scroll", "linea", "zkevm", "blast", "mantle"]\', + post_hook='{{ expose_spells(\'["ethereum", "polygon", "bnb", "avalanche_c", "gnosis", "fantom", "optimism", "arbitrum", "celo", "base", "zksync", "zora", "scroll", "linea", "zkevm", "blast", "mantle", "ronin"]\', "sector", "evms", \'["hildobby"]\') }}' @@ -28,6 +28,7 @@ , ('blast', source('erc20_blast', 'evt_transfer')) , ('mantle', source('erc20_mantle', 'evt_transfer')) , ('sei', source('erc20_sei', 'evt_transfer')) + , ('ronin', source('erc20_ronin', 'evt_transfer')) ] %} SELECT * diff --git a/dbt_subprojects/daily_spellbook/models/evms/evms_erc721_approvals.sql b/dbt_subprojects/daily_spellbook/models/evms/evms_erc721_approvals.sql index 21ef83c3f3f..d683e392d34 100644 --- a/dbt_subprojects/daily_spellbook/models/evms/evms_erc721_approvals.sql +++ b/dbt_subprojects/daily_spellbook/models/evms/evms_erc721_approvals.sql @@ -2,7 +2,7 @@ schema='evms', alias = 'erc721_approvals', unique_key=['blockchain', 'tx_hash', 'evt_index'], - post_hook='{{ expose_spells(\'["ethereum", "polygon", "bnb", "avalanche_c", "gnosis", "fantom", "optimism", "arbitrum", "celo", "base", "zksync", "zora", "scroll", "linea", "zkevm", "blast", "mantle"]\', + post_hook='{{ expose_spells(\'["ethereum", "polygon", "bnb", "avalanche_c", "gnosis", "fantom", "optimism", "arbitrum", "celo", "base", "zksync", "zora", "scroll", "linea", "zkevm", "blast", "mantle", "ronin"]\', "sector", "evms", \'["hildobby"]\') }}' @@ -28,6 +28,7 @@ , ('blast', source('erc721_blast', 'evt_Approval')) , ('mantle', source('erc721_mantle', 'evt_Approval')) , ('sei', source('erc721_sei', 'evt_Approval')) + , ('ronin', source('erc721_ronin', 'evt_Approval')) ] %} SELECT * diff --git a/dbt_subprojects/daily_spellbook/models/evms/evms_erc721_approvalsforall.sql b/dbt_subprojects/daily_spellbook/models/evms/evms_erc721_approvalsforall.sql index 55a260c134f..da8ca9ee6a3 100644 --- a/dbt_subprojects/daily_spellbook/models/evms/evms_erc721_approvalsforall.sql +++ b/dbt_subprojects/daily_spellbook/models/evms/evms_erc721_approvalsforall.sql @@ -2,7 +2,7 @@ schema='evms', alias = 'erc721_approvalsforall', unique_key=['blockchain', 'tx_hash', 'evt_index'], - post_hook='{{ expose_spells(\'["ethereum", "polygon", "bnb", "avalanche_c", "gnosis", "fantom", "optimism", "arbitrum", "celo", "base", "zksync", "zora", "scroll", "linea", "zkevm", "blast", "mantle"]\', + post_hook='{{ expose_spells(\'["ethereum", "polygon", "bnb", "avalanche_c", "gnosis", "fantom", "optimism", "arbitrum", "celo", "base", "zksync", "zora", "scroll", "linea", "zkevm", "blast", "mantle", "ronin"]\', "sector", "evms", \'["hildobby"]\') }}' @@ -28,6 +28,7 @@ , ('blast', source('erc721_blast', 'evt_ApprovalForAll')) , ('mantle', source('erc721_mantle', 'evt_ApprovalForAll')) , ('sei', source('erc721_sei', 'evt_ApprovalForAll')) + , ('ronin', source('erc721_ronin', 'evt_ApprovalForAll')) ] %} SELECT * diff --git a/dbt_subprojects/daily_spellbook/models/evms/evms_erc721_transfers.sql b/dbt_subprojects/daily_spellbook/models/evms/evms_erc721_transfers.sql index 8fe4ff3fc30..68542f21fc3 100644 --- a/dbt_subprojects/daily_spellbook/models/evms/evms_erc721_transfers.sql +++ b/dbt_subprojects/daily_spellbook/models/evms/evms_erc721_transfers.sql @@ -2,7 +2,7 @@ schema='evms', alias = 'erc721_transfers', unique_key=['blockchain', 'tx_hash', 'evt_index'], - post_hook='{{ expose_spells(\'["ethereum", "polygon", "bnb", "avalanche_c", "gnosis", "fantom", "optimism", "arbitrum", "celo", "base", "zksync", "zora", "scroll", "linea", "zkevm", "blast", "mantle"]\', + post_hook='{{ expose_spells(\'["ethereum", "polygon", "bnb", "avalanche_c", "gnosis", "fantom", "optimism", "arbitrum", "celo", "base", "zksync", "zora", "scroll", "linea", "zkevm", "blast", "mantle", "ronin"]\', "sector", "evms", \'["hildobby"]\') }}' @@ -28,6 +28,7 @@ , ('blast', source('erc721_blast', 'evt_transfer')) , ('mantle', source('erc721_mantle', 'evt_transfer')) , ('sei', source('erc721_sei', 'evt_transfer')) + , ('ronin', source('erc721_ronin', 'evt_transfer')) ] %} SELECT * diff --git a/dbt_subprojects/daily_spellbook/models/evms/evms_info.sql b/dbt_subprojects/daily_spellbook/models/evms/evms_info.sql index dcb86d95584..9a2a98639a3 100644 --- a/dbt_subprojects/daily_spellbook/models/evms/evms_info.sql +++ b/dbt_subprojects/daily_spellbook/models/evms/evms_info.sql @@ -8,9 +8,11 @@ , "base" , "blast" , "bnb" + , "boba" , "celo" , "ethereum" , "fantom" + , "flare" , "gnosis" , "kaia" , "linea" @@ -20,6 +22,7 @@ , "ronin" , "scroll" , "sei" + , "viction" , "worldchain" , "zksync" , "zkevm" @@ -63,7 +66,7 @@ FROM ( , (1101, 'zkevm', 'Polygon zkEVM', 'Layer 2', 'ZK Rollup', 'ETH', 0x4f9a0e7fd2bf6067db6994cf12e4495df938e6e9, 'https://zkevm.polygonscan.com/', timestamp '2023-03-24 05:30', 'Polygon', 'Ethereum', 'Ethereum', true) , (1088, 'metis_andromeda', 'Metis Andromeda', NULL, NULL, NULL, NULL, 'https://andromeda-explorer.metis.io/', timestamp '2021-11-18 22:19', 'Optimistic Virtual Machine', 'Ethereum', 'Ethereum', false) , (59144, 'linea', 'Linea', 'Layer 2', 'ZK Rollup', 'ETH', 0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f, 'https://lineascan.build/', timestamp '2023-07-06 13:15', NULL, 'Ethereum Blobs', 'Ethereum', true) - , (288, 'boba', 'Boba Network', 'Layer 2', 'Optimistic Rollup', 'ETH', NULL, 'https://bobascan.com/', timestamp '2021-10-28 05:03', 'Optimistic Virtual Machine', 'Ethereum', 'Ethereum', false) + , (288, 'boba', 'Boba Network', 'Layer 2', 'Optimistic Rollup', 'ETH', 0x4200000000000000000000000000000000000006, 'https://bobascan.com/', timestamp '2021-10-28 05:03', 'OP Stack', 'Ethereum', 'Ethereum', true) , (7700, 'canto', 'Canto', 'Layer 2', NULL, 'ETH', NULL, 'https://evm.explorer.canto.io/', timestamp '2022-07-26 19:27', NULL, 'Ethereum', 'Ethereum', false) , (420, 'optimism_goerli', 'Optimism Goerli', 'Testnet', 'Optimistic Rollup', 'GTH', 0x4200000000000000000000000000000000000006, 'https://optimism-goerli.blockscout.com/', timestamp '2022-06-09 16:55', 'OP Stack', 'Goerli', 'Goerli', false) , (1313161554, 'aurora', 'Aurora', 'Layer 2', NULL, 'ETH', 0xC9BdeEd33CD01541e1eeD10f90519d2C06Fe3feB, 'https://explorer.aurora.dev/', timestamp '2020-07-21 21:50:11', NULL, NULL, NULL, false) @@ -90,5 +93,6 @@ FROM ( , (5000, 'mantle', 'Mantle', 'Layer 2', 'Optimistic Rollup', 'MNT', 0x78c1b0c915c4faa5fffa6cabf0219da63d7f4cb8, 'https://mantlescan.xyz/', timestamp '2023-07-02 18:21', 'Optimistic Virtual Machine', 'Ethereum', 'Ethereum', true) , (42170, 'nova', 'Arbitrum Nova', 'Layer 2', 'Optimistic Rollup', 'ETH', 0x722e8bdd2ce80a4422e880164f2079488e115365, 'https://nova-explorer.arbitrum.io/', timestamp '2022-06-25 04:01', 'Arbitrum', 'Ethereum', 'Ethereum', true) , (2020, 'ronin', 'Ronin', 'Layer 1', null, 'RON', 0xe514d9deb7966c8be0ca922de8a064264ea6bcd4, 'https://app.roninchain.com/', timestamp '2021-01-25 10:49', NULL, NULL, NULL, true) + , (14, 'flare', 'Flare', 'Layer 1', NULL, 'FLR', NULL, 'https://flare-explorer.flare.network/', timestamp '2022-07-13 15:32', NULL, NULL, NULL, true) + , (88, 'viction', 'Viction', 'Layer 1', NULL, 'VIC', 0xC054751BdBD24Ae713BA3Dc9Bd9434aBe2abc1ce, 'https://vicscan.xyz/', timestamp '2018-12-14 07:50:20', NULL, NULL, NULL, true) ) AS temp_table (chain_id, blockchain, name, chain_type, rollup_type, native_token_symbol, wrapped_native_token_address, explorer_link, first_block_time, codebase, data_availability, settlement, is_on_dune) - diff --git a/dbt_subprojects/daily_spellbook/models/evms/evms_logs.sql b/dbt_subprojects/daily_spellbook/models/evms/evms_logs.sql index 8b8035feca9..11067157432 100644 --- a/dbt_subprojects/daily_spellbook/models/evms/evms_logs.sql +++ b/dbt_subprojects/daily_spellbook/models/evms/evms_logs.sql @@ -2,7 +2,7 @@ schema='evms', alias = 'logs', unique_key=['blockchain', 'tx_hash'], - post_hook='{{ expose_spells(\'["ethereum", "polygon", "bnb", "avalanche_c", "gnosis", "fantom", "optimism", "arbitrum", "celo", "base", "zksync", "zora", "scroll", "linea", "zkevm", "blast", "mantle"]\', + post_hook='{{ expose_spells(\'["ethereum", "polygon", "bnb", "avalanche_c", "gnosis", "fantom", "optimism", "arbitrum", "celo", "base", "zksync", "zora", "scroll", "linea", "zkevm", "blast", "mantle", "ronin"]\', "sector", "evms", \'["hildobby","rantum"]\') }}' @@ -29,6 +29,7 @@ , ('mantle', source('mantle', 'logs')) , ('mode', source('mode', 'logs')) , ('sei', source('sei', 'logs')) + , ('ronin', source('ronin', 'logs')) ] %} SELECT * diff --git a/dbt_subprojects/daily_spellbook/models/evms/evms_logs_decoded.sql b/dbt_subprojects/daily_spellbook/models/evms/evms_logs_decoded.sql index e3d4df61af2..a603911bf52 100644 --- a/dbt_subprojects/daily_spellbook/models/evms/evms_logs_decoded.sql +++ b/dbt_subprojects/daily_spellbook/models/evms/evms_logs_decoded.sql @@ -2,7 +2,7 @@ schema='evms', alias = 'logs_decoded', unique_key=['blockchain', 'tx_hash'], - post_hook='{{ expose_spells(\'["ethereum", "polygon", "bnb", "avalanche_c", "gnosis", "fantom", "optimism", "arbitrum", "celo", "base", "zksync", "zora", "scroll", "linea", "zkevm", "blast", "mantle"]\', + post_hook='{{ expose_spells(\'["ethereum", "polygon", "bnb", "avalanche_c", "gnosis", "fantom", "optimism", "arbitrum", "celo", "base", "zksync", "zora", "scroll", "linea", "zkevm", "blast", "mantle", "ronin"]\', "sector", "evms", \'["hildobby"]\') }}' @@ -28,6 +28,7 @@ , ('blast', source('blast', 'logs_decoded')) , ('mantle', source('mantle', 'logs_decoded')) , ('sei', source('sei', 'logs_decoded')) + , ('ronin', source('ronin', 'logs_decoded')) ] %} SELECT * diff --git a/dbt_subprojects/daily_spellbook/models/evms/evms_non_app_method_ids.sql b/dbt_subprojects/daily_spellbook/models/evms/evms_non_app_method_ids.sql index cde347b82d7..bb96ab091ea 100644 --- a/dbt_subprojects/daily_spellbook/models/evms/evms_non_app_method_ids.sql +++ b/dbt_subprojects/daily_spellbook/models/evms/evms_non_app_method_ids.sql @@ -3,7 +3,7 @@ tags = [ 'static'], schema = 'non_app_method_ids', alias = 'non_app_method_ids', - post_hook='{{ expose_spells(\'["ethereum","optimism","arbitrum","polygon","gnosis","avalanche_c","fantom","goerli","bnb","base","celo", "zora"]\', + post_hook='{{ expose_spells(\'["ethereum","optimism","arbitrum","polygon","gnosis","avalanche_c","fantom","goerli","bnb","base","celo", "zora", "ronin"]\', "sector", "method_ids", \'["msilb7"]\') }}' @@ -23,6 +23,7 @@ ,'bnb' ,'base' ,'celo' + , 'ronin' ] %} WITH aggrregate_methods AS ( diff --git a/dbt_subprojects/daily_spellbook/models/evms/evms_schema.yml b/dbt_subprojects/daily_spellbook/models/evms/evms_schema.yml index dbe4c032c1e..2ba49ad153e 100644 --- a/dbt_subprojects/daily_spellbook/models/evms/evms_schema.yml +++ b/dbt_subprojects/daily_spellbook/models/evms/evms_schema.yml @@ -3,11 +3,11 @@ version: 2 models: - name: evms_transactions meta: - blockchain: ethereum, polygon, bnb, avalanche_c, gnosis, fantom, optimism, arbitrum, celo, base, zksync, zora, scroll, linea, zkevm, blast, mantle, mode, sei + blockchain: ethereum, polygon, bnb, avalanche_c, gnosis, fantom, optimism, arbitrum, celo, base, zksync, zora, scroll, linea, zkevm, blast, mantle, mode, sei, ronin sector: evms contributors: [hildobby, synthquest] config: - tags: ['evms', 'transactions'] + tags: ["evms", "transactions"] description: "An EVM transaction refers to an action initiated by an externally-owned account (i.e., an account managed by a human, not a contract)." columns: - &blockchain @@ -76,11 +76,11 @@ models: - name: evms_traces meta: - blockchain: ethereum, polygon, bnb, avalanche_c, gnosis, fantom, optimism, arbitrum, celo, base, zksync, zora, scroll, linea, zkevm, blast, mantle, mode, sei + blockchain: ethereum, polygon, bnb, avalanche_c, gnosis, fantom, optimism, arbitrum, celo, base, zksync, zora, scroll, linea, zkevm, blast, mantle, mode, sei, ronin sector: evms contributors: [hildobby, synthquest] config: - tags: ['evms', 'traces'] + tags: ["evms", "traces"] description: "An EVM trace is a small atomic action that modify the internal state of the Ethereum Virtual Machine. The three main trace types are call, create, and suicide." columns: - *blockchain @@ -127,11 +127,11 @@ models: - name: evms_traces_decoded meta: - blockchain: ethereum, polygon, bnb, avalanche_c, gnosis, fantom, optimism, arbitrum, celo, base, zksync, zora, scroll, linea, zkevm, blast, mantle, sei + blockchain: ethereum, polygon, bnb, avalanche_c, gnosis, fantom, optimism, arbitrum, celo, base, zksync, zora, scroll, linea, zkevm, blast, mantle, sei, ronin sector: evms contributors: [hildobby, synthquest] config: - tags: ['evms', 'traces', 'decoded'] + tags: ["evms", "traces", "decoded"] description: "An EVM trace is a small atomic action that modify the internal state of the Ethereum Virtual Machine. The three main trace types are call, create, and suicide. Decoded traces include additional information based on submitted smart contracts and their ABI" columns: - *blockchain @@ -153,11 +153,11 @@ models: - name: evms_logs meta: - blockchain: ethereum, polygon, bnb, avalanche_c, gnosis, fantom, optimism, arbitrum, celo, base, zksync, zora, scroll, linea, zkevm, blast, mantle, mode, sei + blockchain: ethereum, polygon, bnb, avalanche_c, gnosis, fantom, optimism, arbitrum, celo, base, zksync, zora, scroll, linea, zkevm, blast, mantle, mode, sei, ronin sector: evms contributors: [hildobby, synthquest, rantum] config: - tags: ['evms', 'logs'] + tags: ["evms", "logs"] description: "An EVM log can be used to describe an event within a smart contract, like a token transfer or a change of ownership." columns: - *blockchain @@ -183,11 +183,11 @@ models: - name: evms_logs_decoded meta: - blockchain: ethereum, polygon, bnb, avalanche_c, gnosis, fantom, optimism, arbitrum, celo, base, zksync, zora, scroll, linea, zkevm, blast, mantle, sei + blockchain: ethereum, polygon, bnb, avalanche_c, gnosis, fantom, optimism, arbitrum, celo, base, zksync, zora, scroll, linea, zkevm, blast, mantle, sei, ronin sector: evms contributors: [hildobby, synthquest] config: - tags: ['evms', 'logs', 'decoded'] + tags: ["evms", "logs", "decoded"] description: "An EVM log can be used to describe an event within a smart contract, like a token transfer or a change of ownership. Those logs are decoded based on submitted smart contracts to make them human readable." columns: - *blockchain @@ -209,11 +209,11 @@ models: - name: evms_blocks meta: - blockchain: ethereum, polygon, bnb, avalanche_c, gnosis, fantom, optimism, arbitrum, celo, base, zksync, zora, scroll, linea, zkevm, blast, mantle, mode, sei + blockchain: ethereum, polygon, bnb, avalanche_c, gnosis, fantom, optimism, arbitrum, celo, base, zksync, zora, scroll, linea, zkevm, blast, mantle, mode, sei, ronin sector: evms contributors: [hildobby, synthquest] config: - tags: ['evms', 'blocks'] + tags: ["evms", "blocks"] description: "Blocks are batches of transactions with a hash of the previous block in the chain. This links blocks together (in a chain) because hashes are cryptographically derived from the block data." columns: - *blockchain @@ -232,17 +232,17 @@ models: - name: evms_contracts meta: - blockchain: ethereum, polygon, bnb, avalanche_c, gnosis, fantom, optimism, arbitrum, celo, base, zksync, zora, scroll, linea, zkevm, blast, mantle, sei + blockchain: ethereum, polygon, bnb, avalanche_c, gnosis, fantom, optimism, arbitrum, celo, base, zksync, zora, scroll, linea, zkevm, blast, mantle, sei, ronin sector: evms contributors: [hildobby, synthquest] config: - tags: ['evms', 'contracts'] + tags: ["evms", "contracts"] description: "A view keeping track of what contracts are decoded across EVM chains on Dune; contains information associated with the decoded contract such as namespace, name, address, ABI." data_tests: - dbt_utils.unique_combination_of_columns: combination_of_columns: - - blockchain - - address + - blockchain + - address columns: - *blockchain - name: abi @@ -270,14 +270,14 @@ models: values: ["factory", "base", "dynamic"] - name: created_at description: "Timestamp for contract creation" - + - name: evms_creation_traces meta: - blockchain: ethereum, polygon, bnb, avalanche_c, gnosis, fantom, optimism, arbitrum, celo, base, zksync, zora, scroll, linea, zkevm, blast, mantle, sei + blockchain: ethereum, polygon, bnb, avalanche_c, gnosis, fantom, optimism, arbitrum, celo, base, zksync, zora, scroll, linea, zkevm, blast, mantle, sei, ronin sector: evms contributors: [hildobby, synthquest] config: - tags: ['evms', 'traces', 'creation', 'contracts'] + tags: ["evms", "traces", "creation", "contracts"] description: "EVM chains creation traces" columns: - *blockchain @@ -293,11 +293,11 @@ models: - name: evms_erc20_transfers meta: - blockchain: ethereum, polygon, bnb, avalanche_c, gnosis, fantom, optimism, arbitrum, celo, base, zksync, zora, scroll, linea, zkevm, blast, mantle, sei + blockchain: ethereum, polygon, bnb, avalanche_c, gnosis, fantom, optimism, arbitrum, celo, base, zksync, zora, scroll, linea, zkevm, blast, mantle, sei, ronin sector: evms contributors: [hildobby, synthquest] config: - tags: ['evms', 'erc20', 'transfers'] + tags: ["evms", "erc20", "transfers"] description: "Transfers events for ERC20 tokens on EVM chains." columns: - *blockchain @@ -322,11 +322,11 @@ models: - name: evms_erc20_approvals meta: - blockchain: ethereum, polygon, bnb, avalanche_c, gnosis, fantom, optimism, arbitrum, celo, base, zksync, zora, scroll, linea, zkevm, blast, mantle, sei + blockchain: ethereum, polygon, bnb, avalanche_c, gnosis, fantom, optimism, arbitrum, celo, base, zksync, zora, scroll, linea, zkevm, blast, mantle, sei, ronin sector: evms contributors: [hildobby, synthquest] config: - tags: ['evms', 'erc20', 'approvals'] + tags: ["evms", "erc20", "approvals"] description: "Approval events for ERC20 tokens on EVM chains." columns: - *blockchain @@ -345,11 +345,11 @@ models: - name: evms_erc1155_transferssingle meta: - blockchain: ethereum, polygon, bnb, avalanche_c, gnosis, fantom, optimism, arbitrum, celo, base, zksync, zora, scroll, linea, zkevm, blast, mantle, sei + blockchain: ethereum, polygon, bnb, avalanche_c, gnosis, fantom, optimism, arbitrum, celo, base, zksync, zora, scroll, linea, zkevm, blast, mantle, sei, ronin sector: evms contributors: [hildobby, synthquest] config: - tags: ['evms', 'erc1155', 'transfers', 'single'] + tags: ["evms", "erc1155", "transfers", "single"] description: "Single transfers events for ERC1155 tokens on EVM chains." columns: - *blockchain @@ -370,11 +370,11 @@ models: - name: evms_erc1155_transfersbatch meta: - blockchain: ethereum, polygon, bnb, avalanche_c, gnosis, fantom, optimism, arbitrum, celo, base, zksync, zora, scroll, linea, zkevm, blast, mantle, sei + blockchain: ethereum, polygon, bnb, avalanche_c, gnosis, fantom, optimism, arbitrum, celo, base, zksync, zora, scroll, linea, zkevm, blast, mantle, sei, ronin sector: evms contributors: [hildobby, synthquest] config: - tags: ['evms', 'erc1155', 'transfers', 'batch'] + tags: ["evms", "erc1155", "transfers", "batch"] description: "Batch transfers events for ERC1155 tokens on EVM chains." columns: - *blockchain @@ -395,11 +395,11 @@ models: - name: evms_erc1155_approvalsforall meta: - blockchain: ethereum, polygon, bnb, avalanche_c, gnosis, fantom, optimism, arbitrum, celo, base, zksync, zora, scroll, linea, zkevm, blast, mantle, sei + blockchain: ethereum, polygon, bnb, avalanche_c, gnosis, fantom, optimism, arbitrum, celo, base, zksync, zora, scroll, linea, zkevm, blast, mantle, sei, ronin sector: evms contributors: [hildobby, synthquest] config: - tags: ['evms', 'erc1155', 'approvals'] + tags: ["evms", "erc1155", "approvals"] description: "Approval for all events for ERC1155 tokens on EVM chains." columns: - *blockchain @@ -420,11 +420,11 @@ models: - name: evms_erc721_transfers meta: - blockchain: ethereum, polygon, bnb, avalanche_c, gnosis, fantom, optimism, arbitrum, celo, base, zksync, zora, scroll, linea, zkevm, blast, mantle, sei + blockchain: ethereum, polygon, bnb, avalanche_c, gnosis, fantom, optimism, arbitrum, celo, base, zksync, zora, scroll, linea, zkevm, blast, mantle, sei, ronin sector: evms contributors: [hildobby, synthquest] config: - tags: ['evms', 'erc721', 'transfers'] + tags: ["evms", "erc721", "transfers"] description: "Transfers events for ERC721 tokens on EVM chains." columns: - *blockchain @@ -441,11 +441,11 @@ models: - name: evms_erc721_approvals meta: - blockchain: ethereum, polygon, bnb, avalanche_c, gnosis, fantom, optimism, arbitrum, celo, base, zksync, zora, scroll, linea, zkevm, blast, mantle, sei + blockchain: ethereum, polygon, bnb, avalanche_c, gnosis, fantom, optimism, arbitrum, celo, base, zksync, zora, scroll, linea, zkevm, blast, mantle, sei, ronin sector: evms contributors: [hildobby, synthquest] config: - tags: ['evms', 'erc721', 'approvals'] + tags: ["evms", "erc721", "approvals"] description: "Approval events for ERC721 tokens on EVM chains." columns: - *blockchain @@ -464,11 +464,11 @@ models: - name: evms_erc721_approvalsforall meta: - blockchain: ethereum, polygon, bnb, avalanche_c, gnosis, fantom, optimism, arbitrum, celo, base, zksync, zora, scroll, linea, zkevm, blast, mantle, sei + blockchain: ethereum, polygon, bnb, avalanche_c, gnosis, fantom, optimism, arbitrum, celo, base, zksync, zora, scroll, linea, zkevm, blast, mantle, sei, ronin sector: evms contributors: [hildobby, synthquest] config: - tags: ['evms', 'erc721', 'approvals'] + tags: ["evms", "erc721", "approvals"] description: "Approval for all events for ERC721 tokens on EVM chains." columns: - *blockchain @@ -488,9 +488,9 @@ models: sector: evms contributors: hildobby config: - tags: ['evms', 'info'] + tags: ["evms", "info"] description: "Some information about the EVM chains" - columns: + columns: - name: chain_id description: "Chain ID" - name: blockchain @@ -513,54 +513,54 @@ models: - name: codebase description: "Codebase used" - name: data_availability - description: "Chain where proofs are submitted to" + description: "Chain where proofs are submitted to" - name: settlement - description: "Chain that is being settled on" + description: "Chain that is being settled on" - name: is_on_dune description: "Is the chain on Dune" - name: evms_non_app_method_ids meta: - blockchain: ethereum,optimism,arbitrum,polygon,gnosis,avalanche_c,fantom,goerli,bnb,base,celo + blockchain: ethereum, optimism, arbitrum, polygon, gnosis, avalanche_c, fantom, goerli, bnb, base, celo, ronin project: method_ids contributors: msilb7 config: - tags: ['method_ids','methods','function','signature'] + tags: ["method_ids", "methods", "function", "signature"] description: > - A table containing mappings for method ids (function signatures) that can be considered to be non-app transactions. There will be one row per blockchain x method_id combination. + A table containing mappings for method ids (function signatures) that can be considered to be non-app transactions. There will be one row per blockchain x method_id combination. data_tests: - dbt_utils.unique_combination_of_columns: combination_of_columns: - - blockchain - - method_id + - blockchain + - method_id columns: - *blockchain - - &method_id + - &method_id name: method_id description: "Method ID (first 4 bytes of calldata), in '0x....' format" - - &method_descriptor + - &method_descriptor name: method_descriptor - description: "Manual descriptor of the method ID." - + description: "Manual descriptor of the method ID." + - name: evm_smart_account_method_ids meta: blockchain: ethereum,optimism,arbitrum,polygon,gnosis,avalanche_c,fantom,goerli,bnb,base,celo,zora project: method_ids contributors: msilb7 config: - tags: ['method_ids','methods','function','signature'] + tags: ["method_ids", "methods", "function", "signature"] description: > - A table containing mappings for method ids (function signatures) that can be considered to be non-app transactions. There will be one row per blockchain x method_id combination. + A table containing mappings for method ids (function signatures) that can be considered to be non-app transactions. There will be one row per blockchain x method_id combination. data_tests: - dbt_utils.unique_combination_of_columns: combination_of_columns: - - blockchain - - method_id + - blockchain + - method_id columns: - *blockchain - - *method_id - - *method_descriptor - - &contract_project + - *method_id + - *method_descriptor + - &contract_project name: contract_project description: "Project associated with the method" @@ -570,16 +570,16 @@ models: project: method_ids contributors: msilb7 config: - tags: ['method_ids','methods','function','signature'] + tags: ["method_ids", "methods", "function", "signature"] description: > - A table containing mappings for method ids (function signatures) that can be considered to be non-app transactions. There will be one row per blockchain x method_id combination. + A table containing mappings for method ids (function signatures) that can be considered to be non-app transactions. There will be one row per blockchain x method_id combination. data_tests: - dbt_utils.unique_combination_of_columns: combination_of_columns: - - blockchain - - method_id + - blockchain + - method_id columns: - *blockchain - - *method_id - - *method_descriptor - - *contract_project \ No newline at end of file + - *method_id + - *method_descriptor + - *contract_project diff --git a/dbt_subprojects/daily_spellbook/models/evms/evms_traces.sql b/dbt_subprojects/daily_spellbook/models/evms/evms_traces.sql index ec2d7cb5e1f..a519cecc097 100644 --- a/dbt_subprojects/daily_spellbook/models/evms/evms_traces.sql +++ b/dbt_subprojects/daily_spellbook/models/evms/evms_traces.sql @@ -2,7 +2,7 @@ schema='evms', alias = 'traces', unique_key=['blockchain', 'tx_hash', 'evt_index'], - post_hook='{{ expose_spells(\'["ethereum", "polygon", "bnb", "avalanche_c", "gnosis", "fantom", "optimism", "arbitrum", "celo", "base", "zksync", "zora", "scroll", "linea", "zkevm", "blast", "mantle"]\', + post_hook='{{ expose_spells(\'["ethereum", "polygon", "bnb", "avalanche_c", "gnosis", "fantom", "optimism", "arbitrum", "celo", "base", "zksync", "zora", "scroll", "linea", "zkevm", "blast", "mantle", "ronin"]\', "sector", "evms", \'["hildobby"]\') }}' @@ -29,6 +29,7 @@ , ('mantle', source('mantle', 'traces')) , ('mode', source('mode', 'traces')) , ('sei', source('sei', 'traces')) + , ('ronin', source('ronin', 'traces')) ] %} SELECT * diff --git a/dbt_subprojects/daily_spellbook/models/evms/evms_traces_decoded.sql b/dbt_subprojects/daily_spellbook/models/evms/evms_traces_decoded.sql index c043abbfa98..5bdd80ac062 100644 --- a/dbt_subprojects/daily_spellbook/models/evms/evms_traces_decoded.sql +++ b/dbt_subprojects/daily_spellbook/models/evms/evms_traces_decoded.sql @@ -2,7 +2,7 @@ schema='evms', alias = 'traces_decoded', unique_key=['blockchain', 'tx_hash', 'evt_index'], - post_hook='{{ expose_spells(\'["ethereum", "polygon", "bnb", "avalanche_c", "gnosis", "fantom", "optimism", "arbitrum", "celo", "base", "zksync", "zora", "scroll", "linea", "zkevm", "blast", "mantle"]\', + post_hook='{{ expose_spells(\'["ethereum", "polygon", "bnb", "avalanche_c", "gnosis", "fantom", "optimism", "arbitrum", "celo", "base", "zksync", "zora", "scroll", "linea", "zkevm", "blast", "mantle", "ronin"]\', "sector", "evms", \'["hildobby"]\') }}' @@ -28,6 +28,7 @@ , ('blast', source('blast', 'traces_decoded')) , ('mantle', source('mantle', 'traces_decoded')) , ('sei', source('sei', 'traces_decoded')) + , ('ronin', source('ronin', 'traces_decoded')) ] %} SELECT * diff --git a/dbt_subprojects/daily_spellbook/models/evms/evms_transactions.sql b/dbt_subprojects/daily_spellbook/models/evms/evms_transactions.sql index 8e1e49ae65c..4ea26272bca 100644 --- a/dbt_subprojects/daily_spellbook/models/evms/evms_transactions.sql +++ b/dbt_subprojects/daily_spellbook/models/evms/evms_transactions.sql @@ -2,7 +2,7 @@ schema='evms', alias = 'transactions', unique_key=['blockchain', 'tx_hash', 'evt_index'], - post_hook='{{ expose_spells(\'["ethereum", "polygon", "bnb", "avalanche_c", "gnosis", "fantom", "optimism", "arbitrum", "celo", "base", "zksync", "zora", "scroll", "linea", "zkevm", "blast", "mantle"]\', + post_hook='{{ expose_spells(\'["ethereum", "polygon", "bnb", "avalanche_c", "gnosis", "fantom", "optimism", "arbitrum", "celo", "base", "zksync", "zora", "scroll", "linea", "zkevm", "blast", "mantle", "ronin"]\', "sector", "evms", \'["hildobby", "synthquest"]\') }}' @@ -29,6 +29,7 @@ , ('blast', source('blast', 'transactions')) , ('mantle', source('mantle', 'transactions')) , ('sei', source('sei', 'transactions')) + , ('ronin', source('ronin', 'transactions')) ] %} {% set unstructured_transactions_models = [ diff --git a/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/capital_pool/nexusmutual_ethereum_capital_pool_totals.sql b/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/capital_pool/nexusmutual_ethereum_capital_pool_totals.sql index 0b7019fac62..c0bbf2369a4 100644 --- a/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/capital_pool/nexusmutual_ethereum_capital_pool_totals.sql +++ b/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/capital_pool/nexusmutual_ethereum_capital_pool_totals.sql @@ -269,6 +269,15 @@ daily_avg_cbbtc_prices as ( group by 1 ), +daily_reth_eth_prices as ( + select + date_trunc('day', call_block_time) as block_date, + avg(output_0 / 1e18) as avg_reth_eth_price + from {{ source('rocketpool_ethereum', 'RocketTokenRETH_call_getExchangeRate') }} + where call_block_time >= timestamp '2023-04-18' + group by 1 +), + day_sequence as ( select cast(d.seq_date as timestamp) as block_date from (select sequence(date '2019-05-23', current_date, interval '1' day) as days) as days_s @@ -337,7 +346,7 @@ daily_running_totals_enriched as ( -- rETH coalesce(drt.reth_total, 0) as reth_total, coalesce(drt.reth_total * p_avg_reth.price_usd, 0) as avg_reth_usd_total, - coalesce(drt.reth_total * p_avg_reth.price_usd / p_avg_eth.price_usd, 0) as avg_reth_eth_total, + coalesce(drt.reth_total * p_reth_eth.avg_reth_eth_price, 0) as avg_reth_eth_total, -- USDC coalesce(drt.usdc_total, 0) as usdc_total, coalesce(drt.usdc_total * p_avg_usdc.price_usd, 0) as avg_usdc_usd_total, @@ -362,6 +371,7 @@ daily_running_totals_enriched as ( left join daily_avg_reth_prices p_avg_reth on drt.block_date = p_avg_reth.block_date left join daily_avg_usdc_prices p_avg_usdc on drt.block_date = p_avg_usdc.block_date left join daily_avg_cbbtc_prices p_avg_cbbtc on drt.block_date = p_avg_cbbtc.block_date + left join daily_reth_eth_prices p_reth_eth on drt.block_date = p_reth_eth.block_date ) select diff --git a/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/covers/_schema.yml b/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/covers/_schema.yml index edee74ce8e9..9d9778dd957 100644 --- a/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/covers/_schema.yml +++ b/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/covers/_schema.yml @@ -246,6 +246,7 @@ models: - &is_migrated name: is_migrated description: "is migrated flag" + - name: cover_ipfs_data - name: trace_address - *tx_hash diff --git a/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/covers/nexusmutual_ethereum_covers_v2.sql b/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/covers/nexusmutual_ethereum_covers_v2.sql index 448047f7964..ec1f72e4071 100644 --- a/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/covers/nexusmutual_ethereum_covers_v2.sql +++ b/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/covers/nexusmutual_ethereum_covers_v2.sql @@ -32,6 +32,7 @@ cover_sales as ( from_hex(json_query(c.params, 'lax $.commissionDestination' omit quotes)) as commission_destination, cast(json_query(t.pool_allocation, 'lax $.coverAmountInAsset') as uint256) as cover_amount_in_asset, cast(json_query(t.pool_allocation, 'lax $.skip') as boolean) as pool_allocation_skip, + cast(json_query(c.params, 'lax $.ipfsData' omit quotes) as varchar) as cover_ipfs_data, c.call_trace_address as trace_address, c.call_tx_hash as tx_hash from {{ source('nexusmutual_ethereum', 'Cover_call_buyCover') }} c @@ -88,7 +89,7 @@ cover_premiums as ( when 7 then 'cbBTC' else 'NA' end as cover_asset, - c.sum_assured / if(c.cover_asset = 6, 1e6, 1e18) as sum_assured, + c.sum_assured / case c.cover_asset when 6 then 1e6 when 7 then 1e8 else 1e18 end as sum_assured, case c.payment_asset when 0 then 'ETH' when 1 then 'DAI' @@ -99,6 +100,7 @@ cover_premiums as ( end as premium_asset, c.cover_owner, c.commission_destination, + c.cover_ipfs_data, c.trace_address, c.tx_hash from cover_sales c @@ -138,6 +140,7 @@ covers_v2 as ( cp.commission, cp.commission_ratio, cp.commission_destination, + cp.cover_ipfs_data, cp.trace_address, cp.tx_hash from cover_premiums cp @@ -195,6 +198,7 @@ covers as ( commission_ratio, commission_destination, false as is_migrated, + cover_ipfs_data, trace_address, tx_hash from covers_v2 @@ -223,6 +227,7 @@ covers as ( commission_ratio, commission_destination, true as is_migrated, + null as cover_ipfs_data, null as trace_address, tx_hash from covers_v1_migrated @@ -255,6 +260,7 @@ select commission_ratio, commission_destination, is_migrated, + cover_ipfs_data, trace_address, tx_hash from covers diff --git a/dbt_subprojects/daily_spellbook/models/swell/balances/ethereum/swell_balances_ethereum_core_assets.sql b/dbt_subprojects/daily_spellbook/models/swell/balances/ethereum/swell_balances_ethereum_core_assets.sql new file mode 100644 index 00000000000..66bf403601c --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/swell/balances/ethereum/swell_balances_ethereum_core_assets.sql @@ -0,0 +1,58 @@ +{{ + config( + schema = 'swell_balances_ethereum', + alias = 'core_assets', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['day', 'wallet_address', 'token_address'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.day')], + post_hook='{{ expose_spells(\'["ethereum"]\', + "project", + "swell", + \'["maybeYonas"]\') }}' + ) +}} + +with +tokens as ( + select * from (values + (0xf951E335afb289353dc249e82926178EaC7DEd78, 'swETH', 'Swell LRT'), + (0xFAe103DC9cf190eD75350761e95403b7b8aFa6c0, 'rswETH', 'Swell LRT'), + (0x0a6E7Ba5042B38349e437ec6Db6214AEC7B35676, 'SWELL', 'Swell LRT'), + (0x358d94b5b2F147D741088803d932Acb566acB7B6, 'rSWELL', 'Swell LRT'), + (0x9Ed15383940CC380fAEF0a75edacE507cC775f22, 'earnETH', 'Swell LRT'), + (0x66E47E6957B85Cf62564610B76dD206BB04d831a, 'earnBTC', 'Swell LRT'), + (0x8DB2350D78aBc13f5673A411D4700BCF87864dDE, 'swBTC', 'Swell LRT') + ) as t( + token_address, + symbol, + name + ) +), +balances as ( + {{ + balances_incremental_subset_daily( + blockchain = 'ethereum', + token_list = 'tokens', + start_date = '2023-04-12' + ) + }} +) + +select + -- t.name, + b.blockchain, + b.day, + b.address as wallet_address, + b.token_symbol, + b.token_address, + b.token_standard, + b.token_id, + b.balance, + b.balance_usd, + b.last_updated, + b.next_update +from balances b +-- left join tokens t +-- on b.token_address = t.token_address diff --git a/dbt_subprojects/daily_spellbook/models/swell/balances/ethereum/swell_balances_ethereum_schema.yml b/dbt_subprojects/daily_spellbook/models/swell/balances/ethereum/swell_balances_ethereum_schema.yml new file mode 100644 index 00000000000..733fd566ef0 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/swell/balances/ethereum/swell_balances_ethereum_schema.yml @@ -0,0 +1,63 @@ +version: 2 + +models: + - name: swell_balances_ethereum_core_assets + + meta: + blockchain: ethereum + project: swell + contributors: maybeYonas + + config: + tags: ['swell', 'restaking', 'lrt', 'lst', 'vaults', 'balances'] + description: "balances of swell asset holders" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - wallet_address + - token_address + - check_seed: + seed_file: ref('swell_balances_ethereum_core_assets_seed') + match_columns: + - blockchain + - day + - wallet_address + - token_address + check_columns: + - balance + - last_updated + columns: + - &blockchain + name: blockchain + description: "blockchain" + - &day + name: day + description: "date on which the token balance is logged" + - &wallet_address + name: wallet_address + description: "wallet address of the holder" + - &token_symbol + name: token_symbol + description: "token symbol" + - &token_address + name: token_address + description: "token address" + - &token_standard + name: token_standard + description: "standard of the token (erc20)" + - &token_id + name: token_id + description: "ID of the token" + - &balance + name: balance + description: "asset balance of the wallet" + - &balance_usd + name: balance_usd + description: "usd value of token balance of the wallet" + - &last_updated + name: last_updated + description: "UTC timestamp when balance was last updated" + - &next_update + name: next_update + description: "UTC timestamp when balance is next updated" diff --git a/dbt_subprojects/daily_spellbook/models/swell/rsweth/ethereum/swell_rsweth_ethereum_schema.yml b/dbt_subprojects/daily_spellbook/models/swell/rsweth/ethereum/swell_rsweth_ethereum_schema.yml new file mode 100644 index 00000000000..2ac88a66d10 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/swell/rsweth/ethereum/swell_rsweth_ethereum_schema.yml @@ -0,0 +1,91 @@ +version: 2 + +models: + - name: swell_rsweth_ethereum_withdrawals + meta: + blockchain: ethereum + project: swell + contributors: maybeYonas + + config: + tags: ['swell', 'restaking', 'lrt', 'withdrawals'] + description: "rswETH withdrawals" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - token_id + - check_seed: + seed_file: ref('swell_rsweth_ethereum_withdrawals_seed') + match_columns: + - token_id + check_columns: + - request_tx_hash + - request_block_number + - request_index + - owner + - rswETH_amount + - rswETH_request_rate + - processed_tx_hash + - processed_block_number + - processed_index + - rswETH_processed_rate + - claim_tx_hash + - claim_block_number + - claim_index + - ETH_amount + + columns: + - &request_block_time + name: request_block_time + description: "timestamp at withdrawal request" + - &request_tx_hash + name: request_tx_hash + description: "hash of tx at withdrawal request" + - &request_block_number + name: request_block_number + description: "block at withdrawal request" + - &request_index + name: request_index + description: "event index at at withdrawal request" + - &token_id + name: token_id + description: "unique id of withdrawal" + - &owner + name: owner + description: "owner of withdrawn eth" + - &rswETH_amount + name: rswETH_amount + description: "amount of rsweth burned" + - &rswETH_request_rate + name: rswETH_request_rate + description: "rsweth to eth rate at withdrawal request" + - &processed_block_time + name: processed_block_time + description: "timestamp at withdrawal ready for completion" + - &processed_tx_hash + name: processed_tx_hash + description: "hash of tx at withdrawal ready for completion" + - &processed_block_number + name: processed_block_number + description: "block at withdrawal ready for completion" + - &processed_index + name: processed_index + description: "event index at at withdrawal ready for completion" + - &rswETH_processed_rate + name: rswETH_processed_rate + description: "rsweth to eth rate at withdrawal completion" + - &claim_block_time + name: claim_block_time + description: "timestamp at withdrawal claimed" + - &claim_tx_hash + name: claim_tx_hash + description: "hash of tx at withdrawal claimed" + - &claim_block_number + name: claim_block_number + description: "block at withdrawal claimed" + - &claim_index + name: claim_index + description: "event index at at withdrawal claimed" + - Ð_amount + name: ETH_amount + description: "eth amount claimed by user" \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/swell/rsweth/ethereum/swell_rsweth_ethereum_withdrawals.sql b/dbt_subprojects/daily_spellbook/models/swell/rsweth/ethereum/swell_rsweth_ethereum_withdrawals.sql new file mode 100644 index 00000000000..1f0a6730ae6 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/swell/rsweth/ethereum/swell_rsweth_ethereum_withdrawals.sql @@ -0,0 +1,94 @@ +{{ config( + schema = 'swell_rsweth_ethereum', + alias = 'withdrawals', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['token_id'], + post_hook='{{ expose_spells(\'["ethereum"]\', + "project", + "swell", + \'["maybeYonas"]\') }}' + ) +}} + +{% set incremental %} + where evt_block_time >= ( + select min(request_block_time) + from {{ this }} + where claim_block_time is null + ) +{% endset %} + +with +rsweth_decoded_withdrawal_requests as ( + select + evt_block_time, evt_tx_hash, evt_block_number, evt_index, + lastTokenIdProcessed, + owner, + tokenId, + amount, + timestamp, + rateWhenCreated + from {{source ('swell_v3_ethereum', 'RswEXIT_evt_WithdrawRequestCreated')}} + -- from swell_v3_ethereum.RswEXIT_evt_WithdrawRequestCreated + {% if is_incremental() %} + {{incremental}} + {% endif %} +), +rsweth_decoded_withdrawal_claimed as ( + select + evt_block_time, evt_tx_hash, evt_block_number, evt_index, + owner, + tokenId, + exitClaimedETH + from {{source ('swell_v3_ethereum', 'RswEXIT_evt_WithdrawalClaimed')}} + -- from swell_v3_ethereum.RswEXIT_evt_WithdrawalClaimed + {% if is_incremental() %} + {{incremental}} + {% endif %} + +), +rsweth_decoded_withdrawal_processed as ( + select + evt_block_time, evt_tx_hash, evt_block_number, evt_index, + fromTokenId, + toTokenId, + processedRate, + processedExitingETH, + processedExitedETH + from {{source ('swell_v3_ethereum', 'RswEXIT_evt_WithdrawalsProcessed')}} + -- from swell_v3_ethereum.RswEXIT_evt_WithdrawalsProcessed + {% if is_incremental() %} + {{incremental}} + {% endif %} +) + +select + r.evt_block_time as request_block_time, + r.evt_tx_hash as request_tx_hash, + r.evt_block_number as request_block_number, + r.evt_index as request_index, + r.tokenId as token_id, + r.owner as owner, + r.amount/1e18 as rswETH_amount, + r.rateWhenCreated/1e18 as rswETH_request_rate, + + p.evt_block_time as processed_block_time, + p.evt_tx_hash as processed_tx_hash, + p.evt_block_number as processed_block_number, + p.evt_index as processed_index, + p.processedRate/1e18 as rswETH_processed_rate, + + c.evt_block_time as claim_block_time, + c.evt_tx_hash as claim_tx_hash, + c.evt_block_number as claim_block_number, + c.evt_index as claim_index, + c.exitClaimedETH/1e18 as ETH_amount +from rsweth_decoded_withdrawal_requests r + left join rsweth_decoded_withdrawal_processed p + on r.tokenId >= p.fromTokenId + and r.tokenId <= p.toTokenId + left join rsweth_decoded_withdrawal_claimed c + on r.tokenId = c.tokenId +order by 1 desc \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/seeds/swell/balances/ethereum/schema.yml b/dbt_subprojects/daily_spellbook/seeds/swell/balances/ethereum/schema.yml new file mode 100644 index 00000000000..5bf343416bd --- /dev/null +++ b/dbt_subprojects/daily_spellbook/seeds/swell/balances/ethereum/schema.yml @@ -0,0 +1,12 @@ +version: 2 + +seeds: + - name: swell_balances_ethereum_core_assets_seed + config: + column_types: + blockchain: varchar + day: timestamp + wallet_address: varbinary + token_address: varbinary + balance: double + last_updated: timestamp \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/seeds/swell/balances/ethereum/swell_balances_ethereum_core_assets_seed.csv b/dbt_subprojects/daily_spellbook/seeds/swell/balances/ethereum/swell_balances_ethereum_core_assets_seed.csv new file mode 100644 index 00000000000..56bd9d1d361 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/seeds/swell/balances/ethereum/swell_balances_ethereum_core_assets_seed.csv @@ -0,0 +1,8 @@ +blockchain,day,wallet_address,token_address,balance,last_updated +ethereum,2024-08-13 00:00:00.000 UTC,0x4589Ef5d52a152C25Daa513cF43b1389Bd1f3C00,0xf951E335afb289353dc249e82926178EaC7DEd78,0.004752378895635013,2024-02-29 00:00:00.000 UTC +ethereum,2024-12-04 00:00:00.000 UTC,0xaf1ec97ea59e9052ee563e4265c39291c020e3dd,0x0a6e7ba5042b38349e437ec6db6214aec7b35676,1074.616281,2024-11-08 00:00:00.000 UTC +ethereum,2024-12-05 00:00:00.000 UTC,0x841ea52b74c94420a61d41ba790e710e1af8ee0a,0xFAe103DC9cf190eD75350761e95403b7b8aFa6c0,0.050121577326075153,2024-11-24 00:00:00.000 UTC +ethereum,2024-08-13 00:00:00.000 UTC,0xfee2d4498085581dde097b9924e4e3544682d767,0x8db2350d78abc13f5673a411d4700bcf87864dde,0.04096165,2024-08-13 00:00:00.000 UTC +ethereum,2024-12-04 00:00:00.000 UTC,0xbdD5d655ad781FB9929BFe515EB4A50090444C21,0x9Ed15383940CC380fAEF0a75edacE507cC775f22,89.828941195874851394,2024-11-08 00:00:00.000 UTC +ethereum,2024-12-01 00:00:00.000 UTC,0x84a6a7c0674A3AA03e09c026600cb46181821f07,0x66E47E6957B85Cf62564610B76dD206BB04d831a,1,2024-11-25 00:00:00.000 UTC +ethereum,2024-12-04 00:00:00.000 UTC,0x22aA3f5D1daFfe1a9DF298e79a0CF2f98C1b92FF,0x358d94b5b2F147D741088803d932Acb566acB7B6,278707.960865665406065408,2024-12-02 00:00:00.000 UTC \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/seeds/swell/rsweth/ethereum/schema.yml b/dbt_subprojects/daily_spellbook/seeds/swell/rsweth/ethereum/schema.yml new file mode 100644 index 00000000000..84344e87d47 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/seeds/swell/rsweth/ethereum/schema.yml @@ -0,0 +1,24 @@ +version: 2 + +seeds: + - name: swell_rsweth_ethereum_withdrawals_seed + config: + column_types: + request_block_time: timestamp + request_tx_hash: varbinary + request_block_number: bigint + request_index: integer + token_id: integer + owner: varbinary + rswETH_amount: double + rswETH_request_rate: double + processed_block_time: timestamp + processed_tx_hash: varbinary + processed_block_number: bigint + processed_index: integer + rswETH_processed_rate: double + claim_block_time: timestamp + claim_tx_hash: varbinary + claim_block_number: bigint + claim_index: integer + ETH_amount: double \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/seeds/swell/rsweth/ethereum/swell_rsweth_ethereum_withdrawals_seed.csv b/dbt_subprojects/daily_spellbook/seeds/swell/rsweth/ethereum/swell_rsweth_ethereum_withdrawals_seed.csv new file mode 100644 index 00000000000..c46f8111e3e --- /dev/null +++ b/dbt_subprojects/daily_spellbook/seeds/swell/rsweth/ethereum/swell_rsweth_ethereum_withdrawals_seed.csv @@ -0,0 +1,3 @@ +request_block_time,request_tx_hash,request_block_number,request_index,token_id,owner,rswETH_amount,rswETH_request_rate,processed_block_time,processed_tx_hash,processed_block_number,processed_index,rswETH_processed_rate,claim_block_time,claim_tx_hash,claim_block_number,claim_index,ETH_amount +2024-11-12 06:57:47.000 UTC,0x978742baca60c9f02eec6f8328ee77abb85716eb111d340497315f077f049388,21169958,227,3007,0xc77c6375e9fd581701425a6fb70bf371fb1cba28,500.00,1.023476642102901592,2024-11-21 01:09:47.000 UTC,0x9a0ac005f69cd7df2f10134ae5004a666c0ceb1baf034fdb41460439f02b684d,21232733,167,1.024494608040389206,2024-11-22 02:55:11.000 UTC,0x0fd5c4551eda43ad93f6833e0f5463afac8e88d30e3263cabcf4da9477b81fbf,21240420,274,511.738321051450796 +2024-11-12 06:56:47.000 UTC,0xd0a7cd3f2f67cca12f2fe22ef7a5f0df922c1716d2f894a8c20406fdf01fd9dd,21169953,461,3006,0xc77c6375e9fd581701425a6fb70bf371fb1cba28,500.00,1.023476642102901592,2024-11-21 01:09:47.000 UTC,0x9a0ac005f69cd7df2f10134ae5004a666c0ceb1baf034fdb41460439f02b684d,21232733,167,1.024494608040389206,2024-11-22 02:54:35.000 UTC,0xf4aa4a769d39d6aadc54591eca47f59e688487580ef55f5bf4b21880bce16d3e,21240417,322,511.738321051450796 \ No newline at end of file diff --git a/dbt_subprojects/dex/README.md b/dbt_subprojects/dex/README.md index 8aef6e6c3ac..a14c2b63f6a 100644 --- a/dbt_subprojects/dex/README.md +++ b/dbt_subprojects/dex/README.md @@ -1,5 +1,6 @@ ## DEX subproject + This is a DBT subproject for the main lineages of the DEX sector. Included in this subproject, but not limited to over time: - `dex.trades` - `dex_aggreagtor.trades` @@ -8,4 +9,4 @@ This is a DBT subproject for the main lineages of the DEX sector. Included in th - `dex.sandwiched` - ...and more! -This subproject will be dedicated to building the above spells (and others in the future related to DEX) on an hourly cadence in production. All other spells not included within this subproject will treat these spells as sources. For example, labels spells which read from `dex.trades` will now treat the spell as a source, rather than reference within dbt. \ No newline at end of file +This subproject will be dedicated to building the above spells (and others in the future related to DEX) on an hourly cadence in production. All other spells not included within this subproject will treat these spells as sources. For example, labels spells which read from `dex.trades` will now treat the spell as a source, rather than reference within dbt. diff --git a/dbt_subprojects/dex/dbt_project.yml b/dbt_subprojects/dex/dbt_project.yml index e7ae73c9424..5e25bae64bd 100644 --- a/dbt_subprojects/dex/dbt_project.yml +++ b/dbt_subprojects/dex/dbt_project.yml @@ -13,6 +13,9 @@ quoting: # This setting configures which "profile" dbt uses for this project. profile: "spellbook-local" +flags: + require_certificate_validation: true + vars: DBT_ENV_CUSTOM_ENV_S3_BUCKET: "{{ env_var('DBT_ENV_CUSTOM_ENV_S3_BUCKET', 'local') }}" DBT_ENV_INCREMENTAL_TIME: "{{ env_var('DBT_ENV_INCREMENTAL_TIME', '1') }}" diff --git a/dbt_subprojects/dex/macros/models/_project/balancer_compatible_trades.sql b/dbt_subprojects/dex/macros/models/_project/balancer_compatible_trades.sql index 792c211fee1..13aefc608b6 100644 --- a/dbt_subprojects/dex/macros/models/_project/balancer_compatible_trades.sql +++ b/dbt_subprojects/dex/macros/models/_project/balancer_compatible_trades.sql @@ -179,3 +179,78 @@ SELECT FROM dexs {% endmacro %} + +{# ######################################################################### #} + +{% macro balancer_compatible_v3_trades( + blockchain = '', + project = '', + version = '', + project_decoded_as = 'balancer_v3', + Vault_evt_Swap = 'Vault_evt_Swap' + ) +%} + +WITH + +pool_labels AS ( + SELECT + blockchain, + address AS pool_address, + name AS pool_symbol, + pool_type + FROM {{ ref('labels_balancer_v3_pools') }} +), + +dexs AS ( + SELECT + swap.evt_block_number AS block_number, + swap.evt_block_time AS block_time, + CAST(NULL AS VARBINARY) AS taker, + CAST(NULL AS VARBINARY) AS maker, + swap.amountOut AS token_bought_amount_raw, + swap.amountIn AS token_sold_amount_raw, + swap.tokenOut AS token_bought_address, + swap.tokenIn AS token_sold_address, + swap.pool AS project_contract_address, + swap.pool AS pool_id, + l.pool_symbol, + l.pool_type, + swap.SwapFeePercentage / POWER(10, 18) AS swap_fee, + swap.evt_tx_hash AS tx_hash, + swap.evt_index + FROM {{ source(project_decoded_as ~ '_' ~ blockchain, Vault_evt_Swap) }} swap + LEFT JOIN pool_labels l + ON l.blockchain = '{{ blockchain }}' + AND l.pool_address = swap.pool + WHERE swap.tokenIn <> swap.pool + AND swap.tokenOut <> swap.pool + {% if is_incremental() %} + AND {{ incremental_predicate('swap.evt_block_time') }} + {% endif %} +) + +SELECT + '{{ blockchain }}' AS blockchain, + '{{ project }}' AS project, + '{{ version }}' AS version, + CAST(date_trunc('month', dexs.block_time) AS date) AS block_month, + CAST(date_trunc('day', dexs.block_time) AS date) AS block_date, + dexs.block_time, + dexs.block_number, + dexs.token_bought_amount_raw, + dexs.token_sold_amount_raw, + dexs.token_bought_address, + dexs.token_sold_address, + dexs.taker, + dexs.maker, + dexs.project_contract_address, + dexs.tx_hash, + dexs.evt_index, + dexs.pool_id, + dexs.swap_fee, + dexs.pool_symbol, + dexs.pool_type +FROM dexs + +{% endmacro %} \ No newline at end of file diff --git a/dbt_subprojects/dex/macros/models/enrich_balancer_v3_dex_trades.sql b/dbt_subprojects/dex/macros/models/enrich_balancer_v3_dex_trades.sql new file mode 100644 index 00000000000..094f4360d1a --- /dev/null +++ b/dbt_subprojects/dex/macros/models/enrich_balancer_v3_dex_trades.sql @@ -0,0 +1,122 @@ +{% macro enrich_balancer_v3_dex_trades( + base_trades = null + , filter = null + , tokens_erc20_model = null + ) +%} + +WITH base_trades as ( + SELECT + * + FROM + {{ base_trades }} + WHERE + {{ filter }} + {% if is_incremental() %} + AND + {{ incremental_predicate('block_time') }} + {% endif %} +) +, enrichments AS ( + SELECT + base_trades.blockchain + , base_trades.project + , base_trades.version + , base_trades.block_month + , base_trades.block_date + , base_trades.block_time + , base_trades.block_number + , erc20_bought.symbol AS token_bought_symbol + , erc20_sold.symbol AS token_sold_symbol + , CASE + WHEN lower(erc20_bought.symbol) > lower(erc20_sold.symbol) THEN concat(erc20_sold.symbol, '-', erc20_bought.symbol) + ELSE concat(erc20_bought.symbol, '-', erc20_sold.symbol) + END AS token_pair + , base_trades.token_bought_amount_raw / power(10, erc20_bought.decimals) AS token_bought_amount + , base_trades.token_sold_amount_raw / power(10, erc20_sold.decimals) AS token_sold_amount + , base_trades.token_bought_amount_raw + , base_trades.token_sold_amount_raw + , base_trades.token_bought_address + , base_trades.token_sold_address + , coalesce(base_trades.taker, base_trades.tx_from) AS taker + , base_trades.maker + , base_trades.project_contract_address + , base_trades.tx_hash + , base_trades.tx_from + , base_trades.tx_to + , base_trades.evt_index + FROM + base_trades + LEFT JOIN + {{ tokens_erc20_model }} as erc20_bought + ON erc20_bought.contract_address = base_trades.token_bought_address + AND erc20_bought.blockchain = base_trades.blockchain + LEFT JOIN + {{ tokens_erc20_model }} as erc20_sold + ON erc20_sold.contract_address = base_trades.token_sold_address + AND erc20_sold.blockchain = base_trades.blockchain +) + +, enrichments_with_prices AS ( + {{ + add_amount_usd( + trades_cte = 'enrichments' + ) + }} +) + +, erc4626_prices AS( + SELECT + minute, + blockchain, + wrapped_token, + decimals, + APPROX_PERCENTILE(median_price, 0.5) AS price, + LEAD(minute, 1, NOW()) OVER (PARTITION BY wrapped_token ORDER BY minute) AS time_of_next_change + FROM {{ source('balancer_v3', 'erc4626_token_prices') }} + GROUP BY 1, 2, 3, 4 +) + +SELECT + dexs.blockchain + , project + , version + , block_month + , block_date + , block_time + , block_number + , token_bought_symbol + , token_sold_symbol + , token_pair + , token_bought_amount + , token_sold_amount + , token_bought_amount_raw + , token_sold_amount_raw + , COALESCE( + dexs.amount_usd, + dexs.token_bought_amount * erc4626a.price, + dexs.token_sold_amount * erc4626a.price + ) AS amount_usd + , token_bought_address + , token_sold_address + , taker + , maker + , project_contract_address + , tx_hash + , tx_from + , tx_to + , evt_index +FROM + enrichments_with_prices dexs +LEFT JOIN erc4626_prices erc4626a + ON erc4626a.wrapped_token = dexs.token_bought_address + AND erc4626a.minute <= dexs.block_time + AND dexs.block_time < erc4626a.time_of_next_change + AND dexs.blockchain = erc4626a.blockchain +LEFT JOIN erc4626_prices erc4626b + ON erc4626b.wrapped_token = dexs.token_sold_address + AND erc4626b.minute <= dexs.block_time + AND dexs.block_time < erc4626b.time_of_next_change + AND dexs.blockchain = erc4626b.blockchain + +{% endmacro %} \ No newline at end of file diff --git a/dbt_subprojects/dex/models/_projects/balancer/labels/_schema.yml b/dbt_subprojects/dex/models/_projects/balancer/labels/_schema.yml index 9e2d6f55d00..c9b3bc91415 100644 --- a/dbt_subprojects/dex/models/_projects/balancer/labels/_schema.yml +++ b/dbt_subprojects/dex/models/_projects/balancer/labels/_schema.yml @@ -6,7 +6,7 @@ models: blockchain: ethereum sector: labels project: balancer_v1 - contributors: balancerlabs + contributors: balancerlabs, viniabussafi config: tags: ['labels', 'ethereum', 'balancer', 'pools'] description: "Balancer V1 liquidity pools created on Ethereum. " @@ -51,7 +51,7 @@ models: blockchain: ethereum sector: labels project: balancer_v1 - contributors: balancerlabs + contributors: balancerlabs, viniabussafi config: tags: ['labels', 'ethereum', 'balancer', 'pools'] description: "Balancer V1 liquidity pools created across blockchains." @@ -304,4 +304,76 @@ models: - *created_at - *updated_at - *model_name - - *label_type \ No newline at end of file + - *label_type + + - name: labels_balancer_v3_pools_ethereum + meta: + blockchain: ethereum + sector: labels + project: balancer_v3 + contributors: balancerlabs, viniabussafi + config: + tags: ['labels', 'ethereum', 'balancer', 'pools'] + description: 'Balancer V3 liquidity pools created on Ethereum.' + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - address + columns: + - *blockchain + - *address + - *name + - *category + - *contributor + - *source + - *created_at + - *updated_at + - *model_name + - *label_type + + - name: labels_balancer_v3_pools_gnosis + meta: + blockchain: gnosis + sector: labels + project: balancer_v3 + contributors: balancerlabs, viniabussafi + config: + tags: ['labels', 'zkevm', 'balancer', 'pools'] + description: 'Balancer V3 liquidity pools created on Gnosis.' + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - address + columns: + - *blockchain + - *address + - *name + - *category + - *contributor + - *source + - *created_at + - *updated_at + - *model_name + - *label_type + + + - name: labels_balancer_v3_pools + meta: + blockchain: ethereum, gnosis + sector: labels + project: balancer_v3 + contributors: balancerlabs, viniabussafi + config: + tags: ['labels', 'ethereum', 'gnosis', 'balancer', 'pools'] + description: 'Balancer V3 liquidity pools created across blockchains.' + columns: + - *blockchain + - *address + - *name + - *category + - *contributor + - *source + - *created_at + - *updated_at + - *model_name + - *label_type \ No newline at end of file diff --git a/dbt_subprojects/dex/models/_projects/balancer/labels/arbitrum/labels_balancer_v2_pools_arbitrum.sql b/dbt_subprojects/dex/models/_projects/balancer/labels/arbitrum/labels_balancer_v2_pools_arbitrum.sql index 28698790a26..10f6c91decb 100644 --- a/dbt_subprojects/dex/models/_projects/balancer/labels/arbitrum/labels_balancer_v2_pools_arbitrum.sql +++ b/dbt_subprojects/dex/models/_projects/balancer/labels/arbitrum/labels_balancer_v2_pools_arbitrum.sql @@ -275,6 +275,7 @@ settings AS ( p.pool_type FROM pools p LEFT JOIN {{ source('tokens', 'erc20') }} t ON p.token_address = t.contract_address + AND t.blockchain = 'arbitrum' ) SELECT diff --git a/dbt_subprojects/dex/models/_projects/balancer/labels/avalanche_c/labels_balancer_v2_pools_avalanche_c.sql b/dbt_subprojects/dex/models/_projects/balancer/labels/avalanche_c/labels_balancer_v2_pools_avalanche_c.sql index 15ea79d74de..9ae2b794382 100644 --- a/dbt_subprojects/dex/models/_projects/balancer/labels/avalanche_c/labels_balancer_v2_pools_avalanche_c.sql +++ b/dbt_subprojects/dex/models/_projects/balancer/labels/avalanche_c/labels_balancer_v2_pools_avalanche_c.sql @@ -151,6 +151,7 @@ settings AS ( p.pool_type FROM pools p LEFT JOIN {{ source('tokens', 'erc20') }} t ON p.token_address = t.contract_address + AND t.blockchain = 'avalanche_c' ) SELECT diff --git a/dbt_subprojects/dex/models/_projects/balancer/labels/base/labels_balancer_v2_pools_base.sql b/dbt_subprojects/dex/models/_projects/balancer/labels/base/labels_balancer_v2_pools_base.sql index 1b4c00b5f9e..bbf7e0c347c 100644 --- a/dbt_subprojects/dex/models/_projects/balancer/labels/base/labels_balancer_v2_pools_base.sql +++ b/dbt_subprojects/dex/models/_projects/balancer/labels/base/labels_balancer_v2_pools_base.sql @@ -126,6 +126,7 @@ settings AS ( p.pool_type FROM pools p LEFT JOIN {{ source('tokens', 'erc20') }} t ON p.token_address = t.contract_address + AND t.blockchain = 'base' ) SELECT diff --git a/dbt_subprojects/dex/models/_projects/balancer/labels/ethereum/labels_balancer_v2_pools_ethereum.sql b/dbt_subprojects/dex/models/_projects/balancer/labels/ethereum/labels_balancer_v2_pools_ethereum.sql index 9e9c26f9489..5fdeff93667 100644 --- a/dbt_subprojects/dex/models/_projects/balancer/labels/ethereum/labels_balancer_v2_pools_ethereum.sql +++ b/dbt_subprojects/dex/models/_projects/balancer/labels/ethereum/labels_balancer_v2_pools_ethereum.sql @@ -275,6 +275,7 @@ settings AS ( p.pool_type FROM pools p LEFT JOIN {{ source('tokens', 'erc20') }} t ON p.token_address = t.contract_address + AND t.blockchain = 'ethereum' ) SELECT diff --git a/dbt_subprojects/dex/models/_projects/balancer/labels/ethereum/labels_balancer_v3_pools_ethereum.sql b/dbt_subprojects/dex/models/_projects/balancer/labels/ethereum/labels_balancer_v3_pools_ethereum.sql new file mode 100644 index 00000000000..55a9624bfe3 --- /dev/null +++ b/dbt_subprojects/dex/models/_projects/balancer/labels/ethereum/labels_balancer_v3_pools_ethereum.sql @@ -0,0 +1,100 @@ +{{config( + schema = 'labels', + alias = 'balancer_v3_pools_ethereum', + post_hook = '{{ expose_spells(\'["ethereum"]\', + "sector", + "labels", + \'["viniabussafi"]\') }}' +)}} + +WITH token_data AS ( + SELECT + pool, + ARRAY_AGG(FROM_HEX(json_extract_scalar(token, '$.token')) ORDER BY token_index) AS tokens + FROM ( + SELECT + pool, + tokenConfig, + SEQUENCE(1, CARDINALITY(tokenConfig)) AS token_index_array + FROM {{ source('balancer_v3_ethereum', 'Vault_evt_PoolRegistered') }} + ) AS pool_data + CROSS JOIN UNNEST(tokenConfig, token_index_array) AS t(token, token_index) + GROUP BY 1 + ), + + pools AS ( + SELECT + pool_id, + zip.tokens AS token_address, + zip.weights / POWER(10, 18) AS normalized_weight, + symbol, + pool_type + FROM ( + SELECT + c.pool AS pool_id, + t.tokens, + w.weights, + cc.symbol, + 'weighted' AS pool_type + FROM token_data c + INNER JOIN {{ source('balancer_v3_ethereum', 'WeightedPoolFactory_call_create') }} cc + ON c.pool = cc.output_pool + CROSS JOIN UNNEST(c.tokens) WITH ORDINALITY t(tokens, pos) + CROSS JOIN UNNEST(cc.normalizedWeights) WITH ORDINALITY w(weights, pos) + WHERE t.pos = w.pos + + UNION ALL + + SELECT + c.pool AS pool_id, + t.tokens, + 0 AS weights, + cc.symbol, + 'stable' AS pool_type + FROM token_data c + INNER JOIN {{ source('balancer_v3_ethereum', 'StablePoolFactory_call_create') }} cc + ON c.pool = cc.output_pool + CROSS JOIN UNNEST(c.tokens) AS t(tokens) + ) zip + ), + + settings AS ( + SELECT + pool_id, + coalesce(t.symbol, '?') AS token_symbol, + normalized_weight, + p.symbol AS pool_symbol, + p.pool_type + FROM pools p + LEFT JOIN {{ source('tokens', 'erc20') }} t ON p.token_address = t.contract_address + AND t.blockchain = 'ethereum' + ) + +SELECT + 'ethereum' AS blockchain, + bytearray_substring(pool_id, 1, 20) AS address, + CASE WHEN pool_type IN ('stable') + THEN lower(pool_symbol) + ELSE lower(concat(array_join(array_agg(token_symbol ORDER BY token_symbol), '/'), ' ', + array_join(array_agg(cast(norm_weight AS varchar) ORDER BY token_symbol), '/'))) + END AS name, + pool_type, + 'balancer_v3_pool' AS category, + 'balancerlabs' AS contributor, + 'query' AS source, + TIMESTAMP'2024-12-01 00:00' AS created_at, + now() AS updated_at, + 'balancer_v3_pools_ethereum' AS model_name, + 'identifier' AS label_type +FROM ( + SELECT + s1.pool_id, + token_symbol, + pool_symbol, + cast(100 * normalized_weight AS integer) AS norm_weight, + pool_type + FROM settings s1 + GROUP BY s1.pool_id, token_symbol, pool_symbol, normalized_weight, pool_type +) s +GROUP BY pool_id, pool_symbol, pool_type +ORDER BY 1 \ No newline at end of file diff --git a/dbt_subprojects/dex/models/_projects/balancer/labels/gnosis/labels_balancer_v2_pools_gnosis.sql b/dbt_subprojects/dex/models/_projects/balancer/labels/gnosis/labels_balancer_v2_pools_gnosis.sql index c907edd95e4..0cba149d634 100644 --- a/dbt_subprojects/dex/models/_projects/balancer/labels/gnosis/labels_balancer_v2_pools_gnosis.sql +++ b/dbt_subprojects/dex/models/_projects/balancer/labels/gnosis/labels_balancer_v2_pools_gnosis.sql @@ -192,6 +192,7 @@ settings AS ( p.pool_type FROM pools p LEFT JOIN {{ source('tokens', 'erc20') }} t ON p.token_address = t.contract_address + AND t.blockchain = 'gnosis' ) SELECT diff --git a/dbt_subprojects/dex/models/_projects/balancer/labels/gnosis/labels_balancer_v3_pools_gnosis.sql b/dbt_subprojects/dex/models/_projects/balancer/labels/gnosis/labels_balancer_v3_pools_gnosis.sql new file mode 100644 index 00000000000..8333126451b --- /dev/null +++ b/dbt_subprojects/dex/models/_projects/balancer/labels/gnosis/labels_balancer_v3_pools_gnosis.sql @@ -0,0 +1,100 @@ +{{config( + schema = 'labels', + alias = 'balancer_v3_pools_gnosis', + post_hook = '{{ expose_spells(\'["gnosis"]\', + "sector", + "labels", + \'["viniabussafi"]\') }}' +)}} + +WITH token_data AS ( + SELECT + pool, + ARRAY_AGG(FROM_HEX(json_extract_scalar(token, '$.token')) ORDER BY token_index) AS tokens + FROM ( + SELECT + pool, + tokenConfig, + SEQUENCE(1, CARDINALITY(tokenConfig)) AS token_index_array + FROM {{ source('balancer_v3_gnosis', 'Vault_evt_PoolRegistered') }} + ) AS pool_data + CROSS JOIN UNNEST(tokenConfig, token_index_array) AS t(token, token_index) + GROUP BY 1 + ), + + pools AS ( + SELECT + pool_id, + zip.tokens AS token_address, + zip.weights / POWER(10, 18) AS normalized_weight, + symbol, + pool_type + FROM ( + SELECT + c.pool AS pool_id, + t.tokens, + w.weights, + cc.symbol, + 'weighted' AS pool_type + FROM token_data c + INNER JOIN {{ source('balancer_v3_gnosis', 'WeightedPoolFactory_call_create') }} cc + ON c.pool = cc.output_pool + CROSS JOIN UNNEST(c.tokens) WITH ORDINALITY t(tokens, pos) + CROSS JOIN UNNEST(cc.normalizedWeights) WITH ORDINALITY w(weights, pos) + WHERE t.pos = w.pos + + UNION ALL + + SELECT + c.pool AS pool_id, + t.tokens, + 0 AS weights, + cc.symbol, + 'stable' AS pool_type + FROM token_data c + INNER JOIN {{ source('balancer_v3_gnosis', 'StablePoolFactory_call_create') }} cc + ON c.pool = cc.output_pool + CROSS JOIN UNNEST(c.tokens) AS t(tokens) + ) zip + ), + + settings AS ( + SELECT + pool_id, + coalesce(t.symbol, '?') AS token_symbol, + normalized_weight, + p.symbol AS pool_symbol, + p.pool_type + FROM pools p + LEFT JOIN {{ source('tokens', 'erc20') }} t ON p.token_address = t.contract_address + AND t.blockchain = 'gnosis' + ) + +SELECT + 'gnosis' AS blockchain, + bytearray_substring(pool_id, 1, 20) AS address, + CASE WHEN pool_type IN ('stable') + THEN lower(pool_symbol) + ELSE lower(concat(array_join(array_agg(token_symbol ORDER BY token_symbol), '/'), ' ', + array_join(array_agg(cast(norm_weight AS varchar) ORDER BY token_symbol), '/'))) + END AS name, + pool_type, + 'balancer_v3_pool' AS category, + 'balancerlabs' AS contributor, + 'query' AS source, + TIMESTAMP'2024-12-01 00:00' AS created_at, + now() AS updated_at, + 'balancer_v3_pools_gnosis' AS model_name, + 'identifier' AS label_type +FROM ( + SELECT + s1.pool_id, + token_symbol, + pool_symbol, + cast(100 * normalized_weight AS integer) AS norm_weight, + pool_type + FROM settings s1 + GROUP BY s1.pool_id, token_symbol, pool_symbol, normalized_weight, pool_type +) s +GROUP BY pool_id, pool_symbol, pool_type +ORDER BY 1 diff --git a/dbt_subprojects/dex/models/_projects/balancer/labels/labels_balancer_v3_pools.sql b/dbt_subprojects/dex/models/_projects/balancer/labels/labels_balancer_v3_pools.sql new file mode 100644 index 00000000000..1e9e933869d --- /dev/null +++ b/dbt_subprojects/dex/models/_projects/balancer/labels/labels_balancer_v3_pools.sql @@ -0,0 +1,11 @@ +{{config( + schema = 'labels', + alias = 'balancer_v3_pools', + post_hook='{{ expose_spells(\'["ethereum", "gnosis"]\', + "sector", + "labels", + \'["balancerlabs", "viniabussafi"]\') }}')}} + +SELECT * FROM {{ ref('labels_balancer_v3_pools_ethereum') }} +UNION +SELECT * FROM {{ ref('labels_balancer_v3_pools_gnosis') }} diff --git a/dbt_subprojects/dex/models/_projects/balancer/labels/optimism/labels_balancer_v2_pools_optimism.sql b/dbt_subprojects/dex/models/_projects/balancer/labels/optimism/labels_balancer_v2_pools_optimism.sql index 22a66efaaa4..139d8a5882a 100644 --- a/dbt_subprojects/dex/models/_projects/balancer/labels/optimism/labels_balancer_v2_pools_optimism.sql +++ b/dbt_subprojects/dex/models/_projects/balancer/labels/optimism/labels_balancer_v2_pools_optimism.sql @@ -196,6 +196,7 @@ settings AS ( p.pool_type FROM pools p LEFT JOIN {{ source('tokens', 'erc20') }} t ON p.token_address = t.contract_address + AND t.blockchain = 'optimism' ) SELECT diff --git a/dbt_subprojects/dex/models/_projects/balancer/labels/polygon/labels_balancer_v2_pools_polygon.sql b/dbt_subprojects/dex/models/_projects/balancer/labels/polygon/labels_balancer_v2_pools_polygon.sql index fdcc3adcc08..4ff7daa683e 100644 --- a/dbt_subprojects/dex/models/_projects/balancer/labels/polygon/labels_balancer_v2_pools_polygon.sql +++ b/dbt_subprojects/dex/models/_projects/balancer/labels/polygon/labels_balancer_v2_pools_polygon.sql @@ -273,6 +273,7 @@ settings AS ( p.pool_type FROM pools p LEFT JOIN {{ source('tokens', 'erc20') }} t ON p.token_address = t.contract_address + AND t.blockchain = 'polygon' ) SELECT diff --git a/dbt_subprojects/dex/models/_projects/balancer/labels/zkevm/labels_balancer_v2_pools_zkevm.sql b/dbt_subprojects/dex/models/_projects/balancer/labels/zkevm/labels_balancer_v2_pools_zkevm.sql index 8353fd05ce4..f72c672acd5 100644 --- a/dbt_subprojects/dex/models/_projects/balancer/labels/zkevm/labels_balancer_v2_pools_zkevm.sql +++ b/dbt_subprojects/dex/models/_projects/balancer/labels/zkevm/labels_balancer_v2_pools_zkevm.sql @@ -154,6 +154,7 @@ settings AS ( p.pool_type FROM pools p LEFT JOIN {{ source('tokens', 'erc20') }} t ON p.token_address = t.contract_address + AND t.blockchain = 'zkevm' ) SELECT diff --git a/dbt_subprojects/dex/models/_projects/balancer/pools/_schema.yml b/dbt_subprojects/dex/models/_projects/balancer/pools/_schema.yml index 79a17fe7cdf..c62279b3d91 100644 --- a/dbt_subprojects/dex/models/_projects/balancer/pools/_schema.yml +++ b/dbt_subprojects/dex/models/_projects/balancer/pools/_schema.yml @@ -8,7 +8,7 @@ models: config: tags: ['arbitrum', 'avalanche_c', 'base', 'ethereum', 'gnosis', 'optimism', 'polygon', 'zkevm', 'pools', 'fees'] description: > - Balancer v2 swap fees stored at the pool level. + Balancer v2 and v3 swap fees stored at the pool level. data_tests: - dbt_utils.unique_combination_of_columns: combination_of_columns: @@ -265,4 +265,56 @@ models: - *tx_index - *block_time - *block_number - - *swap_fee_percentage \ No newline at end of file + - *swap_fee_percentage + + - name: balancer_v3_ethereum_pools_fees + meta: + blockchain: ethereum + project: balancer_v3 + contributors: viniabussafi + config: + tags: ['ethereum', 'balancer', 'pools_fees'] + description: > + Balancer v3 swap fees stored at the pool level. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_number + - tx_hash + - index + columns: + - *blockchain + - *version + - *contract_address + - *tx_hash + - *index + - *tx_index + - *block_time + - *block_number + - *swap_fee_percentage + + - name: balancer_v3_gnosis_pools_fees + meta: + blockchain: gnosis + project: balancer_v3 + contributors: viniabussafi + config: + tags: ['gnosis', 'balancer', 'pools_fees'] + description: > + Balancer v3 swap fees stored at the pool level. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_number + - tx_hash + - index + columns: + - *blockchain + - *version + - *contract_address + - *tx_hash + - *index + - *tx_index + - *block_time + - *block_number + - *swap_fee_percentage \ No newline at end of file diff --git a/dbt_subprojects/dex/models/_projects/balancer/pools/balancer_pools_fees.sql b/dbt_subprojects/dex/models/_projects/balancer/pools/balancer_pools_fees.sql index 2a54b518ec1..a733d20db6a 100644 --- a/dbt_subprojects/dex/models/_projects/balancer/pools/balancer_pools_fees.sql +++ b/dbt_subprojects/dex/models/_projects/balancer/pools/balancer_pools_fees.sql @@ -16,7 +16,9 @@ ref('balancer_v2_gnosis_pools_fees'), ref('balancer_v2_optimism_pools_fees'), ref('balancer_v2_polygon_pools_fees'), - ref('balancer_v2_zkevm_pools_fees') + ref('balancer_v2_zkevm_pools_fees'), + ref('balancer_v3_ethereum_pools_fees'), + ref('balancer_v3_gnosis_pools_fees') ] %} diff --git a/dbt_subprojects/dex/models/_projects/balancer/pools/ethereum/balancer_v3_ethereum_pools_fees.sql b/dbt_subprojects/dex/models/_projects/balancer/pools/ethereum/balancer_v3_ethereum_pools_fees.sql new file mode 100644 index 00000000000..69fdd2eb826 --- /dev/null +++ b/dbt_subprojects/dex/models/_projects/balancer/pools/ethereum/balancer_v3_ethereum_pools_fees.sql @@ -0,0 +1,28 @@ +{{ + config( + schema = 'balancer_v3_ethereum', + alias = 'pools_fees', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], + unique_key = ['block_number', 'tx_hash', 'index'] + ) +}} + +SELECT + 'ethereum' AS blockchain, + '3' AS version, + pool AS contract_address, + evt_tx_hash AS tx_hash, + evt_index AS tx_index, + evt_index AS index, + evt_block_time AS block_time, + evt_block_number AS block_number, + swapFeePercentage AS swap_fee_percentage +FROM {{ source ('balancer_v3_ethereum', 'Vault_evt_SwapFeePercentageChanged') }} +WHERE 1 = 1 +{% if is_incremental() %} +AND {{ incremental_predicate('evt_block_time') }} +{% endif %} + diff --git a/dbt_subprojects/dex/models/_projects/balancer/pools/gnosis/balancer_v3_gnosis_pools_fees.sql b/dbt_subprojects/dex/models/_projects/balancer/pools/gnosis/balancer_v3_gnosis_pools_fees.sql new file mode 100644 index 00000000000..88743f46eb9 --- /dev/null +++ b/dbt_subprojects/dex/models/_projects/balancer/pools/gnosis/balancer_v3_gnosis_pools_fees.sql @@ -0,0 +1,28 @@ +{{ + config( + schema = 'balancer_v3_gnosis', + alias = 'pools_fees', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], + unique_key = ['block_number', 'tx_hash', 'index'] + ) +}} + +SELECT + 'gnosis' AS blockchain, + '3' AS version, + pool AS contract_address, + evt_tx_hash AS tx_hash, + evt_index AS tx_index, + evt_index AS index, + evt_block_time AS block_time, + evt_block_number AS block_number, + swapFeePercentage AS swap_fee_percentage +FROM {{ source ('balancer_v3_gnosis', 'Vault_evt_SwapFeePercentageChanged') }} +WHERE 1 = 1 +{% if is_incremental() %} +AND {{ incremental_predicate('evt_block_time') }} +{% endif %} + diff --git a/dbt_subprojects/dex/models/_projects/balancer/trades/ethereum/_schema.yml b/dbt_subprojects/dex/models/_projects/balancer/trades/ethereum/_schema.yml index 14737f94d4a..c46f5ff8483 100644 --- a/dbt_subprojects/dex/models/_projects/balancer/trades/ethereum/_schema.yml +++ b/dbt_subprojects/dex/models/_projects/balancer/trades/ethereum/_schema.yml @@ -138,4 +138,43 @@ models: - *tx_hash - *tx_from - *tx_to - - *evt_index \ No newline at end of file + - *evt_index + + - name: balancer_v3_ethereum_trades + meta: + blockchain: ethereum + sector: dex + contributors: viniabussafi + config: + tags: [ 'balancer', 'ethereum', 'amm', 'trades', 'dex', 'beta' ] + description: > + DEX trades on balancer v3 on ethereum + columns: + - *blockchain + - *project + - *version + - *block_month + - *block_date + - *block_time + - *block_number + - *token_bought_symbol + - *token_sold_symbol + - *token_pair + - *token_bought_amount + - *token_sold_amount + - *token_bought_amount_raw + - *token_sold_amount_raw + - *amount_usd + - *token_bought_address + - *token_sold_address + - *taker + - *maker + - *project_contract_address + - *pool_symbol + - *pool_type + - *pool_id + - *swap_fee + - *tx_hash + - *tx_from + - *tx_to + - *evt_index \ No newline at end of file diff --git a/dbt_subprojects/dex/models/_projects/balancer/trades/ethereum/balancer_ethereum_trades.sql b/dbt_subprojects/dex/models/_projects/balancer/trades/ethereum/balancer_ethereum_trades.sql index 965b86cdf54..d6657d18d4f 100644 --- a/dbt_subprojects/dex/models/_projects/balancer/trades/ethereum/balancer_ethereum_trades.sql +++ b/dbt_subprojects/dex/models/_projects/balancer/trades/ethereum/balancer_ethereum_trades.sql @@ -8,7 +8,8 @@ {% set balancer_models = [ ref('balancer_v1_ethereum_trades'), ref('balancer_v2_ethereum_trades'), - ref('balancer_cowswap_amm_ethereum_trades') + ref('balancer_cowswap_amm_ethereum_trades'), + ref('balancer_v3_ethereum_trades') ] %} SELECT * diff --git a/dbt_subprojects/dex/models/_projects/balancer/trades/ethereum/balancer_v3_ethereum_trades.sql b/dbt_subprojects/dex/models/_projects/balancer/trades/ethereum/balancer_v3_ethereum_trades.sql new file mode 100644 index 00000000000..ad927febd4c --- /dev/null +++ b/dbt_subprojects/dex/models/_projects/balancer/trades/ethereum/balancer_v3_ethereum_trades.sql @@ -0,0 +1,171 @@ +{{ + config( + schema = 'balancer_v3_ethereum', + alias = 'trades', + materialized = 'view', + post_hook = '{{ expose_spells(\'["ethereum"]\', + spell_type = "project", + spell_name = "balancer", + contributors = \'["viniabussafi"]\') }}' + ) +}} + +WITH + dexs_base AS ( + SELECT + tx_hash, + evt_index, + pool_id, + swap_fee, + pool_symbol, + pool_type + FROM {{ ref('balancer_v3_ethereum_base_trades') }} + ), + + dexs AS ( + SELECT + dexs.blockchain, + dexs.project, + dexs.version, + dexs.block_month, + dexs.block_date, + dexs.block_time, + dexs.block_number, + dexs.token_bought_symbol, + dexs.token_sold_symbol, + dexs.token_pair, + dexs.token_bought_amount, + dexs.token_sold_amount, + dexs.token_bought_amount_raw, + dexs.token_sold_amount_raw, + dexs.amount_usd, + dexs.token_bought_address, + dexs.token_sold_address, + dexs.taker, + dexs.maker, + dexs.project_contract_address, + dexs.tx_hash, + dexs.tx_from, + dexs.tx_to, + dexs.evt_index, + dexs_base.pool_id, + dexs_base.swap_fee, + dexs_base.pool_symbol, + dexs_base.pool_type + FROM {{ ref('dex_trades') }} dexs + INNER JOIN dexs_base + ON dexs.tx_hash = dexs_base.tx_hash + AND dexs.evt_index = dexs_base.evt_index + WHERE dexs.blockchain = 'ethereum' + AND dexs.project = 'balancer' + AND dexs.version = '3' + ), + + bpa AS ( + SELECT + dexs.block_number, + dexs.tx_hash, + dexs.evt_index, + bpt_prices.contract_address, + dexs.block_time, + MAX(bpt_prices.day) AS bpa_max_block_date + FROM dexs + LEFT JOIN {{ source('balancer', 'bpt_prices') }} bpt_prices + ON bpt_prices.contract_address = dexs.token_bought_address + AND bpt_prices.day <= DATE_TRUNC('day', dexs.block_time) + AND bpt_prices.blockchain = 'ethereum' + GROUP BY 1, 2, 3, 4, 5 + ), + + bpb AS ( + SELECT + dexs.block_number, + dexs.tx_hash, + dexs.evt_index, + bpt_prices.contract_address, + dexs.block_time, + MAX(bpt_prices.day) AS bpb_max_block_date + FROM dexs + LEFT JOIN {{ source('balancer', 'bpt_prices') }} bpt_prices + ON bpt_prices.contract_address = dexs.token_sold_address + AND bpt_prices.day <= DATE_TRUNC('day', dexs.block_time) + AND bpt_prices.blockchain = 'ethereum' + GROUP BY 1, 2, 3, 4, 5 + ), + + erc4626_prices AS( + SELECT + minute, + wrapped_token, + decimals, + APPROX_PERCENTILE(median_price, 0.5) AS price, + LEAD(minute, 1, NOW()) OVER (PARTITION BY wrapped_token ORDER BY minute) AS time_of_next_change + FROM {{ source('balancer_v3', 'erc4626_token_prices') }} + WHERE blockchain = 'ethereum' + GROUP BY 1, 2, 3 + ) + +SELECT + dexs.blockchain, + dexs.project, + dexs.version, + dexs.block_date, + dexs.block_number, + dexs.block_month, + dexs.block_time, + dexs.token_bought_symbol, + dexs.token_sold_symbol, + dexs.token_pair, + dexs.token_bought_amount, + dexs.token_sold_amount, + dexs.token_bought_amount_raw, + dexs.token_sold_amount_raw, + COALESCE( + dexs.amount_usd, + dexs.token_bought_amount_raw / POWER(10, COALESCE(erc20a.decimals, erc4626a.decimals, 18)) * COALESCE(bpa_bpt_prices.bpt_price, erc4626a.price), + dexs.token_sold_amount_raw / POWER(10, COALESCE(erc20b.decimals, erc4626b.decimals, 18)) * COALESCE(bpb_bpt_prices.bpt_price, erc4626b.price) + ) AS amount_usd, + dexs.token_bought_address, + dexs.token_sold_address, + dexs.taker, + dexs.maker, + dexs.project_contract_address, + dexs.pool_id, + dexs.swap_fee, + dexs.pool_symbol, + dexs.pool_type, + dexs.tx_hash, + dexs.tx_from, + dexs.tx_to, + dexs.evt_index +FROM dexs + LEFT JOIN {{ source('tokens', 'erc20') }} erc20a + ON erc20a.contract_address = dexs.token_bought_address + AND erc20a.blockchain = dexs.blockchain + LEFT JOIN {{ source('tokens', 'erc20') }} erc20b + ON erc20b.contract_address = dexs.token_sold_address + AND erc20b.blockchain = dexs.blockchain + INNER JOIN bpa + ON bpa.block_number = dexs.block_number + AND bpa.tx_hash = dexs.tx_hash + AND bpa.evt_index = dexs.evt_index + LEFT JOIN {{ source('balancer', 'bpt_prices') }} bpa_bpt_prices + ON bpa_bpt_prices.contract_address = bpa.contract_address + AND bpa_bpt_prices.day = bpa.bpa_max_block_date + AND bpa_bpt_prices.blockchain = 'ethereum' + INNER JOIN bpb + ON bpb.block_number = dexs.block_number + AND bpb.tx_hash = dexs.tx_hash + AND bpb.evt_index = dexs.evt_index + LEFT JOIN {{ source('balancer', 'bpt_prices') }} bpb_bpt_prices + ON bpb_bpt_prices.contract_address = bpb.contract_address + AND bpb_bpt_prices.day = bpb.bpb_max_block_date + AND bpb_bpt_prices.blockchain = 'ethereum' + LEFT JOIN erc4626_prices erc4626a + ON erc4626a.wrapped_token = dexs.token_bought_address + AND erc4626a.minute <= dexs.block_time + AND dexs.block_time < erc4626a.time_of_next_change + LEFT JOIN erc4626_prices erc4626b + ON erc4626b.wrapped_token = dexs.token_sold_address + AND erc4626b.minute <= dexs.block_time + AND dexs.block_time < erc4626b.time_of_next_change \ No newline at end of file diff --git a/dbt_subprojects/dex/models/_projects/balancer/trades/gnosis/_schema.yml b/dbt_subprojects/dex/models/_projects/balancer/trades/gnosis/_schema.yml index 7da8f746429..2ba4aa24f59 100644 --- a/dbt_subprojects/dex/models/_projects/balancer/trades/gnosis/_schema.yml +++ b/dbt_subprojects/dex/models/_projects/balancer/trades/gnosis/_schema.yml @@ -142,4 +142,43 @@ models: - *tx_hash - *tx_from - *tx_to - - *evt_index \ No newline at end of file + - *evt_index + + - name: balancer_v3_gnosis_trades + meta: + blockchain: gnosis + sector: dex + contributors: viniabussafi + config: + tags: [ 'balancer', 'gnosis', 'amm', 'trades', 'dex', 'beta' ] + description: > + DEX trades on balancer v3 on gnosis + columns: + - *blockchain + - *project + - *version + - *block_month + - *block_date + - *block_time + - *block_number + - *token_bought_symbol + - *token_sold_symbol + - *token_pair + - *token_bought_amount + - *token_sold_amount + - *token_bought_amount_raw + - *token_sold_amount_raw + - *amount_usd + - *token_bought_address + - *token_sold_address + - *taker + - *maker + - *project_contract_address + - *pool_symbol + - *pool_type + - *pool_id + - *swap_fee + - *tx_hash + - *tx_from + - *tx_to + - *evt_index \ No newline at end of file diff --git a/dbt_subprojects/dex/models/_projects/balancer/trades/gnosis/balancer_gnosis_trades.sql b/dbt_subprojects/dex/models/_projects/balancer/trades/gnosis/balancer_gnosis_trades.sql index abc1b89aa99..4b8d2711d4d 100644 --- a/dbt_subprojects/dex/models/_projects/balancer/trades/gnosis/balancer_gnosis_trades.sql +++ b/dbt_subprojects/dex/models/_projects/balancer/trades/gnosis/balancer_gnosis_trades.sql @@ -7,7 +7,8 @@ {% set balancer_models = [ ref('balancer_v2_gnosis_trades'), - ref('balancer_cowswap_amm_gnosis_trades') + ref('balancer_cowswap_amm_gnosis_trades'), + ref('balancer_v3_gnosis_trades') ] %} SELECT * diff --git a/dbt_subprojects/dex/models/_projects/balancer/trades/gnosis/balancer_v3_gnosis_trades.sql b/dbt_subprojects/dex/models/_projects/balancer/trades/gnosis/balancer_v3_gnosis_trades.sql new file mode 100644 index 00000000000..7aea4bcc382 --- /dev/null +++ b/dbt_subprojects/dex/models/_projects/balancer/trades/gnosis/balancer_v3_gnosis_trades.sql @@ -0,0 +1,171 @@ +{{ + config( + schema = 'balancer_v3_gnosis', + alias = 'trades', + materialized = 'view', + post_hook = '{{ expose_spells(\'["gnosis"]\', + spell_type = "project", + spell_name = "balancer", + contributors = \'["viniabussafi"]\') }}' + ) +}} + +WITH + dexs_base AS ( + SELECT + tx_hash, + evt_index, + pool_id, + swap_fee, + pool_symbol, + pool_type + FROM {{ ref('balancer_v3_gnosis_base_trades') }} + ), + + dexs AS ( + SELECT + dexs.blockchain, + dexs.project, + dexs.version, + dexs.block_month, + dexs.block_date, + dexs.block_time, + dexs.block_number, + dexs.token_bought_symbol, + dexs.token_sold_symbol, + dexs.token_pair, + dexs.token_bought_amount, + dexs.token_sold_amount, + dexs.token_bought_amount_raw, + dexs.token_sold_amount_raw, + dexs.amount_usd, + dexs.token_bought_address, + dexs.token_sold_address, + dexs.taker, + dexs.maker, + dexs.project_contract_address, + dexs.tx_hash, + dexs.tx_from, + dexs.tx_to, + dexs.evt_index, + dexs_base.pool_id, + dexs_base.swap_fee, + dexs_base.pool_symbol, + dexs_base.pool_type + FROM {{ ref('dex_trades') }} dexs + INNER JOIN dexs_base + ON dexs.tx_hash = dexs_base.tx_hash + AND dexs.evt_index = dexs_base.evt_index + WHERE dexs.blockchain = 'gnosis' + AND dexs.project = 'balancer' + AND dexs.version = '3' + ), + + bpa AS ( + SELECT + dexs.block_number, + dexs.tx_hash, + dexs.evt_index, + bpt_prices.contract_address, + dexs.block_time, + MAX(bpt_prices.day) AS bpa_max_block_date + FROM dexs + LEFT JOIN {{ source('balancer', 'bpt_prices') }} bpt_prices + ON bpt_prices.contract_address = dexs.token_bought_address + AND bpt_prices.day <= DATE_TRUNC('day', dexs.block_time) + AND bpt_prices.blockchain = 'gnosis' + GROUP BY 1, 2, 3, 4, 5 + ), + + bpb AS ( + SELECT + dexs.block_number, + dexs.tx_hash, + dexs.evt_index, + bpt_prices.contract_address, + dexs.block_time, + MAX(bpt_prices.day) AS bpb_max_block_date + FROM dexs + LEFT JOIN {{ source('balancer', 'bpt_prices') }} bpt_prices + ON bpt_prices.contract_address = dexs.token_sold_address + AND bpt_prices.day <= DATE_TRUNC('day', dexs.block_time) + AND bpt_prices.blockchain = 'gnosis' + GROUP BY 1, 2, 3, 4, 5 + ), + + erc4626_prices AS( + SELECT + minute, + wrapped_token, + decimals, + APPROX_PERCENTILE(median_price, 0.5) AS price, + LEAD(minute, 1, NOW()) OVER (PARTITION BY wrapped_token ORDER BY minute) AS time_of_next_change + FROM {{ source('balancer_v3', 'erc4626_token_prices') }} + WHERE blockchain = 'gnosis' + GROUP BY 1, 2, 3 + ) + +SELECT + dexs.blockchain, + dexs.project, + dexs.version, + dexs.block_date, + dexs.block_number, + dexs.block_month, + dexs.block_time, + dexs.token_bought_symbol, + dexs.token_sold_symbol, + dexs.token_pair, + dexs.token_bought_amount, + dexs.token_sold_amount, + dexs.token_bought_amount_raw, + dexs.token_sold_amount_raw, + COALESCE( + dexs.amount_usd, + dexs.token_bought_amount_raw / POWER(10, COALESCE(erc20a.decimals, erc4626a.decimals, 18)) * COALESCE(bpa_bpt_prices.bpt_price, erc4626a.price), + dexs.token_sold_amount_raw / POWER(10, COALESCE(erc20b.decimals, erc4626b.decimals, 18)) * COALESCE(bpb_bpt_prices.bpt_price, erc4626b.price) + ) AS amount_usd, + dexs.token_bought_address, + dexs.token_sold_address, + dexs.taker, + dexs.maker, + dexs.project_contract_address, + dexs.pool_id, + dexs.swap_fee, + dexs.pool_symbol, + dexs.pool_type, + dexs.tx_hash, + dexs.tx_from, + dexs.tx_to, + dexs.evt_index +FROM dexs + LEFT JOIN {{ source('tokens', 'erc20') }} erc20a + ON erc20a.contract_address = dexs.token_bought_address + AND erc20a.blockchain = dexs.blockchain + LEFT JOIN {{ source('tokens', 'erc20') }} erc20b + ON erc20b.contract_address = dexs.token_sold_address + AND erc20b.blockchain = dexs.blockchain + INNER JOIN bpa + ON bpa.block_number = dexs.block_number + AND bpa.tx_hash = dexs.tx_hash + AND bpa.evt_index = dexs.evt_index + LEFT JOIN {{ source('balancer', 'bpt_prices') }} bpa_bpt_prices + ON bpa_bpt_prices.contract_address = bpa.contract_address + AND bpa_bpt_prices.day = bpa.bpa_max_block_date + AND bpa_bpt_prices.blockchain = 'gnosis' + INNER JOIN bpb + ON bpb.block_number = dexs.block_number + AND bpb.tx_hash = dexs.tx_hash + AND bpb.evt_index = dexs.evt_index + LEFT JOIN {{ source('balancer', 'bpt_prices') }} bpb_bpt_prices + ON bpb_bpt_prices.contract_address = bpb.contract_address + AND bpb_bpt_prices.day = bpb.bpb_max_block_date + AND bpb_bpt_prices.blockchain = 'gnosis' + LEFT JOIN erc4626_prices erc4626a + ON erc4626a.wrapped_token = dexs.token_bought_address + AND erc4626a.minute <= dexs.block_time + AND dexs.block_time < erc4626a.time_of_next_change + LEFT JOIN erc4626_prices erc4626b + ON erc4626b.wrapped_token = dexs.token_sold_address + AND erc4626b.minute <= dexs.block_time + AND dexs.block_time < erc4626b.time_of_next_change \ No newline at end of file diff --git a/dbt_subprojects/dex/models/_projects/balancer_cowswap_amm/_schema.yml b/dbt_subprojects/dex/models/_projects/balancer_cowswap_amm/_schema.yml index 00c2c437fdd..cb5cf106587 100644 --- a/dbt_subprojects/dex/models/_projects/balancer_cowswap_amm/_schema.yml +++ b/dbt_subprojects/dex/models/_projects/balancer_cowswap_amm/_schema.yml @@ -3,12 +3,12 @@ version: 2 models: - name: balancer_cowswap_amm_trades meta: - blockchain: arbitrum, ethereum, gnosis + blockchain: arbitrum, base, ethereum, gnosis sector: trades project: balancer_cowswap_amm contributors: viniabussafi config: - tags: ['balancer', 'cowswap', 'ethereum', 'gnosis', 'amm', 'trades'] + tags: ['balancer', 'cowswap', 'arbitrum', 'base', 'ethereum', 'gnosis', 'amm', 'trades'] description: "Trades on Balancer CoWSwap AMM pools" columns: - &blockchain @@ -89,12 +89,12 @@ models: - name: labels_balancer_cowswap_amm_pools meta: - blockchain: arbitrum, ethereum, gnosis + blockchain: arbitrum, base, ethereum, gnosis sector: labels project: balancer_cowswap_amm contributors: viniabussafi config: - tags: ['labels', 'ethereum', 'gnosis', 'balancer', 'pools'] + tags: ['labels', 'arbitrum', 'base', 'ethereum', 'gnosis', 'balancer', 'pools'] description: "Balancer CoWSwap AMM liquidity pools created on Ethereum." columns: - *blockchain diff --git a/dbt_subprojects/dex/models/_projects/balancer_cowswap_amm/balancer_cowswap_amm_trades.sql b/dbt_subprojects/dex/models/_projects/balancer_cowswap_amm/balancer_cowswap_amm_trades.sql index 4f0799af9a2..9a40561f718 100644 --- a/dbt_subprojects/dex/models/_projects/balancer_cowswap_amm/balancer_cowswap_amm_trades.sql +++ b/dbt_subprojects/dex/models/_projects/balancer_cowswap_amm/balancer_cowswap_amm_trades.sql @@ -8,6 +8,7 @@ {% set b_cow_amm_models = [ ref('balancer_cowswap_amm_arbitrum_trades'), + ref('balancer_cowswap_amm_base_trades'), ref('balancer_cowswap_amm_ethereum_trades'), ref('balancer_cowswap_amm_gnosis_trades') ] %} diff --git a/dbt_subprojects/dex/models/_projects/balancer_cowswap_amm/base/_schema.yml b/dbt_subprojects/dex/models/_projects/balancer_cowswap_amm/base/_schema.yml new file mode 100644 index 00000000000..9bab1c37503 --- /dev/null +++ b/dbt_subprojects/dex/models/_projects/balancer_cowswap_amm/base/_schema.yml @@ -0,0 +1,137 @@ +version: 2 + +models: + - name: balancer_cowswap_amm_base_trades + meta: + blockchain: base + sector: trades + project: balancer_cowswap_amm + contributors: viniabussafi + config: + tags: ['balancer', 'cowswap', 'base', 'amm', 'trades'] + description: "Trades on Balancer CoWSwap AMM pools" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - evt_index + columns: + - &blockchain + name: blockchain + description: "Blockchain" + - &project + name: project + description: "Project name (balancer)" + - &version + name: version + description: "Version of the project" + - &block_month + name: block_month + description: "Block month in UTC" + - &block_date + name: block_date + description: "Block date in UTC" + - &block_time + name: block_time + description: 'Block time in UTC' + - &block_number + name: block_number + description: 'Block number' + - &token_bought_symbol + name: token_bought_symbol + description: "Token symbol for token bought in the trade" + - &token_sold_symbol + name: token_sold_symbol + description: "Token symbol for token sold in the trade" + - &token_pair + name: token_pair + description: "Token symbol pair for each token involved in the trade" + - &token_bought_amount + name: token_bought_amount + description: "Value of the token bought at time of execution in the original currency" + - &token_sold_amount + name: token_sold_amount + description: "Value of the token sold at time of execution in the original currency" + - &token_bought_amount_raw + name: token_bought_amount_raw + description: "Raw value of the token bought at time of execution in the original currency" + - &token_sold_amount_raw + name: token_sold_amount_raw + description: "Raw value of the token sold at time of execution in the original currency" + - &amount_usd + name: amount_usd + description: "USD value of the trade at time of execution" + - &token_bought_address + name: token_bought_address + description: "Contract address of the token bought" + - &token_sold_address + name: token_sold_address + description: "Contract address of the token sold" + - &taker + name: taker + description: "Address of trader who purchased a token" + - &maker + name: maker + description: "Address of trader who sold a token" + - &project_contract_address + name: project_contract_address + description: "Pool address" + - &tx_hash + name: tx_hash + description: "Tx. Hash" + - &tx_from + name: tx_from + description: "transaction.from" + - &tx_to + name: tx_to + description: "transaction.to" + - &evt_index + name: evt_index + description: 'Event index' + - name: pool_type + - name: pool_symbol + - name: swap_fee + + - name: labels_balancer_cowswap_amm_pools_base + meta: + blockchain: base + sector: labels + project: balancer_cowswap_amm + contributors: viniabussafi + config: + tags: ['labels', 'base', 'balancer', 'pools'] + description: "Balancer CoWSwap AMM liquidity pools created on base." + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - address + columns: + - *blockchain + - &address + name: address + description: "Address of liquidity pool" + - &name + name: name + description: "Label name of pool containing the token symbols and their respective weights (if applicable)" + - name: pool_type + - &category + name: category + description: "Label category" + - &contributor + name: contributor + description: "Wizard(s) contributing to labels" + - &source + name: source + description: "How were labels generated (could be static or query)" + - &created_at + name: created_at + description: "When were labels created" + - &updated_at + name: updated_at + description: "When were labels updated for the last time" + - &model_name + name: model_name + description: "Name of the label model sourced from" + - &label_type + name: label_type + description: "Type of label (see labels overall readme)" \ No newline at end of file diff --git a/dbt_subprojects/dex/models/_projects/balancer_cowswap_amm/base/balancer_cowswap_amm_base_trades.sql b/dbt_subprojects/dex/models/_projects/balancer_cowswap_amm/base/balancer_cowswap_amm_base_trades.sql new file mode 100644 index 00000000000..91789f13833 --- /dev/null +++ b/dbt_subprojects/dex/models/_projects/balancer_cowswap_amm/base/balancer_cowswap_amm_base_trades.sql @@ -0,0 +1,74 @@ +{% set blockchain = 'base' %} + +{{ + config( + schema = 'balancer_cowswap_amm_' + blockchain, + alias = 'trades', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], + unique_key = ['tx_hash', 'evt_index'] + ) +}} + + SELECT + '{{blockchain}}' AS blockchain + , 'balancer' AS project + , '1' AS version + , CAST(date_trunc('month', trade.evt_block_time) AS DATE) AS block_month + , CAST(date_trunc('day', trade.evt_block_time) AS DATE) AS block_date + , trade.evt_block_time AS block_time + , trade.evt_block_number block_number + , tb.symbol AS token_bought_symbol + , ts.symbol AS token_sold_symbol + , CONCAT(ts.symbol, '-', tb.symbol) AS token_pair + , (trade.buyAmount / POWER(10, COALESCE(pb.decimals, tb.decimals))) AS token_bought_amount + , ((trade.sellAmount - trade.feeAmount) / POWER(10, COALESCE(ps.decimals, ts.decimals))) AS token_sold_amount + , trade.buyAmount AS token_bought_amount_raw + , trade.sellAmount AS token_sold_amount_raw + , COALESCE(trade.buyAmount / POWER(10, COALESCE(pb.decimals, tb.decimals)) * pb.price, + trade.sellAmount / POWER(10, COALESCE(ps.decimals, ts.decimals)) * ps.price) + AS amount_usd + ,trade.buyToken AS token_bought_address + ,trade.sellToken AS token_sold_address + ,CAST(NULL AS VARBINARY) AS taker + ,CAST(NULL AS VARBINARY) AS maker + , pool.bPool AS pool_id + , pool.bPool AS project_contract_address + , trade.evt_tx_hash AS tx_hash + , settlement.solver AS tx_from + , trade.contract_address AS tx_to + , trade.evt_index AS evt_index + , p.name AS pool_symbol + , p.pool_type + , (trade.feeAmount / POWER (10, ts.decimals)) AS swap_fee + FROM {{ source('gnosis_protocol_v2_base', 'GPv2Settlement_evt_Trade') }} trade + INNER JOIN {{ source('b_cow_amm_base', 'BCoWFactory_evt_LOG_NEW_POOL') }} pool + ON trade.owner = pool.bPool + LEFT JOIN {{ source('prices', 'usd') }} AS ps + ON sellToken = ps.contract_address + AND ps.minute = date_trunc('minute', trade.evt_block_time) + AND ps.blockchain = '{{blockchain}}' + {% if is_incremental() %} + AND {{ incremental_predicate('ps.minute') }} + {% endif %} + LEFT JOIN {{ source('prices', 'usd') }} AS pb + ON pb.contract_address = buyToken + AND pb.minute = date_trunc('minute', trade.evt_block_time) + AND pb.blockchain = '{{blockchain}}' + {% if is_incremental() %} + AND {{ incremental_predicate('pb.minute') }} + {% endif %} + LEFT JOIN {{ source('tokens', 'erc20') }} AS ts + ON trade.sellToken = ts.contract_address + AND ts.blockchain = '{{blockchain}}' + LEFT JOIN {{ source('tokens', 'erc20') }} AS tb + ON trade.buyToken = tb.contract_address + AND tb.blockchain = '{{blockchain}}' + LEFT JOIN {{ source('gnosis_protocol_v2_base', 'GPv2Settlement_evt_Settlement') }} AS settlement + ON trade.evt_tx_hash = settlement.evt_tx_hash + LEFT JOIN {{ ref('labels_balancer_cowswap_amm_pools_base') }} p ON p.address = trade.owner + {% if is_incremental() %} + WHERE {{ incremental_predicate('trade.evt_block_time') }} + {% endif %} diff --git a/dbt_subprojects/dex/models/_projects/balancer_cowswap_amm/base/labels_balancer_cowswap_amm_pools_base.sql b/dbt_subprojects/dex/models/_projects/balancer_cowswap_amm/base/labels_balancer_cowswap_amm_pools_base.sql new file mode 100644 index 00000000000..61c2076dac4 --- /dev/null +++ b/dbt_subprojects/dex/models/_projects/balancer_cowswap_amm/base/labels_balancer_cowswap_amm_pools_base.sql @@ -0,0 +1,70 @@ +{% set blockchain = 'base' %} + +{{config( + schema = 'labels', + alias = 'balancer_cowswap_amm_pools_' + blockchain, + materialized = 'table', + file_format = 'delta' + ) +}} + +WITH events AS ( + -- binds + SELECT call_block_number AS block_number, + contract_address AS pool, + token, + denorm + FROM {{ source('b_cow_amm_base', 'BCoWPool_call_bind') }} + WHERE call_success + + UNION all + + -- unbinds + SELECT call_block_number AS block_number, + contract_address AS pool, + token, + uint256 '0' AS denorm + FROM {{ source('b_cow_amm_base', 'BCoWPool_call_unbind') }} + WHERE call_success +), + +state_with_gaps AS ( + SELECT events.block_number + , events.pool + , events.token + , CAST(events.denorm AS uint256) AS denorm, + LEAD(events.block_number, 1, 99999999) OVER (PARTITION BY events.pool, events.token ORDER BY events.block_number) AS next_block_number + FROM events +), + +settings AS ( + SELECT pool, + coalesce(t.symbol,'?') AS symbol, + denorm, + next_block_number + FROM state_with_gaps s + LEFT JOIN {{ source('tokens', 'erc20') }} t ON s.token = t.contract_address + AND t.blockchain = '{{blockchain}}' + WHERE next_block_number = 99999999 + AND denorm > uint256 '0' +) + + SELECT + '{{blockchain}}' AS blockchain, + pool AS address, + CONCAT('BCowAMM: ', array_join(array_agg(symbol), '/'), ' ', array_join(array_agg(cast(norm_weight AS varchar)), '/')) AS name, + 'Balancer CoWSwap AMM' AS pool_type, + 'balancer_cowswap_amm_pool' AS category, + 'balancerlabs' AS contributor, + 'query' AS source, + timestamp '2024-07-20' AS created_at, + now() AS updated_at, + 'balancer_cowswap_amm_pools_base' AS model_name, + 'identifier' as label_type + FROM ( + SELECT s1.pool, symbol, cast(100*denorm/total_denorm AS integer) AS norm_weight FROM settings s1 + INNER JOIN (SELECT pool, sum(denorm) AS total_denorm FROM settings GROUP BY pool) s2 + ON s1.pool = s2.pool + ORDER BY 1 ASC , 3 DESC, 2 ASC + ) s + GROUP BY 1, 2 \ No newline at end of file diff --git a/dbt_subprojects/dex/models/_projects/balancer_cowswap_amm/labels_balancer_cowswap_amm_pools.sql b/dbt_subprojects/dex/models/_projects/balancer_cowswap_amm/labels_balancer_cowswap_amm_pools.sql index c4032bb58a7..35dfe348fb2 100644 --- a/dbt_subprojects/dex/models/_projects/balancer_cowswap_amm/labels_balancer_cowswap_amm_pools.sql +++ b/dbt_subprojects/dex/models/_projects/balancer_cowswap_amm/labels_balancer_cowswap_amm_pools.sql @@ -7,6 +7,7 @@ {% set b_cow_amm_models = [ ref('labels_balancer_cowswap_amm_pools_arbitrum'), + ref('labels_balancer_cowswap_amm_pools_base'), ref('labels_balancer_cowswap_amm_pools_ethereum'), ref('labels_balancer_cowswap_amm_pools_gnosis') ] %} diff --git a/dbt_subprojects/dex/models/_projects/cow_protocol/_schema.yml b/dbt_subprojects/dex/models/_projects/cow_protocol/_schema.yml index 958a9d028d5..9e0e203f3ef 100644 --- a/dbt_subprojects/dex/models/_projects/cow_protocol/_schema.yml +++ b/dbt_subprojects/dex/models/_projects/cow_protocol/_schema.yml @@ -8,18 +8,26 @@ models: project: cow_protocol contributors: bh2smith, gentrexha config: - tags: ['ethereum','cow_protocol','trades','dex','aggregator','cross-chain'] + tags: + [ + "ethereum", + "cow_protocol", + "trades", + "dex", + "aggregator", + "cross-chain", + ] description: > - CoW Protocol trades on all chains across all contracts and versions. - This table will load dex trades downstream. - This particular version of the protocol trades table is intended to conform - with the columns as specified in dex.trades sector. - A more detailed version of the protocol trades table can be found under `cow_protocol_ethereum.trades` + CoW Protocol trades on all chains across all contracts and versions. + This table will load dex trades downstream. + This particular version of the protocol trades table is intended to conform + with the columns as specified in dex.trades sector. + A more detailed version of the protocol trades table can be found under `cow_protocol_ethereum.trades` columns: - &blockchain name: blockchain description: "Blockchain which the project is deployed" - - &project + - &project name: project description: "Project name" - &version @@ -92,7 +100,7 @@ models: project: cow_protocol contributors: olgafetisova config: - tags: ['arbitrum','cow_protocol','trades', 'dex', 'aggregator'] + tags: ["arbitrum", "cow_protocol", "trades", "dex", "aggregator"] description: > CoW Protocol enriched trades list on Arbitrum Chain data_tests: @@ -169,7 +177,7 @@ models: project: cow_protocol contributors: bh2smith, gentrexha config: - tags: ['ethereum','cow_protocol','trades', 'dex', 'aggregator'] + tags: ["ethereum", "cow_protocol", "trades", "dex", "aggregator"] description: > CoW Protocol enriched trades list on Ethereum data_tests: @@ -253,7 +261,7 @@ models: project: cow_protocol contributors: bh2smith config: - tags: ['gnosis','cow_protocol','trades', 'dex', 'aggregator'] + tags: ["gnosis", "cow_protocol", "trades", "dex", "aggregator"] description: > CoW Protocol enriched trades list on Gnosis Chain data_tests: @@ -322,4 +330,81 @@ models: - name: flags description: "bitmap with additional trade information (cf. https://github.com/cowprotocol/contracts/blob/main/src/contracts/libraries/GPv2Trade.sol#L58-L94)" - name: surplus_usd - description: "USD value of surplus (difference between limit and executed price)" \ No newline at end of file + description: "USD value of surplus (difference between limit and executed price)" + + - name: cow_protocol_base_trades + meta: + blockchain: base + project: cow_protocol + contributors: felix + config: + tags: ["base", "cow_protocol", "trades", "dex", "aggregator"] + description: > + CoW Protocol enriched trades list on Base + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - order_uid + - evt_index + columns: + - name: block_date + description: "UTC event block date of each trade" + - name: block_time + description: "Timestamp for block event time in UTC" + - name: tx_hash + description: "Transaction hash of trade" + - name: evt_index + description: "Index of the corresponding trade event" + - name: order_uid + description: "Unique identifier of order involved in trade. Note that partially fillable orders can be touched multiple times so this is not a unique ID for trade events." + - name: trader + description: "Owner of the order being traded (aka trader)" + - name: sell_token_address + description: "Ethereum address of sellToken" + - name: sell_token + description: "Symbol of sellToken" + - name: buy_token_address + description: "Ethereum address of buyToken" + - name: buy_token + description: "Symbol of buyToken" + - name: token_pair + description: "Ordered concatenation of buy/sell token symbols involved in trade" + - name: units_sold + description: "Units of sellToken sold (incorporates token decimals)." + - name: atoms_sold + description: "Amount (in atoms) of the sellToken sold" + - name: units_bought + description: "Units of buyToken bought (incorporates token decimals)." + - name: atoms_bought + description: "Amount (in atoms) of the buyToken bought" + - name: usd_value + description: "USD value of trade (taken as the max of buy value, sell value when both available, otherwise whichever is known)" + - name: buy_price + description: "USD price of buyToken at the time of trade" + - name: buy_value_usd + description: "USD value of buyToken amount" + - name: sell_price + description: "USD price of sellToken at the time of trade" + - name: sell_value_usd + description: "USD value of sellToken amount" + - name: fee + description: "Unit of fee taken (in sellToken) - incorporating token decimals" + - name: fee_atoms + description: "Amount (in atoms) of fee - taken in sellToken" + - name: fee_usd + description: "USD value of trade fee" + - name: app_data + description: "Hashed metadata related to trade event (full content available on IPFS)" + - name: receiver + description: "Recipient of trades buyToken" + - name: limit_sell_amount + description: "Sell amount side of the limit price" + - name: limit_buy_amount + description: "Buy amount side of the limit price" + - name: valid_to + description: "epoch timestamp (in seconds) until when the order was valid" + - name: flags + description: "bitmap with additional trade information (cf. https://github.com/cowprotocol/contracts/blob/main/src/contracts/libraries/GPv2Trade.sol#L58-L94)" + - name: surplus_usd + description: "USD value of surplus (difference between limit and executed price)" diff --git a/dbt_subprojects/dex/models/_projects/cow_protocol/arbitrum/cow_protocol_arbitrum_trades.sql b/dbt_subprojects/dex/models/_projects/cow_protocol/arbitrum/cow_protocol_arbitrum_trades.sql index f8d70b4fbd5..71743c9ac54 100644 --- a/dbt_subprojects/dex/models/_projects/cow_protocol/arbitrum/cow_protocol_arbitrum_trades.sql +++ b/dbt_subprojects/dex/models/_projects/cow_protocol/arbitrum/cow_protocol_arbitrum_trades.sql @@ -1,17 +1,17 @@ {{ config( - schema = 'cow_protocol_arbitrum', - alias='trades', - materialized='incremental', - partition_by = ['block_month'], - unique_key = ['tx_hash', 'order_uid', 'evt_index'], - on_schema_change='sync_all_columns', - file_format ='delta', - incremental_strategy='merge', - incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], - post_hook='{{ expose_spells(\'["arbitrum"]\', - "project", - "cow_protocol", - \'["olgafetisova"]\') }}' + schema='cow_protocol_arbitrum', + alias='trades', + materialized='incremental', + partition_by = ['block_month'], + unique_key = ['tx_hash', 'order_uid', 'evt_index'], + on_schema_change='sync_all_columns', + file_format ='delta', + incremental_strategy='merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], + post_hook='{{ expose_spells(\'["arbitrum"]\', + "project", + "cow_protocol", + \'["olgafetisova"]\') }}' ) }} @@ -26,17 +26,17 @@ trades_with_prices AS ( evt_block_number as block_number, evt_tx_hash as tx_hash, evt_index, - settlement.contract_address as project_contract_address, + trade.contract_address as project_contract_address, owner as trader, orderUid as order_uid, sellToken as sell_token, buyToken as buy_token, - (sellAmount - feeAmount) as sell_amount, + sellAmount - feeAmount as sell_amount, buyAmount as buy_amount, feeAmount as fee_amount, ps.price as sell_price, pb.price as buy_price - FROM {{ source('gnosis_protocol_v2_arbitrum', 'GPv2Settlement_evt_Trade') }} settlement + FROM {{ source('gnosis_protocol_v2_arbitrum', 'GPv2Settlement_evt_Trade') }} trade LEFT OUTER JOIN {{ source('prices', 'usd') }} as ps ON sellToken = ps.contract_address AND ps.minute = date_trunc('minute', evt_block_time) @@ -45,7 +45,12 @@ trades_with_prices AS ( AND {{ incremental_predicate('ps.minute') }} {% endif %} LEFT OUTER JOIN {{ source('prices', 'usd') }} as pb - ON pb.contract_address = buyToken + ON pb.contract_address = ( + CASE + WHEN buyToken = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + THEN 0x82af49447d8a07e3bd95bd0d56f35241523fbab1 + ELSE buyToken + END) AND pb.minute = date_trunc('minute', evt_block_time) AND pb.blockchain = 'arbitrum' {% if is_incremental() %} @@ -73,7 +78,8 @@ trades_with_token_units as ( END) as sell_token, buy_token as buy_token_address, (CASE - WHEN tb.symbol IS NULL THEN cast(buy_token AS varchar) + WHEN tb.symbol IS NULL THEN cast(buy_token as varchar) + WHEN buy_token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee THEN 'ETH' ELSE tb.symbol END) as buy_token, sell_amount / pow(10, ts.decimals) as units_sold, @@ -89,7 +95,12 @@ trades_with_token_units as ( LEFT OUTER JOIN {{ source('tokens', 'erc20') }} ts ON ts.blockchain='arbitrum' AND ts.contract_address = sell_token LEFT OUTER JOIN {{ source('tokens', 'erc20') }} tb - ON tb.blockchain='arbitrum' AND tb.contract_address = buy_token + ON tb.blockchain='arbitrum' AND tb.contract_address = + (CASE + WHEN buy_token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + THEN 0x82af49447d8a07e3bd95bd0d56f35241523fbab1 + ELSE buy_token + END) ), sorted_orders as ( select @@ -146,6 +157,25 @@ uid_to_app_id as ( i = j ), +eth_flow_senders as ( + select + sender, + bytearray_concat( + bytearray_concat( + output_orderHash, + bytearray_substring(event.contract_address, 1, 20) + ), + 0xffffffff + ) AS order_uid + from {{ source('cow_protocol_arbitrum', 'CoWSwapEthFlow_evt_OrderPlacement') }} event + inner join {{ source('cow_protocol_arbitrum', 'CoWSwapEthFlow_call_createOrder') }} call + on call_block_number = evt_block_number + and call_tx_hash = evt_tx_hash + {% if is_incremental() %} + where {{ incremental_predicate('evt_block_time') }} + {% endif %} +), + valued_trades as ( SELECT block_date, block_month, @@ -156,9 +186,10 @@ valued_trades as ( ARRAY[-1] as trace_address, project_contract_address, trades.order_uid, - trader, + -- ETH Flow orders have trader = sender of orderCreation. + case when sender is not null then sender else trader end as trader, sell_token_address, - sell_token, + case when sender is not null then 'ETH' else sell_token end as sell_token, buy_token_address, buy_token, case @@ -216,11 +247,12 @@ valued_trades as ( JOIN uid_to_app_id ON uid = trades.order_uid AND hash=tx_hash + LEFT OUTER JOIN eth_flow_senders efs + ON trades.order_uid = efs.order_uid ) -select - *, - -- Relative surplus (in %) is the difference between limit price and executed price as a ratio of the limit price. - -- Absolute surplus (in USD) is relative surplus multiplied with the value of the trade - usd_value * (atoms_bought * limit_sell_amount - atoms_sold * limit_buy_amount) / (atoms_bought * limit_sell_amount) as surplus_usd +select *, + -- Relative surplus (in %) is the difference between limit price and executed price as a ratio of the limit price. + -- Absolute surplus (in USD) is relative surplus multiplied with the value of the trade + usd_value * (atoms_bought * limit_sell_amount - atoms_sold * limit_buy_amount) / (atoms_bought * limit_sell_amount) as surplus_usd from valued_trades diff --git a/dbt_subprojects/dex/models/_projects/cow_protocol/base/cow_protocol_base_trades.sql b/dbt_subprojects/dex/models/_projects/cow_protocol/base/cow_protocol_base_trades.sql new file mode 100644 index 00000000000..449e1b0f3d5 --- /dev/null +++ b/dbt_subprojects/dex/models/_projects/cow_protocol/base/cow_protocol_base_trades.sql @@ -0,0 +1,257 @@ +{{ config( + schema='cow_protocol_base', + alias='trades', + materialized='incremental', + partition_by = ['block_month'], + unique_key = ['tx_hash', 'order_uid', 'evt_index'], + on_schema_change='sync_all_columns', + file_format ='delta', + incremental_strategy='merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], + post_hook='{{ expose_spells(\'["base"]\', + "project", + "cow_protocol", + \'["felix"]\') }}' + ) +}} + +WITH +-- First subquery joins buy and sell token prices from prices.usd. +-- Also deducts fee from sell amount. +trades_with_prices AS ( + SELECT cast(date_trunc('day', evt_block_time) as date) as block_date, + cast(date_trunc('month', evt_block_time) as date) as block_month, + evt_block_time as block_time, + evt_block_number as block_number, + evt_tx_hash as tx_hash, + evt_index, + trade.contract_address as project_contract_address, + owner as trader, + orderUid as order_uid, + sellToken as sell_token, + buyToken as buy_token, + sellAmount - feeAmount as sell_amount, + buyAmount as buy_amount, + feeAmount as fee_amount, + ps.price as sell_price, + pb.price as buy_price + FROM {{ source('gnosis_protocol_v2_base', 'GPv2Settlement_evt_Trade') }} trade + LEFT OUTER JOIN {{ source('prices', 'usd') }} as ps + ON sellToken = ps.contract_address + AND ps.minute = date_trunc('minute', evt_block_time) + AND ps.blockchain = 'base' + {% if is_incremental() %} + AND {{ incremental_predicate('ps.minute') }} + {% endif %} + LEFT OUTER JOIN {{ source('prices', 'usd') }} as pb + ON pb.contract_address = ( + CASE + WHEN buyToken = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + THEN 0x4200000000000000000000000000000000000006 + ELSE buyToken + END) + AND pb.minute = date_trunc('minute', evt_block_time) + AND pb.blockchain = 'base' + {% if is_incremental() %} + AND {{ incremental_predicate('pb.minute') }} + {% endif %} + {% if is_incremental() %} + WHERE {{ incremental_predicate('evt_block_time') }} + {% endif %} +), +-- Second subquery gets token symbol and decimals from tokens.erc20 (to display units bought and sold) +trades_with_token_units as ( + SELECT block_date, + block_month, + block_time, + block_number, + tx_hash, + evt_index, + project_contract_address, + order_uid, + trader, + sell_token as sell_token_address, + (CASE + WHEN ts.symbol IS NULL THEN cast(sell_token as varchar) + ELSE ts.symbol + END) as sell_token, + buy_token as buy_token_address, + (CASE + WHEN tb.symbol IS NULL THEN cast(buy_token as varchar) + WHEN buy_token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee THEN 'ETH' + ELSE tb.symbol + END) as buy_token, + sell_amount / pow(10, ts.decimals) as units_sold, + sell_amount as atoms_sold, + buy_amount / pow(10, tb.decimals) as units_bought, + buy_amount as atoms_bought, + -- We use sell value when possible and buy value when not + fee_amount / pow(10, ts.decimals) as fee, + fee_amount as fee_atoms, + sell_price, + buy_price + FROM trades_with_prices + LEFT OUTER JOIN {{ source('tokens', 'erc20') }} ts + ON ts.blockchain='base' AND ts.contract_address = sell_token + LEFT OUTER JOIN {{ source('tokens', 'erc20') }} tb + ON tb.blockchain='base' AND tb.contract_address = + (CASE + WHEN buy_token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + THEN 0x4200000000000000000000000000000000000006 + ELSE buy_token + END) +), +sorted_orders as ( + select + evt_tx_hash, + evt_block_number, + array_agg(orderUid order by evt_index) as order_ids + from ( + select + evt_tx_hash, + evt_index, + evt_block_number, + orderUid + from {{ source('gnosis_protocol_v2_base', 'GPv2Settlement_evt_Trade') }} + {% if is_incremental() %} + where {{ incremental_predicate('evt_block_time') }} + {% endif %} + ) + group by evt_tx_hash, evt_block_number +), + +orders_and_trades as ( + select + evt_tx_hash, + trades, + order_ids + from sorted_orders + inner join {{ source('gnosis_protocol_v2_base', 'GPv2Settlement_call_settle') }} + on evt_block_number = call_block_number + and evt_tx_hash = call_tx_hash +), + +uid_to_app_id as ( + SELECT + distinct uid, + evt_tx_hash as hash, + from_hex(JSON_EXTRACT_SCALAR(trade, '$.appData')) AS app_data, + from_hex(JSON_EXTRACT_SCALAR(trade, '$.receiver')) AS receiver, + cast(JSON_EXTRACT_SCALAR(trade, '$.sellAmount') as uint256) AS limit_sell_amount, + cast(JSON_EXTRACT_SCALAR(trade, '$.buyAmount') as uint256) AS limit_buy_amount, + date_format( + from_unixtime(cast(JSON_EXTRACT_SCALAR(trade, '$.validTo') as double)), + '%Y-%m-%d %T' + ) AS valid_to, + cast(JSON_EXTRACT_SCALAR(trade, '$.flags') as integer) AS flags + FROM + orders_and_trades + CROSS JOIN UNNEST (order_ids) + WITH + ORDINALITY AS o (uid, i) + CROSS JOIN UNNEST (trades) + WITH + ORDINALITY AS t (trade, j) + WHERE + i = j +), + +eth_flow_senders as ( + select + sender, + bytearray_concat( + bytearray_concat( + output_orderHash, + bytearray_substring(event.contract_address, 1, 20) + ), + 0xffffffff + ) AS order_uid + from {{ source('cow_protocol_base', 'CoWSwapEthFlow_evt_OrderPlacement') }} event + inner join {{ source('cow_protocol_base', 'CoWSwapEthFlow_call_createOrder') }} call + on call_block_number = evt_block_number + and call_tx_hash = evt_tx_hash + {% if is_incremental() %} + where {{ incremental_predicate('evt_block_time') }} + {% endif %} +), + +valued_trades as ( + SELECT block_date, + block_month, + block_time, + block_number, + tx_hash, + evt_index, + ARRAY[-1] as trace_address, + project_contract_address, + trades.order_uid, + -- ETH Flow orders have trader = sender of orderCreation. + case when sender is not null then sender else trader end as trader, + sell_token_address, + case when sender is not null then 'ETH' else sell_token end as sell_token, + buy_token_address, + buy_token, + case + when lower(buy_token) > lower(sell_token) then concat(sell_token, '-', buy_token) + else concat(buy_token, '-', sell_token) + end as token_pair, + units_sold, + atoms_sold, + units_bought, + atoms_bought, + (CASE + WHEN sell_price IS NOT NULL THEN + -- Choose the larger of two prices when both not null. + CASE + WHEN buy_price IS NOT NULL and buy_price * COALESCE(units_bought,0) > sell_price * COALESCE(units_sold,0) + then buy_price * units_bought + ELSE sell_price * units_sold + END + WHEN sell_price IS NULL AND buy_price IS NOT NULL THEN buy_price * units_bought + END) as usd_value, + buy_price, + buy_price * units_bought as buy_value_usd, + sell_price, + sell_price * units_sold as sell_value_usd, + fee, + fee_atoms, + (CASE + WHEN sell_price IS NOT NULL THEN + CASE + WHEN buy_price IS NOT NULL and buy_price * COALESCE(units_bought,0) > sell_price * COALESCE(units_sold,0) + then buy_price * units_bought * fee / units_sold + ELSE sell_price * fee + END + WHEN sell_price IS NULL AND buy_price IS NOT NULL + THEN buy_price * units_bought * fee / units_sold + END) as fee_usd, + app_data, + case + when receiver = 0x0000000000000000000000000000000000000000 + then trader + else receiver + end as receiver, + limit_sell_amount, + limit_buy_amount, + valid_to, + flags, + case when (flags % 2) = 0 then 'SELL' else 'BUY' end as order_type, + bitwise_and(flags, 2) != 0 as partial_fill, + (CASE + when (flags % 2) = 0 then atoms_sold / limit_sell_amount + else atoms_bought / limit_buy_amount + end + ) as fill_proportion + FROM trades_with_token_units trades + JOIN uid_to_app_id + ON uid = trades.order_uid + AND hash=tx_hash + LEFT OUTER JOIN eth_flow_senders efs + ON trades.order_uid = efs.order_uid +) + +select *, + -- Relative surplus (in %) is the difference between limit price and executed price as a ratio of the limit price. + -- Absolute surplus (in USD) is relative surplus multiplied with the value of the trade + usd_value * (atoms_bought * limit_sell_amount - atoms_sold * limit_buy_amount) / (atoms_bought * limit_sell_amount) as surplus_usd +from valued_trades diff --git a/dbt_subprojects/dex/models/_projects/cow_protocol/cow_protocol_trades.sql b/dbt_subprojects/dex/models/_projects/cow_protocol/cow_protocol_trades.sql index aa731eafcf3..1b76dbdc8f0 100644 --- a/dbt_subprojects/dex/models/_projects/cow_protocol/cow_protocol_trades.sql +++ b/dbt_subprojects/dex/models/_projects/cow_protocol/cow_protocol_trades.sql @@ -96,4 +96,34 @@ FROM trace_address, evt_index FROM {{ ref('cow_protocol_arbitrum_trades') }} + + UNION ALL + + + SELECT + 'base' AS blockchain, + 'cow_protocol' AS project, + '1' AS version, + block_date, + block_month, + block_time, + buy_token AS token_bought_symbol, + sell_token AS token_sold_symbol, + token_pair, + units_bought AS token_bought_amount, + units_sold AS token_sold_amount, + atoms_bought AS token_bought_amount_raw, + atoms_sold AS token_sold_amount_raw, + usd_value AS amount_usd, + buy_token_address AS token_bought_address, + sell_token_address AS token_sold_address, + trader AS taker, + CAST(NULL AS VARBINARY) AS maker, + project_contract_address, + tx_hash, + trader AS tx_from, + receiver AS tx_to, + trace_address, + evt_index + FROM {{ ref('cow_protocol_base_trades') }} ) diff --git a/dbt_subprojects/dex/models/_projects/cow_protocol/gnosis/cow_protocol_gnosis_trades.sql b/dbt_subprojects/dex/models/_projects/cow_protocol/gnosis/cow_protocol_gnosis_trades.sql index efc7923ced8..5155a6364d4 100644 --- a/dbt_subprojects/dex/models/_projects/cow_protocol/gnosis/cow_protocol_gnosis_trades.sql +++ b/dbt_subprojects/dex/models/_projects/cow_protocol/gnosis/cow_protocol_gnosis_trades.sql @@ -1,17 +1,17 @@ {{ config( - schema = 'cow_protocol_gnosis', - alias='trades', - materialized='incremental', - partition_by = ['block_month'], - unique_key = ['tx_hash', 'order_uid', 'evt_index'], - on_schema_change='sync_all_columns', - file_format ='delta', - incremental_strategy='merge', - incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], - post_hook='{{ expose_spells(\'["gnosis"]\', - "project", - "cow_protocol", - \'["bh2smith", "gentrexha", "olgafetisova"]\') }}' + schema='cow_protocol_gnosis', + alias='trades', + materialized='incremental', + partition_by = ['block_month'], + unique_key = ['tx_hash', 'order_uid', 'evt_index'], + on_schema_change='sync_all_columns', + file_format ='delta', + incremental_strategy='merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], + post_hook='{{ expose_spells(\'["gnosis"]\', + "project", + "cow_protocol", + \'["bh2smith", "gentrexha", "olgafetisova"]\') }}' ) }} @@ -26,17 +26,17 @@ trades_with_prices AS ( evt_block_number as block_number, evt_tx_hash as tx_hash, evt_index, - settlement.contract_address as project_contract_address, + trade.contract_address as project_contract_address, owner as trader, orderUid as order_uid, sellToken as sell_token, buyToken as buy_token, - (sellAmount - feeAmount) as sell_amount, + sellAmount - feeAmount as sell_amount, buyAmount as buy_amount, feeAmount as fee_amount, ps.price as sell_price, pb.price as buy_price - FROM {{ source('gnosis_protocol_v2_gnosis', 'GPv2Settlement_evt_Trade') }} settlement + FROM {{ source('gnosis_protocol_v2_gnosis', 'GPv2Settlement_evt_Trade') }} trade LEFT OUTER JOIN {{ source('prices', 'usd') }} as ps ON sellToken = ps.contract_address AND ps.minute = date_trunc('minute', evt_block_time) @@ -78,7 +78,7 @@ trades_with_token_units as ( END) as sell_token, buy_token as buy_token_address, (CASE - WHEN tb.symbol IS NULL THEN cast(buy_token AS varchar) + WHEN tb.symbol IS NULL THEN cast(buy_token as varchar) WHEN buy_token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee THEN 'xDAI' ELSE tb.symbol END) as buy_token, @@ -157,6 +157,25 @@ uid_to_app_id as ( i = j ), +eth_flow_senders as ( + select + sender, + bytearray_concat( + bytearray_concat( + output_orderHash, + bytearray_substring(event.contract_address, 1, 20) + ), + 0xffffffff + ) AS order_uid + from {{ source('cow_protocol_gnosis', 'CoWSwapEthFlow_evt_OrderPlacement') }} event + inner join {{ source('cow_protocol_gnosis', 'CoWSwapEthFlow_call_createOrder') }} call + on call_block_number = evt_block_number + and call_tx_hash = evt_tx_hash + {% if is_incremental() %} + where {{ incremental_predicate('evt_block_time') }} + {% endif %} +), + valued_trades as ( SELECT block_date, block_month, @@ -167,9 +186,10 @@ valued_trades as ( ARRAY[-1] as trace_address, project_contract_address, trades.order_uid, - trader, + -- ETH Flow orders have trader = sender of orderCreation. + case when sender is not null then sender else trader end as trader, sell_token_address, - sell_token, + case when sender is not null then 'xDAI' else sell_token end as sell_token, buy_token_address, buy_token, case @@ -227,11 +247,12 @@ valued_trades as ( JOIN uid_to_app_id ON uid = trades.order_uid AND hash=tx_hash + LEFT OUTER JOIN eth_flow_senders efs + ON trades.order_uid = efs.order_uid ) -select - *, - -- Relative surplus (in %) is the difference between limit price and executed price as a ratio of the limit price. - -- Absolute surplus (in USD) is relative surplus multiplied with the value of the trade - usd_value * (atoms_bought * limit_sell_amount - atoms_sold * limit_buy_amount) / (atoms_bought * limit_sell_amount) as surplus_usd +select *, + -- Relative surplus (in %) is the difference between limit price and executed price as a ratio of the limit price. + -- Absolute surplus (in USD) is relative surplus multiplied with the value of the trade + usd_value * (atoms_bought * limit_sell_amount - atoms_sold * limit_buy_amount) / (atoms_bought * limit_sell_amount) as surplus_usd from valued_trades diff --git a/dbt_subprojects/dex/models/_projects/fluid/ethereum/fluid_v1_ethereum_pools.sql b/dbt_subprojects/dex/models/_projects/fluid/ethereum/fluid_v1_ethereum_pools.sql new file mode 100644 index 00000000000..f716aad3990 --- /dev/null +++ b/dbt_subprojects/dex/models/_projects/fluid/ethereum/fluid_v1_ethereum_pools.sql @@ -0,0 +1,53 @@ +{{ + config( + schema = 'fluid_ethereum', + alias = 'pools', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['dex'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], + post_hook='{{ expose_spells(blockchains = \'["ethereum"]\', + spell_type = "project", + spell_name = "fluid", + contributors = \'["maybeYonas", "pyor_xyz"]\') }}' + ) +}} + +{% set weth_address = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' %} + +with +decoded_events as ( + select + block_time, + block_number, + index as evt_index, + tx_hash, + contract_address as factory, + substr(topic1, 13) as dex, + substr(topic2, 13) as supplyToken, + substr(topic3, 13) as borrowToken, + bytearray_to_uint256(data) as dexId + from {{ source('ethereum', 'logs')}} + where topic0 = 0x3fecd5f7aca6136a20a999e7d11ff5dcea4bd675cb125f93ccd7d53f98ec57e4 + -- DexT1Deployed -> sample tx: https://etherscan.io/tx/0xabf5c0e676e69de941c283400d7ac5f47b17a09d870f225b5240522f95da501c#eventlog + and block_number > 20776998 + {% if is_incremental() %} + and {{ incremental_predicate('block_time') }} + {% endif %} +) + +select + 'ethereum' as blockchain, + 'fluid' as project, + '1' as version, + block_time, + block_number, + evt_index, + tx_hash, + factory, + dex, + case supplyToken when 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee then {{weth_address}} else supplyToken end as supply_token, + case borrowToken when 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee then {{weth_address}} else borrowToken end as borrow_token, + dexId as dex_id +from decoded_events \ No newline at end of file diff --git a/dbt_subprojects/dex/models/_projects/fluid/ethereum/schema.yml b/dbt_subprojects/dex/models/_projects/fluid/ethereum/schema.yml new file mode 100644 index 00000000000..8a955decee1 --- /dev/null +++ b/dbt_subprojects/dex/models/_projects/fluid/ethereum/schema.yml @@ -0,0 +1,54 @@ +version: 2 + +models: + - name: fluid_v1_ethereum_pools + meta: + blockchain: ethereum + sector: dex + project: fluid + contributor: maybeYonas + config: + tags: ['ethereum', 'trades', 'fluid', 'dex'] + description: "fluid pools" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - dex + columns: + - &blockchain + name: blockchain + description: "blockchain where the pool is deployed" + - &project + name: project + description: "project name" + - &version + name: version + description: "project version" + - &block_time + name: block_time + description: "utc block timestamp when the pool is deployed" + - &block_number + name: block_number + description: "block number at which the pool is deployed" + - &evt_index + name: evt_index + description: "index of log emitted" + - &tx_hash + name: tx_hash + description: "hash of tx in which pool is deployed" + - &factory + name: factory + description: "factory contract deploying the pool" + - &dex + name: dex + description: "pool contract address" + - &supply_token + name: supply_token + description: "supply token" + - &borrow_token + name: borrow_token + description: "borrow token" + - &dex_id + name: dex_id + description: "nonce unique to factory and pool" + diff --git a/dbt_subprojects/dex/models/_projects/kyberswap/arbitrum/kyberswap_aggregator_arbitrum_trades.sql b/dbt_subprojects/dex/models/_projects/kyberswap/arbitrum/kyberswap_aggregator_arbitrum_trades.sql index 0a4948d3c33..26a4d5702b1 100644 --- a/dbt_subprojects/dex/models/_projects/kyberswap/arbitrum/kyberswap_aggregator_arbitrum_trades.sql +++ b/dbt_subprojects/dex/models/_projects/kyberswap/arbitrum/kyberswap_aggregator_arbitrum_trades.sql @@ -1,6 +1,6 @@ {{ config ( - + schema = 'kyberswap_aggregator_arbitrum', alias = 'trades', partition_by = ['block_month'], @@ -37,7 +37,8 @@ WITH meta_router AS FROM {{ source('kyber_arbitrum', 'MetaAggregationRouterV2_evt_Swapped') }} WHERE - dstToken != 0x7d3eedb40fbecd9fba383504e066fdf67382a835 --bug with MTK token + dstToken not in (0x7d3eedb40fbecd9fba383504e066fdf67382a835 --bug with MTK token + ,0x2C29c2Bbdcb8c5de36FA3dBe0e7797B5396B0E61) --bug with MyToken token {% if is_incremental() %} AND evt_block_time >= date_trunc('day', now() - INTERVAL '7' DAY) {% endif %} diff --git a/dbt_subprojects/dex/models/_projects/kyberswap/avalanche_c/kyberswap_aggregator_avalanche_c_trades.sql b/dbt_subprojects/dex/models/_projects/kyberswap/avalanche_c/kyberswap_aggregator_avalanche_c_trades.sql index 635d3fb2724..2061a3ddc8b 100644 --- a/dbt_subprojects/dex/models/_projects/kyberswap/avalanche_c/kyberswap_aggregator_avalanche_c_trades.sql +++ b/dbt_subprojects/dex/models/_projects/kyberswap/avalanche_c/kyberswap_aggregator_avalanche_c_trades.sql @@ -1,6 +1,6 @@ {{ config ( - + schema = 'kyberswap_aggregator_avalanche_c', alias = 'trades', partition_by = ['block_month'], @@ -36,8 +36,11 @@ WITH meta_router AS ,ARRAY[-1] AS trace_address FROM {{ source('kyber_avalanche_c', 'MetaAggregationRouterV2_evt_Swapped') }} + WHERE 0x250f8f7750735e3ab5dc9db3a542f6b71999ed38 not in (dstToken, srcToken) + -- There are 2 weird transactions with this token where the return and spent amounts in the event are not correct + -- these result in inflated volume, so we'll ignore this token in any trades. {% if is_incremental() %} - WHERE evt_block_time >= date_trunc('day', now() - INTERVAL '7' DAY) + AND evt_block_time >= date_trunc('day', now() - INTERVAL '7' DAY) {% endif %} ) SELECT diff --git a/dbt_subprojects/dex/models/_projects/paraswap/arbitrum/paraswap_v6_arbitrum_trades_decoded.sql b/dbt_subprojects/dex/models/_projects/paraswap/arbitrum/paraswap_v6_arbitrum_trades_decoded.sql index 502fc389f43..1024152f7ff 100644 --- a/dbt_subprojects/dex/models/_projects/paraswap/arbitrum/paraswap_v6_arbitrum_trades_decoded.sql +++ b/dbt_subprojects/dex/models/_projects/paraswap/arbitrum/paraswap_v6_arbitrum_trades_decoded.sql @@ -6,8 +6,13 @@ file_format = 'delta', incremental_strategy = 'merge', incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.blockTime')], - unique_key = ['call_tx_hash', 'method', 'call_trace_address'] + unique_key = ['call_tx_hash', 'method', 'call_trace_address'], + post_hook='{{ expose_spells(blockchains = \'["arbitrum"]\', + spell_type = "project", + spell_name = "paraswap_v6", + contributors = \'["eptighte", "mwamedacen"]\') }}' ) + }} {{ paraswap_v6_trades_master('arbitrum', 'paraswap') }} \ No newline at end of file diff --git a/dbt_subprojects/dex/models/_projects/paraswap/avalanche_c/paraswap_v6_avalanche_c_trades_decoded.sql b/dbt_subprojects/dex/models/_projects/paraswap/avalanche_c/paraswap_v6_avalanche_c_trades_decoded.sql index 8115c77340e..01ff942135a 100644 --- a/dbt_subprojects/dex/models/_projects/paraswap/avalanche_c/paraswap_v6_avalanche_c_trades_decoded.sql +++ b/dbt_subprojects/dex/models/_projects/paraswap/avalanche_c/paraswap_v6_avalanche_c_trades_decoded.sql @@ -6,7 +6,11 @@ file_format = 'delta', incremental_strategy = 'merge', incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.blockTime')], - unique_key = ['call_tx_hash', 'method', 'call_trace_address'] + unique_key = ['call_tx_hash', 'method', 'call_trace_address'], + post_hook='{{ expose_spells(blockchains = \'["avalanche_c"]\', + spell_type = "project", + spell_name = "paraswap_v6", + contributors = \'["eptighte", "mwamedacen"]\') }}' ) }} diff --git a/dbt_subprojects/dex/models/_projects/paraswap/base/paraswap_v6_base_trades_decoded.sql b/dbt_subprojects/dex/models/_projects/paraswap/base/paraswap_v6_base_trades_decoded.sql index f8d2ea8f24b..3029cf2c40b 100644 --- a/dbt_subprojects/dex/models/_projects/paraswap/base/paraswap_v6_base_trades_decoded.sql +++ b/dbt_subprojects/dex/models/_projects/paraswap/base/paraswap_v6_base_trades_decoded.sql @@ -6,7 +6,11 @@ file_format = 'delta', incremental_strategy = 'merge', incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.blockTime')], - unique_key = ['call_tx_hash', 'method', 'call_trace_address'] + unique_key = ['call_tx_hash', 'method', 'call_trace_address'], + post_hook='{{ expose_spells(blockchains = \'["base"]\', + spell_type = "project", + spell_name = "paraswap_v6", + contributors = \'["eptighte", "mwamedacen"]\') }}' ) }} diff --git a/dbt_subprojects/dex/models/_projects/paraswap/bnb/paraswap_v6_bnb_trades_decoded.sql b/dbt_subprojects/dex/models/_projects/paraswap/bnb/paraswap_v6_bnb_trades_decoded.sql index 594d41c2743..257c866aa86 100644 --- a/dbt_subprojects/dex/models/_projects/paraswap/bnb/paraswap_v6_bnb_trades_decoded.sql +++ b/dbt_subprojects/dex/models/_projects/paraswap/bnb/paraswap_v6_bnb_trades_decoded.sql @@ -6,7 +6,11 @@ file_format = 'delta', incremental_strategy = 'merge', incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.blockTime')], - unique_key = ['call_tx_hash', 'method', 'call_trace_address'] + unique_key = ['call_tx_hash', 'method', 'call_trace_address'], + post_hook='{{ expose_spells(blockchains = \'["bnb"]\', + spell_type = "project", + spell_name = "paraswap_v6", + contributors = \'["eptighte", "mwamedacen"]\') }}' ) }} diff --git a/dbt_subprojects/dex/models/_projects/paraswap/ethereum/paraswap_v6_ethereum_trades_decoded.sql b/dbt_subprojects/dex/models/_projects/paraswap/ethereum/paraswap_v6_ethereum_trades_decoded.sql index eb2a0849ccc..a36e1034c9d 100644 --- a/dbt_subprojects/dex/models/_projects/paraswap/ethereum/paraswap_v6_ethereum_trades_decoded.sql +++ b/dbt_subprojects/dex/models/_projects/paraswap/ethereum/paraswap_v6_ethereum_trades_decoded.sql @@ -6,7 +6,11 @@ file_format = 'delta', incremental_strategy = 'merge', incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.blockTime')], - unique_key = ['call_tx_hash', 'method', 'call_trace_address'] + unique_key = ['call_tx_hash', 'method', 'call_trace_address'], + post_hook='{{ expose_spells(blockchains = \'["ethereum"]\', + spell_type = "project", + spell_name = "paraswap_v6", + contributors = \'["eptighte", "mwamedacen"]\') }}' ) }} diff --git a/dbt_subprojects/dex/models/_projects/paraswap/fantom/paraswap_v6_fantom_trades_decoded.sql b/dbt_subprojects/dex/models/_projects/paraswap/fantom/paraswap_v6_fantom_trades_decoded.sql index ef3047c2ff0..796f9333021 100644 --- a/dbt_subprojects/dex/models/_projects/paraswap/fantom/paraswap_v6_fantom_trades_decoded.sql +++ b/dbt_subprojects/dex/models/_projects/paraswap/fantom/paraswap_v6_fantom_trades_decoded.sql @@ -6,7 +6,11 @@ file_format = 'delta', incremental_strategy = 'merge', incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.blockTime')], - unique_key = ['call_tx_hash', 'method', 'call_trace_address'] + unique_key = ['call_tx_hash', 'method', 'call_trace_address'], + post_hook='{{ expose_spells(blockchains = \'["fantom"]\', + spell_type = "project", + spell_name = "paraswap_v6", + contributors = \'["eptighte", "mwamedacen"]\') }}' ) }} diff --git a/dbt_subprojects/dex/models/_projects/paraswap/optimism/paraswap_v6_optimism_trades_decoded.sql b/dbt_subprojects/dex/models/_projects/paraswap/optimism/paraswap_v6_optimism_trades_decoded.sql index f9fec8cccdb..e5b7223726d 100644 --- a/dbt_subprojects/dex/models/_projects/paraswap/optimism/paraswap_v6_optimism_trades_decoded.sql +++ b/dbt_subprojects/dex/models/_projects/paraswap/optimism/paraswap_v6_optimism_trades_decoded.sql @@ -6,7 +6,11 @@ file_format = 'delta', incremental_strategy = 'merge', incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.blockTime')], - unique_key = ['call_tx_hash', 'method', 'call_trace_address'] + unique_key = ['call_tx_hash', 'method', 'call_trace_address'], + post_hook='{{ expose_spells(blockchains = \'["optimism"]\', + spell_type = "project", + spell_name = "paraswap_v6", + contributors = \'["eptighte", "mwamedacen"]\') }}' ) }} diff --git a/dbt_subprojects/dex/models/_projects/paraswap/polygon/paraswap_v6_polygon_trades_decoded.sql b/dbt_subprojects/dex/models/_projects/paraswap/polygon/paraswap_v6_polygon_trades_decoded.sql index ee56d154a6b..6672db00e66 100644 --- a/dbt_subprojects/dex/models/_projects/paraswap/polygon/paraswap_v6_polygon_trades_decoded.sql +++ b/dbt_subprojects/dex/models/_projects/paraswap/polygon/paraswap_v6_polygon_trades_decoded.sql @@ -6,7 +6,11 @@ file_format = 'delta', incremental_strategy = 'merge', incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.blockTime')], - unique_key = ['call_tx_hash', 'method', 'call_trace_address'] + unique_key = ['call_tx_hash', 'method', 'call_trace_address'], + post_hook='{{ expose_spells(blockchains = \'["polygon"]\', + spell_type = "project", + spell_name = "paraswap_v6", + contributors = \'["eptighte", "mwamedacen"]\') }}' ) }} diff --git a/dbt_subprojects/dex/models/bot_trades/_schema.yml b/dbt_subprojects/dex/models/bot_trades/_schema.yml new file mode 100644 index 00000000000..4973ff57beb --- /dev/null +++ b/dbt_subprojects/dex/models/bot_trades/_schema.yml @@ -0,0 +1,227 @@ +version: 2 + +models: + - name: dex_evm_bot_trades + meta: + blockchain: ethereum, base, bnb, avalanche_c + sector: dex + contributors: ["whale_hunter"] + config: + tags: ["evm", "dex", "bot", "trades"] + description: > + Trades by trading bots on EVM chains + columns: + - &blockchain + name: blockchain + description: "Blockchain which the DEX is deployed" + - &block_number + name: block_number + description: "Block number that includes the DEX trade" + - &block_time + name: block_time + description: "UTC event block time of each DEX trade" + - &block_date + name: block_date + description: "UTC event block date of each DEX trade" + - &block_month + name: block_month + description: "UTC event block month of each DEX trade" + - &bot + name: bot + description: "Trading bot which executed the trade" + - &amount_usd + name: amount_usd + description: "USD value of the trade at time of execution" + - &type + name: type + description: "Wether the trade is a buy or sell" + - &token_bought_amount + name: token_bought_amount + description: "Value of the token bought at time of execution in the original currency" + - &token_bought_symbol + name: token_bought_symbol + description: "Token symbol for token bought in the trade" + - &token_bought_address + name: token_bought_address + description: "Contract address of the token bought" + - &token_sold_amount + name: token_sold_amount + description: "Value of the token sold at time of execution in the original currency" + - &token_sold_symbol + name: token_sold_symbol + description: "Token symbol for token sold in the trade" + - &token_sold_address + name: token_sold_address + description: "Contract address of the token sold" + - &fee_percentage_fraction + name: fee_percentage_fraction + description: "The trading fee in percent, as a fraction of 100" + - &fee_usd + name: fee_usd + description: "USD value of the fee at time of execution" + - &fee_token_amount + name: fee_token_amount + description: "Value of the fee paid at time of execution in the original currency" + - &fee_token_symbol + name: fee_token_symbol + description: "Token symbol for fee token" + - &fee_token_address + name: fee_token_address + description: "Contract address of the fee token" + - &project + name: project + description: "Project name of the DEX" + - &version + name: version + description: "Version of the contract built and deployed by the DEX project" + - &token_pair + name: token_pair + description: "Token symbol pair for each token involved in the trade" + - &project_contract_address + name: project_contract_address + description: "Project contract address which executed the trade on the blockchain" + - &user + name: user + description: "Address which initiated the trade" + - &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" + - &is_last_trade_in_transaction + name: is_last_trade_in_transaction + description: "Wether the trade is the last hop of the trade transaction, in case of a multi-hop trade" + + - name: banana_gun_ethereum_bot_trades + meta: + blockchain: ethereum + sector: dex + project: banana_gun + contributors: whale_hunter + config: + tags: ["evm", "dex", "banana_gun", "trades"] + description: > + Banana Gun trades on Ethereum + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - tx_hash + - evt_index + - check_bot_trades_seed: + seed_file: ref('banana_gun_ethereum_trades_seed') + + - name: banana_gun_base_bot_trades + meta: + blockchain: base + sector: dex + project: banana_gun + contributors: whale_hunter + config: + tags: ["evm", "dex", "banana_gun", "trades"] + description: > + Banana Gun trades on Base + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - tx_hash + - evt_index + - check_bot_trades_seed: + seed_file: ref('banana_gun_base_trades_seed') + + - name: pepeboost_ethereum_bot_trades + meta: + blockchain: ethereum + sector: dex + project: pepeboost + contributors: whale_hunter + config: + tags: ["evm", "dex", "pepeboost", "trades"] + description: > + Pepeboost trades on Ethereum + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - tx_hash + - evt_index + - check_bot_trades_seed: + seed_file: ref('pepeboost_ethereum_trades_seed') + + - name: readyswap_ethereum_bot_trades + meta: + blockchain: ethereum + sector: dex + project: readyswap + contributors: whale_hunter + config: + tags: ["evm", "dex", "readyswap", "trades"] + description: > + ReadySwap trades on Ethereum + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - tx_hash + - evt_index + - check_bot_trades_seed: + seed_file: ref('readyswap_ethereum_trades_seed') + + - name: flokibot_ethereum_bot_trades + meta: + blockchain: ethereum + sector: dex + project: flokibot + contributors: whale_hunter + config: + tags: ["evm", "dex", "flokibot", "trades"] + description: > + Flokibot trades on Ethereum + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - tx_hash + - evt_index + - check_bot_trades_seed: + seed_file: ref('flokibot_ethereum_trades_seed') + + - name: flokibot_base_bot_trades + meta: + blockchain: base + sector: dex + project: flokibot + contributors: whale_hunter + config: + tags: ["evm", "dex", "flokibot", "trades"] + description: > + Flokibot trades on Base + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - tx_hash + - evt_index + - check_bot_trades_seed: + seed_file: ref('flokibot_base_trades_seed') + + - name: flokibot_bnb_bot_trades + meta: + blockchain: bnb + sector: dex + project: flokibot + contributors: whale_hunter + config: + tags: ["evm", "dex", "flokibot", "trades"] + description: > + Flokibot trades on BNB + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - tx_hash + - evt_index + - check_bot_trades_seed: + seed_file: ref('flokibot_bnb_trades_seed') diff --git a/dbt_subprojects/dex/models/bot_trades/banana_gun/base/banana_gun_base_bot_trades.sql b/dbt_subprojects/dex/models/bot_trades/banana_gun/base/banana_gun_base_bot_trades.sql new file mode 100644 index 00000000000..6126ae66844 --- /dev/null +++ b/dbt_subprojects/dex/models/bot_trades/banana_gun/base/banana_gun_base_bot_trades.sql @@ -0,0 +1,196 @@ +{{ config( + alias = 'bot_trades', + schema = 'banana_gun_base', + partition_by = ['block_month'], + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], + unique_key = ['blockchain', 'tx_hash', 'evt_index'] + ) +}} + +{% set project_name = 'Banana Gun' %} +{% set project_start_date = '2024-03-05' %} +{% set blockchain = 'base' %} +{% set bot_deployer_1 = '0x37aAb97476bA8dC785476611006fD5dDA4eed66B' %} +{% set weth = '0x4200000000000000000000000000000000000006' %} +{% set fee_token_symbol = 'ETH' %} + +WITH + botContracts AS ( + SELECT + address + FROM + {{ source('base','creation_traces') }} + WHERE + ( + "from" = {{bot_deployer_1}} + ) + AND block_time >= TIMESTAMP '{{project_start_date}}' + ), + botTrades AS ( + SELECT + trades.block_time, + amount_usd, + IF( + token_sold_address = {{weth}}, + 'Buy', + 'Sell' + ) AS type, + token_bought_amount, + token_bought_symbol, + token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_address, + project, + version, + token_pair, + project_contract_address, + tx_from AS user, + tx_to AS bot, + trades.tx_hash, + evt_index + FROM + {{ source('dex', 'trades') }} as trades + JOIN botContracts ON trades.tx_to = botContracts.address + WHERE + trades.blockchain = '{{blockchain}}' + {% if is_incremental() %} + AND {{ incremental_predicate('trades.block_time') }} + {% else %} + AND trades.block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + ), + highestEventIndexForEachTrade AS ( + SELECT + tx_hash, + MAX(evt_index) AS highestEventIndex + FROM + botTrades + GROUP BY + tx_hash + ), + botETHDeposits AS ( + SELECT + tx_hash, + block_number, + CAST(value AS DECIMAL (38, 0)) AS deltaGwei, + CAST(value AS DECIMAL (38, 0)) AS depositGwei + FROM + {{ source('base','traces') }} + JOIN botContracts ON to = botContracts.address + WHERE + {% if is_incremental() %} + {{ incremental_predicate('block_time') }} + {% else %} + block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + AND value > CAST(0 AS UINT256) + ), + botETHWithdrawals AS ( + SELECT + tx_hash, + block_number, + CAST(value AS DECIMAL (38, 0)) * -1 AS deltaGwei, + 0 AS depositGwei, + block_hash, + to + FROM + {{ source('base','traces') }} + JOIN botContracts ON "from" = botContracts.address + WHERE + {% if is_incremental() %} + {{ incremental_predicate('block_time') }} + {% else %} + block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + AND value > CAST(0 AS UINT256) + ), + botEthTransfers AS ( + /* Deposits */ + ( + SELECT + tx_hash, + block_number, + deltaGwei, + depositGwei + FROM + botETHDeposits + ) + UNION ALL + /* Withdrawals */ + ( + SELECT + tx_hash, + block_number, + deltaGwei, + depositGwei + FROM + botETHWithdrawals + ) + ), + botEthDeltas AS ( + SELECT + tx_hash, + block_number, + SUM(deltaGwei) AS feeGwei, + SUM(depositGwei) AS depositGwei + FROM + botEthTransfers + GROUP BY + tx_hash, + block_number + ) +SELECT + block_time, + date_trunc('day', botTrades.block_time) as block_date, + date_trunc('month', botTrades.block_time) as block_month, + '{{project_name}}' as bot, + block_number, + '{{blockchain}}' AS blockchain, + -- Trade + amount_usd, + type, + token_bought_amount, + token_bought_symbol, + token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_address, + -- Fees + ROUND( + CAST(feeGwei AS DOUBLE) / CAST(depositGwei AS DOUBLE), + /* Round feePercentage to 0.01% steps */ + 4 + ) AS fee_percentage_fraction, + (feeGwei / 1e18) * price AS fee_usd, + feeGwei / 1e18 fee_token_amount, + '{{fee_token_symbol}}' AS fee_token_symbol, + {{weth}} AS fee_token_address, + -- Dex + project, + version, + token_pair, + project_contract_address, + -- User + user, + botTrades.tx_hash, + evt_index, + IF(evt_index = highestEventIndex, true, false) AS is_last_trade_in_transaction +FROM + botTrades + JOIN highestEventIndexForEachTrade ON botTrades.tx_hash = highestEventIndexForEachTrade.tx_hash + LEFT JOIN botETHDeltas ON botTrades.tx_hash = botETHDeltas.tx_hash + LEFT JOIN {{ source('prices', 'usd') }} ON ( + blockchain = '{{blockchain}}' + AND contract_address = {{weth}} + AND minute = DATE_TRUNC('minute', block_time) + {% if is_incremental() %} + AND {{ incremental_predicate('minute') }} + {% endif %} + ) +ORDER BY + block_time DESC, + evt_index DESC \ No newline at end of file diff --git a/dbt_subprojects/dex/models/bot_trades/banana_gun/ethereum/banana_gun_ethereum_bot_trades.sql b/dbt_subprojects/dex/models/bot_trades/banana_gun/ethereum/banana_gun_ethereum_bot_trades.sql new file mode 100644 index 00000000000..51b2a6ecf64 --- /dev/null +++ b/dbt_subprojects/dex/models/bot_trades/banana_gun/ethereum/banana_gun_ethereum_bot_trades.sql @@ -0,0 +1,198 @@ +{{ config( + alias = 'bot_trades', + schema = 'banana_gun_ethereum', + partition_by = ['block_month'], + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], + unique_key = ['blockchain', 'tx_hash', 'evt_index'] + ) +}} + +{% set project_name = 'Banana Gun' %} +{% set project_start_date = '2023-05-26' %} +{% set blockchain = 'ethereum' %} +{% set bot_deployer_1 = '0xf414d478934c29d9a80244a3626c681a71e53bb2' %} +{% set bot_deployer_2 = '0x37aAb97476bA8dC785476611006fD5dDA4eed66B' %} +{% set weth = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' %} +{% set fee_token_symbol = 'ETH' %} + +WITH + botContracts AS ( + SELECT + address + FROM + {{ source('ethereum','creation_traces') }} + WHERE + ( + "from" = {{bot_deployer_1}} + OR "from" = {{bot_deployer_2}} + ) + AND block_time >= TIMESTAMP '{{project_start_date}}' + ), + botTrades AS ( + SELECT + trades.block_time, + amount_usd, + IF( + token_sold_address = {{weth}}, + 'Buy', + 'Sell' + ) AS type, + token_bought_amount, + token_bought_symbol, + token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_address, + project, + version, + token_pair, + project_contract_address, + tx_from AS user, + tx_to AS bot, + trades.tx_hash, + evt_index + FROM + {{ source('dex', 'trades') }} as trades + JOIN botContracts ON trades.tx_to = botContracts.address + WHERE + trades.blockchain = '{{blockchain}}' + {% if is_incremental() %} + AND {{ incremental_predicate('trades.block_time') }} + {% else %} + AND trades.block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + ), + highestEventIndexForEachTrade AS ( + SELECT + tx_hash, + MAX(evt_index) AS highestEventIndex + FROM + botTrades + GROUP BY + tx_hash + ), + botETHDeposits AS ( + SELECT + tx_hash, + block_number, + CAST(value AS DECIMAL (38, 0)) AS deltaGwei, + CAST(value AS DECIMAL (38, 0)) AS depositGwei + FROM + {{ source('ethereum','traces') }} + JOIN botContracts ON to = botContracts.address + WHERE + {% if is_incremental() %} + {{ incremental_predicate('block_time') }} + {% else %} + block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + AND value > 0 + ), + botETHWithdrawals AS ( + SELECT + tx_hash, + block_number, + CAST(value AS DECIMAL (38, 0)) * -1 AS deltaGwei, + 0 AS depositGwei, + block_hash, + to + FROM + {{ source('ethereum','traces') }} + JOIN botContracts ON "from" = botContracts.address + WHERE + {% if is_incremental() %} + {{ incremental_predicate('block_time') }} + {% else %} + block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + AND value > 0 + ), + botEthTransfers AS ( + /* Deposits */ + ( + SELECT + tx_hash, + block_number, + deltaGwei, + depositGwei + FROM + botETHDeposits + ) + UNION ALL + /* Withdrawals */ + ( + SELECT + tx_hash, + block_number, + deltaGwei, + depositGwei + FROM + botETHWithdrawals + ) + ), + botEthDeltas AS ( + SELECT + tx_hash, + block_number, + SUM(deltaGwei) AS feeGwei, + SUM(depositGwei) AS depositGwei + FROM + botEthTransfers + GROUP BY + tx_hash, + block_number + ) +SELECT + block_time, + date_trunc('day', botTrades.block_time) as block_date, + date_trunc('month', botTrades.block_time) as block_month, + '{{project_name}}' as bot, + block_number, + '{{blockchain}}' AS blockchain, + -- Trade + amount_usd, + type, + token_bought_amount, + token_bought_symbol, + token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_address, + -- Fees + ROUND( + CAST(feeGwei AS DOUBLE) / CAST(depositGwei AS DOUBLE), + /* Round feePercentage to 0.01% steps */ + 4 + ) AS fee_percentage_fraction, + (feeGwei / 1e18) * price AS fee_usd, + feeGwei / 1e18 fee_token_amount, + '{{fee_token_symbol}}' AS fee_token_symbol, + {{weth}} AS fee_token_address, + -- Dex + project, + version, + token_pair, + project_contract_address, + -- User + user AS user, + botTrades.tx_hash, + evt_index, + IF(evt_index = highestEventIndex, true, false) AS is_last_trade_in_transaction +FROM + botTrades + JOIN highestEventIndexForEachTrade ON botTrades.tx_hash = highestEventIndexForEachTrade.tx_hash + LEFT JOIN botETHDeltas ON botTrades.tx_hash = botETHDeltas.tx_hash + LEFT JOIN {{ source('prices', 'usd') }} ON ( + blockchain = '{{blockchain}}' + AND contract_address = {{weth}} + AND minute = DATE_TRUNC('minute', block_time) + {% if is_incremental() %} + AND {{ incremental_predicate('minute') }} + {% endif %} + ) +ORDER BY + block_time DESC, + evt_index DESC \ No newline at end of file diff --git a/dbt_subprojects/dex/models/bot_trades/dex_evm_bot_trades.sql b/dbt_subprojects/dex/models/bot_trades/dex_evm_bot_trades.sql new file mode 100644 index 00000000000..75b185949eb --- /dev/null +++ b/dbt_subprojects/dex/models/bot_trades/dex_evm_bot_trades.sql @@ -0,0 +1,62 @@ +{{ + config( + schema = 'dex_evm', + alias = 'bot_trades', + materialized = 'view', + post_hook = '{{ expose_spells( + blockchains = \'["ethereum", "base", "blast", "arbitrum", "bnb", "avalanche_c"]\', + spell_type = "sector", + spell_name = "bot_trades", + contributors = \'["whale_hunter"]\') }}' + ) +}} + + + +{% set evm_trading_bots = [ + ref('banana_gun_base_bot_trades') + ,ref('banana_gun_ethereum_bot_trades') + ,ref('readyswap_ethereum_bot_trades') + ,ref('pepeboost_ethereum_bot_trades') + ,ref('flokibot_base_bot_trades') + ,ref('flokibot_bnb_bot_trades') + ,ref('flokibot_ethereum_bot_trades') +] %} + +{% for bot in evm_trading_bots %} +SELECT block_time, + block_date, + block_month, + bot, + block_number, + blockchain, + -- Trade + amount_usd, + type, + token_bought_amount, + token_bought_symbol, + token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_address, + -- Fees + fee_percentage_fraction, + fee_usd, + fee_token_amount, + fee_token_symbol, + fee_token_address, + -- Dex + project, + version, + token_pair, + project_contract_address, + -- User + user, + tx_hash, + evt_index, + is_last_trade_in_transaction +FROM {{ bot }} +{% if not loop.last %} +UNION ALL +{% endif %} +{% endfor %} \ No newline at end of file diff --git a/dbt_subprojects/dex/models/bot_trades/flokibot/base/flokibot_base_bot_trades.sql b/dbt_subprojects/dex/models/bot_trades/flokibot/base/flokibot_base_bot_trades.sql new file mode 100644 index 00000000000..dbdbdc01f5d --- /dev/null +++ b/dbt_subprojects/dex/models/bot_trades/flokibot/base/flokibot_base_bot_trades.sql @@ -0,0 +1,184 @@ +{{ + config( + alias='bot_trades', + schema='flokibot_base', + partition_by=['block_month'], + materialized='incremental', + file_format='delta', + incremental_strategy='merge', + incremental_predicates=[ + incremental_predicate('DBT_INTERNAL_DEST.block_time') + ], + unique_key=['blockchain', 'tx_hash', 'evt_index'], + ) +}} + +{% set project_name = 'Floki Trading Bot' %} +{% set project_start_date = '2024-02-13' %} +{% set blockchain = 'base' %} +{% set bot_deployer_1 = '0xdeb9e55e0f20bc59029271372ecea50e67182a3a' %} +{% set bot_deployer_2 = '0xcE6a13955EC32B6B1b7EBe089302b536Ad40aeC3' %} +{% set treasury_fee_wallet_1 = '0xc69df57dbb39e52d5836753e6abb71a9ab271c2d' %} +{% set treasury_fee_wallet_2 = '0x800E2f14a25Ae52300209b2D7Fb45cC27ae91a9d' %} +{% set buyback_fee_wallet_1 = '0xCc5374Be204990A3205EB9f93C5bD37B4f8e2c5e' %} +{% set aggregator_fee_wallet_1 = '0x7b41114eCB5C09d483343116C229Be3d3eb3b0fC' %} +{% set weth = '0x4200000000000000000000000000000000000006' %} +{% set fee_token_symbol = 'ETH' %} + +with + bot_contracts as ( + select block_time, address + from {{ source('base', 'creation_traces') }} + where + ("from" = {{ bot_deployer_1 }} or "from" = {{ bot_deployer_2 }}) + and block_time >= timestamp '{{project_start_date}}' + ), + fees as ( + select sum(value) / 1e18 as fee_token_amount, tx_hash + from {{ source('base', 'traces') }} + where + ( + to = {{ treasury_fee_wallet_1 }} + or to = {{ treasury_fee_wallet_2 }} + or to = {{ aggregator_fee_wallet_1 }} + or to = {{ buyback_fee_wallet_1 }} + ) + and tx_success = true + and value > 0 + {% if is_incremental() %} + and {{ incremental_predicate('block_time') }} + {% else %} and block_time >= timestamp '{{project_start_date}}' + {% endif %} + group by tx_hash + ), + oneinch_aggregator_trades as ( + select call_block_time as block_time, call_tx_hash as tx_hash + from {{ source('oneinch_base', 'AggregationRouterV6_call_swap') }} + where + ( + varbinary_position(data, {{ aggregator_fee_wallet_1 }}) > 0 + or varbinary_position(data, {{ treasury_fee_wallet_1 }}) > 0 + or varbinary_position(data, {{ treasury_fee_wallet_2 }}) > 0 + or varbinary_position(data, {{ buyback_fee_wallet_1 }}) > 0 + ) + and call_success + {% if is_incremental() %} + and {{ incremental_predicate('call_block_time') }} + {% else %} and call_block_time >= timestamp '{{project_start_date}}' + {% endif %} + ), + openocean_aggregator_trades as ( + select evt_block_time as block_time, evt_tx_hash as tx_hash + from {{ source('openocean_v2_base', 'OpenOceanExchange_evt_Swapped') }} + where + referrer = {{ aggregator_fee_wallet_1 }} + or referrer = {{ treasury_fee_wallet_1 }} + or referrer = {{ treasury_fee_wallet_2 }} + or referrer = {{ buyback_fee_wallet_1 }} + {% if is_incremental() %} + and {{ incremental_predicate('evt_block_time') }} + {% else %} and evt_block_time >= timestamp '{{project_start_date}}' + {% endif %} + ), + trade_transactions as ( + select block_time, address, null as tx_hash + from bot_contracts + union all + select block_time, null as address, tx_hash + from oneinch_aggregator_trades + union all + select block_time, null as address, tx_hash + from openocean_aggregator_trades + ), + bot_trades as ( + select + trades.block_time, + trades.block_number, + amount_usd, + if(token_sold_address = {{ weth }}, 'Buy', 'Sell') as type, + token_bought_amount, + token_bought_symbol, + token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_address, + fee_token_amount, + '{{fee_token_symbol}}' as fee_token_symbol, + {{ weth }} as fee_token_address, + project, + version, + token_pair, + project_contract_address, + tx_from as user, + tx_to as bot, + trades.tx_hash, + evt_index + from {{ source('dex', 'trades') }} as trades + join trade_transactions ON ( + ( + trades.tx_to = trade_transactions.address + OR trades.tx_hash = trade_transactions.tx_hash + ) + AND trades.block_time >= trade_transactions.block_time + ) + left join fees on fees.tx_hash = trades.tx_hash + where + trades.blockchain = '{{blockchain}}' + {% if is_incremental() %} + and {{ incremental_predicate('trades.block_time') }} + {% else %} and trades.block_time >= timestamp '{{project_start_date}}' + {% endif %} + ), + highest_event_index_for_each_trade as ( + select tx_hash, max(evt_index) as highest_event_index + from bot_trades + group by tx_hash + ) +select + block_time, + date_trunc('day', bot_trades.block_time) as block_date, + date_trunc('month', bot_trades.block_time) as block_month, + '{{project_name}}' as bot, + block_number, + '{{blockchain}}' as blockchain, + -- Trade + amount_usd, + type, + token_bought_amount, + token_bought_symbol, + token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_address, + -- Fees + round( + fee_token_amount * price / cast(amount_usd as double), + 4 -- Round feePercentage to 0.01% steps + ) as fee_percentage_fraction, + fee_token_amount * price as fee_usd, + fee_token_amount, + '{{fee_token_symbol}}' as fee_token_symbol, + fee_token_address, + -- Dex + project, + version, + token_pair, + project_contract_address, + -- User + user as user, + bot_trades.tx_hash, + evt_index, + if(evt_index = highest_event_index, true, false) as is_last_trade_in_transaction +from bot_trades +join + highest_event_index_for_each_trade + on bot_trades.tx_hash = highest_event_index_for_each_trade.tx_hash +left join + {{ source('prices', 'usd') }} + on ( + blockchain = '{{blockchain}}' + and contract_address = {{ weth }} + and minute = date_trunc('minute', block_time) + {% if is_incremental() %} and {{ incremental_predicate('minute') }} {% endif %} + ) +order by block_time desc, evt_index desc diff --git a/dbt_subprojects/dex/models/bot_trades/flokibot/bnb/flokibot_bnb_bot_trades.sql b/dbt_subprojects/dex/models/bot_trades/flokibot/bnb/flokibot_bnb_bot_trades.sql new file mode 100644 index 00000000000..0ae3261690a --- /dev/null +++ b/dbt_subprojects/dex/models/bot_trades/flokibot/bnb/flokibot_bnb_bot_trades.sql @@ -0,0 +1,189 @@ +{{ + config( + alias='bot_trades', + schema='flokibot_bnb', + partition_by=['block_month'], + materialized='incremental', + file_format='delta', + incremental_strategy='merge', + incremental_predicates=[ + incremental_predicate('DBT_INTERNAL_DEST.block_time') + ], + unique_key=['blockchain', 'tx_hash', 'evt_index'], + ) +}} + +{% set project_name = 'Floki Trading Bot' %} +{% set project_start_date = '2024-02-13' %} +{% set blockchain = 'bnb' %} +{% set bot_deployer_1 = '0xdeb9E55E0F20bC59029271372ECea50E67182A3A' %} +{% set bot_deployer_2 = '0xfE188fee982CF9588841ea8540bD490a495D9f2c' %} +{% set bot_deployer_3 = '0xcE6a13955EC32B6B1b7EBe089302b536Ad40aeC3' %} +{% set treasury_fee_wallet_1 = '0xc69df57dbb39e52d5836753e6abb71a9ab271c2d' %} +{% set treasury_fee_wallet_2 = '0x07b127f66cf580aBd2FC59b7836fc2CF6cec3502' %} +{% set treasury_fee_wallet_3 = '0x197d8fab9d5a4c026a56d01f529caf023ba46df5' %} +{% set buyback_fee_wallet_1 = '0xCc5374Be204990A3205EB9f93C5bD37B4f8e2c5e' %} +{% set aggregator_fee_wallet_1 = '0x7b41114eCB5C09d483343116C229Be3d3eb3b0fC' %} +{% set wbnb = '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c' %} +{% set fee_token_symbol = 'BNB' %} + +with + bot_contracts as ( + select block_time, address + from {{ source('bnb', 'creation_traces') }} + where + ("from" = {{ bot_deployer_1 }} or "from" = {{ bot_deployer_2 }} or "from" = {{ bot_deployer_3 }}) + and block_time >= timestamp '{{project_start_date}}' + ), + fees as ( + select sum(value) / 1e18 as fee_token_amount, tx_hash + from {{ source('bnb', 'traces') }} + where + ( + to = {{ aggregator_fee_wallet_1 }} + or to = {{ treasury_fee_wallet_1 }} + or to = {{ treasury_fee_wallet_2 }} + or to = {{ treasury_fee_wallet_3 }} + or to = {{ buyback_fee_wallet_1 }} + ) + and tx_success = true + and value > 0 + {% if is_incremental() %} + and {{ incremental_predicate('block_time') }} + {% else %} and block_time >= timestamp '{{project_start_date}}' + {% endif %} + group by tx_hash + ), + oneinch_aggregator_trades as ( + select call_block_time as block_time, call_tx_hash as tx_hash + from {{ source('oneinch_bnb', 'AggregationRouterV6_call_swap') }} + where + ( + varbinary_position(data, {{ aggregator_fee_wallet_1 }}) > 0 + or varbinary_position(data, {{ treasury_fee_wallet_1 }}) > 0 + or varbinary_position(data, {{ treasury_fee_wallet_2 }}) > 0 + or varbinary_position(data, {{ treasury_fee_wallet_3 }}) > 0 + or varbinary_position(data, {{ buyback_fee_wallet_1 }}) > 0 + ) + and call_success + {% if is_incremental() %} + and {{ incremental_predicate('call_block_time') }} + {% else %} and call_block_time >= timestamp '{{project_start_date}}' + {% endif %} + ), + openocean_aggregator_trades as ( + select evt_block_time as block_time, evt_tx_hash as tx_hash + from {{ source('openocean_v2_bnb', 'OpenOceanExchange_evt_Swapped') }} + where + referrer = {{ aggregator_fee_wallet_1 }} + OR referrer = {{ treasury_fee_wallet_1 }} + OR referrer = {{ treasury_fee_wallet_2 }} + OR referrer = {{ treasury_fee_wallet_3 }} + OR referrer = {{ buyback_fee_wallet_1 }} + {% if is_incremental() %} + and {{ incremental_predicate('evt_block_time') }} + {% else %} and evt_block_time >= timestamp '{{project_start_date}}' + {% endif %} + ), + trade_transactions as ( + select block_time, address, null as tx_hash + from bot_contracts + union all + select block_time, null as address, tx_hash + from oneinch_aggregator_trades + union all + select block_time, null as address, tx_hash + from openocean_aggregator_trades + ), + bot_trades as ( + select + trades.block_time, + trades.block_number, + amount_usd, + if(token_sold_address = {{ wbnb }}, 'Buy', 'Sell') as type, + token_bought_amount, + token_bought_symbol, + token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_address, + fee_token_amount, + '{{fee_token_symbol}}' as fee_token_symbol, + {{ wbnb }} as fee_token_address, + project, + version, + token_pair, + project_contract_address, + tx_from as user, + tx_to as bot, + trades.tx_hash, + evt_index + from {{ source('dex', 'trades') }} as trades + join trade_transactions ON ( + ( + trades.tx_to = trade_transactions.address + OR trades.tx_hash = trade_transactions.tx_hash + ) + AND trades.block_time >= trade_transactions.block_time + ) + left join fees on fees.tx_hash = trades.tx_hash + where + trades.blockchain = '{{blockchain}}' + {% if is_incremental() %} + and {{ incremental_predicate('trades.block_time') }} + {% else %} and trades.block_time >= timestamp '{{project_start_date}}' + {% endif %} + ), + highest_event_index_for_each_trade as ( + select tx_hash, max(evt_index) as highest_event_index + from bot_trades + group by tx_hash + ) +select + block_time, + date_trunc('day', bot_trades.block_time) as block_date, + date_trunc('month', bot_trades.block_time) as block_month, + '{{project_name}}' as bot, + block_number, + '{{blockchain}}' as blockchain, + -- Trade + amount_usd, + type, + token_bought_amount, + token_bought_symbol, + token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_address, + -- Fees + round( + fee_token_amount * price / cast(amount_usd as double), + 4 -- Round feePercentage to 0.01% steps + ) as fee_percentage_fraction, + fee_token_amount * price as fee_usd, + fee_token_amount, + '{{fee_token_symbol}}' as fee_token_symbol, + fee_token_address, + -- Dex + project, + version, + token_pair, + project_contract_address, + -- User + user as user, + bot_trades.tx_hash, + evt_index, + if(evt_index = highest_event_index, true, false) as is_last_trade_in_transaction +from bot_trades +join + highest_event_index_for_each_trade + on bot_trades.tx_hash = highest_event_index_for_each_trade.tx_hash +left join + {{ source('prices', 'usd') }} + on ( + blockchain = '{{blockchain}}' + and contract_address = {{ wbnb }} + and minute = date_trunc('minute', block_time) + {% if is_incremental() %} and {{ incremental_predicate('minute') }} {% endif %} + ) +order by block_time desc, evt_index desc diff --git a/dbt_subprojects/dex/models/bot_trades/flokibot/ethereum/flokibot_ethereum_bot_trades.sql b/dbt_subprojects/dex/models/bot_trades/flokibot/ethereum/flokibot_ethereum_bot_trades.sql new file mode 100644 index 00000000000..65b05a754c4 --- /dev/null +++ b/dbt_subprojects/dex/models/bot_trades/flokibot/ethereum/flokibot_ethereum_bot_trades.sql @@ -0,0 +1,184 @@ +{{ + config( + alias='bot_trades', + schema='flokibot_ethereum', + partition_by=['block_month'], + materialized='incremental', + file_format='delta', + incremental_strategy='merge', + incremental_predicates=[ + incremental_predicate('DBT_INTERNAL_DEST.block_time') + ], + unique_key=['blockchain', 'tx_hash', 'evt_index'], + ) +}} + +{% set project_name = 'Floki Trading Bot' %} +{% set project_start_date = '2024-02-01' %} +{% set blockchain = 'ethereum' %} +{% set bot_deployer_1 = '0xdeb9E55E0F20bC59029271372ECea50E67182A3A' %} +{% set bot_deployer_2 = '0xcE6a13955EC32B6B1b7EBe089302b536Ad40aeC3' %} +{% set treasury_fee_wallet_1 = '0xc69df57dbb39e52d5836753e6abb71a9ab271c2d' %} +{% set treasury_fee_wallet_2 = '0xffdc626bb733a8c2e906242598e2e99752dcb922' %} +{% set buyback_fee_wallet_1 = '0xCc5374Be204990A3205EB9f93C5bD37B4f8e2c5e' %} +{% set aggregator_fee_wallet_1 = '0x7b41114eCB5C09d483343116C229Be3d3eb3b0fC' %} +{% set weth = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' %} +{% set fee_token_symbol = 'ETH' %} + +with + bot_contracts as ( + select block_time, address + from {{ source('ethereum', 'creation_traces') }} + where + ("from" = {{ bot_deployer_1 }} or "from" = {{ bot_deployer_2 }}) + and block_time >= timestamp '{{project_start_date}}' + ), + fees as ( + select sum(value) / 1e18 as fee_token_amount, tx_hash + from {{ source('ethereum', 'traces') }} + where + ( + to = {{ treasury_fee_wallet_1 }} + or to = {{ treasury_fee_wallet_2 }} + or to = {{ aggregator_fee_wallet_1 }} + or to = {{ buyback_fee_wallet_1 }} + ) + and tx_success = true + and value > 0 + {% if is_incremental() %} + and {{ incremental_predicate('block_time') }} + {% else %} and block_time >= timestamp '{{project_start_date}}' + {% endif %} + group by tx_hash + ), + oneinch_aggregator_trades as ( + select call_block_time as block_time, call_tx_hash as tx_hash + from {{ source('oneinch_ethereum', 'AggregationRouterV6_call_swap') }} + where + ( + varbinary_position(data, {{ aggregator_fee_wallet_1 }}) > 0 + or varbinary_position(data, {{ treasury_fee_wallet_1 }}) > 0 + or varbinary_position(data, {{ treasury_fee_wallet_2 }}) > 0 + or varbinary_position(data, {{ buyback_fee_wallet_1 }}) > 0 + ) + and call_success + {% if is_incremental() %} + and {{ incremental_predicate('call_block_time') }} + {% else %} and call_block_time >= timestamp '{{project_start_date}}' + {% endif %} + ), + openocean_aggregator_trades as ( + select evt_block_time as block_time, evt_tx_hash as tx_hash + from {{ source('openocean_v2_ethereum', 'OpenOceanExchangeProxy_evt_Swapped') }} + where + referrer = {{ treasury_fee_wallet_1 }} + or referrer = {{ treasury_fee_wallet_2 }} + or referrer = {{ aggregator_fee_wallet_1 }} + or referrer = {{ buyback_fee_wallet_1 }} + {% if is_incremental() %} + and {{ incremental_predicate('evt_block_time') }} + {% else %} and evt_block_time >= timestamp '{{project_start_date}}' + {% endif %} + ), + trade_transactions as ( + select block_time, address, null as tx_hash + from bot_contracts + union all + select block_time, null as address, tx_hash + from oneinch_aggregator_trades + union all + select block_time, null as address, tx_hash + from openocean_aggregator_trades + ), + bot_trades as ( + select + trades.block_time, + trades.block_number, + amount_usd, + if(token_sold_address = {{ weth }}, 'Buy', 'Sell') as type, + token_bought_amount, + token_bought_symbol, + token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_address, + fee_token_amount, + '{{fee_token_symbol}}' as fee_token_symbol, + {{ weth }} as fee_token_address, + project, + version, + token_pair, + project_contract_address, + tx_from as user, + tx_to as bot, + trades.tx_hash, + evt_index + from {{ source('dex', 'trades') }} as trades + join trade_transactions ON ( + ( + trades.tx_to = trade_transactions.address + OR trades.tx_hash = trade_transactions.tx_hash + ) + AND trades.block_time >= trade_transactions.block_time + ) + left join fees on fees.tx_hash = trades.tx_hash + where + trades.blockchain = '{{blockchain}}' + {% if is_incremental() %} + and {{ incremental_predicate('trades.block_time') }} + {% else %} and trades.block_time >= timestamp '{{project_start_date}}' + {% endif %} + ), + highest_event_index_for_each_trade as ( + select tx_hash, max(evt_index) as highest_event_index + from bot_trades + group by tx_hash + ) +select + block_time, + date_trunc('day', bot_trades.block_time) as block_date, + date_trunc('month', bot_trades.block_time) as block_month, + '{{project_name}}' as bot, + block_number, + '{{blockchain}}' as blockchain, + -- Trade + amount_usd, + type, + token_bought_amount, + token_bought_symbol, + token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_address, + -- Fees + round( + fee_token_amount * price / cast(amount_usd as double), + 4 -- Round feePercentage to 0.01% steps + ) as fee_percentage_fraction, + fee_token_amount * price as fee_usd, + fee_token_amount, + '{{fee_token_symbol}}' as fee_token_symbol, + fee_token_address, + -- Dex + project, + version, + token_pair, + project_contract_address, + -- User + user as user, + bot_trades.tx_hash, + evt_index, + if(evt_index = highest_event_index, true, false) as is_last_trade_in_transaction +from bot_trades +join + highest_event_index_for_each_trade + on bot_trades.tx_hash = highest_event_index_for_each_trade.tx_hash +left join + {{ source('prices', 'usd') }} + on ( + blockchain = '{{blockchain}}' + and contract_address = {{ weth }} + and minute = date_trunc('minute', block_time) + {% if is_incremental() %} and {{ incremental_predicate('minute') }} {% endif %} + ) +order by block_time desc, evt_index desc diff --git a/dbt_subprojects/dex/models/bot_trades/pepeboost/ethereum/pepeboost_ethereum_bot_trades.sql b/dbt_subprojects/dex/models/bot_trades/pepeboost/ethereum/pepeboost_ethereum_bot_trades.sql new file mode 100644 index 00000000000..ce24a17c97e --- /dev/null +++ b/dbt_subprojects/dex/models/bot_trades/pepeboost/ethereum/pepeboost_ethereum_bot_trades.sql @@ -0,0 +1,194 @@ +{{ config( + alias = 'bot_trades', + schema = 'pepeboost_ethereum', + partition_by = ['block_month'], + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], + unique_key = ['blockchain', 'tx_hash', 'evt_index'] + ) +}} + +{% set project_name = 'Pepeboost' %} +{% set project_start_date = '2023-08-28' %} +{% set blockchain = 'ethereum' %} +{% set bot_deployer_1 = '0xeaBEe4C63bD085Fd906d6be5d387B5EEDfF83919' %} +{% set weth = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' %} +{% set fee_token_symbol = 'ETH' %} + +WITH + botContracts AS ( + SELECT + address + FROM + {{ source('ethereum','creation_traces') }} + WHERE + "from" = {{bot_deployer_1}} + AND block_time >= TIMESTAMP '{{project_start_date}}' + ), + botTrades AS ( + SELECT + trades.block_time, + amount_usd, + IF( + token_sold_address = {{weth}}, + 'Buy', + 'Sell' + ) AS type, + token_bought_amount, + token_bought_symbol, + token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_address, + project, + version, + token_pair, + project_contract_address, + tx_from AS user, + tx_to AS bot, + trades.tx_hash, + evt_index + FROM + {{ source('dex', 'trades') }} as trades + JOIN botContracts ON trades.tx_to = botContracts.address + WHERE + trades.blockchain = '{{blockchain}}' + {% if is_incremental() %} + AND {{ incremental_predicate('trades.block_time') }} + {% else %} + AND trades.block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + ), + highestEventIndexForEachTrade AS ( + SELECT + tx_hash, + MAX(evt_index) AS highestEventIndex + FROM + botTrades + GROUP BY + tx_hash + ), + botETHDeposits AS ( + SELECT + tx_hash, + block_number, + CAST(value AS DECIMAL (38, 0)) AS deltaGwei, + CAST(value AS DECIMAL (38, 0)) AS depositGwei + FROM + {{ source('ethereum','traces') }} + JOIN botContracts ON to = botContracts.address + WHERE + {% if is_incremental() %} + {{ incremental_predicate('block_time') }} + {% else %} + block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + AND value > 0 + ), + botETHWithdrawals AS ( + SELECT + tx_hash, + block_number, + CAST(value AS DECIMAL (38, 0)) * -1 AS deltaGwei, + 0 AS depositGwei, + block_hash, + to + FROM + {{ source('ethereum','traces') }} + JOIN botContracts ON "from" = botContracts.address + WHERE + {% if is_incremental() %} + {{ incremental_predicate('block_time') }} + {% else %} + block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + AND value > 0 + ), + botEthTransfers AS ( + /* Deposits */ + ( + SELECT + tx_hash, + block_number, + deltaGwei, + depositGwei + FROM + botETHDeposits + ) + UNION ALL + /* Withdrawals */ + ( + SELECT + tx_hash, + block_number, + deltaGwei, + depositGwei + FROM + botETHWithdrawals + ) + ), + botEthDeltas AS ( + SELECT + tx_hash, + block_number, + SUM(deltaGwei) AS feeGwei, + SUM(depositGwei) AS depositGwei + FROM + botEthTransfers + GROUP BY + tx_hash, + block_number + ) +SELECT + block_time, + date_trunc('day', botTrades.block_time) as block_date, + date_trunc('month', botTrades.block_time) as block_month, + '{{project_name}}' as bot, + block_number, + '{{blockchain}}' AS blockchain, + -- Trade + amount_usd, + type, + token_bought_amount, + token_bought_symbol, + token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_address, + -- Fees + ROUND( + CAST(feeGwei AS DOUBLE) / CAST(depositGwei AS DOUBLE), + /* Round feePercentage to 0.01% steps */ + 4 + ) AS fee_percentage_fraction, + (feeGwei / 1e18) * price AS fee_usd, + feeGwei / 1e18 fee_token_amount, + '{{fee_token_symbol}}' AS fee_token_symbol, + {{weth}} AS fee_token_address, + -- Dex + project, + version, + token_pair, + project_contract_address, + -- User + user AS user, + botTrades.tx_hash, + evt_index, + IF(evt_index = highestEventIndex, true, false) AS is_last_trade_in_transaction +FROM + botTrades + JOIN highestEventIndexForEachTrade ON botTrades.tx_hash = highestEventIndexForEachTrade.tx_hash + LEFT JOIN botETHDeltas ON botTrades.tx_hash = botETHDeltas.tx_hash + LEFT JOIN {{ source('prices', 'usd') }} ON ( + blockchain = '{{blockchain}}' + AND contract_address = {{weth}} + AND minute = DATE_TRUNC('minute', block_time) + {% if is_incremental() %} + AND {{ incremental_predicate('minute') }} + {% endif %} + ) +ORDER BY + block_time DESC, + evt_index DESC \ No newline at end of file diff --git a/dbt_subprojects/dex/models/bot_trades/readyswap/ethereum/readyswap_ethereum_bot_trades.sql b/dbt_subprojects/dex/models/bot_trades/readyswap/ethereum/readyswap_ethereum_bot_trades.sql new file mode 100644 index 00000000000..bfa6169db5e --- /dev/null +++ b/dbt_subprojects/dex/models/bot_trades/readyswap/ethereum/readyswap_ethereum_bot_trades.sql @@ -0,0 +1,150 @@ +{{ + config( + alias='bot_trades', + schema='readyswap_ethereum', + partition_by=['block_month'], + materialized='incremental', + file_format='delta', + incremental_strategy='merge', + incremental_predicates=[ + incremental_predicate('DBT_INTERNAL_DEST.block_time') + ], + unique_key=['blockchain', 'tx_hash', 'evt_index'], + ) +}} + +{% set project_name = 'ReadySwap' %} +{% set project_start_date = '2023-05-12' %} +{% set blockchain = 'ethereum' %} +{% set bot_deployer_1 = '0xCf695491Dd1Afff04C50892dE0d758641e6D7Afd' %} +{% set fee_wallet_1 = '0x3d91e131Cc353018B4e95b7A5a475e8681fa6790' %} +{% set weth = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' %} +{% set fee_token_symbol = 'ETH' %} + +with + bot_contracts as ( + select address + from {{ source('ethereum', 'creation_traces') }} + where + ("from" = {{ bot_deployer_1 }}) + and block_time >= timestamp '{{project_start_date}}' + ), + bot_trades as ( + select + trades.block_time, + amount_usd, + if(token_sold_address = {{ weth }}, 'Buy', 'Sell') as type, + token_bought_amount, + token_bought_symbol, + token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_address, + project, + version, + token_pair, + project_contract_address, + tx_from as user, + tx_to as bot, + trades.tx_hash, + evt_index + from {{ source('dex', 'trades') }} as trades + join bot_contracts on trades.tx_to = bot_contracts.address + where + trades.blockchain = '{{blockchain}}' + {% if is_incremental() %} + and {{ incremental_predicate('trades.block_time') }} + {% else %} and trades.block_time >= timestamp '{{project_start_date}}' + {% endif %} + ), + highest_event_index_for_each_trade as ( + select tx_hash, max(evt_index) as highest_event_index + from bot_trades + group by tx_hash + ), + fee_payments as ( + select + tx_hash, + block_number, + sum(value) as fee_gwei + from {{ source('ethereum', 'traces') }} + where + to = {{ fee_wallet_1 }} + and value > 0 + {% if is_incremental() %} and {{ incremental_predicate('block_time') }} + {% else %} and block_time >= timestamp '{{project_start_date}}' + {% endif %} + group by tx_hash, block_number + ), + bot_eth_deposits as ( + select + tx_hash, + block_number, + sum(value) as deposit_gwei + from {{ source('ethereum', 'traces') }} + join bot_contracts on to = bot_contracts.address + where + {% if is_incremental() %} {{ incremental_predicate('block_time') }} + {% else %} block_time >= timestamp '{{project_start_date}}' + {% endif %} + and value > 0 + group by tx_hash, block_number + ), + bot_deposits_and_fee_payments as ( + select + coalesce(bot_eth_deposits.tx_hash, fee_payments.tx_hash) as tx_hash, + coalesce(bot_eth_deposits.block_number, fee_payments.block_number) as block_number, + coalesce(fee_gwei, cast(0 AS UINT256)) as fee_gwei, + coalesce(deposit_gwei, cast(0 AS UINT256)) as deposit_gwei + from fee_payments + full outer join bot_eth_deposits on fee_payments.tx_hash = bot_eth_deposits.tx_hash + ) +select + block_time, + date_trunc('day', bot_trades.block_time) as block_date, + date_trunc('month', bot_trades.block_time) as block_month, + '{{project_name}}' as bot, + block_number, + '{{blockchain}}' as blockchain, + -- Trade + amount_usd, + type, + token_bought_amount, + token_bought_symbol, + token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_address, + -- Fees + round( + cast(fee_gwei as double) / cast(deposit_gwei as double), + 4 -- Round feePercentage to 0.01% steps + ) as fee_percentage_fraction, + (fee_gwei / 1e18) * price as fee_usd, + fee_gwei / 1e18 fee_token_amount, + '{{fee_token_symbol}}' as fee_token_symbol, + {{ weth }} as fee_token_address, + -- Dex + project, + version, + token_pair, + project_contract_address, + -- User + user as user, + bot_trades.tx_hash, + evt_index, + if(evt_index = highest_event_index, true, false) as is_last_trade_in_transaction +from bot_trades +join + highest_event_index_for_each_trade + on bot_trades.tx_hash = highest_event_index_for_each_trade.tx_hash +left join bot_deposits_and_fee_payments on bot_trades.tx_hash = bot_deposits_and_fee_payments.tx_hash +left join + {{ source('prices', 'usd') }} + on ( + blockchain = '{{blockchain}}' + and contract_address = {{ weth }} + and minute = date_trunc('minute', block_time) + {% if is_incremental() %} and {{ incremental_predicate('minute') }} {% endif %} + ) +order by block_time desc, evt_index desc diff --git a/dbt_subprojects/dex/models/dex_info.sql b/dbt_subprojects/dex/models/dex_info.sql index d63b8308303..8f68ddf7469 100644 --- a/dbt_subprojects/dex/models/dex_info.sql +++ b/dbt_subprojects/dex/models/dex_info.sql @@ -185,4 +185,15 @@ FROM (VALUES , ('kaia_swap', 'KaiaSwap', 'Direct', 'KaiaSwap') , ('defi_kingdoms', 'DeFi Kingdoms', 'Direct', 'DeFiKingdoms') , ('hyperjump', 'HyperJump', 'Direct', 'Hyperjump_fi') + , ('infusion', 'Infusion', 'Direct', 'infusionfinance') + , ('stablebase', 'StableBase', 'Direct', 'stablebasefi') + , ('flashliquidity', 'Flashliquidity', 'Direct', 'flashliquidity') + , ('akronswap', 'Akronswap', 'Direct', 'AkronFinance') + , ('saddle_finance', 'Saddle Finance', 'Direct', 'saddlefinance') + , ('katana', 'Katana', 'Direct', 'AxieInfinity') + , ('jetswap', 'JetSwap', 'Direct', 'Jetfuelfinance') + , ('bridgers', 'Bridgers', 'Direct', 'Bridgersxyz') + , ('levinswap', 'Levinswap', 'Direct', 'levinswap') + , ('gravity_finance', 'GravityFinance', 'Direct', 'Gravity_Finance') + , ('fluid', 'Fluid DEX', 'Direct', '0xfluid') ) AS temp_table (project, name, marketplace_type, x_username) diff --git a/dbt_subprojects/dex/models/trades/_schema.yml b/dbt_subprojects/dex/models/trades/_schema.yml index af7849351df..cb10cfb6b1d 100644 --- a/dbt_subprojects/dex/models/trades/_schema.yml +++ b/dbt_subprojects/dex/models/trades/_schema.yml @@ -4,10 +4,10 @@ models: - name: dex_trades meta: docs_slug: /curated/trading/DEX/dex-trades - blockchain: arbitrum, avalanche_c, base, bnb, celo, ethereum, fantom, gnosis, kaia, optimism, polygon, scroll, zksync, linea, blast, sei + blockchain: arbitrum, avalanche_c, base, bnb, celo, ethereum, fantom, gnosis, kaia, optimism, polygon, scroll, zksync, linea, blast, sei, ronin sector: dex short_description: The `dex.trades` table captures detailed data on trades executed via decentralized exchanges (DEXs). This table contains a detailed breakdown of trade execution containing one or many trades per transaction. - contributors: 0xRob, hosuke, jeff-dude, tomfutago + contributors: 0xRob, hosuke, jeff-dude, tomfutago, viniabussafi config: tags: [ 'dex', 'trades'] description: '{{ doc("dex_trades_doc") }}' @@ -102,7 +102,7 @@ models: - name: dex_base_trades meta: - blockchain: arbitrum, avalanche_c, base, bnb, celo, ethereum, fantom, gnosis, kaia,optimism, polygon, scroll, zksync, linea, blast, sei + blockchain: arbitrum, avalanche_c, base, bnb, celo, ethereum, fantom, gnosis, kaia,optimism, polygon, scroll, zksync, linea, blast, sei, ronin sector: dex contributors: 0xRob, hosuke, jeff-dude, tomfutago, viniabussafi config: diff --git a/dbt_subprojects/dex/models/trades/base/_schema.yml b/dbt_subprojects/dex/models/trades/base/_schema.yml index a8010396e2a..fde1b6d7532 100644 --- a/dbt_subprojects/dex/models/trades/base/_schema.yml +++ b/dbt_subprojects/dex/models/trades/base/_schema.yml @@ -12,7 +12,7 @@ models: project: uniswap contributors: wuligy config: - tags: [ 'base', 'dex', 'trades', 'uniswap', 'v3' ] + tags: ["base", "dex", "trades", "uniswap", "v3"] description: "uniswap base v3 base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -24,7 +24,6 @@ models: filter: version: 3 - - name: aerodrome_base_base_trades meta: blockchain: base @@ -32,7 +31,7 @@ models: project: aerodrome contributors: msilb7, tomfutago, Henrystats config: - tags: [ 'base', 'dex', 'trades', 'aerodrome' ] + tags: ["base", "dex", "trades", "aerodrome"] description: aerodrome base trades data_tests: - dbt_utils.unique_combination_of_columns: @@ -42,6 +41,22 @@ models: - check_dex_base_trades_seed: seed_file: ref('aerodrome_base_base_trades_seed') + - name: stablebase_base_base_trades + meta: + blockchain: base + sector: dex + project: stablebase + contributors: principatel + config: + tags: ["base", "dex", "trades", "stablebase"] + description: stablebase base trades + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - evt_index + - check_dex_base_trades_seed: + seed_file: ref('stablebase_base_base_trades_seed') - name: sushiswap_v1_base_base_trades meta: @@ -50,7 +65,7 @@ models: project: sushiswap contributors: tomfutago config: - tags: [ 'base', 'dex', 'trades', 'sushiswap', 'v1' ] + tags: ["base", "dex", "trades", "sushiswap", "v1"] description: "sushiswap base v1 base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -62,7 +77,6 @@ models: filter: version: 1 - - name: sushiswap_v2_base_base_trades meta: blockchain: base @@ -70,7 +84,7 @@ models: project: sushiswap contributors: wuligy, tomfutago config: - tags: [ 'base', 'dex', 'trades', 'sushiswap', 'v2' ] + tags: ["base", "dex", "trades", "sushiswap", "v2"] description: "sushiswap base v2 base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -89,7 +103,7 @@ models: project: pancakeswap contributors: chef_seaweed, tomfutago config: - tags: [ 'base', 'dex', 'trades', 'pancakeswap', 'uniswap', 'v2' ] + tags: ["base", "dex", "trades", "pancakeswap", "uniswap", "v2"] description: "Pancakeswap Base v2 base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -108,7 +122,7 @@ models: project: balancer contributors: bizzyvinci, thetroyharris, tomfutago config: - tags: [ 'base', 'dex', 'trades', 'balancer' ] + tags: ["base", "dex", "trades", "balancer"] description: "Balancer v2 base base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -127,7 +141,7 @@ models: project: pancakeswap contributors: chef_seaweed, tomfutago config: - tags: [ 'base', 'dex', 'trades', 'pancakeswap', 'uniswap', 'v3' ] + tags: ["base", "dex", "trades", "pancakeswap", "uniswap", "v3"] description: "Pancakeswap Base v3 base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -146,7 +160,7 @@ models: project: dodo contributors: owen05, tomfutago config: - tags: [ 'base', 'dex', 'trades', 'dodo' ] + tags: ["base", "dex", "trades", "dodo"] description: "Dodo base base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -165,7 +179,7 @@ models: project: maverick contributors: get620v, tomfutago config: - tags: [ 'base', 'dex', 'trades', 'maverick' ] + tags: ["base", "dex", "trades", "maverick"] description: "Maverick Base base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -184,7 +198,7 @@ models: project: maverick contributors: get620v config: - tags: [ 'base', 'dex', 'trades', 'maverick' ] + tags: ["base", "dex", "trades", "maverick"] description: "Maverick Base base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -203,7 +217,7 @@ models: project: smardex contributors: Chain_L config: - tags: [ 'base', 'dex', 'trades', 'smardex' ] + tags: ["base", "dex", "trades", "smardex"] description: "smardex base trades on base" data_tests: - dbt_utils.unique_combination_of_columns: @@ -220,7 +234,7 @@ models: project: baseswap contributors: ARDev097 config: - tags: [ 'base', 'dex', 'trades', 'baseswap' ] + tags: ["base", "dex", "trades", "baseswap"] description: "baseswap base trades on base" data_tests: - dbt_utils.unique_combination_of_columns: @@ -239,7 +253,7 @@ models: project: baseswap contributors: chef_seaweed config: - tags: [ 'base', 'dex', 'trades', 'baseswap' ] + tags: ["base", "dex", "trades", "baseswap"] description: "baseswap base trades on base" data_tests: - dbt_utils.unique_combination_of_columns: @@ -258,7 +272,7 @@ models: project: dackieswap contributors: Chain_L config: - tags: [ 'base', 'dex', 'trades', 'dackieswap' ] + tags: ["base", "dex", "trades", "dackieswap"] description: "dackieswap base trades on base" data_tests: - dbt_utils.unique_combination_of_columns: @@ -275,7 +289,7 @@ models: project: scale contributors: ARDev097 config: - tags: [ 'base', 'dex', 'trades', 'scale' ] + tags: ["base", "dex", "trades", "scale"] description: "scale base trades on base" data_tests: - dbt_utils.unique_combination_of_columns: @@ -292,7 +306,7 @@ models: project: rubicon contributors: denver, tomfutago config: - tags: [ 'base', 'dex', 'trades', 'rubicon' ] + tags: ["base", "dex", "trades", "rubicon"] description: "rubicon base base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -302,7 +316,6 @@ models: - check_dex_base_trades_seed: seed_file: ref('rubicon_base_base_trades_seed') - - name: kyberswap_base_base_trades meta: blockchain: base @@ -310,7 +323,7 @@ models: project: kyberswap contributors: lldao config: - tags: [ 'base', 'dex', 'trades', 'kyberswap' ] + tags: ["base", "dex", "trades", "kyberswap"] description: "kyberswap base base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -322,7 +335,6 @@ models: filter: version: 2 - - name: woofi_base_base_trades meta: blockchain: base @@ -330,7 +342,7 @@ models: project: woofi contributors: lldao config: - tags: [ 'base', 'dex', 'trades', 'woofi' ] + tags: ["base", "dex", "trades", "woofi"] description: "woofi base base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -342,7 +354,6 @@ models: filter: version: 2 - - name: velocimeter_v2_base_base_trades meta: blockchain: base @@ -350,7 +361,7 @@ models: project: velocimeter_v2 contributors: lldao config: - tags: [ 'base', 'dex', 'trades', 'velocimeter_v2' ] + tags: ["base", "dex", "trades", "velocimeter_v2"] description: "velocimeter_v2 base base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -362,7 +373,6 @@ models: filter: version: 2 - - name: moonbase_base_base_trades meta: blockchain: base @@ -370,7 +380,7 @@ models: project: moonbase contributors: LLDAO config: - tags: [ 'base', 'dex', 'trades', 'moonbase' ] + tags: ["base", "dex", "trades", "moonbase"] description: "moonbase base base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -382,7 +392,6 @@ models: filter: version: 1 - - name: sobal_base_base_trades meta: blockchain: base @@ -390,7 +399,7 @@ models: project: sobal contributors: LLDAO config: - tags: [ 'base', 'dex', 'trades', 'sobal' ] + tags: ["base", "dex", "trades", "sobal"] description: "sobal base base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -402,7 +411,6 @@ models: filter: version: 1 - - name: plantbaseswap_base_base_trades meta: blockchain: base @@ -410,7 +418,7 @@ models: project: plantbaseswap contributors: LLDAO config: - tags: [ 'base', 'dex', 'trades', 'plantbaseswap' ] + tags: ["base", "dex", "trades", "plantbaseswap"] description: "plantbaseswap base base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -422,7 +430,6 @@ models: filter: version: 2 - - name: derpdex_base_base_trades meta: blockchain: base @@ -430,7 +437,7 @@ models: project: derpdex contributors: LLDAO config: - tags: [ 'base', 'dex', 'trades', 'derpdex' ] + tags: ["base", "dex", "trades", "derpdex"] description: "derpdex base base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -442,8 +449,6 @@ models: filter: version: 1 - - - name: torus_base_base_trades meta: blockchain: base @@ -451,7 +456,7 @@ models: project: torus contributors: LLDAO config: - tags: [ 'base', 'dex', 'trades', 'torus', 'v1' ] + tags: ["base", "dex", "trades", "torus", "v1"] description: "torus base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -461,7 +466,6 @@ models: - check_dex_base_trades_seed: seed_file: ref('torus_base_base_trades_seed') - - name: throne_exchange_v2_base_base_trades meta: blockchain: base @@ -469,7 +473,7 @@ models: project: throne_exchange contributors: LLDAO config: - tags: [ 'base', 'dex', 'trades', 'throne_exchange' ] + tags: ["base", "dex", "trades", "throne_exchange"] description: "throne_exchange base base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -481,7 +485,6 @@ models: filter: version: 2 - - name: sharkswap_base_base_trades meta: blockchain: base @@ -489,7 +492,7 @@ models: project: sharkswap contributors: LLDAO config: - tags: [ 'base', 'dex', 'trades', 'sharkswap' ] + tags: ["base", "dex", "trades", "sharkswap"] description: "sharkswap base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -501,7 +504,6 @@ models: filter: version: 1 - - name: throne_exchange_v3_base_base_trades meta: blockchain: base @@ -509,7 +511,7 @@ models: project: throne_exchange contributors: LLDAO config: - tags: [ 'base', 'dex', 'trades', 'throne_exchange' ] + tags: ["base", "dex", "trades", "throne_exchange"] description: "throne_exchange base base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -521,7 +523,6 @@ models: filter: version: 3 - - name: horizondex_base_base_trades meta: blockchain: base @@ -529,7 +530,7 @@ models: project: horizondex contributors: p2c2e config: - tags: [ 'base', 'dex', 'trades', 'horizondex' ] + tags: ["base", "dex", "trades", "horizondex"] description: "horizondex dex swaps on base chain" data_tests: - dbt_utils.unique_combination_of_columns: @@ -541,7 +542,6 @@ models: filter: version: 1 - - name: citadelswap_base_base_trades meta: blockchain: base @@ -549,7 +549,7 @@ models: project: citadelswap contributors: LLDAO config: - tags: [ 'base', 'dex', 'trades', 'citadelswap' ] + tags: ["base", "dex", "trades", "citadelswap"] description: "citadelswap base base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -561,7 +561,6 @@ models: filter: version: 1 - - name: autotronic_base_base_trades meta: blockchain: base @@ -569,7 +568,7 @@ models: project: autotronic contributors: LLDAO config: - tags: [ 'base', 'dex', 'trades', 'autotronic' ] + tags: ["base", "dex", "trades", "autotronic"] description: "autotronic base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -581,7 +580,6 @@ models: filter: version: 1 - - name: uniswap_v2_base_base_trades meta: blockchain: base @@ -589,7 +587,7 @@ models: project: uniswap contributors: Henrystats config: - tags: [ 'base', 'dex', 'trades', 'uniswap', 'v2' ] + tags: ["base", "dex", "trades", "uniswap", "v2"] description: "uniswap base v2 base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -601,7 +599,6 @@ models: filter: version: 2 - - name: soswap_base_base_trades meta: blockchain: base @@ -609,7 +606,7 @@ models: project: soswap contributors: archie config: - tags: [ 'base', 'dex', 'trades', 'soswap' ] + tags: ["base", "dex", "trades", "soswap"] description: "soswap base base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -621,7 +618,6 @@ models: filter: version: 1 - - name: elk_finance_base_base_trades meta: blockchain: base @@ -629,7 +625,7 @@ models: project: elk_finance contributors: archie config: - tags: [ 'base', 'dex', 'trades', 'elk_finance' ] + tags: ["base", "dex", "trades", "elk_finance"] description: "elk_finance base base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -641,7 +637,6 @@ models: filter: version: 1 - - name: oasisswap_base_base_trades meta: blockchain: base @@ -649,7 +644,7 @@ models: project: oasisswap contributors: archie config: - tags: [ 'base', 'dex', 'trades', 'oasisswap' ] + tags: ["base", "dex", "trades", "oasisswap"] description: "oasisswap base base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -661,7 +656,6 @@ models: filter: version: 1 - - name: leetswap_v2_base_base_trades meta: blockchain: base @@ -669,7 +663,7 @@ models: project: leetswap_v2 contributors: archie config: - tags: [ 'base', 'dex', 'trades', 'leetswap' ] + tags: ["base", "dex", "trades", "leetswap"] description: "leetswap_v2 base base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -688,7 +682,7 @@ models: project: openocean contributors: Henrystats, tomfutago config: - tags: [ 'base', 'dex', 'trades', 'openocean' ] + tags: ["base", "dex", "trades", "openocean"] description: "openocean base base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -705,7 +699,7 @@ models: project: rocketswap contributors: intensodefi config: - tags: [ 'base', 'dex', 'trades', 'rocketswap' ] + tags: ["base", "dex", "trades", "rocketswap"] description: "rocketswap base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -724,7 +718,7 @@ models: project: wombat_exchange contributors: Henrystats config: - tags: [ 'base', 'dex', 'trades', 'wombat_exchange' ] + tags: ["base", "dex", "trades", "wombat_exchange"] description: "wombat exchange base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -743,7 +737,7 @@ models: project: icecreamswap contributors: sofiat config: - tags: [ 'base', 'dex', 'trades', 'icecreamswap' ] + tags: ["base", "dex", "trades", "icecreamswap"] description: "icecreamswap base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -760,7 +754,7 @@ models: project: alienbase contributors: intensodefi config: - tags: [ 'base', 'dex', 'trades', 'alienbase' ] + tags: ["base", "dex", "trades", "alienbase"] description: "alienbase base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -779,7 +773,7 @@ models: project: swapbased contributors: intensodefi config: - tags: [ 'base', 'dex', 'trades', 'swapbased' ] + tags: ["base", "dex", "trades", "swapbased"] description: "swapbased base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -798,7 +792,7 @@ models: project: gridex contributors: sofiat config: - tags: [ 'base', 'dex', 'trades', 'gridex' ] + tags: ["base", "dex", "trades", "gridex"] description: "gridex base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -817,7 +811,7 @@ models: project: baseswap contributors: sofiat config: - tags: [ 'base', 'dex', 'trades', 'baseswap' ] + tags: ["base", "dex", "trades", "baseswap"] description: "baseswap base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -836,7 +830,7 @@ models: project: synthswap contributors: sofiat config: - tags: [ 'base', 'dex', 'trades', 'synthswap' ] + tags: ["base", "dex", "trades", "synthswap"] description: "synthswap base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -855,7 +849,7 @@ models: project: solidly contributors: sofiat config: - tags: [ 'base', 'dex', 'trades', 'solidly' ] + tags: ["base", "dex", "trades", "solidly"] description: "solidly base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -874,7 +868,7 @@ models: project: energon contributors: sofiat config: - tags: [ 'base', 'dex', 'trades', 'energon' ] + tags: ["base", "dex", "trades", "energon"] description: "energon base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -893,7 +887,7 @@ models: project: voltswap contributors: sofiat config: - tags: [ 'base', 'dex', 'trades', 'voltswap' ] + tags: ["base", "dex", "trades", "voltswap"] description: "voltswap base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -912,7 +906,7 @@ models: project: crescentswap contributors: sofiat config: - tags: [ 'base', 'dex', 'trades', 'crescentswap' ] + tags: ["base", "dex", "trades", "crescentswap"] description: "crescentswap base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -931,7 +925,7 @@ models: project: baso_finance contributors: sofiat config: - tags: [ 'base', 'dex', 'trades', 'baso_finance' ] + tags: ["base", "dex", "trades", "baso_finance"] description: "baso finance base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -948,7 +942,7 @@ models: project: clipper contributors: amalashkevich config: - tags: [ 'base', 'dex', 'trades', 'clipper' ] + tags: ["base", "dex", "trades", "clipper"] description: "clipper base base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -968,7 +962,7 @@ models: project: swaap contributors: borelien config: - tags: [ 'base', 'dex', 'trades', 'swaap', 'v2'] + tags: ["base", "dex", "trades", "swaap", "v2"] description: "swaap v2 base base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -987,7 +981,7 @@ models: project: xchange contributors: mike-x7f config: - tags: [ 'base', 'dex', 'trades', 'xchange' ] + tags: ["base", "dex", "trades", "xchange"] description: "xchange base base trades" data_tests: - dbt_utils.unique_combination_of_columns: @@ -996,3 +990,54 @@ models: - evt_index - check_dex_base_trades_seed: seed_file: ref('xchange_base_base_trades_seed') + + - name: infusion_base_base_trades + meta: + blockchain: base + sector: dex + project: infusion + contributors: jason + config: + tags: [ 'base', 'dex', 'trades', 'infusion' ] + description: "infusion base base trades" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - evt_index + - check_dex_base_trades_seed: + seed_file: ref('infusion_base_base_trades_seed') + + - name: flashliquidity_base_base_trades + meta: + blockchain: base + sector: dex + project: flashliquidity + contributors: archie + config: + tags: [ 'base', 'dex', 'trades', 'flashliquidity' ] + description: "flashliquidity base base trades" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - evt_index + - check_dex_base_trades_seed: + seed_file: ref('flashliquidity_base_base_trades_seed') + + - name: akronswap_base_base_trades + meta: + blockchain: base + sector: dex + project: akronswap + contributors: archie + config: + tags: [ 'base', 'dex', 'trades', 'akronswap' ] + description: "akronswap base base trades" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - evt_index + - check_dex_base_trades_seed: + seed_file: ref('akronswap_base_base_trades_seed') diff --git a/dbt_subprojects/dex/models/trades/base/dex_base_base_trades.sql b/dbt_subprojects/dex/models/trades/base/dex_base_base_trades.sql index 742449afaea..fb04c901264 100644 --- a/dbt_subprojects/dex/models/trades/base/dex_base_base_trades.sql +++ b/dbt_subprojects/dex/models/trades/base/dex_base_base_trades.sql @@ -9,6 +9,7 @@ ref('uniswap_v3_base_base_trades') , ref('sushiswap_v1_base_base_trades') , ref('sushiswap_v2_base_base_trades') + , ref('stablebase_base_base_trades') , ref('aerodrome_base_base_trades') , ref('pancakeswap_v2_base_base_trades') , ref('pancakeswap_v3_base_base_trades') @@ -50,6 +51,9 @@ , ref('solidly_v3_base_base_trades') , ref('swaap_v2_base_base_trades') , ref('xchange_base_base_trades') + , ref('infusion_base_base_trades') + , ref('flashliquidity_base_base_trades') + , ref('akronswap_base_base_trades') ] %} WITH base_union AS ( diff --git a/dbt_subprojects/dex/models/trades/base/platforms/akronswap_base_base_trades.sql b/dbt_subprojects/dex/models/trades/base/platforms/akronswap_base_base_trades.sql new file mode 100644 index 00000000000..ef4641d1e2c --- /dev/null +++ b/dbt_subprojects/dex/models/trades/base/platforms/akronswap_base_base_trades.sql @@ -0,0 +1,21 @@ +{{ + config( + schema = 'akronswap_base', + alias = 'base_trades', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['tx_hash', 'evt_index'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] + ) +}} + +{{ + uniswap_compatible_v2_trades( + blockchain = 'base', + project = 'akronswap', + version = '2', + Pair_evt_Swap = source('akronswap_base', 'UniswapV2Pair_evt_Swap'), + Factory_evt_PairCreated = source('akronswap_base', 'UniswapV2Factory_evt_PairCreated') + ) +}} \ No newline at end of file diff --git a/dbt_subprojects/dex/models/trades/base/platforms/flashliquidity_base_base_trades.sql b/dbt_subprojects/dex/models/trades/base/platforms/flashliquidity_base_base_trades.sql new file mode 100644 index 00000000000..98c4ae25d82 --- /dev/null +++ b/dbt_subprojects/dex/models/trades/base/platforms/flashliquidity_base_base_trades.sql @@ -0,0 +1,21 @@ +{{ + config( + schema = 'flashliquidity_base', + alias = 'base_trades', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['tx_hash', 'evt_index'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] + ) +}} + +{{ + uniswap_compatible_v2_trades( + blockchain = 'base', + project = 'flashliquidity', + version = '1', + Pair_evt_Swap = source('flashliquidity_base', 'FlashLiquidityPair_evt_Swap'), + Factory_evt_PairCreated = source('flashliquidity_base', 'FlashLiquidityFactory_evt_PairCreated') + ) +}} diff --git a/dbt_subprojects/dex/models/trades/base/platforms/infusion_base_base_trades.sql b/dbt_subprojects/dex/models/trades/base/platforms/infusion_base_base_trades.sql new file mode 100644 index 00000000000..e8d326a8c0b --- /dev/null +++ b/dbt_subprojects/dex/models/trades/base/platforms/infusion_base_base_trades.sql @@ -0,0 +1,20 @@ +{{ config( + schema = 'infusion_base' + , alias = 'base_trades' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['tx_hash', 'evt_index'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] + ) +}} + +{{ + uniswap_compatible_v2_trades( + blockchain = 'base' + , project = 'infusion' + , version = '1' + , Pair_evt_Swap = source('infusion_base', 'Pair_evt_Swap') + , Factory_evt_PairCreated = source('infusion_base', 'PairFactory_evt_PairCreated') + ) +}} \ No newline at end of file diff --git a/dbt_subprojects/dex/models/trades/base/platforms/stablebase_base_base_trades.sql b/dbt_subprojects/dex/models/trades/base/platforms/stablebase_base_base_trades.sql new file mode 100644 index 00000000000..f2c2df02aef --- /dev/null +++ b/dbt_subprojects/dex/models/trades/base/platforms/stablebase_base_base_trades.sql @@ -0,0 +1,50 @@ +{{ config( + schema = 'stablebase_base', + alias = 'base_trades', + partition_by = ['block_month'], + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['block_date', 'blockchain', 'project', 'version', 'tx_hash', 'evt_index'] +) }} + +WITH token_swaps AS ( + SELECT + evt_block_number AS block_number, + CAST(evt_block_time AS timestamp(3) with time zone) AS block_time, + evt_tx_from AS maker, + evt_tx_to AS taker, + tokensSold AS token_sold_amount_raw, + tokensBought AS token_bought_amount_raw, + CAST(soldId AS varbinary) AS token_sold_address, + CAST(boughtId AS varbinary) AS token_bought_address, + contract_address AS project_contract_address, + evt_tx_hash AS tx_hash, + evt_index AS evt_index + FROM + {{ source('stablebase_base', 'SwapFlashLoan_evt_TokenSwap') }} + {% if is_incremental() %} + WHERE + {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +SELECT + 'base' AS blockchain, + 'stablebase' AS project, + '1' AS version, + CAST(date_trunc('month', token_swaps.block_time) AS date) AS block_month, + CAST(date_trunc('day', token_swaps.block_time) AS date) AS block_date, + token_swaps.block_time, + token_swaps.block_number, + token_swaps.token_sold_amount_raw, + token_swaps.token_bought_amount_raw, + token_swaps.token_sold_address, + token_swaps.token_bought_address, + token_swaps.maker, + token_swaps.taker, + token_swaps.project_contract_address, + token_swaps.tx_hash, + token_swaps.evt_index +FROM + token_swaps diff --git a/dbt_subprojects/dex/models/trades/dex_base_trades.sql b/dbt_subprojects/dex/models/trades/dex_base_trades.sql index 944f36da985..6a5a68bb734 100644 --- a/dbt_subprojects/dex/models/trades/dex_base_trades.sql +++ b/dbt_subprojects/dex/models/trades/dex_base_trades.sql @@ -26,6 +26,7 @@ , ref('dex_nova_base_trades') , ref('dex_optimism_base_trades') , ref('dex_polygon_base_trades') + , ref('dex_ronin_base_trades') , ref('dex_scroll_base_trades') , ref('dex_sei_base_trades') , ref('dex_worldchain_base_trades') diff --git a/dbt_subprojects/dex/models/trades/dex_trades.sql b/dbt_subprojects/dex/models/trades/dex_trades.sql index 0452bb2d1db..203df9a845d 100644 --- a/dbt_subprojects/dex/models/trades/dex_trades.sql +++ b/dbt_subprojects/dex/models/trades/dex_trades.sql @@ -23,6 +23,7 @@ , "nova" , "optimism" , "polygon" + , "ronin" , "scroll" , "sei" , "zkevm" @@ -31,7 +32,7 @@ ]\', "sector", "dex", - \'["hosuke", "0xrob", "jeff-dude", "tomfutago"]\') }}') + \'["hosuke", "0xrob", "jeff-dude", "tomfutago", "viniabussafi"]\') }}') }} -- keep existing dbt lineages for the following projects, as the team built themselves and use the spells throughout the entire lineage @@ -52,11 +53,21 @@ WITH curve AS ( ) }} ) +, balancer_v3 AS ( + -- due to Balancer V3 having trades between ERC4626 tokens, which won't be priced on prices.usd, enrich separately + {{ + enrich_balancer_v3_dex_trades( + base_trades = ref('dex_base_trades') + , filter = "(project = 'balancer' AND version = '3')" + , tokens_erc20_model = source('tokens', 'erc20') + ) + }} +) , dexs AS ( {{ enrich_dex_trades( base_trades = ref('dex_base_trades') - , filter = "project != 'curve'" + , filter = "project != 'curve' AND NOT (project = 'balancer' AND version = '3')" , tokens_erc20_model = source('tokens', 'erc20') ) }} @@ -105,6 +116,7 @@ WITH curve AS ( 'curve' , 'as_is_dexs' , 'dexs' + , 'balancer_v3' ] %} diff --git a/dbt_subprojects/dex/models/trades/ethereum/_schema.yml b/dbt_subprojects/dex/models/trades/ethereum/_schema.yml index aa463001637..5b33a0992c0 100644 --- a/dbt_subprojects/dex/models/trades/ethereum/_schema.yml +++ b/dbt_subprojects/dex/models/trades/ethereum/_schema.yml @@ -251,7 +251,7 @@ models: blockchain: ethereum sector: dex project: balancer - contributors: bizzyvinci, thetroyharris, tomfutago + contributors: bizzyvinci, thetroyharris, tomfutago, viniabussafi config: tags: ["ethereum", "dex", "trades", "balancer"] description: "Balancer v2 ethereum base trades" @@ -265,6 +265,25 @@ models: filter: version: 2 + - name: balancer_v3_ethereum_base_trades + meta: + blockchain: ethereum + sector: dex + project: balancer + contributors: viniabussafi + config: + tags: ["ethereum", "dex", "trades", "balancer"] + description: "Balancer v3 ethereum base trades" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - evt_index + - check_dex_base_trades_seed: + seed_file: ref('balancer_ethereum_base_trades_seed') + filter: + version: 3 + - name: fraxswap_ethereum_base_trades meta: blockchain: ethereum @@ -626,3 +645,22 @@ models: combination_of_columns: - tx_hash - evt_index + + - name: fluid_v1_ethereum_base_trades + meta: + blockchain: ethereum + sector: dex + project: fluid + contributors: maybeYonas, pyor_xyz + config: + tags: ["ethereum", "dex", "trades", "fluid"] + description: "fluid dex ethereum base trades" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - evt_index + - check_dex_base_trades_seed: + seed_file: ref('fluid_ethereum_base_trades_seed') + filter: + version: 1 diff --git a/dbt_subprojects/dex/models/trades/ethereum/dex_ethereum_base_trades.sql b/dbt_subprojects/dex/models/trades/ethereum/dex_ethereum_base_trades.sql index 3a121900231..7dc42461e0d 100644 --- a/dbt_subprojects/dex/models/trades/ethereum/dex_ethereum_base_trades.sql +++ b/dbt_subprojects/dex/models/trades/ethereum/dex_ethereum_base_trades.sql @@ -20,6 +20,7 @@ , ref('shibaswap_v1_ethereum_base_trades') , ref('balancer_v1_ethereum_base_trades') , ref('balancer_v2_ethereum_base_trades') + , ref('balancer_v3_ethereum_base_trades') , ref('fraxswap_ethereum_base_trades') , ref('bancor_ethereum_base_trades') , ref('verse_dex_ethereum_base_trades') @@ -39,6 +40,7 @@ , ref('swaap_v2_ethereum_base_trades') , ref('valantis_hot_ethereum_base_trades') , ref('xchange_v2_ethereum_base_trades') + , ref('fluid_v1_ethereum_base_trades') ] %} WITH base_union AS ( diff --git a/dbt_subprojects/dex/models/trades/ethereum/platforms/balancer_v3_ethereum_base_trades.sql b/dbt_subprojects/dex/models/trades/ethereum/platforms/balancer_v3_ethereum_base_trades.sql new file mode 100644 index 00000000000..46aff728ebd --- /dev/null +++ b/dbt_subprojects/dex/models/trades/ethereum/platforms/balancer_v3_ethereum_base_trades.sql @@ -0,0 +1,19 @@ +{{ + config( + schema = 'balancer_v3_ethereum', + alias = 'base_trades', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['tx_hash', 'evt_index'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] + ) +}} + +{{ + balancer_compatible_v3_trades( + blockchain = 'ethereum', + project = 'balancer', + version = '3' + ) +}} diff --git a/dbt_subprojects/dex/models/trades/ethereum/platforms/fluid_v1_ethereum_base_trades.sql b/dbt_subprojects/dex/models/trades/ethereum/platforms/fluid_v1_ethereum_base_trades.sql new file mode 100644 index 00000000000..2c6008d451b --- /dev/null +++ b/dbt_subprojects/dex/models/trades/ethereum/platforms/fluid_v1_ethereum_base_trades.sql @@ -0,0 +1,60 @@ +{{ + config( + schema = 'fluid_v1_ethereum', + alias = 'base_trades', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['tx_hash', 'evt_index'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] + ) +}} + +with +decoded_events as ( + select + '1' as version, + t.evt_block_number as block_number, + t.evt_block_time as block_time, + t.to as taker, + cast(null as varbinary) as maker, + t.amountOut as token_bought_amount_raw, + t.amountIn as token_sold_amount_raw, + case when swap0to1 + then p.borrow_token + else p.supply_token + end as token_bought_address, + case when not(swap0to1) + then p.borrow_token + else p.supply_token + end as token_sold_address, + t.contract_address as project_contract_address, + t.evt_tx_hash as tx_hash, + t.evt_index + from {{ source('fluid_ethereum', 'FluidDexT1_evt_Swap') }} t + inner join {{ ref('fluid_v1_ethereum_pools') }} p + on t.contract_address = p.dex + {% if is_incremental() %} + where {{ incremental_predicate('t.evt_block_time') }} + {% endif %} +) + + +SELECT + 'ethereum' as blockchain, + 'fluid' as project, + dexs.version, + cast(date_trunc('month', dexs.block_time) as date) as block_month, + cast(date_trunc('day', dexs.block_time) as date) as block_date, + dexs.block_time, + dexs.block_number, + dexs.token_bought_amount_raw, + dexs.token_sold_amount_raw, + dexs.token_bought_address, + dexs.token_sold_address, + dexs.taker, + dexs.maker, + dexs.project_contract_address, + dexs.tx_hash, + dexs.evt_index +FROM decoded_events dexs diff --git a/dbt_subprojects/dex/models/trades/gnosis/_schema.yml b/dbt_subprojects/dex/models/trades/gnosis/_schema.yml index 71d0b3551f1..2dee59ac657 100644 --- a/dbt_subprojects/dex/models/trades/gnosis/_schema.yml +++ b/dbt_subprojects/dex/models/trades/gnosis/_schema.yml @@ -48,7 +48,7 @@ models: blockchain: gnosis sector: dex project: balancer - contributors: bizzyvinci, thetroyharris, tomfutago + contributors: bizzyvinci, thetroyharris, tomfutago, viniabussafi config: tags: [ 'gnosis', 'dex', 'trades', 'balancer' ] description: "Balancer v2 gnosis base trades" @@ -62,6 +62,25 @@ models: filter: version: 2 + - name: balancer_v3_gnosis_base_trades + meta: + blockchain: gnosis + sector: dex + project: balancer + contributors: viniabussafi + config: + tags: [ 'gnosis', 'dex', 'trades', 'balancer' ] + description: "Balancer v3 gnosis base trades" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - evt_index + - check_dex_base_trades_seed: + seed_file: ref('balancer_gnosis_base_trades_seed') + filter: + version: 3 + - name: honeyswap_v2_gnosis_base_trades meta: blockchain: gnosis @@ -80,3 +99,37 @@ models: seed_file: ref('honeyswap_gnosis_base_trades_seed') filter: version: 2 + + - name: elk_finance_gnosis_base_trades + meta: + blockchain: gnosis + sector: dex + project: elk_finance + contributors: blanchemaria6 + config: + tags: ['gnosis', 'dex', 'trades', 'elk_finance'] + description: "elk finance gnosis base trades" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - evt_index + - check_dex_base_trades_seed: + seed_file: ref('elk_finance_gnosis_base_trades_seed') + + - name: levinswap_gnosis_base_trades + meta: + blockchain: gnosis + sector: dex + project: levinswap + contributors: intensodefi + config: + tags: ['gnosis', 'dex', 'trades', 'levinswap'] + description: "levinswap gnosis base trades" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - evt_index + - check_dex_base_trades_seed: + seed_file: ref('levinswap_gnosis_base_trades_seed') diff --git a/dbt_subprojects/dex/models/trades/gnosis/dex_gnosis_base_trades.sql b/dbt_subprojects/dex/models/trades/gnosis/dex_gnosis_base_trades.sql index 1803ccbcca8..599b6cdceb4 100644 --- a/dbt_subprojects/dex/models/trades/gnosis/dex_gnosis_base_trades.sql +++ b/dbt_subprojects/dex/models/trades/gnosis/dex_gnosis_base_trades.sql @@ -9,7 +9,10 @@ ref('sushiswap_v1_gnosis_base_trades') , ref('sushiswap_v2_gnosis_base_trades') , ref('balancer_v2_gnosis_base_trades') + , ref('balancer_v3_gnosis_base_trades') , ref('honeyswap_v2_gnosis_base_trades') + , ref('elk_finance_gnosis_base_trades') + , ref('levinswap_gnosis_base_trades') ] %} WITH base_union AS ( @@ -48,4 +51,4 @@ WITH base_union AS ( , blockchain = 'gnosis' , columns = ['from', 'to', 'index'] ) -}} \ No newline at end of file +}} diff --git a/dbt_subprojects/dex/models/trades/gnosis/platforms/balancer_v3_gnosis_base_trades.sql b/dbt_subprojects/dex/models/trades/gnosis/platforms/balancer_v3_gnosis_base_trades.sql new file mode 100644 index 00000000000..9e78c0be294 --- /dev/null +++ b/dbt_subprojects/dex/models/trades/gnosis/platforms/balancer_v3_gnosis_base_trades.sql @@ -0,0 +1,19 @@ +{{ + config( + schema = 'balancer_v3_gnosis', + alias = 'base_trades', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['tx_hash', 'evt_index'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] + ) +}} + +{{ + balancer_compatible_v3_trades( + blockchain = 'gnosis', + project = 'balancer', + version = '3' + ) +}} diff --git a/dbt_subprojects/dex/models/trades/gnosis/platforms/elk_finance_gnosis_base_trades.sql b/dbt_subprojects/dex/models/trades/gnosis/platforms/elk_finance_gnosis_base_trades.sql new file mode 100644 index 00000000000..be4724a9984 --- /dev/null +++ b/dbt_subprojects/dex/models/trades/gnosis/platforms/elk_finance_gnosis_base_trades.sql @@ -0,0 +1,21 @@ +{{ + config( + schema = 'elk_finance_gnosis', + alias = 'base_trades', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['tx_hash', 'evt_index'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] + ) +}} + +{{ + uniswap_compatible_v2_trades( + blockchain = 'gnosis', + project = 'elk_finance', + version = '1', + Pair_evt_Swap = source('elk_finance_gnosis', 'ElkPair_evt_Swap'), + Factory_evt_PairCreated = source('elk_finance_gnosis', 'ElkFactory_evt_PairCreated') + ) +}} diff --git a/dbt_subprojects/dex/models/trades/gnosis/platforms/levinswap_gnosis_base_trades.sql b/dbt_subprojects/dex/models/trades/gnosis/platforms/levinswap_gnosis_base_trades.sql new file mode 100644 index 00000000000..48b6edd32f9 --- /dev/null +++ b/dbt_subprojects/dex/models/trades/gnosis/platforms/levinswap_gnosis_base_trades.sql @@ -0,0 +1,21 @@ +{{ + config( + schema = 'levinswap_gnosis', + alias = 'base_trades', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['tx_hash', 'evt_index'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] + ) +}} + +{{ + uniswap_compatible_v2_trades( + blockchain = 'gnosis', + project = 'levinswap', + version = '1', + Pair_evt_Swap = source('levinswap_gnosis', 'UniswapV2Pair_evt_Swap'), + Factory_evt_PairCreated = source('levinswap_gnosis', 'UniswapV2Factory_evt_PairCreated') + ) +}} diff --git a/dbt_subprojects/dex/models/trades/optimism/_schema.yml b/dbt_subprojects/dex/models/trades/optimism/_schema.yml index 031f300b0dc..de83c8b4136 100644 --- a/dbt_subprojects/dex/models/trades/optimism/_schema.yml +++ b/dbt_subprojects/dex/models/trades/optimism/_schema.yml @@ -568,3 +568,37 @@ models: seed_file: ref('swaap_optimism_base_trades_seed') filter: version: 2 + + - name: saddle_finance_optimism_base_trades + meta: + blockchain: optimism + sector: dex + project: saddle_finance + contributors: princi + config: + tags: [ 'optimism', 'dex', 'trades', 'saddle_finance'] + description: "saddle finance optimism base trades" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - evt_index + - check_dex_base_trades_seed: + seed_file: ref('saddle_finance_optimism_base_trades_seed') + + - name: bridgers_optimism_base_trades + meta: + blockchain: optimism + sector: dex + project: bridgers + contributors: princi + config: + tags: [ 'optimism', 'dex', 'trades', 'bridgers'] + description: "bridgers optimism base trades" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - evt_index + - check_dex_base_trades_seed: + seed_file: ref('bridgers_optimism_base_trades_seed') \ No newline at end of file diff --git a/dbt_subprojects/dex/models/trades/optimism/dex_optimism_base_trades.sql b/dbt_subprojects/dex/models/trades/optimism/dex_optimism_base_trades.sql index f81d356fac8..65342178024 100644 --- a/dbt_subprojects/dex/models/trades/optimism/dex_optimism_base_trades.sql +++ b/dbt_subprojects/dex/models/trades/optimism/dex_optimism_base_trades.sql @@ -35,6 +35,8 @@ , ref('elk_finance_optimism_base_trades') , ref('fraxswap_optimism_base_trades') , ref('swaap_v2_optimism_base_trades') + , ref('saddle_finance_optimism_base_trades') + , ref('bridgers_optimism_base_trades') ] %} WITH base_union AS ( diff --git a/dbt_subprojects/dex/models/trades/optimism/platforms/bridgers_optimism_base_trades.sql b/dbt_subprojects/dex/models/trades/optimism/platforms/bridgers_optimism_base_trades.sql new file mode 100644 index 00000000000..d5a8668a166 --- /dev/null +++ b/dbt_subprojects/dex/models/trades/optimism/platforms/bridgers_optimism_base_trades.sql @@ -0,0 +1,50 @@ +{{ config( + schema = 'bridgers_optimism', + alias = 'base_trades', + partition_by = ['block_month'], + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['tx_hash', 'evt_index'] +) }} + +WITH token_swaps AS ( + SELECT + evt_block_number AS block_number, + CAST(evt_block_time AS timestamp(3) with time zone) AS block_time, + evt_tx_from AS maker, + evt_tx_to AS taker, + fromAmount AS token_sold_amount_raw, + minReturnAmount AS token_bought_amount_raw, + CAST(sender AS varbinary) AS token_sold_address, + CAST(destination AS varbinary) AS token_bought_address, + CAST(contract_address AS varbinary) AS project_contract_address, + evt_tx_hash AS tx_hash, + evt_index AS evt_index + FROM + {{ source('bridgers_optimism', 'Bridgers_evt_Swap') }} + {% if is_incremental() %} + WHERE + {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +SELECT + 'optimism' AS blockchain, + 'bridgers' AS project, + '1' AS version, + CAST(date_trunc('month', token_swaps.block_time) AS date) AS block_month, + CAST(date_trunc('day', token_swaps.block_time) AS date) AS block_date, + token_swaps.block_time, + token_swaps.block_number, + token_swaps.token_sold_amount_raw, + token_swaps.token_bought_amount_raw, + token_swaps.token_sold_address, + token_swaps.token_bought_address, + token_swaps.maker, + token_swaps.taker, + token_swaps.project_contract_address, + token_swaps.tx_hash, + token_swaps.evt_index +FROM + token_swaps diff --git a/dbt_subprojects/dex/models/trades/optimism/platforms/saddle_finance_optimism_base_trades.sql b/dbt_subprojects/dex/models/trades/optimism/platforms/saddle_finance_optimism_base_trades.sql new file mode 100644 index 00000000000..dda9f17a17e --- /dev/null +++ b/dbt_subprojects/dex/models/trades/optimism/platforms/saddle_finance_optimism_base_trades.sql @@ -0,0 +1,50 @@ +{{ config( + schema = 'saddle_finance_optimism', + alias = 'base_trades', + partition_by = ['block_month'], + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['tx_hash', 'evt_index'] +) }} + +WITH token_swaps AS ( + SELECT + evt_block_number AS block_number, + CAST(evt_block_time AS timestamp(3) with time zone) AS block_time, + evt_tx_from AS maker, + evt_tx_to AS taker, + tokensSold AS token_sold_amount_raw, + tokensBought AS token_bought_amount_raw, + CAST(soldId AS varbinary) AS token_sold_address, + CAST(boughtId AS varbinary) AS token_bought_address, + contract_address AS project_contract_address, + evt_tx_hash AS tx_hash, + evt_index AS evt_index + FROM + {{ source('saddle_finance_optimism', 'SwapFlashLoan_evt_TokenSwap') }} + {% if is_incremental() %} + WHERE + {{ incremental_predicate('evt_block_time') }} + {% endif %} +) + +SELECT + 'optimism' AS blockchain, + 'saddle_finance' AS project, + '1' AS version, + CAST(date_trunc('month', token_swaps.block_time) AS date) AS block_month, + CAST(date_trunc('day', token_swaps.block_time) AS date) AS block_date, + token_swaps.block_time, + token_swaps.block_number, + token_swaps.token_sold_amount_raw, + token_swaps.token_bought_amount_raw, + token_swaps.token_sold_address, + token_swaps.token_bought_address, + token_swaps.maker, + token_swaps.taker, + token_swaps.project_contract_address, + token_swaps.tx_hash, + token_swaps.evt_index +FROM + token_swaps diff --git a/dbt_subprojects/dex/models/trades/polygon/_schema.yml b/dbt_subprojects/dex/models/trades/polygon/_schema.yml index a267955034e..f96740412f2 100644 --- a/dbt_subprojects/dex/models/trades/polygon/_schema.yml +++ b/dbt_subprojects/dex/models/trades/polygon/_schema.yml @@ -396,3 +396,37 @@ models: - evt_index - check_dex_base_trades_seed: seed_file: ref('dfyn_polygon_base_trades_seed') + + - name: jetswap_polygon_base_trades + meta: + blockchain: polygon + sector: dex + project: jetswap + contributors: intensodefi + config: + tags: [ 'polygon', 'dex', 'trades', 'jetswap' ] + description: "jetswap polygon base trades" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - evt_index + - check_dex_base_trades_seed: + seed_file: ref('jetswap_polygon_base_trades_seed') + + - name: gravity_finance_polygon_base_trades + meta: + blockchain: polygon + sector: dex + project: gravity_finance + contributors: blanchemaria6 + config: + tags: [ 'polygon', 'dex', 'trades', 'gravity_finance' ] + description: "gravity_finance polygon base trades" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - evt_index + - check_dex_base_trades_seed: + seed_file: ref('gravity_finance_polygon_base_trades_seed') diff --git a/dbt_subprojects/dex/models/trades/polygon/dex_polygon_base_trades.sql b/dbt_subprojects/dex/models/trades/polygon/dex_polygon_base_trades.sql index 7ffdae04a9b..dfd6b528df3 100644 --- a/dbt_subprojects/dex/models/trades/polygon/dex_polygon_base_trades.sql +++ b/dbt_subprojects/dex/models/trades/polygon/dex_polygon_base_trades.sql @@ -26,6 +26,8 @@ , ref('gridex_polygon_base_trades') , ref('swaap_v2_polygon_base_trades') , ref('dfyn_polygon_base_trades') + , ref('jetswap_polygon_base_trades') + , ref('gravity_finance_polygon_base_trades') ] %} WITH base_union AS ( diff --git a/dbt_subprojects/dex/models/trades/polygon/platforms/gravity_finance_polygon_base_trades.sql b/dbt_subprojects/dex/models/trades/polygon/platforms/gravity_finance_polygon_base_trades.sql new file mode 100644 index 00000000000..618310ae78d --- /dev/null +++ b/dbt_subprojects/dex/models/trades/polygon/platforms/gravity_finance_polygon_base_trades.sql @@ -0,0 +1,21 @@ +{{ + config( + schema = 'gravity_finance_polygon', + alias = 'base_trades', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['tx_hash', 'evt_index'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] + ) +}} + +{{ + uniswap_compatible_v2_trades( + blockchain = 'polygon', + project = 'gravity_finance', + version = '1', + Pair_evt_Swap = source('gravity_finance_polygon', 'UniswapV2Pair_evt_Swap'), + Factory_evt_PairCreated = source('gravity_finance_polygon', 'UniswapV2Factory_evt_PairCreated') + ) +}} diff --git a/dbt_subprojects/dex/models/trades/polygon/platforms/jetswap_polygon_base_trades.sql b/dbt_subprojects/dex/models/trades/polygon/platforms/jetswap_polygon_base_trades.sql new file mode 100644 index 00000000000..2591a61614d --- /dev/null +++ b/dbt_subprojects/dex/models/trades/polygon/platforms/jetswap_polygon_base_trades.sql @@ -0,0 +1,20 @@ +{{ config( + schema = 'jetswap_polygon' + , alias = 'base_trades' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['tx_hash', 'evt_index'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] + ) +}} + +{{ + uniswap_compatible_v2_trades( + blockchain = 'polygon', + project = 'jetswap', + version = '1', + Pair_evt_Swap = source('jetswap_polygon', 'JetswapPair_evt_Swap'), + Factory_evt_PairCreated = source('jetswap_polygon', 'JetswapFactory_evt_PairCreated') + ) +}} diff --git a/dbt_subprojects/dex/models/trades/ronin/_schema.yml b/dbt_subprojects/dex/models/trades/ronin/_schema.yml new file mode 100644 index 00000000000..9402dc644cc --- /dev/null +++ b/dbt_subprojects/dex/models/trades/ronin/_schema.yml @@ -0,0 +1,44 @@ +version: 2 + +models: + - name: dex_ronin_base_trades + data_tests: + - check_dex_info_relationship + + - name: katana_v2_ronin_base_trades + meta: + blockchain: ronin + sector: dex + project: katana + contributors: jeff-dude, cxheng315 + config: + tags: ["ronin", "dex", "trades", "katana"] + description: "Katana v2 ronin base trades" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - evt_index + - check_dex_base_trades_seed: + seed_file: ref('katana_ronin_base_trades_seed') + filter: + version: 2 + + - name: katana_v3_ronin_base_trades + meta: + blockchain: ronin + sector: dex + project: katana + contributors: cxheng315 + config: + tags: ["ronin", "dex", "trades", "katana"] + description: "Katana v3 ronin base trades" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - evt_index + - check_dex_base_trades_seed: + seed_file: ref('katana_ronin_base_trades_seed') + filter: + version: 3 diff --git a/dbt_subprojects/dex/models/trades/ronin/dex_ronin_base_trades.sql b/dbt_subprojects/dex/models/trades/ronin/dex_ronin_base_trades.sql new file mode 100644 index 00000000000..108ff7cd73d --- /dev/null +++ b/dbt_subprojects/dex/models/trades/ronin/dex_ronin_base_trades.sql @@ -0,0 +1,49 @@ +{{ config( + schema = 'dex_ronin' + , alias = 'base_trades' + , materialized = 'view' + ) +}} + +{% set base_models = [ + ref('katana_v2_ronin_base_trades') + , ref('katana_v3_ronin_base_trades') +] %} + +WITH base_union AS ( + SELECT * + FROM ( + {% for base_model in base_models %} + SELECT + blockchain + , project + , version + , block_month + , block_date + , block_time + , block_number + , token_bought_amount_raw + , token_sold_amount_raw + , token_bought_address + , token_sold_address + , taker + , maker + , project_contract_address + , tx_hash + , evt_index + FROM + {{ base_model }} + {% if not loop.last %} + UNION ALL + {% endif %} + {% endfor %} + ) +) + +{{ + add_tx_columns( + model_cte = 'base_union' + , blockchain = 'ronin' + , columns = ['from', 'to', 'index'] + ) +}} diff --git a/dbt_subprojects/dex/models/trades/ronin/platforms/katana_v2_ronin_base_trades.sql b/dbt_subprojects/dex/models/trades/ronin/platforms/katana_v2_ronin_base_trades.sql new file mode 100644 index 00000000000..e6a6eeb4997 --- /dev/null +++ b/dbt_subprojects/dex/models/trades/ronin/platforms/katana_v2_ronin_base_trades.sql @@ -0,0 +1,56 @@ +{{ config( + schema = 'katana_v2_ronin' + , alias = 'base_trades' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['tx_hash', 'evt_index'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] + ) +}} + +WITH dexs AS +( + SELECT + t.evt_block_number AS block_number + , t.evt_block_time AS block_time + , t._to AS taker + , t.contract_address AS maker + , CASE WHEN _amount0Out = UINT256 '0' THEN _amount1Out ELSE _amount0Out END AS token_bought_amount_raw + , CASE WHEN _amount0In = UINT256 '0' OR _amount1Out = UINT256 '0' THEN _amount1In ELSE _amount0In END AS token_sold_amount_raw + , CASE WHEN _amount0Out = UINT256 '0' THEN f._token1 ELSE f._token0 END AS token_bought_address + , CASE WHEN _amount0In = UINT256 '0' OR _amount1Out = UINT256 '0' THEN f._token1 ELSE f._token0 END AS token_sold_address + , t.contract_address AS project_contract_address + , t.evt_tx_hash AS tx_hash + , t.evt_index AS evt_index + FROM + {{ source('katana_dex_ronin', 'KatanaPair_evt_Swap') }} t + INNER JOIN + {{ source('katana_dex_ronin', 'KatanaFactory_evt_PairCreated') }} f + ON f._pair = t.contract_address + {% if is_incremental() %} + WHERE + {{ incremental_predicate('t.evt_block_time') }} + {% endif %} + +) + +SELECT + 'ronin' AS blockchain + , 'katana' AS project + , '2' AS version + , CAST(date_trunc('month', dexs.block_time) AS date) AS block_month + , CAST(date_trunc('day', dexs.block_time) AS date) AS block_date + , dexs.block_time + , dexs.block_number + , dexs.token_bought_amount_raw + , dexs.token_sold_amount_raw + , dexs.token_bought_address + , dexs.token_sold_address + , dexs.taker + , dexs.maker + , dexs.project_contract_address + , dexs.tx_hash + , dexs.evt_index +FROM + dexs \ No newline at end of file diff --git a/dbt_subprojects/dex/models/trades/ronin/platforms/katana_v3_ronin_base_trades.sql b/dbt_subprojects/dex/models/trades/ronin/platforms/katana_v3_ronin_base_trades.sql new file mode 100644 index 00000000000..ad3b9dd5e27 --- /dev/null +++ b/dbt_subprojects/dex/models/trades/ronin/platforms/katana_v3_ronin_base_trades.sql @@ -0,0 +1,21 @@ +{{ + config( + schema = 'katana_v3_ronin' + , alias = 'base_trades' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['tx_hash', 'evt_index'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] + ) +}} + +{{ + uniswap_compatible_v3_trades( + blockchain = 'ronin' + , project = 'katana' + , version = '3' + , Pair_evt_Swap = source('katana_dex_ronin', 'KatanaV3Pool_evt_Swap') + , Factory_evt_PoolCreated = source('katana_dex_ronin', 'KatanaV3Factory_evt_PoolCreated') + ) +}} diff --git a/dbt_subprojects/dex/models/trades/zksync/_schema.yml b/dbt_subprojects/dex/models/trades/zksync/_schema.yml index b359a8a13c5..1926ab03ca0 100644 --- a/dbt_subprojects/dex/models/trades/zksync/_schema.yml +++ b/dbt_subprojects/dex/models/trades/zksync/_schema.yml @@ -222,6 +222,27 @@ models: - evt_index - check_dex_base_trades_seed: seed_file: ref('zkswap_finance_zksync_base_trades_seed') + filter: + version: 1 + + - name: zkswap_finance_v3_zksync_base_trades + meta: + blockchain: zksync + sector: dex + project: zkswap_finance + contributors: lgingerich + config: + tags: [ 'zksync', 'dex', 'trades', 'zkswap_finance' ] + description: "zkSwap Finance V3 zksync base trades" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - evt_index + - check_dex_base_trades_seed: + seed_file: ref('zkswap_finance_zksync_base_trades_seed') + filter: + version: 3 - name: gemswap_zksync_base_trades meta: diff --git a/dbt_subprojects/dex/models/trades/zksync/dex_zksync_base_trades.sql b/dbt_subprojects/dex/models/trades/zksync/dex_zksync_base_trades.sql index 7e5e58347ee..85dcf53065f 100644 --- a/dbt_subprojects/dex/models/trades/zksync/dex_zksync_base_trades.sql +++ b/dbt_subprojects/dex/models/trades/zksync/dex_zksync_base_trades.sql @@ -19,6 +19,7 @@ , ref('ezkalibur_v2_zksync_base_trades') , ref('wagmi_v1_zksync_base_trades') , ref('zkswap_finance_zksync_base_trades') + , ref('zkswap_finance_v3_zksync_base_trades') , ref('gemswap_zksync_base_trades') , ref('vesync_v1_zksync_base_trades') , ref('dracula_finance_zksync_base_trades') diff --git a/dbt_subprojects/dex/models/trades/zksync/platforms/zkswap_finance_v3_zksync_base_trades.sql b/dbt_subprojects/dex/models/trades/zksync/platforms/zkswap_finance_v3_zksync_base_trades.sql new file mode 100644 index 00000000000..29c2d8c2df2 --- /dev/null +++ b/dbt_subprojects/dex/models/trades/zksync/platforms/zkswap_finance_v3_zksync_base_trades.sql @@ -0,0 +1,21 @@ +{{ + config( + schema = 'zkswap_finance_v3_zksync', + alias = 'base_trades', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['tx_hash', 'evt_index'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] + ) +}} + +{{ + uniswap_compatible_v3_trades( + blockchain = 'zksync', + project = 'zkswap_finance', + version = '3', + Pair_evt_Swap = source('zkswap_finance_v3_zksync', 'ZFV3Pool_evt_Swap'), + Factory_evt_PoolCreated = source('zkswap_finance_v3_zksync', 'ZFV3Factory_evt_PoolCreated') + ) +}} diff --git a/dbt_subprojects/dex/seeds/bot_trades/banana_gun/banana_gun_base_trades_seed.csv b/dbt_subprojects/dex/seeds/bot_trades/banana_gun/banana_gun_base_trades_seed.csv new file mode 100644 index 00000000000..8f565dddb42 --- /dev/null +++ b/dbt_subprojects/dex/seeds/bot_trades/banana_gun/banana_gun_base_trades_seed.csv @@ -0,0 +1,21 @@ +block_time,block_date,block_month,bot,block_number,blockchain,amount_usd,type,token_bought_amount,token_bought_symbol,token_bought_address,token_sold_amount,token_sold_symbol,token_sold_address,fee_percentage_fraction,fee_usd,fee_token_amount,fee_token_symbol,fee_token_address,project,version,token_pair,project_contract_address,user,tx_hash,evt_index,is_last_trade_in_transaction +2024-09-07 08:46:55.000 UTC,2024-09-07 00:00:00.000 UTC,2024-09-01 00:00:00.000 UTC,Banana Gun,19454734,base,3441.57,Sell,1.5,WETH,0x4200000000000000000000000000000000000006,206629.39352997296,MIGGLES,0xb1a03eda10342529bbf8eb700a06c60441fef25d,0.005,34.4157,0.015,ETH,0x4200000000000000000000000000000000000006,uniswap,2,MIGGLES-WETH,0x17a3ad8c74c4947005afeda9965305ae2eb2518a,0x40237a6d80e9a4d9cd8341c5ad42ce3733b822c1,0xda8352e2a41cc3d5793e2211816d7c234ddad30db2b97860f4b6c26be6d5aa67,7,true +2024-09-01 14:10:41.000 UTC,2024-09-01 00:00:00.000 UTC,2024-09-01 00:00:00.000 UTC,Banana Gun,19205247,base,48.757227722772264,Buy,836176.1213013215,DarkPepePope,0xdc3793eab4681e57b2755783403b3dcc573f220b,0.0198019801980198,WETH,0x4200000000000000000000000000000000000006,0.005,0.48757227722772517,0.000198019801980199,ETH,0x4200000000000000000000000000000000000006,uniswap,2,DarkPepePope-WETH,0x67a45158523835d8477a1877c756c7b8c252d722,0x117c921e599ee1c4f73fe74b08ca584db08475e4,0x25c17e72dc3ede0eec14d4e34b198a7b6854904e8bd862af99814d28e4566204,12,true +2024-09-01 14:10:41.000 UTC,2024-09-01 00:00:00.000 UTC,2024-09-01 00:00:00.000 UTC,Banana Gun,19205247,base,731.358415841584,Buy,538747.542958548,MUNCHER,0xdcce6d3d2f6fe2e9201de68422f7568610b39860,0.297029702970297,WETH,0x4200000000000000000000000000000000000006,0.005,7.313584158415843,0.002970297029702971,ETH,0x4200000000000000000000000000000000000006,uniswap,2,MUNCHER-WETH,0x3be1dd1c8f859fc49f1da72b1d1328b6595a297d,0x56714990cef7019a7ee8a5bc0e8e6ad991aa76e5,0x0ee0458c7dd96ee1125196cbdb414f31de5c2ab6561ec05be72c791359264e3a,5,true +2024-09-10 09:14:03.000 UTC,2024-09-10 00:00:00.000 UTC,2024-09-01 00:00:00.000 UTC,Banana Gun,19585148,base,349.26831683168314,Buy,9105325812.505402,D.O.G.E,0x755b004d7d5dc8fdc92c39333134811e3a69955d,0.1485148514851485,WETH,0x4200000000000000000000000000000000000006,0.005,3.4926831683168333,0.001485148514851486,ETH,0x4200000000000000000000000000000000000006,uniswap,2,D.O.G.E-WETH,0x45b992355d1fa3c5c50ba446c90b578a7b779433,0xaaf1df00167fe59d43c8d1944a6f28aaf8f40f83,0xf09148ffe271bfe5d28c3547362073257ce0d2bb86e6ef788fe6195247441a43,4,true +2024-09-06 15:51:25.000 UTC,2024-09-06 00:00:00.000 UTC,2024-09-01 00:00:00.000 UTC,Banana Gun,19424269,base,112.36625779738371,Sell,0.048872106175385115,WETH,0x4200000000000000000000000000000000000006,1027321.7559139789,UBPS,0x0c90c756350fb803a7d5d9f9ee5ac29e77369973,0.005,1.1236625779738343,0.00048872106175385,ETH,0x4200000000000000000000000000000000000006,uniswap,2,UBPS-WETH,0x4557eacd191e266d4166c603131ef3b006836cae,0x24acc9d9517c1ccfd7ffeaaefbc8666a582fc64b,0xdf164d9670faa4429521a5339a0676d7f47c74817a86fd03cf85fb8e9083757c,9,true +2024-09-05 05:14:37.000 UTC,2024-09-05 00:00:00.000 UTC,2024-09-01 00:00:00.000 UTC,Banana Gun,19361965,base,4.844921559141894,Sell,0.002009432065639148,WETH,0x4200000000000000000000000000000000000006,74784.28391180358,BARIO,0x814fe70e85025bec87d4ad3f3b713bdcaac0579b,0.005,0.04844921559141778,0.000020094320656391,ETH,0x4200000000000000000000000000000000000006,uniswap,3,BARIO-WETH,0x19efcd30370cd4858df84415d9b63eda2048ef27,0x012cd7fb379b72d4c19988d377c3076aa81583a6,0xca1fd9509fd36d1eb4174857b14bfb9dd1fe8ab18fc31c61ad5425301c9b9017,2,true +2024-09-04 00:57:23.000 UTC,2024-09-04 00:00:00.000 UTC,2024-09-01 00:00:00.000 UTC,Banana Gun,19311048,base,0.4824217821782178,Buy,26.822871758695317,MIGGLES,0xb1a03eda10342529bbf8eb700a06c60441fef25d,0.000198019801980198,WETH,0x4200000000000000000000000000000000000006,0.005,0.004824217821782226,0.000001980198019802,ETH,0x4200000000000000000000000000000000000006,uniswap,2,MIGGLES-WETH,0x17a3ad8c74c4947005afeda9965305ae2eb2518a,0xbd5ce37cf9c61d781b28ba8c1d612e12f6507243,0x70166ba1b17ce988996e5240a8fd71021e716b29863236a468c636ededbe5b18,35,true +2024-09-05 16:51:15.000 UTC,2024-09-05 00:00:00.000 UTC,2024-09-01 00:00:00.000 UTC,Banana Gun,19382864,base,141.05584158415843,Buy,16561085558.942457,PEPE,0x52b492a33e447cdb854c7fc19f1e57e8bfa1777d,0.05940594059405941,WETH,0x4200000000000000000000000000000000000006,0.005,1.4105584158415865,0.000594059405940595,ETH,0x4200000000000000000000000000000000000006,uniswap,3,PEPE-WETH,0x0fb597d6cfe5be0d5258a7f017599c2a4ece34c7,0xa7650835f35c4997f93a9e3bb40bc6c0ba8d059d,0x49b82a258a59bd179c4da535038bad40186d59224c431e7fad34a0adf50bf68a,3,true +2024-09-05 22:16:21.000 UTC,2024-09-05 00:00:00.000 UTC,2024-09-01 00:00:00.000 UTC,Banana Gun,19392617,base,117.19306930693071,Buy,8673078.991486527,XRAY,0x3c48ae7b78bf9ba91fc8e5f6f6bf9f089f278328,0.04950495049504951,WETH,0x4200000000000000000000000000000000000006,0.005,1.1719306930693094,0.000495049504950496,ETH,0x4200000000000000000000000000000000000006,uniswap,2,WETH-XRAY,0xb924036f602fa75f0d4ac9545ee4d6d00261c8ad,0xc4dd8211988263c932c0afb59677dd92ab898046,0x6fcd2bc0c758a0aff18c18069a13173f90e7455ed93d8f5317ff62d78dd1cf61,11,true +2024-09-05 21:22:43.000 UTC,2024-09-05 00:00:00.000 UTC,2024-09-01 00:00:00.000 UTC,Banana Gun,19391008,base,235.0237623762376,Buy,17697.68136626327,WELL,0xa88594d404727625a9437c3f886c7643872296ae,0.09900990099009901,WETH,0x4200000000000000000000000000000000000006,0.005,2.350237623762378,0.000990099009900991,ETH,0x4200000000000000000000000000000000000006,aerodrome,1,WELL-WETH,0x89d0f320ac73dd7d9513ffc5bc58d1161452a657,0x56d0ffbb368ecfb8111a6637fc698d6325e8bc01,0x553bf030f289a28cdb96e4da372ebb3ecf8b138062845edc5266494744d894a3,6,true +2024-09-01 16:31:43.000 UTC,2024-09-01 00:00:00.000 UTC,2024-09-01 00:00:00.000 UTC,Banana Gun,19209478,base,0.23501467838723727,Sell,0.000094977299170814,WETH,0x4200000000000000000000000000000000000006,51.4387631,Nermie,0x519a319e9bb1000c504a20485084df2337c4c14d,0.005,0.0023501467838670776,9.49772991706e-7,ETH,0x4200000000000000000000000000000000000006,sushiswap,1,Nermie-WETH,0xeb5b859dcc061e1e567d89c8ea5bacbe570b6c4e,0x2f0fcdfda8b4065a4d266ddc53c077750e3b485f,0xa203f9e3f43c2288aff00fc6a9f2aea8a3dc6f84f2c32abcd70c8d6a272ba743,10,true +2024-09-01 12:09:59.000 UTC,2024-09-01 00:00:00.000 UTC,2024-09-01 00:00:00.000 UTC,Banana Gun,19201626,base,4959.661963579478,Sell,1.9988723188013517,WETH,0x4200000000000000000000000000000000000006,,,0xc53eb9ecc247465e2e1fb16b2ede3a6446053170,0.005,49.59661963579477,0.01998872318801351,ETH,0x4200000000000000000000000000000000000006,uniswap,2,,0xa854492182dcbda450bcd9ee04870818484dd8ad,0x591be26c53aa3ed600c1c994ecbc2deb545bebb4,0x0c581fc5af9d3a53525f5d31fb09fb9d4dbe5772629ed1c5b2879ad6a59ba30c,11,true +2024-09-01 12:09:59.000 UTC,2024-09-01 00:00:00.000 UTC,2024-09-01 00:00:00.000 UTC,Banana Gun,19201626,base,51.84239373333868,Sell,0.020893828356637105,WETH,0x4200000000000000000000000000000000000006,,,0xc53eb9ecc247465e2e1fb16b2ede3a6446053170,0.005,49.59661963579477,0.01998872318801351,ETH,0x4200000000000000000000000000000000000006,uniswap,2,,0xa854492182dcbda450bcd9ee04870818484dd8ad,0x591be26c53aa3ed600c1c994ecbc2deb545bebb4,0x0c581fc5af9d3a53525f5d31fb09fb9d4dbe5772629ed1c5b2879ad6a59ba30c,3,false +2024-09-04 15:30:23.000 UTC,2024-09-04 00:00:00.000 UTC,2024-09-01 00:00:00.000 UTC,Banana Gun,19337238,base,24.098712871287123,Buy,878817.008049761,TRFY,0xa7ebc5f9b67e790ac0b5d24ed0d531d319cea597,0.0099009900990099,WETH,0x4200000000000000000000000000000000000006,0.005,0.2409871287128737,0.0000990099009901,ETH,0x4200000000000000000000000000000000000006,uniswap,2,TRFY-WETH,0x5f27785b5e2c8263bdec279c75245b980099ac9d,0x64c23d3f619d825bab287f3c52a0f39d3a03c263,0x37c292515191685a193c9400f4fed0ecdc3e1e8dc08e2a527f79cbc000cec727,4,true +2024-09-02 16:30:51.000 UTC,2024-09-02 00:00:00.000 UTC,2024-09-01 00:00:00.000 UTC,Banana Gun,19252652,base,33.64625262721495,Sell,0.013366804770162664,WETH,0x4200000000000000000000000000000000000006,1541948.1284249476,BEE,0xfd09f108d1728e6b6ed241ccd254775e322f1ed6,0.005,0.3364625262721479,0.000133668047701626,ETH,0x4200000000000000000000000000000000000006,uniswap,2,BEE-WETH,0x500e45173f466c058e6dcecd15b27a1e091d92d4,0x64c23d3f619d825bab287f3c52a0f39d3a03c263,0x097dd6b26059fce8166f8fea84aaa12ae13b075cf0d077f717cc1bc31e41ec1b,5,true +2024-09-05 21:11:25.000 UTC,2024-09-05 00:00:00.000 UTC,2024-09-01 00:00:00.000 UTC,Banana Gun,19390669,base,117.3920792079208,Buy,5649267.692887611,COFFEE,0xc54b2b7ee65918a8ec08048cd2377998e7415312,0.04950495049504951,WETH,0x4200000000000000000000000000000000000006,0.005,1.1739207920792103,0.000495049504950496,ETH,0x4200000000000000000000000000000000000006,uniswap,2,COFFEE-WETH,0xe28afb7f1cac4bbf87cd9875aa06f470aec965a4,0xe3ea037ca6ea651cc3f476712b30374c2115e74e,0xdaf6c33941140880d5baff25f8c65f1362048575535d31bff39d07a56ac510ae,11,true +2024-09-05 21:11:25.000 UTC,2024-09-05 00:00:00.000 UTC,2024-09-01 00:00:00.000 UTC,Banana Gun,19390669,base,117.3920792079208,Buy,4982612.726137387,COFFEE,0xc54b2b7ee65918a8ec08048cd2377998e7415312,0.04950495049504951,WETH,0x4200000000000000000000000000000000000006,0.005,1.1739207920792103,0.000495049504950496,ETH,0x4200000000000000000000000000000000000006,uniswap,2,COFFEE-WETH,0xe28afb7f1cac4bbf87cd9875aa06f470aec965a4,0xb73bc3772cf29da413966f36fe18a1dd392cf1b6,0xcc475368ad6c4e6e30df134aaad618fc9fcc9101cf01518c2be3d3170ee11d3c,32,true +2024-09-05 21:11:55.000 UTC,2024-09-05 00:00:00.000 UTC,2024-09-01 00:00:00.000 UTC,Banana Gun,19390684,base,117.3920792079208,Buy,4786468.142259231,COFFEE,0xc54b2b7ee65918a8ec08048cd2377998e7415312,0.04950495049504951,WETH,0x4200000000000000000000000000000000000006,0.005,1.1739207920792103,0.000495049504950496,ETH,0x4200000000000000000000000000000000000006,uniswap,2,COFFEE-WETH,0xe28afb7f1cac4bbf87cd9875aa06f470aec965a4,0xe9869a8c089502b8a8b54b53a9df3ce295a4c17b,0x6909a7e16826cf57cbf3b836e57dcb850150f86902c7d62892db55ab02916947,4,true +2024-09-05 21:11:25.000 UTC,2024-09-05 00:00:00.000 UTC,2024-09-01 00:00:00.000 UTC,Banana Gun,19390669,base,117.3920792079208,Buy,5191072.771597835,COFFEE,0xc54b2b7ee65918a8ec08048cd2377998e7415312,0.04950495049504951,WETH,0x4200000000000000000000000000000000000006,0.005,1.1739207920792103,0.000495049504950496,ETH,0x4200000000000000000000000000000000000006,uniswap,2,COFFEE-WETH,0xe28afb7f1cac4bbf87cd9875aa06f470aec965a4,0xfe906d692a47246518fe05cd5852501bfb51f012,0x2935af8e620e15691ca2b9e5dc78d1179dc2b4222d1835a35d5955d3951c7a36,25,true +2024-09-05 21:11:55.000 UTC,2024-09-05 00:00:00.000 UTC,2024-09-01 00:00:00.000 UTC,Banana Gun,19390684,base,117.3920792079208,Buy,4601687.433549198,COFFEE,0xc54b2b7ee65918a8ec08048cd2377998e7415312,0.04950495049504951,WETH,0x4200000000000000000000000000000000000006,0.005,1.1739207920792103,0.000495049504950496,ETH,0x4200000000000000000000000000000000000006,uniswap,2,COFFEE-WETH,0xe28afb7f1cac4bbf87cd9875aa06f470aec965a4,0xfe906d692a47246518fe05cd5852501bfb51f012,0x3f15863dd32a63136646bde0b816fa080f6153c0d6d74d94d7b0bb5fa3d59140,11,true diff --git a/dbt_subprojects/dex/seeds/bot_trades/banana_gun/banana_gun_ethereum_trades_seed.csv b/dbt_subprojects/dex/seeds/bot_trades/banana_gun/banana_gun_ethereum_trades_seed.csv new file mode 100644 index 00000000000..bbaf14cedf0 --- /dev/null +++ b/dbt_subprojects/dex/seeds/bot_trades/banana_gun/banana_gun_ethereum_trades_seed.csv @@ -0,0 +1,21 @@ +block_time,block_date,block_month,bot,block_number,blockchain,amount_usd,type,token_bought_amount,token_bought_symbol,token_bought_address,token_sold_amount,token_sold_symbol,token_sold_address,fee_percentage_fraction,fee_usd,fee_token_amount,fee_token_symbol,fee_token_address,project,version,token_pair,project_contract_address,user,tx_hash,evt_index,is_last_trade_in_transaction +2023-06-19 15:26:59.000 UTC,2023-06-19 00:00:00.000 UTC,2023-06-01 00:00:00.000 UTC,Banana Gun,17514676,ethereum,83.12745837737252,Sell,0.04836365974946039,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,401724.712464711,IG,0x1c60343f8ee1db0617097341abf56c308597d9d9,0.005,0.4037242114329775,0.000234887253568174,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,IG-WETH,0xec3615f6cd9f2df234c877e501d53f9eef22fcc4,0x842be3379d61bb4d63e757ab485fee99a6cebecc,0x6173075a5d069d1db4187e145ab35849e0bbc25cc2eb8164d0ec8afd76d27ad7,24,false +2023-06-06 17:22:11.000 UTC,2023-06-06 00:00:00.000 UTC,2023-06-01 00:00:00.000 UTC,Banana Gun,17422854,ethereum,116.46015223455811,Sell,0.06250511334447438,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,48700.164228039175,0xC,0x2aa4c7e845ced2cb3180a6584df15efd0d886bdb,0.005,0.5823007611727888,0.000312525566722371,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,0xC-WETH,0x57680221d5f90d871f82f43fdf4824a2717041e7,0xc4fb7ad11fbc1c5733e5f56043f44c690d6c5686,0x7611950dedf03734be5a95a7d5a983bd20edcaeae9151568dc32424b6a61ada5,45,true +2023-06-17 13:13:11.000 UTC,2023-06-17 00:00:00.000 UTC,2023-06-01 00:00:00.000 UTC,Banana Gun,17499751,ethereum,83.27189660506818,Sell,0.04785878709449592,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,8710044.64601209,METH,0x2d6cfa8781755c922a14d0e7c111700060490198,0.005,0.41635948302533987,0.000239293935472479,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,METH-WETH,0xcd9e2214ae0449d47f2becd56516d1a497a8c5e7,0xbbd018a45b40bb699df47c7bca87623810a2534b,0x69efeb79af7bc11600b5d11a6a8d85a7949f7695801fe1c648916eef368a0d4e,14,true +2023-06-21 21:56:23.000 UTC,2023-06-21 00:00:00.000 UTC,2023-06-01 00:00:00.000 UTC,Banana Gun,17530850,ethereum,182.88032782937748,Sell,0.09753877587635802,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,15122057.069775704,DEN,0xe28901beb0630379ced910053294b6f953309c3a,0.005,0.9144016391468872,0.00048769387938179,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,3,DEN-WETH,0xe4da8e91076fdd026c5582279268785dd44f0038,0xe12352f93b86b7262099e8039580990c80e83ca5,0xa92bd896bb9c23194180d03fc93ecea65155c42ed1aaaa89737772f8f98ea1c6,12,true +2023-06-19 18:12:47.000 UTC,2023-06-19 00:00:00.000 UTC,2023-06-01 00:00:00.000 UTC,Banana Gun,17515493,ethereum,419.944958659094,Sell,0.24176868838212176,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,48012.75194671747,$ELY,0x8ed2fc62d6850eaadcb717465752dab591286839,0.005,2.973855242525905,0.001712093612742825,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,$ELY-WETH,0xeed363729bdb7f9d7b5fce5dbf8bd5cc4fc98f7f,0xc8ef2326093c2491bb474be405fb04f5cb89a7ce,0xd96b1f10f419f83a3653e10d39dcb667f56fb92eeb13ec66e3bae2643311f10d,92,false +2023-06-30 12:38:47.000 UTC,2023-06-30 00:00:00.000 UTC,2023-06-01 00:00:00.000 UTC,Banana Gun,17592143,ethereum,189.009205,Buy,835861314077.003,EPEP,0x975b624dda0903c8100bafccfd537458933d410e,0.0995,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,0.005,0.949795,0.0005,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,EPEP-WETH,0x32eabaec2bd26d647b568715a514a76757c86145,0x8b38b7f821b9a7216d45d49047ecfbf80ae3a566,0xfc7d27e1633e07e8581a8c16939936aa446c07a4399ad9f908d563e868b260e3,22,true +2023-06-28 16:03:59.000 UTC,2023-06-28 00:00:00.000 UTC,2023-06-01 00:00:00.000 UTC,Banana Gun,17578886,ethereum,229.26480250785545,Sell,0.12313750900059911,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,275400,FIND,0x638df5a6ef481b4e01982ba750d0008c98ed4c24,0.005,1.1463240125392762,0.000615687545002995,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,FIND-WETH,0xd384a0f245d6a54856f924a9708fdde8c7f3d3a9,0x5b46ff3f518d4db5ff50105dfbe917ce79f6c3bb,0x7d6d07a85bdd642e6964552e1f8e72f0a8911e3408b3c9a10072f6928d89a3aa,42,true +2023-06-05 02:01:35.000 UTC,2023-06-05 00:00:00.000 UTC,2023-06-01 00:00:00.000 UTC,Banana Gun,17411242,ethereum,377.23,Buy,2758703618.5463076,SATOSHI,0xf048fdef5f29ca7f4f96a97d534eec1b17c0356f,0.2,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,0,0,0,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,SATOSHI-WETH,0x76197528ae1f5586c0d636a8859edb2c5daf7681,0x7fd1fa18d2748a0b39d413724d733d2a24075280,0x0e37882eb552c5f9ff5497a076203a4717654ced04ca8c34adbedd41356d32f5,31,true +2023-06-19 12:05:47.000 UTC,2023-06-19 00:00:00.000 UTC,2023-06-01 00:00:00.000 UTC,Banana Gun,17513684,ethereum,361.039881415359,Sell,0.2091178526463281,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,71874339683920.4,SHA,0x95565f27d9b7fcacb04954ca4f24b486a641f001,0.005,1.8051994070767943,0.00104558926323164,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,SHA-WETH,0x81de191d0a57f86901a7aec8d44a0698e0f8fb96,0xe12352f93b86b7262099e8039580990c80e83ca5,0xab8668a0d124e9a2c2a4e01e19476e150007e9ac7f4370339c8ad79f690f8813,22,true +2023-06-25 16:00:23.000 UTC,2023-06-25 00:00:00.000 UTC,2023-06-01 00:00:00.000 UTC,Banana Gun,17557542,ethereum,62.20631360805016,Buy,12000000000,QBERT,0xa09116cfd21f49689c32083cb3a3632d40c6f7fe,0.03293639664106686,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,0.0016,0.31103156804025023,0.000164681983205334,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,QBERT-WETH,0x9461485ef8c8c8cdfc910e81e58b03c6b4485553,0xe77fd9756dac9ebfe8a7d9c623d988814987964e,0x41acb6080b560735fd8479e7dc59daf01815c6f9aa6c440ad0ba55aeed653c97,60,true +2023-06-05 01:02:35.000 UTC,2023-06-05 00:00:00.000 UTC,2023-06-01 00:00:00.000 UTC,Banana Gun,17410953,ethereum,266.1148617401801,Sell,0.1412027091472491,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,750000,ASUKA,0xfe25f375aa07298f75c39d155855a7c6ecfbbf69,0.005,3.2677701481407015,0.00173390540750211,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,ASUKA-WETH,0xfc93d2b86be176548d2b1b8c007adc85d6c0cc8b,0x9c99d7af32c576eb71dbccc3718be211eb3e14ab,0x263ef72c8cef7859284b4d64f7503ed04e141f79c4482e9fb8360bcbddc79af7,20,false +2023-06-20 15:29:23.000 UTC,2023-06-20 00:00:00.000 UTC,2023-06-01 00:00:00.000 UTC,Banana Gun,17521804,ethereum,56.0700216923059,Sell,0.03259278604695981,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,7354.848321544704,0xDeaD,0xdead0f0e934a4137a21811bff798850b0a90dead,0.005,0.2803501084615294,0.000162963930234799,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,0xDeaD-WETH,0xc9a2d5f44b90d957716e656229e142d37270d19a,0x490a028a817a4eb52164c37fda25cff1f1b4b180,0xad85c2bf9d0fc141fe3e44c0f7e69e169c7b9e9bf834c57535d71aa677f296cc,57,true +2023-06-25 19:49:47.000 UTC,2023-06-25 00:00:00.000 UTC,2023-06-01 00:00:00.000 UTC,Banana Gun,17558676,ethereum,141.05486574079083,Sell,0.07459510388525856,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,441453.320819254,VisionX,0x8551353a87993c14329df0322f673bca640e3906,0.005,0.7052743287039527,0.000372975519426292,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,VisionX-WETH,0xae5dcd5f4e54998b740eec0af1d8bcbd3ad21b03,0xdee6cfc3c51550e5bd46a4613a09424bc62b6be6,0x96347e0ab77ff0988b616ff584ca8bf2b823ba202e56a1299d45b0e71212a666,20,true +2023-06-23 18:45:23.000 UTC,2023-06-23 00:00:00.000 UTC,2023-06-01 00:00:00.000 UTC,Banana Gun,17544135,ethereum,382.533684871126,Sell,0.2003990260527886,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,102707.0809698149,FUMOKILLER,0x9bbe2cebee8c0aba957224e512e4de54bbf79fe6,0.005,1.9126684243556284,0.001001995130263942,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,FUMOKILLER-WETH,0x91459946d9ad8c89fa807488f9e84d83263b5678,0xc4fb7ad11fbc1c5733e5f56043f44c690d6c5686,0x00db9d11fdfc76d624438c577ce6b0734cc50deea875cdb656d730ef036cc1c4,49,true +2023-06-29 20:34:23.000 UTC,2023-06-29 00:00:00.000 UTC,2023-06-01 00:00:00.000 UTC,Banana Gun,17587364,ethereum,106.34892104701531,Sell,0.057466023130925144,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,1600000,MrsPepe2.0,0x0c2eee9858623f8e6da32c1c3683ed22ef7be5fc,0.005,0.5317446052350753,0.000287330115654625,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,MrsPepe2.0-WETH,0xeaca43d704daae77aed4722a60c32b5538e4aa1c,0xafabb3a635747797dd05ab662ce5dd070ee28b91,0x2f08c34efc6e3397146aaf70afb65afe4d7d47a6811e2b837df933fea1f308b4,70,true +2023-06-29 12:31:47.000 UTC,2023-06-29 00:00:00.000 UTC,2023-06-01 00:00:00.000 UTC,Banana Gun,17584974,ethereum,153.49601411690773,Sell,0.08200186665504244,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,12331187.874773905,YFO,0x1f8c2c3e9a17ecd378911a122e876a43993a5e51,0.005,0.7674800705845383,0.000410009333275212,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,WETH-YFO,0xacbd3bdce79c65250ee53aded4a186d4ca2ace23,0xfcc33fc7ab61cda35b8b8abee0635733b388d1bf,0x4f21c5f745e6945c74d6270f63510139bdffa452b150499cef4c03fcab508aae,142,true +2023-06-20 22:14:11.000 UTC,2023-06-20 00:00:00.000 UTC,2023-06-01 00:00:00.000 UTC,Banana Gun,17523802,ethereum,0.7480057655563455,Sell,0.000420468901031122,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,7394.251038698974,RPUNKS,0x340b8776063abfdd5117c35e3a4b228079ea6d90,0.005,0.17150376326334374,0.000096405672499603,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,RPUNKS-WETH,0x7dfb889c888189e91c3ca56a993c55594eee3b61,0x0d87e9d89a0c24f5879ea8ab72590ff5cedf2c9b,0x04858f207f668c2a36221c2bd878680dd4f62e7fc925ffd884c50e8a41c8bd9c,90,false +2023-06-20 15:00:11.000 UTC,2023-06-20 00:00:00.000 UTC,2023-06-01 00:00:00.000 UTC,Banana Gun,17521662,ethereum,171.22855500000003,Buy,2636.3410224539093,0xDeaD,0xdead0f0e934a4137a21811bff798850b0a90dead,0.0995,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,0.005,0.860445,0.0005,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,0xDeaD-WETH,0xc9a2d5f44b90d957716e656229e142d37270d19a,0xf5ccaf5dcd921b98c594ccdd3b16435006113cc6,0xf33227d240b85898ce859514f0b0c8c016973a1921ce2cea0cd95a8e251aa04b,274,true +2023-06-21 22:48:59.000 UTC,2023-06-21 00:00:00.000 UTC,2023-06-01 00:00:00.000 UTC,Banana Gun,17531111,ethereum,360.64435523988095,Sell,0.1915335967029475,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,261323.81103556513,BCT,0x2281c37cc6e7ac0ded17eb1494f63f94a8ee568a,0.005,1.8032217761994038,0.000957667983514737,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,BCT-WETH,0x244ce07231d5156f22a21212768c1fa5e8d84e1b,0xbd42b534f896448ac6cfa7d8229d5b76d46f1927,0x08e369ddc65e1cfba3f2f4ce79a1a7c375d1511ba7d91dcbe641dfe124e1de87,20,true +2023-06-08 22:40:23.000 UTC,2023-06-08 00:00:00.000 UTC,2023-06-01 00:00:00.000 UTC,Banana Gun,17438595,ethereum,84.80449692865044,Buy,20000000000,TARD,0x4a0386cf685e5e2b73a730a85ac3ee65a62585f5,0.045737914574223326,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,0,0,0,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,TARD-WETH,0x01084d791298ed32bde3481d06b1a59d36757897,0xc8ef2326093c2491bb474be405fb04f5cb89a7ce,0x29e5a82febb20b6539ceb635e7d70588d867860456a17fa10739624e28f198d8,61,true diff --git a/dbt_subprojects/dex/seeds/bot_trades/banana_gun/schema.yml b/dbt_subprojects/dex/seeds/bot_trades/banana_gun/schema.yml new file mode 100644 index 00000000000..9e25049c7c2 --- /dev/null +++ b/dbt_subprojects/dex/seeds/bot_trades/banana_gun/schema.yml @@ -0,0 +1,24 @@ +version: 2 + +seeds: + - name: banana_gun_ethereum_trades_seed + config: + column_types: + version: varchar + token_bought_address: varbinary + token_sold_address: varbinary + fee_token_address: varbinary + project_contract_address: varbinary + user: varbinary + tx_hash: varbinary + + - name: banana_gun_base_trades_seed + config: + column_types: + version: varchar + token_bought_address: varbinary + token_sold_address: varbinary + fee_token_address: varbinary + project_contract_address: varbinary + user: varbinary + tx_hash: varbinary diff --git a/dbt_subprojects/dex/seeds/bot_trades/flokibot/flokibot_base_trades_seed.csv b/dbt_subprojects/dex/seeds/bot_trades/flokibot/flokibot_base_trades_seed.csv new file mode 100644 index 00000000000..37f8fa3b5d1 --- /dev/null +++ b/dbt_subprojects/dex/seeds/bot_trades/flokibot/flokibot_base_trades_seed.csv @@ -0,0 +1,21 @@ +block_time,block_date,block_month,bot,block_number,blockchain,amount_usd,type,token_bought_amount,token_bought_symbol,token_bought_address,token_sold_amount,token_sold_symbol,token_sold_address,fee_percentage_fraction,fee_usd,fee_token_amount,fee_token_symbol,fee_token_address,project,version,token_pair,project_contract_address,user,tx_hash,evt_index,is_last_trade_in_transaction +2024-11-27 04:37:49.000 UTC,2024-11-27 00:00:00.000 UTC,2024-11-01 00:00:00.000 UTC,Floki Trading Bot,22946461,base,0.33883937999999997,Buy,520.2338446502055,USA,0xb56d0839998fd79efcd15c27cf966250aa58d6d3,0.000099,WETH,0x4200000000000000000000000000000000000006,0.0101,0.00342262,0.000001,ETH,0x4200000000000000000000000000000000000006,uniswap,3,USA-WETH,0x6e668dcafaaab8e9dc9b8255fe125622230fb9a6,0xe96321ceb4deae752ffbf876ce9fcf45587a4492,0xe66b19d7b39766715feef54cef41d1657047f1746eb22795a0a65d115259aeba,243,true +2024-10-29 23:42:19.000 UTC,2024-10-29 00:00:00.000 UTC,2024-10-01 00:00:00.000 UTC,Floki Trading Bot,21727996,base,2.6076699000000003,Buy,48950.585902226,NEIRO,0xa816ee97b1d7ae50fb0c68672a56f45334b90aa7,0.00099,WETH,0x4200000000000000000000000000000000000006,0.0101,0.026340100000000005,0.00001,ETH,0x4200000000000000000000000000000000000006,uniswap,2,NEIRO-WETH,0x052ed7ee8377e03b10c312b7cda7edb39d0daa33,0x332f1d9653f43fb13668594cbc957bf7ad63e737,0xe27c53821c1061adf5ac8bbc728a41360019ace832f89649622f7c8bd9b50a7d,433,true +2024-10-17 18:57:01.000 UTC,2024-10-17 00:00:00.000 UTC,2024-10-01 00:00:00.000 UTC,Floki Trading Bot,21201037,base,0.12637520885044923,Sell,0.000048847645402608,WETH,0x4200000000000000000000000000000000000006,3.0287101028116847,TRUMP,0x2e1d332893dc16124194e598a29866d2d5e8786b,,,,ETH,0x4200000000000000000000000000000000000006,uniswap,2,TRUMP-WETH,0xd33805985642fa9338e1fa150ca811406f96f0de,0x332f1d9653f43fb13668594cbc957bf7ad63e737,0x5cd4aaaf25c12cf954b7456f0243f63e8c41ba63cf8b2287c3672687ed7a8b0e,121,true +2024-10-11 01:19:35.000 UTC,2024-10-11 00:00:00.000 UTC,2024-10-01 00:00:00.000 UTC,Floki Trading Bot,20910114,base,0.3574667213813365,Sell,0.000149849181676596,WETH,0x4200000000000000000000000000000000000006,,,0xb0492857994e2af4ad0fa41d10bd711d4534f768,,,,ETH,0x4200000000000000000000000000000000000006,uniswap,2,,0xab10864ace3da8046e2218fbccda1c23318a4219,0xe162325f3579e99c7a051232c242b6f9bcc0f39c,0xf0d3958952b71eda82a42d443f3a5390248b131e063951e552ce6f86cc8b0709,93,true +2024-10-31 20:12:43.000 UTC,2024-10-31 00:00:00.000 UTC,2024-10-01 00:00:00.000 UTC,Floki Trading Bot,21808108,base,0.24954929999999997,Buy,0.2184472091214867,AERO,0x940181a94a35a4569e4529a3cdfb74e38fd98631,0.000099,WETH,0x4200000000000000000000000000000000000006,0.0101,0.0025207,0.000001,ETH,0x4200000000000000000000000000000000000006,pancakeswap,3,AERO-WETH,0x20cb8f872ae894f7c9e32e621c186e5afce82fd0,0x74a916ac78d5f52d5fafc078e9bf27993bf7ecdb,0x2e9d1e914f025dde460cd912813f7ade049db078de214708112ac65756eeaeda,1459,true +2024-10-30 10:30:39.000 UTC,2024-10-30 00:00:00.000 UTC,2024-10-01 00:00:00.000 UTC,Floki Trading Bot,21747446,base,199.6681192420227,Sell,0.07432415241006633,WETH,0x4200000000000000000000000000000000000006,110477.50457230002,USA,0xb56d0839998fd79efcd15c27cf966250aa58d6d3,,,,ETH,0x4200000000000000000000000000000000000006,uniswap,3,USA-WETH,0x6e668dcafaaab8e9dc9b8255fe125622230fb9a6,0xa1128f9b8ffcedb16d6fdcf1509ccbb14816da7b,0xf8c26d9130ce0b754ecdfda6c9eebeb0e058962b98a9760c0a4ac45e0ca7ff4d,516,false +2024-10-27 22:55:55.000 UTC,2024-10-27 00:00:00.000 UTC,2024-10-01 00:00:00.000 UTC,Floki Trading Bot,21640204,base,0.7324634032629762,Sell,0.000291212459849626,WETH,0x4200000000000000000000000000000000000006,10.192021241117352,TRUMP,0x2e1d332893dc16124194e598a29866d2d5e8786b,,,,ETH,0x4200000000000000000000000000000000000006,uniswap,2,TRUMP-WETH,0xd33805985642fa9338e1fa150ca811406f96f0de,0x332f1d9653f43fb13668594cbc957bf7ad63e737,0x26bd4e82b438fb52070dd8cc650e95106c945e81886eae1f54471f034a9e306a,65,true +2024-10-13 08:51:01.000 UTC,2024-10-13 00:00:00.000 UTC,2024-10-01 00:00:00.000 UTC,Floki Trading Bot,21010057,base,9.7629444,Buy,72532.06361495884,TYBG,0x0d97f261b1e88845184f678e2d1e7a98d9fd38de,0.00396,WETH,0x4200000000000000000000000000000000000006,0.0101,0.0986156,0.00004,ETH,0x4200000000000000000000000000000000000006,sushiswap,1,TYBG-WETH,0xf65bb528ced09008603509c3fda43e1ccfddf935,0x081120a2bb4882d04644790a1440be231e71c3fc,0x5133fbcabdc067b3a53581c550f0a83d2d535ff5ec217019da3695c74d70479e,50,true +2024-10-13 04:53:25.000 UTC,2024-10-13 00:00:00.000 UTC,2024-10-01 00:00:00.000 UTC,Floki Trading Bot,21002929,base,0.24389441999999997,Buy,19.786076776911564,ANDY,0x18a8bd1fe17a1bb9ffb39ecd83e9489cfd17a022,0.000099,WETH,0x4200000000000000000000000000000000000006,0.0101,0.00246358,0.000001,ETH,0x4200000000000000000000000000000000000006,sushiswap,1,ANDY-WETH,0xff5375bd65056dbe6119256fc3be2eb0ffa8a840,0xe162325f3579e99c7a051232c242b6f9bcc0f39c,0xd48698d7bd98e4aeb80d05aa1ef5124094fcdc03be76b208add7ba22b4399242,41,true +2024-10-13 02:52:35.000 UTC,2024-10-13 00:00:00.000 UTC,2024-10-01 00:00:00.000 UTC,Floki Trading Bot,20999304,base,0.024064873853599695,Sell,0.000009742272272372,WETH,0x4200000000000000000000000000000000000006,15.787352393617192,USA,0xb56d0839998fd79efcd15c27cf966250aa58d6d3,,,,ETH,0x4200000000000000000000000000000000000006,uniswap,2,USA-WETH,0xfffed65c9fdaf0818867e8b6d841fdb0631bc223,0x74b1ae6bc107f6b95620ec0b808b1a85fa150421,0x5fade0e53b6e9452b95398732ed3e976808826d521aa4391bf09d4b8e6c7b4b2,145,true +2024-10-27 22:46:13.000 UTC,2024-10-27 00:00:00.000 UTC,2024-10-01 00:00:00.000 UTC,Floki Trading Bot,21639913,base,0.24908102999999995,Buy,3.42403973966794,TRUMP,0x2e1d332893dc16124194e598a29866d2d5e8786b,0.000099,WETH,0x4200000000000000000000000000000000000006,0.0101,0.0025159699999999998,0.000001,ETH,0x4200000000000000000000000000000000000006,uniswap,2,TRUMP-WETH,0xd33805985642fa9338e1fa150ca811406f96f0de,0x332f1d9653f43fb13668594cbc957bf7ad63e737,0x9f96599ad1e15b1221074d05c0434ff4a0aacd4970030ce90c21916dc56a2c1b,580,true +2024-10-27 16:47:47.000 UTC,2024-10-27 00:00:00.000 UTC,2024-10-01 00:00:00.000 UTC,Floki Trading Bot,21629160,base,0.24709212,Buy,136553.29223940978,BASE,0xd07379a755a8f11b57610154861d694b2a0f615a,0.000099,WETH,0x4200000000000000000000000000000000000006,0.0101,0.00249588,0.000001,ETH,0x4200000000000000000000000000000000000006,swapbased,1,BASE-WETH,0x5554419ccd0293d9383901f461c7c3e0c66e925f,0xd1a2dc602e86814f4a9996fb7901d2f3caee4fa0,0x11baa2b637dfd468bc907c4082dbe39a869768bc79e64e0544bdca42dd306b2c,88,true +2024-10-13 07:49:51.000 UTC,2024-10-13 00:00:00.000 UTC,2024-10-01 00:00:00.000 UTC,Floki Trading Bot,21008222,base,59.028199560000004,Buy,438049.5664395944,TYBG,0x0d97f261b1e88845184f678e2d1e7a98d9fd38de,0.023958,WETH,0x4200000000000000000000000000000000000006,0.0459,2.710202,0.0011,ETH,0x4200000000000000000000000000000000000006,aerodrome,slipstream,TYBG-WETH,0x8d628d22d298b4a6e3dc9171d4b7aa5229e2353c,0x081120a2bb4882d04644790a1440be231e71c3fc,0x66dc9a8e7a87d501e8eb4ac8ddce4c9cb3d3cbc33304ea5e7d702f45cc3f5517,154,false +2024-10-30 07:53:37.000 UTC,2024-10-30 00:00:00.000 UTC,2024-10-01 00:00:00.000 UTC,Floki Trading Bot,21742735,base,0.26348652,Buy,10.092482462526931,SKOP,0x6d3b8c76c5396642960243febf736c6be8b60562,0.000099,WETH,0x4200000000000000000000000000000000000006,0.0101,0.00266148,0.000001,ETH,0x4200000000000000000000000000000000000006,uniswap,2,SKOP-WETH,0xa5c7015c81d2280032b031406048c75696ba77d5,0x332f1d9653f43fb13668594cbc957bf7ad63e737,0xa65a33733441514c34cca9e82e27cd74f95ea42ceb9fb21f66f1983e992a6507,277,true +2024-10-17 03:04:45.000 UTC,2024-10-17 00:00:00.000 UTC,2024-10-01 00:00:00.000 UTC,Floki Trading Bot,21172469,base,0.0727270236,Buy,4.080240547382812,SKOP,0x6d3b8c76c5396642960243febf736c6be8b60562,0.00002772,WETH,0x4200000000000000000000000000000000000006,0.0361,0.00262363,0.000001,ETH,0x4200000000000000000000000000000000000006,aerodrome,1,SKOP-WETH,0x18c55864d9bc0d7c3f6dc18e3a1d20e50f551891,0x332f1d9653f43fb13668594cbc957bf7ad63e737,0x866164ab910f1f15c54a30ea438724fec953a1aaf963bd998f47e05471a4bb60,62,false +2024-10-13 07:49:51.000 UTC,2024-10-13 00:00:00.000 UTC,2024-10-01 00:00:00.000 UTC,Floki Trading Bot,21008222,base,128.78879904000001,Buy,955759.5197680636,TYBG,0x0d97f261b1e88845184f678e2d1e7a98d9fd38de,0.052272,WETH,0x4200000000000000000000000000000000000006,0.021,2.710202,0.0011,ETH,0x4200000000000000000000000000000000000006,uniswap,3,TYBG-WETH,0xe745a591970e0fa981204cf525e170a2b9e4fb93,0x081120a2bb4882d04644790a1440be231e71c3fc,0x66dc9a8e7a87d501e8eb4ac8ddce4c9cb3d3cbc33304ea5e7d702f45cc3f5517,158,true +2024-10-14 17:32:43.000 UTC,2024-10-14 00:00:00.000 UTC,2024-10-01 00:00:00.000 UTC,Floki Trading Bot,21068908,base,0.32123877776357196,Sell,0.000122715137279037,WETH,0x4200000000000000000000000000000000000006,,,0xb0492857994e2af4ad0fa41d10bd711d4534f768,,,,ETH,0x4200000000000000000000000000000000000006,uniswap,2,,0xab10864ace3da8046e2218fbccda1c23318a4219,0xe162325f3579e99c7a051232c242b6f9bcc0f39c,0x2a89fbe29f1a7a4b37e97e17c08e721d102051966f47594ca05498e3a39a4425,110,true +2024-10-30 07:43:23.000 UTC,2024-10-30 00:00:00.000 UTC,2024-10-01 00:00:00.000 UTC,Floki Trading Bot,21742428,base,0.26436761999999997,Buy,2.808298863289798,TRUMP,0x2e1d332893dc16124194e598a29866d2d5e8786b,0.000099,WETH,0x4200000000000000000000000000000000000006,0.0101,0.00267038,0.000001,ETH,0x4200000000000000000000000000000000000006,uniswap,2,TRUMP-WETH,0xd33805985642fa9338e1fa150ca811406f96f0de,0x332f1d9653f43fb13668594cbc957bf7ad63e737,0x93f4a732fefdfe54bcfecba0584c253b077d157fb8ffc83dfcbd4084695a60b7,36,true +2024-10-17 03:07:37.000 UTC,2024-10-17 00:00:00.000 UTC,2024-10-01 00:00:00.000 UTC,Floki Trading Bot,21172555,base,0.3836886733810342,Sell,0.000146134268252482,WETH,0x4200000000000000000000000000000000000006,1104.249675604,NEIRO,0xa816ee97b1d7ae50fb0c68672a56f45334b90aa7,,,,ETH,0x4200000000000000000000000000000000000006,uniswap,2,NEIRO-WETH,0x052ed7ee8377e03b10c312b7cda7edb39d0daa33,0x332f1d9653f43fb13668594cbc957bf7ad63e737,0x5591cab4cb6daded34e3e5b7f366830dfa1e0ce388c375982ccce5dbb3294ef6,32,true +2024-10-14 17:32:43.000 UTC,2024-10-14 00:00:00.000 UTC,2024-10-01 00:00:00.000 UTC,Floki Trading Bot,21068908,base,287.07337637096515,Sell,0.10966374930129773,WETH,0x4200000000000000000000000000000000000006,,,0xb0492857994e2af4ad0fa41d10bd711d4534f768,,,,ETH,0x4200000000000000000000000000000000000006,uniswap,2,,0xab10864ace3da8046e2218fbccda1c23318a4219,0xe162325f3579e99c7a051232c242b6f9bcc0f39c,0x2a89fbe29f1a7a4b37e97e17c08e721d102051966f47594ca05498e3a39a4425,104,false diff --git a/dbt_subprojects/dex/seeds/bot_trades/flokibot/flokibot_bnb_trades_seed.csv b/dbt_subprojects/dex/seeds/bot_trades/flokibot/flokibot_bnb_trades_seed.csv new file mode 100644 index 00000000000..850cba1b57e --- /dev/null +++ b/dbt_subprojects/dex/seeds/bot_trades/flokibot/flokibot_bnb_trades_seed.csv @@ -0,0 +1,21 @@ +block_time,block_date,block_month,bot,block_number,blockchain,amount_usd,type,token_bought_amount,token_bought_symbol,token_bought_address,token_sold_amount,token_sold_symbol,token_sold_address,fee_percentage_fraction,fee_usd,fee_token_amount,fee_token_symbol,fee_token_address,project,version,token_pair,project_contract_address,user,tx_hash,evt_index,is_last_trade_in_transaction +2024-12-01 06:08:41.000 UTC,2024-12-01 00:00:00.000 UTC,2024-12-01 00:00:00.000 UTC,Floki Trading Bot,44484170,bnb,0.7069570199999999,Buy,15758.15255764733,CAT,0x6894cde390a3f51155ea41ed24a33a4827d3063d,0.001089,WBNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,0.0101,0.007140979999999999,0.000011,BNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,pancakeswap,2,CAT-WBNB,0x6df9adc1837bf37e0b1b943d59a7e50d9678c81b,0xa2692d110bddf9e3235f3b6d00e8108e3ccdfa04,0x6b4a3b71a5e8871bb802fe2448fe87db6af8d9a7dc4916be850f83339da35adf,72,true +2024-12-01 05:57:08.000 UTC,2024-12-01 00:00:00.000 UTC,2024-12-01 00:00:00.000 UTC,Floki Trading Bot,44483939,bnb,572.1670328391788,Sell,0.8813009762937307,WBNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,12851365.705668807,CAT,0x6894cde390a3f51155ea41ed24a33a4827d3063d,,,,BNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,pancakeswap,3,CAT-WBNB,0x588d7cf062f4edd7c7c7f2d66fd770e03b1ea735,0xcfa1c1596780cb77fba610f85826fea58e988842,0x3736d5260401f4829a383851e35167586ca074aff19e590f19dff4fd767ca5af,175,true +2024-12-01 05:38:59.000 UTC,2024-12-01 00:00:00.000 UTC,2024-12-01 00:00:00.000 UTC,Floki Trading Bot,44483576,bnb,63.6124781019977,Sell,0.09792109062389007,WBNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,1438290.103368273,CAT,0x6894cde390a3f51155ea41ed24a33a4827d3063d,,,,BNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,pancakeswap,3,CAT-WBNB,0x588d7cf062f4edd7c7c7f2d66fd770e03b1ea735,0x2e170be73bddd948f9dbd7b5ca873a5a48d40633,0xfd9e62486c20e559c92c33e3714f9c20b323e0c1315f27bd9b607beb866a3c1d,98,true +2024-12-01 06:17:56.000 UTC,2024-12-01 00:00:00.000 UTC,2024-12-01 00:00:00.000 UTC,Floki Trading Bot,44484355,bnb,0.6434406,Buy,14311.815785843628,CAT,0x6894cde390a3f51155ea41ed24a33a4827d3063d,0.00099,WBNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,0.0101,0.006499400000000001,0.00001,BNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,pancakeswap,2,CAT-WBNB,0x6df9adc1837bf37e0b1b943d59a7e50d9678c81b,0xc52102e7cf3a46aaaf59d4c16f63ab704a0753a1,0xf4858f045ab00048cb27931f63b21ee7abdc3dfad8c093fd70c11640a6b2263f,119,true +2024-12-01 05:44:53.000 UTC,2024-12-01 00:00:00.000 UTC,2024-12-01 00:00:00.000 UTC,Floki Trading Bot,44483694,bnb,0.6425892000000001,Buy,14504.676434395149,CAT,0x6894cde390a3f51155ea41ed24a33a4827d3063d,0.00099,WBNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,0.0101,0.0064908000000000006,0.00001,BNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,pancakeswap,2,CAT-WBNB,0x6df9adc1837bf37e0b1b943d59a7e50d9678c81b,0x7905e8e6323dcc3730ef51db9918f4d5496d6ed6,0x259ff14631286325766590034ab5e712144850622232cc6093d262e590839736,43,true +2024-12-01 02:55:02.000 UTC,2024-12-01 00:00:00.000 UTC,2024-12-01 00:00:00.000 UTC,Floki Trading Bot,44480297,bnb,320.74515,Buy,7336656.59421379,CAT,0x6894cde390a3f51155ea41ed24a33a4827d3063d,0.495,WBNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,0.0101,3.23985,0.005,BNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,pancakeswap,2,CAT-WBNB,0x6df9adc1837bf37e0b1b943d59a7e50d9678c81b,0x06aa01d9d5370a7853e4ce1c394487cbde38467c,0x2412a65ab0328ebb0a3d5c303d6cb3b491e6f6648260951691c354f0c19a007a,58,true +2024-12-01 05:10:11.000 UTC,2024-12-01 00:00:00.000 UTC,2024-12-01 00:00:00.000 UTC,Floki Trading Bot,44483000,bnb,0.6443118000000001,Buy,14538.50332775852,CAT,0x6894cde390a3f51155ea41ed24a33a4827d3063d,0.00099,WBNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,0.0101,0.006508200000000001,0.00001,BNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,pancakeswap,2,CAT-WBNB,0x6df9adc1837bf37e0b1b943d59a7e50d9678c81b,0x1d24d1b353caef80af08b4f3fda7210d4cbad32a,0x09ccd88430170286c7de82fb24f63c45d2f3cb5d1f327acd98f741835756b4eb,48,true +2024-12-01 03:04:59.000 UTC,2024-12-01 00:00:00.000 UTC,2024-12-01 00:00:00.000 UTC,Floki Trading Bot,44480496,bnb,320.22044999999997,Buy,7347347.6147423815,CAT,0x6894cde390a3f51155ea41ed24a33a4827d3063d,0.495,WBNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,,,,BNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,pancakeswap,2,CAT-WBNB,0x6df9adc1837bf37e0b1b943d59a7e50d9678c81b,0x40045b953b7168339f87dbe2c6c43f4808a27f46,0x78a178a37adc1be58b816b518fbc8d7d4ffc274d34ba9439ffc00569d944c909,66,true +2024-12-01 01:02:32.000 UTC,2024-12-01 00:00:00.000 UTC,2024-12-01 00:00:00.000 UTC,Floki Trading Bot,44478047,bnb,4.357445453967259,Sell,0.006693670241739007,WBNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,97174.31931894596,CAT,0x6894cde390a3f51155ea41ed24a33a4827d3063d,,,,BNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,uniswap,3,CAT-WBNB,0x05c0a0b84b6b67499c33e6403686f45cab063810,0xd6debea50b34fd002249fab262ca8af692e24ebf,0xf649f80b73c0efe000eedc6564f0f120c5a50cab0f4f3a6be1ce14e42b3b42aa,453,true +2024-12-01 05:24:59.000 UTC,2024-12-01 00:00:00.000 UTC,2024-12-01 00:00:00.000 UTC,Floki Trading Bot,44483296,bnb,64.43811,Buy,1456670.3541323277,CAT,0x6894cde390a3f51155ea41ed24a33a4827d3063d,0.099,WBNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,0.0101,0.65089,0.001,BNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,pancakeswap,2,CAT-WBNB,0x6df9adc1837bf37e0b1b943d59a7e50d9678c81b,0x19a48629d6bc384634223646065ab70ec1cf866d,0xd1b0e061b7dbeb0132cd0a935603ffeeb9a66322483fb55fd5df430fb862cd2a,65,true +2024-12-01 05:41:44.000 UTC,2024-12-01 00:00:00.000 UTC,2024-12-01 00:00:00.000 UTC,Floki Trading Bot,44483631,bnb,63.554928938311484,Sell,0.09791540170443008,WBNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,271196.736042164,FLOKI,0xfb5b838b6cfeedc2873ab27866079ac55363d37e,0.01,0.6355492893831144,0.0009791540170443,BNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,pancakeswap,2,FLOKI-WBNB,0x231d9e7181e8479a8b40930961e93e7ed798542c,0x2e170be73bddd948f9dbd7b5ca873a5a48d40633,0xf37fdb8195b2a6be26e189a7427c977803aa1652ff5207720696c60c9d05987e,42,true +2024-12-01 03:38:50.000 UTC,2024-12-01 00:00:00.000 UTC,2024-12-01 00:00:00.000 UTC,Floki Trading Bot,44481173,bnb,0.6430941,Buy,14534.765202561795,CAT,0x6894cde390a3f51155ea41ed24a33a4827d3063d,0.00099,WBNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,0.0101,0.006495900000000001,0.00001,BNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,pancakeswap,2,CAT-WBNB,0x6df9adc1837bf37e0b1b943d59a7e50d9678c81b,0xe408cfe7caf64196f57b15e8bc7c34c73acd38a9,0x85dbf4fd8f6fb97313e4cff6d3bb1156bb0cf43401484fdc9a5c3dd02bd514ba,44,true +2024-12-01 00:13:17.000 UTC,2024-12-01 00:00:00.000 UTC,2024-12-01 00:00:00.000 UTC,Floki Trading Bot,44477062,bnb,1552.5279138857659,Sell,2.3721548617005346,WBNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,21934,TOKEN,0x4507cef57c46789ef8d1a19ea45f4216bae2b528,0.01,15.52527913885766,0.023721548617005348,BNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,pancakeswap,2,TOKEN-WBNB,0x05616b7b6da03fb4c773b76663816b360ccaede4,0x559645f9eb8d6935bb489d6f04a8315372d70111,0x73ff2a7ae3f45bfcf375ea2e220f29e8ad8f5278f4c8fb8da28621ee48a59f01,183,true +2024-12-01 05:41:44.000 UTC,2024-12-01 00:00:00.000 UTC,2024-12-01 00:00:00.000 UTC,Floki Trading Bot,44483631,bnb,0.0016005088123281475,Sell,0.000002465811321144,WBNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,6.829533578,FLOKI,0xfb5b838b6cfeedc2873ab27866079ac55363d37e,397.092,0.6355492893831144,0.0009791540170443,BNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,pancakeswap,2,FLOKI-WBNB,0x231d9e7181e8479a8b40930961e93e7ed798542c,0x2e170be73bddd948f9dbd7b5ca873a5a48d40633,0xf37fdb8195b2a6be26e189a7427c977803aa1652ff5207720696c60c9d05987e,25,false +2024-12-01 00:13:17.000 UTC,2024-12-01 00:00:00.000 UTC,2024-12-01 00:00:00.000 UTC,Floki Trading Bot,44477062,bnb,0.4659387033785003,Sell,0.000711921989027167,WBNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,6.57984954,TOKEN,0x4507cef57c46789ef8d1a19ea45f4216bae2b528,33.3204,15.52527913885766,0.023721548617005348,BNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,pancakeswap,2,TOKEN-WBNB,0x05616b7b6da03fb4c773b76663816b360ccaede4,0x559645f9eb8d6935bb489d6f04a8315372d70111,0x73ff2a7ae3f45bfcf375ea2e220f29e8ad8f5278f4c8fb8da28621ee48a59f01,165,false +2024-12-01 05:49:47.000 UTC,2024-12-01 00:00:00.000 UTC,2024-12-01 00:00:00.000 UTC,Floki Trading Bot,44483792,bnb,824.6520450119638,Sell,1.2692422043525884,WBNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,18511266.159998745,CAT,0x6894cde390a3f51155ea41ed24a33a4827d3063d,,,,BNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,pancakeswap,3,CAT-WBNB,0x588d7cf062f4edd7c7c7f2d66fd770e03b1ea735,0xcfa1c1596780cb77fba610f85826fea58e988842,0xaa84f5c1c3bac9d228bebdd666d5b1d7817acbd4fbf6f3f6c06a37f53bce87bc,60,true +2024-12-01 06:52:26.000 UTC,2024-12-01 00:00:00.000 UTC,2024-12-01 00:00:00.000 UTC,Floki Trading Bot,44485045,bnb,0.7791272652408384,Sell,0.001198178059915785,WBNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,17439.9731907165,CAT,0x6894cde390a3f51155ea41ed24a33a4827d3063d,,,,BNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,pancakeswap,3,CAT-WBNB,0x1a1adea3c1e2f55526379a21023ef46714e73d06,0x365f65f76c581d0e00962392003b185e9c92a133,0x2d7aa90e273457d50efcb2866ebdd4918a62cf3ea3732de9e3f3fa36cf83acf8,83,true +2024-12-01 02:33:26.000 UTC,2024-12-01 00:00:00.000 UTC,2024-12-01 00:00:00.000 UTC,Floki Trading Bot,44479865,bnb,48.024672977768915,Sell,0.07382618711129563,WBNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,1082266.712964405,CAT,0x6894cde390a3f51155ea41ed24a33a4827d3063d,,,,BNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,pancakeswap,3,CAT-WBNB,0x588d7cf062f4edd7c7c7f2d66fd770e03b1ea735,0x596817f9472e492489de0bc24e4605d139abc19d,0x93b4b675c36ccde9c1561d9b574e21a0a74f9b222d14ef5b94d499075807c796,82,true +2024-12-01 05:49:20.000 UTC,2024-12-01 00:00:00.000 UTC,2024-12-01 00:00:00.000 UTC,Floki Trading Bot,44483783,bnb,66.89517120000001,Buy,1495280.3937194524,CAT,0x6894cde390a3f51155ea41ed24a33a4827d3063d,0.10296,WBNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,,,,BNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,uniswap,3,CAT-WBNB,0x05c0a0b84b6b67499c33e6403686f45cab063810,0xcfa1c1596780cb77fba610f85826fea58e988842,0x0607e759ff525b3f7f27dd5799be08347e19463da741be78c47e068494bed8c6,96,false +2024-12-01 05:48:56.000 UTC,2024-12-01 00:00:00.000 UTC,2024-12-01 00:00:00.000 UTC,Floki Trading Bot,44483775,bnb,859.503341921597,Sell,1.322882690884684,WBNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,19241616.414468314,CAT,0x6894cde390a3f51155ea41ed24a33a4827d3063d,,,,BNB,0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c,pancakeswap,3,CAT-WBNB,0x588d7cf062f4edd7c7c7f2d66fd770e03b1ea735,0xcfa1c1596780cb77fba610f85826fea58e988842,0x10c816a8e63272b4054b261659d060001a14b5bc6c208e04a46c21d34bd712b9,8,true diff --git a/dbt_subprojects/dex/seeds/bot_trades/flokibot/flokibot_ethereum_trades_seed.csv b/dbt_subprojects/dex/seeds/bot_trades/flokibot/flokibot_ethereum_trades_seed.csv new file mode 100644 index 00000000000..3a54630f1f8 --- /dev/null +++ b/dbt_subprojects/dex/seeds/bot_trades/flokibot/flokibot_ethereum_trades_seed.csv @@ -0,0 +1,21 @@ +block_time,block_date,block_month,bot,block_number,blockchain,amount_usd,type,token_bought_amount,token_bought_symbol,token_bought_address,token_sold_amount,token_sold_symbol,token_sold_address,fee_percentage_fraction,fee_usd,fee_token_amount,fee_token_symbol,fee_token_address,project,version,token_pair,project_contract_address,user,tx_hash,evt_index,is_last_trade_in_transaction +2024-02-13 13:26:11.000 UTC,2024-02-13 00:00:00.000 UTC,2024-02-01 00:00:00.000 UTC,Floki Trading Bot,19219371,ethereum,49.855582061697035,Buy,1541.058761682,TOKEN,0x4507cef57c46789ef8d1a19ea45f4216bae2b528,0.01864317630008864,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,,,,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,TOKEN-WETH,0xc7e6b676bfc73ae40bcc4577f22aab1682c691c6,0x78c4f5cef16333804394fe736fc5868351968fd7,0xb8f01482f050c21182adfb98f0c0331325b2118634e5458ecebdce61b9af3e9c,227,true +2024-02-13 13:26:11.000 UTC,2024-02-13 00:00:00.000 UTC,2024-02-01 00:00:00.000 UTC,Floki Trading Bot,19219371,ethereum,100.06479999999999,Buy,100,USDT,0xdac17f958d2ee523a2206206994597c13d831ec7,0.03751105931449979,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,,,,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,USDT-WETH,0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852,0x78c4f5cef16333804394fe736fc5868351968fd7,0xb8f01482f050c21182adfb98f0c0331325b2118634e5458ecebdce61b9af3e9c,218,false +2024-02-13 13:26:11.000 UTC,2024-02-13 00:00:00.000 UTC,2024-02-01 00:00:00.000 UTC,Floki Trading Bot,19219371,ethereum,49.855582061697035,Sell,0.01864317630008864,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,50,USDT,0xdac17f958d2ee523a2206206994597c13d831ec7,,,,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,USDT-WETH,0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852,0x78c4f5cef16333804394fe736fc5868351968fd7,0xb8f01482f050c21182adfb98f0c0331325b2118634e5458ecebdce61b9af3e9c,223,false +2024-02-13 12:42:47.000 UTC,2024-02-13 00:00:00.000 UTC,2024-02-01 00:00:00.000 UTC,Floki Trading Bot,19219163,ethereum,49.75253646823398,Buy,1538.612246785,TOKEN,0x4507cef57c46789ef8d1a19ea45f4216bae2b528,0.0185924761181016,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,,,,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,TOKEN-WETH,0xc7e6b676bfc73ae40bcc4577f22aab1682c691c6,0xa1198aa72fbc54441585425c7beb8b266ddfb951,0xc80cd0bdfd34a9f33437acba12d99116e217729cd9cbdf2feceec7ecdfd7016d,1112,true +2024-02-13 12:42:47.000 UTC,2024-02-13 00:00:00.000 UTC,2024-02-01 00:00:00.000 UTC,Floki Trading Bot,19219163,ethereum,49.75253646823398,Sell,0.0185924761181016,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,50,USDT,0xdac17f958d2ee523a2206206994597c13d831ec7,,,,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,USDT-WETH,0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852,0xa1198aa72fbc54441585425c7beb8b266ddfb951,0xc80cd0bdfd34a9f33437acba12d99116e217729cd9cbdf2feceec7ecdfd7016d,1108,false +2024-02-13 12:42:47.000 UTC,2024-02-13 00:00:00.000 UTC,2024-02-01 00:00:00.000 UTC,Floki Trading Bot,19219163,ethereum,100.0135,Buy,100,USDT,0xdac17f958d2ee523a2206206994597c13d831ec7,0.03740904788982464,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,,,,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,USDT-WETH,0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852,0xa1198aa72fbc54441585425c7beb8b266ddfb951,0xc80cd0bdfd34a9f33437acba12d99116e217729cd9cbdf2feceec7ecdfd7016d,1103,false +2024-02-17 21:36:23.000 UTC,2024-02-17 00:00:00.000 UTC,2024-02-01 00:00:00.000 UTC,Floki Trading Bot,19250287,ethereum,49.88413945963971,Buy,1461.637897524,TOKEN,0x4507cef57c46789ef8d1a19ea45f4216bae2b528,0.017853958811757907,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,,,,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,TOKEN-WETH,0xc7e6b676bfc73ae40bcc4577f22aab1682c691c6,0xd4f6bfd4bd2fef270dc5798c8320080b187ae089,0x69e356badb13f89d4a4246cef98b828bd6dfd29baac59a70caa7548e487fd408,114,true +2024-02-17 21:36:23.000 UTC,2024-02-17 00:00:00.000 UTC,2024-02-01 00:00:00.000 UTC,Floki Trading Bot,19250287,ethereum,100.0492,Buy,100,USDT,0xdac17f958d2ee523a2206206994597c13d831ec7,0.03592311227725229,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,,,,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,USDT-WETH,0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852,0xd4f6bfd4bd2fef270dc5798c8320080b187ae089,0x69e356badb13f89d4a4246cef98b828bd6dfd29baac59a70caa7548e487fd408,105,false +2024-02-17 21:36:23.000 UTC,2024-02-17 00:00:00.000 UTC,2024-02-01 00:00:00.000 UTC,Floki Trading Bot,19250287,ethereum,49.88413945963971,Sell,0.017853958811757907,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,50,USDT,0xdac17f958d2ee523a2206206994597c13d831ec7,,,,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,USDT-WETH,0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852,0xd4f6bfd4bd2fef270dc5798c8320080b187ae089,0x69e356badb13f89d4a4246cef98b828bd6dfd29baac59a70caa7548e487fd408,110,false +2024-02-25 00:41:47.000 UTC,2024-02-25 00:00:00.000 UTC,2024-02-01 00:00:00.000 UTC,Floki Trading Bot,19301087,ethereum,100.18169999999999,Buy,100,USDT,0xdac17f958d2ee523a2206206994597c13d831ec7,0.03352325931297117,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,,,,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,USDT-WETH,0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852,0x1ce9b29b82bb3e6d9a22b622b0c1398f0c2aafa6,0x719b7d0582dcb0b8064ed06dfebcb807d079dc32af66a1b9f6b983c9ef4ca627,225,false +2024-02-25 00:41:47.000 UTC,2024-02-25 00:00:00.000 UTC,2024-02-01 00:00:00.000 UTC,Floki Trading Bot,19301087,ethereum,49.820551418894055,Sell,0.0166612215927624,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,50,USDT,0xdac17f958d2ee523a2206206994597c13d831ec7,,,,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,USDT-WETH,0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852,0x1ce9b29b82bb3e6d9a22b622b0c1398f0c2aafa6,0x719b7d0582dcb0b8064ed06dfebcb807d079dc32af66a1b9f6b983c9ef4ca627,230,false +2024-02-25 00:41:47.000 UTC,2024-02-25 00:00:00.000 UTC,2024-02-01 00:00:00.000 UTC,Floki Trading Bot,19301087,ethereum,49.820551418894055,Buy,1365.848487601,TOKEN,0x4507cef57c46789ef8d1a19ea45f4216bae2b528,0.0166612215927624,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,,,,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,TOKEN-WETH,0xc7e6b676bfc73ae40bcc4577f22aab1682c691c6,0x1ce9b29b82bb3e6d9a22b622b0c1398f0c2aafa6,0x719b7d0582dcb0b8064ed06dfebcb807d079dc32af66a1b9f6b983c9ef4ca627,234,true +2024-02-14 02:36:47.000 UTC,2024-02-14 00:00:00.000 UTC,2024-02-01 00:00:00.000 UTC,Floki Trading Bot,19223276,ethereum,49.91385925985842,Sell,0.018989989940709252,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,50,USDT,0xdac17f958d2ee523a2206206994597c13d831ec7,,,,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,USDT-WETH,0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852,0x65c0697d67310caa44c20d5263d3ea2e24d8ff02,0x5bc2d176954a04eb066faca6fad27987a246798b29df266428d0c452568096d1,222,false +2024-02-14 02:36:47.000 UTC,2024-02-14 00:00:00.000 UTC,2024-02-01 00:00:00.000 UTC,Floki Trading Bot,19223276,ethereum,49.91385925985842,Buy,1605.382586816,TOKEN,0x4507cef57c46789ef8d1a19ea45f4216bae2b528,0.018989989940709252,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,,,,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,TOKEN-WETH,0xc7e6b676bfc73ae40bcc4577f22aab1682c691c6,0x65c0697d67310caa44c20d5263d3ea2e24d8ff02,0x5bc2d176954a04eb066faca6fad27987a246798b29df266428d0c452568096d1,226,true +2024-02-14 02:36:47.000 UTC,2024-02-14 00:00:00.000 UTC,2024-02-01 00:00:00.000 UTC,Floki Trading Bot,19223276,ethereum,100.07159999999999,Buy,100,USDT,0xdac17f958d2ee523a2206206994597c13d831ec7,0.03820886646960064,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,,,,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,USDT-WETH,0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852,0x65c0697d67310caa44c20d5263d3ea2e24d8ff02,0x5bc2d176954a04eb066faca6fad27987a246798b29df266428d0c452568096d1,217,false +2024-02-13 13:47:59.000 UTC,2024-02-13 00:00:00.000 UTC,2024-02-01 00:00:00.000 UTC,Floki Trading Bot,19219479,ethereum,49.96830409960819,Sell,0.01889796721755456,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,50,USDT,0xdac17f958d2ee523a2206206994597c13d831ec7,,,,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,USDT-WETH,0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852,0xa1198aa72fbc54441585425c7beb8b266ddfb951,0x45415f4c4e7305ee67ea859634542ae5e5795fb4d6653574fe9f76e092c5c6f0,136,false +2024-02-13 13:47:59.000 UTC,2024-02-13 00:00:00.000 UTC,2024-02-01 00:00:00.000 UTC,Floki Trading Bot,19219479,ethereum,49.96830409960819,Buy,1575.491567539,TOKEN,0x4507cef57c46789ef8d1a19ea45f4216bae2b528,0.01889796721755456,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,,,,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,TOKEN-WETH,0xc7e6b676bfc73ae40bcc4577f22aab1682c691c6,0xa1198aa72fbc54441585425c7beb8b266ddfb951,0x45415f4c4e7305ee67ea859634542ae5e5795fb4d6653574fe9f76e092c5c6f0,140,true +2024-02-13 13:47:59.000 UTC,2024-02-13 00:00:00.000 UTC,2024-02-01 00:00:00.000 UTC,Floki Trading Bot,19219479,ethereum,100.0727,Buy,100,USDT,0xdac17f958d2ee523a2206206994597c13d831ec7,0.038023711998634656,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,,,,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,USDT-WETH,0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852,0xa1198aa72fbc54441585425c7beb8b266ddfb951,0x45415f4c4e7305ee67ea859634542ae5e5795fb4d6653574fe9f76e092c5c6f0,131,false +2024-02-20 14:10:59.000 UTC,2024-02-20 00:00:00.000 UTC,2024-02-01 00:00:00.000 UTC,Floki Trading Bot,19269419,ethereum,49.89031343571954,Buy,1348.528098563,TOKEN,0x4507cef57c46789ef8d1a19ea45f4216bae2b528,0.016691361776292175,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,,,,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,TOKEN-WETH,0xc7e6b676bfc73ae40bcc4577f22aab1682c691c6,0xa1ab11e84b88e06b54ece58d79b46df8d006aab4,0x430711fe0aeae96ac381b8b6a9de64f4e40b3ab77c6e094da92bf4d2b88e3f2f,154,true +2024-02-20 14:10:59.000 UTC,2024-02-20 00:00:00.000 UTC,2024-02-01 00:00:00.000 UTC,Floki Trading Bot,19269419,ethereum,100.1747,Buy,100,USDT,0xdac17f958d2ee523a2206206994597c13d831ec7,0.03358390458672427,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,,,,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,USDT-WETH,0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852,0xa1ab11e84b88e06b54ece58d79b46df8d006aab4,0x430711fe0aeae96ac381b8b6a9de64f4e40b3ab77c6e094da92bf4d2b88e3f2f,145,false diff --git a/dbt_subprojects/dex/seeds/bot_trades/flokibot/schema.yml b/dbt_subprojects/dex/seeds/bot_trades/flokibot/schema.yml new file mode 100644 index 00000000000..49ff5c1ad78 --- /dev/null +++ b/dbt_subprojects/dex/seeds/bot_trades/flokibot/schema.yml @@ -0,0 +1,33 @@ +version: 2 + +seeds: + - name: flokibot_base_trades_seed + config: + column_types: + version: varchar + token_bought_address: varbinary + token_sold_address: varbinary + fee_token_address: varbinary + project_contract_address: varbinary + user: varbinary + tx_hash: varbinary + - name: flokibot_bnb_trades_seed + config: + column_types: + version: varchar + token_bought_address: varbinary + token_sold_address: varbinary + fee_token_address: varbinary + project_contract_address: varbinary + user: varbinary + tx_hash: varbinary + - name: flokibot_ethereum_trades_seed + config: + column_types: + version: varchar + token_bought_address: varbinary + token_sold_address: varbinary + fee_token_address: varbinary + project_contract_address: varbinary + user: varbinary + tx_hash: varbinary diff --git a/dbt_subprojects/dex/seeds/bot_trades/pepeboost/pepeboost_ethereum_trades_seed.csv b/dbt_subprojects/dex/seeds/bot_trades/pepeboost/pepeboost_ethereum_trades_seed.csv new file mode 100644 index 00000000000..5645bdd3976 --- /dev/null +++ b/dbt_subprojects/dex/seeds/bot_trades/pepeboost/pepeboost_ethereum_trades_seed.csv @@ -0,0 +1,21 @@ +block_time,block_date,block_month,bot,block_number,blockchain,amount_usd,type,token_bought_amount,token_bought_symbol,token_bought_address,token_sold_amount,token_sold_symbol,token_sold_address,fee_percentage_fraction,fee_usd,fee_token_amount,fee_token_symbol,fee_token_address,project,version,token_pair,project_contract_address,user,tx_hash,evt_index,is_last_trade_in_transaction +2024-03-16 11:48:11.000 UTC,2024-03-16 00:00:00.000 UTC,2024-03-01 00:00:00.000 UTC,Pepeboost,19447257,ethereum,1827.9162000000001,Buy,50817275171.0449,HELGA,0x78e3b2ee11950df78a35fd924e92fbb8d1403780,0.495,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,0.01,18.463800000000003,0.005,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,HELGA-WETH,0x5484094940909b16fe991d1adad6a40dfef63417,0x85dba58d67e021489ee1f843de7a7e1fc1ec60e7,0x91f963bc342304acdec15f1716199e8f32e6a3e66bdf88a9e9129fa2a21fa563,58,true +2024-03-10 08:09:23.000 UTC,2024-03-10 00:00:00.000 UTC,2024-03-01 00:00:00.000 UTC,Pepeboost,19403410,ethereum,371.51845134960644,Sell,0.09389271523478493,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,8895.610034508,TRSCT,0xfe98796e0af4ababd716508429e51ff9ac1bb4d5,0.005,3.715184513496063,0.000938927152347849,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,TRSCT-WETH,0xd4fe3d36d8c405833972987c5fd977345aae2e8a,0x2c32c56471ddae47225ee82658c176945733b180,0x4290ee906089f82d1ba46320d3d2f0737a895009f701afc0d7adfc8e31fbb81d,55,true +2024-03-17 04:57:35.000 UTC,2024-03-17 00:00:00.000 UTC,2024-03-01 00:00:00.000 UTC,Pepeboost,19452334,ethereum,282.385224,Buy,9586055909.065296,Jason,0x5d101234df81ab0dfea96e089e3c3dd8840a6ac9,0.0792,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,0.01,2.852376,0.0008,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,Jason-WETH,0x49cb6005bcb0aac703e724abe7e76786e9b46226,0xe8490eefeecdcf6cde83dd58ba084c40d98c6535,0xcd74520b2128a5896bfe82f63154cfa89d2febe57b6de5d78df92c63531a3ffd,104,true +2024-03-04 14:12:35.000 UTC,2024-03-04 00:00:00.000 UTC,2024-03-01 00:00:00.000 UTC,Pepeboost,19362317,ethereum,689.63202,Buy,87639994.84559023,TRUMP INU,0xd3fb8597d260efb2e693efd500d62a330a00f1eb,0.198,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,0.01,6.96598,0.002,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,TRUMP INU-WETH,0xa20379e47b2b9b5a02557fd2c862d2915a509bd3,0xf64e814ffad5be14f87a28ab96f9f7112c02d402,0x4835dbed040a104d98fd2e8b8e765e9381dca73c351d28c8b33eb8f6be8106a1,75,true +2024-03-10 07:58:23.000 UTC,2024-03-10 00:00:00.000 UTC,2024-03-01 00:00:00.000 UTC,Pepeboost,19403356,ethereum,979.39215,Buy,710909441.5894133,BOYSCLUB,0x2d9996f3b9d2e73540fdbfdfe81d71e9e08cbf03,0.2475,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,0.01,9.89285,0.0025,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,BOYSCLUB-WETH,0x7dbc4253e35f20be7164f0a3e0959c33136d007d,0x422412ee213110bc6a7ef3d1d14237893a862bb2,0xefd57d544fade3d4261a7edf0d4f6c0a752802fe79c06ae11a1b04709892141a,94,true +2024-03-02 11:30:23.000 UTC,2024-03-02 00:00:00.000 UTC,2024-03-01 00:00:00.000 UTC,Pepeboost,19347195,ethereum,676.22544,Buy,5989066734.089885,HELGA,0x78e3b2ee11950df78a35fd924e92fbb8d1403780,0.198,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,0.01,6.83056,0.002,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,HELGA-WETH,0x5484094940909b16fe991d1adad6a40dfef63417,0x7523a8fdbcc92143cf523b6d771433369e915722,0x18f32fec182dba1359473a365d08eb6ead9701d38b8ab31b286976aec8582b61,44,true +2024-03-24 03:17:59.000 UTC,2024-03-24 00:00:00.000 UTC,2024-03-01 00:00:00.000 UTC,Pepeboost,19501691,ethereum,1317.00096,Buy,1829.0936718975227,DEAI,0x1495bc9e44af1f8bcb62278d2bec4540cf0c05ea,0.396,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,0.01,13.303040000000001,0.004,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,3,DEAI-WETH,0x1385fc1fe0418ea0b4fcf7adc61fc7535ab7f80d,0x854afe28e369c5c2a11f6db6eb40474715c6f121,0xea9797fd00cee663435ccea89614ec3e15f232c9b71173363583727c4cda4eba,25,true +2024-03-28 04:34:23.000 UTC,2024-03-28 00:00:00.000 UTC,2024-03-01 00:00:00.000 UTC,Pepeboost,19530259,ethereum,788.4641517453738,Sell,0.22455688987963482,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,169786.953716372,ZENO,0xd51e4965ad973e8c1e1f22369bb884e6914b012c,0.005,7.884641517453737,0.002245568898796348,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,WETH-ZENO,0xef64da9c4840b2c88b2f73b79db3c4e51e27f53a,0xd11f4f01e19d81f8f5abe1f72b1703abfa6b2bbe,0x7568957888e39759fb13c2f16ea0c6216fcbafe34a51ec6e8f9f051e7b4e2858,29,true +2024-03-16 18:38:23.000 UTC,2024-03-16 00:00:00.000 UTC,2024-03-01 00:00:00.000 UTC,Pepeboost,19449282,ethereum,797.8422523975116,Sell,0.22122464352984395,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,3854750.491038198,vitalek,0xf5264e1673c9365e7c5d4d1d8b440bbf131ff435,0.005,7.978422523975114,0.002212246435298439,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,vitalek-WETH,0xc8733a25df841f25afeb97ac77e39909d80d5a37,0x9e2d558fccde1ba893ccd00a967dcb39385cae8f,0x9e43de67645117f2b226bdc4e8487fd840cec5640659a5fec57b982c830810c7,145,true +2024-03-01 15:37:23.000 UTC,2024-03-01 00:00:00.000 UTC,2024-03-01 00:00:00.000 UTC,Pepeboost,19341264,ethereum,530.3106900148174,Sell,0.15543473953989473,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,5985742.476313816,VAI,0x0cbda0b3fafc4f3730e2c574f52c01c7d94a8a0c,0.005,5.303106900148173,0.001554347395398947,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,VAI-WETH,0x9021acf529ea6a068188e948891db3450bd9f35b,0x84c54ed3b718abd4fa7890b8ce140de6df4e3559,0xc7952373fbacede7463bf770c785da9a818d4063de3760962015079c33f1e661,57,true +2024-03-10 14:53:35.000 UTC,2024-03-10 00:00:00.000 UTC,2024-03-01 00:00:00.000 UTC,Pepeboost,19405416,ethereum,1776.9845572782094,Sell,0.45657597348347356,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,899875.5930412533,vitalek,0xf5264e1673c9365e7c5d4d1d8b440bbf131ff435,0.005,17.769845572782092,0.004565759734834735,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,vitalek-WETH,0xc8733a25df841f25afeb97ac77e39909d80d5a37,0x7523a8fdbcc92143cf523b6d771433369e915722,0x6ae1f85413e33f71f5528b1dd620916b0e1abc5e993ec626ed4b7d6936029c42,80,true +2024-03-10 05:31:23.000 UTC,2024-03-10 00:00:00.000 UTC,2024-03-01 00:00:00.000 UTC,Pepeboost,19402622,ethereum,322.89277658668607,Sell,0.0816455851448454,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,608817.981919313,BRETT,0x80ee5c641a8ffc607545219a3856562f56427fe9,0.005,3.2289277658668603,0.000816455851448454,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,BRETT-WETH,0x95f2610d0475d72e75bfcbd8bb7ecafe1f351b8d,0xca1857c70aa23f9b5620dbe2bd71b46cd4cb8386,0x6da3fe9d1d3fe30f4e67ed3392984d620805754c1581a4c06227d1e365a15d56,60,true +2024-03-14 07:10:23.000 UTC,2024-03-14 00:00:00.000 UTC,2024-03-01 00:00:00.000 UTC,Pepeboost,19431678,ethereum,789.6517200000001,Buy,758892204.8401858,SPEPE,0x7dafe897a6ff1d7b0b64f908e60e8665b61d53af,0.198,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,0.01,7.97628,0.002,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,SPEPE-WETH,0xf4041d29ad20219188cb6f4a3ea0fd1b8192a856,0xe4fe0f848583560b8d58a11288cf3dcb1d97ba81,0xe3fe2589cfb03be13632d3f0c588b96a73192cf965ea771c254b2b8cb8ff2709,35,true +2024-03-27 06:32:59.000 UTC,2024-03-27 00:00:00.000 UTC,2024-03-01 00:00:00.000 UTC,Pepeboost,19523922,ethereum,7149.4632,Buy,2837722531.63614,GROK1.5,0xa711bcc2b6f5c4fc3dfaccc2a01148765cbbab1c,1.98,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,0.01,72.2168,0.02,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,GROK1.5-WETH,0x8a4008961a27752e1c7178b73b9d5fa1d37fee3c,0x4f75a7ca7f6c527d051e400795307e5a395f1b05,0xeca5c9e2e45077a7fe9f4fb19cc4279d8d3556fa3a808c77a822352f9397e56b,46,true +2024-03-07 16:11:35.000 UTC,2024-03-07 00:00:00.000 UTC,2024-03-01 00:00:00.000 UTC,Pepeboost,19384405,ethereum,761.65056,Buy,35389.9155006131,HOSTAI,0x07e128e823d2b9b22edbda43820aa1a72de99613,0.198,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,0.01,7.69344,0.002,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,HOSTAI-WETH,0x88ee95da6046bc3256d43b7c6883e61415b6e442,0xc7576de93acff71a4516476431a03a1a7f20f3a6,0xd4439e2a97d08d5ee847dc38b80e8b33957db593d5543c88784f24d266cef0c4,47,true +2024-03-07 19:50:35.000 UTC,2024-03-07 00:00:00.000 UTC,2024-03-01 00:00:00.000 UTC,Pepeboost,19385493,ethereum,4276.941256077766,Sell,1.1036555721767025,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,2612.2416695698207,TAS,0x64d5fea7d2d600918b76159285994d6ed218f264,0.005,42.76941256077766,0.011036555721767025,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,TAS-WETH,0x40849deb556ff2c682088a12b0299ad821ae231a,0xa0a8cdf195b8f383339946a6d748ef6b1d55337e,0x410aa5ad1888333775a990fcb0faf140470b0b8e2036d20aa3e0a9b954963790,62,true +2024-03-12 17:37:11.000 UTC,2024-03-12 00:00:00.000 UTC,2024-03-01 00:00:00.000 UTC,Pepeboost,19420533,ethereum,341.20073688283304,Sell,0.08796962241282545,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,894722874971.9131,Dinger,0xcd145189a12ccc3f9c622766fb20d00dc2059ead,0.005,3.4120073688283283,0.000879696224128254,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,Dinger-WETH,0x62f0a25f884cc9bf186196cc1cae15a58fce4732,0xccbb78b5b5066128c70310aaf87254e33054711f,0xef54f3fd55bf02228fdd390ffa11f60415c7c37c6375445c45aa4a5fc456c7b5,55,true +2024-03-15 23:39:35.000 UTC,2024-03-15 00:00:00.000 UTC,2024-03-01 00:00:00.000 UTC,Pepeboost,19443665,ethereum,1420.366789210197,Sell,0.380544410177255,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,495160811.29605335,GROK1.5,0xa711bcc2b6f5c4fc3dfaccc2a01148765cbbab1c,0.005,14.203667892101969,0.003805444101772549,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,GROK1.5-WETH,0x8a4008961a27752e1c7178b73b9d5fa1d37fee3c,0x6ff42a9d716ffa5f8e234d00486065226e0376d4,0x7f9e9f40792db4c65e763bc10233eaafec8d163783840fcedadfcec35dea2196,23,true +2024-03-07 03:59:59.000 UTC,2024-03-07 00:00:00.000 UTC,2024-03-01 00:00:00.000 UTC,Pepeboost,19380769,ethereum,1311.07284,Buy,1158788900.8645384,DieHarder,0xeea5fb81328343984298819275bda5489e796e62,0.3465,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,0.01,13.243160000000001,0.0035,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,DieHarder-WETH,0x70410f43d761c5134fdb6e427beb57c1849bac0f,0x79eb850503df9c01997c4ce4ee35a240cce9a45e,0x5cd2a3a05f9f173704256bad8e47e4aabb8abb3220065870a128002a2b5055d2,64,true +2024-03-18 04:24:23.000 UTC,2024-03-18 00:00:00.000 UTC,2024-03-01 00:00:00.000 UTC,Pepeboost,19459285,ethereum,12.078782121141744,Sell,0.003364600753529773,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,845.6214538922925,RAI,0x049c3ee0c38742c1d4904ae957de66d2b240031d,0.005,0.12078782121141482,0.000033646007535297,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,RAI-WETH,0xd12dabe90a1b3dbbf11f257d9d57014ac5ca74cf,0xce23b9958e8e72c716a58041110d05bd705abfff,0xf672df35cd8d7454a7a018da265152a811c2bd05ad21600e1cf9f553e72c5f9e,25,true diff --git a/dbt_subprojects/dex/seeds/bot_trades/pepeboost/schema.yml b/dbt_subprojects/dex/seeds/bot_trades/pepeboost/schema.yml new file mode 100644 index 00000000000..dd18e224376 --- /dev/null +++ b/dbt_subprojects/dex/seeds/bot_trades/pepeboost/schema.yml @@ -0,0 +1,13 @@ +version: 2 + +seeds: + - name: pepeboost_ethereum_trades_seed + config: + column_types: + version: varchar + token_bought_address: varbinary + token_sold_address: varbinary + fee_token_address: varbinary + project_contract_address: varbinary + user: varbinary + tx_hash: varbinary diff --git a/dbt_subprojects/dex/seeds/bot_trades/readyswap/readyswap_ethereum_trades_seed.csv b/dbt_subprojects/dex/seeds/bot_trades/readyswap/readyswap_ethereum_trades_seed.csv new file mode 100644 index 00000000000..ee3a5c3659c --- /dev/null +++ b/dbt_subprojects/dex/seeds/bot_trades/readyswap/readyswap_ethereum_trades_seed.csv @@ -0,0 +1,21 @@ +block_time,block_date,block_month,bot,block_number,blockchain,amount_usd,type,token_bought_amount,token_bought_symbol,token_bought_address,token_sold_amount,token_sold_symbol,token_sold_address,fee_percentage_fraction,fee_usd,fee_token_amount,fee_token_symbol,fee_token_address,project,version,token_pair,project_contract_address,user,tx_hash,evt_index,is_last_trade_in_transaction +2024-07-22 14:22:35.000 UTC,2024-07-22 00:00:00.000 UTC,2024-07-01 00:00:00.000 UTC,ReadySwap,20362638,ethereum,345.40629,Buy,422329649.8284222,DMAGA,0x07b74763b630f59eba4f711b4745a4b38dcc15ee,0.0995,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,0.0043,1.73571,0.0005,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,DMAGA-WETH,0xa34b6c3086737b6ded2908b08994ade3aed941e8,0x7cdd83f650f583dcbd53bf3507ab3a8ca8f7c35e,0x68c30a2223e31de4a8a1ebf281d88a332c0a2d7598b9b343a208889cc7795dd3,29,true +2024-07-31 10:07:23.000 UTC,2024-07-31 00:00:00.000 UTC,2024-07-01 00:00:00.000 UTC,ReadySwap,20425833,ethereum,3301.5890999999997,Buy,27100.76761123,NEIRO,0xee2a03aa6dacf51c18679c516ad5283d8e7c2637,0.995,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,0.005,16.590899999999998,0.005,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,NEIRO-WETH,0x3885fbe4cd8aed7b7e9625923927fa1ce30662a3,0x0b7c57a13b1fcf185cbdf40382c721429b4352f0,0xafda1b81ef6d67bff0b990d9ce011e82fab39478299448409046ffcbf43a87e3,14,true +2024-07-16 21:13:11.000 UTC,2024-07-16 00:00:00.000 UTC,2024-07-01 00:00:00.000 UTC,ReadySwap,20321686,ethereum,15.944534061147703,Sell,0.004630274096176523,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,,,0xd40c688da9df74e03566eaf0a7c754ed98fbb8cc,0.0025,0.0797226703057364,0.000023151370480882,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,,0x8ee1270d83705e7202e9b56aa7e15eeed58c046b,0xfcf058d3219fb91383a0f2f5972a84d7951147a1,0x29833ead514731eeea0004aa416c385e022079427ce8a281d603e2ab9b4eaa84,374,true +2024-07-25 07:11:47.000 UTC,2024-07-25 00:00:00.000 UTC,2024-07-01 00:00:00.000 UTC,ReadySwap,20381989,ethereum,303.2560508324369,Sell,0.09554772275878877,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,8414.655882369,DRIP,0xb8a914a00664e9361eae187468eff94905dfbc15,0.0025,1.5162802541621818,0.000477738613793943,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,DRIP-WETH,0x4374eead5e21540f9ce0695ebb92708313d1f42b,0x9c3543ffc3dc675dceecaa430f74a1dc8fc0874b,0x858f89a07d1636e29359b40bf475050ae1013a32a338eefd17a3d65997fedab1,225,true +2024-07-24 06:26:11.000 UTC,2024-07-24 00:00:00.000 UTC,2024-07-01 00:00:00.000 UTC,ReadySwap,20374600,ethereum,350.62905929124753,Sell,0.1017330495599228,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,584415863606.6559,Mogei,0xb1c8f9a6ced16d5eac825c59afb9c76504941158,0.0025,1.7531452964562342,0.000508665247799613,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,Mogei-WETH,0x112a9f103222060c6fa5b8ec576cd559c94e43f0,0x9c3543ffc3dc675dceecaa430f74a1dc8fc0874b,0x58dcf2edc13a845410a47dbe27f46b7475e41e14d4676fd87fb08dde46f5a287,173,true +2024-07-18 11:06:11.000 UTC,2024-07-18 00:00:00.000 UTC,2024-07-01 00:00:00.000 UTC,ReadySwap,20332996,ethereum,850.4427385211566,Sell,0.24686721351348836,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,471283.4902592069,TRUMP,0x194605aa511d90f1cbfec2d6aa61c3d713f7157e,0.0025,4.25221369260578,0.001234336067567441,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,TRUMP-WETH,0xc82f817bb2dbbdee88f954e0c42332662b8870fa,0x9c3543ffc3dc675dceecaa430f74a1dc8fc0874b,0x126156ad631ffb8d78f637635f90ea66852f11de0cf524db7f2c1f48053e3b48,204,true +2024-07-18 19:55:11.000 UTC,2024-07-18 00:00:00.000 UTC,2024-07-01 00:00:00.000 UTC,ReadySwap,20335630,ethereum,379.409454825,Buy,250493711927.0643,WWNF,0x2ec6603cff128dd4500e6edc90cf4a25050f37b3,0.1113405,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,0.005,1.906580175,0.0005595,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,WETH-WWNF,0x921b9fc57124651642678a1865fad627e3b8eb4d,0x2de65f84526dc07fd874b43047b34aa5bc1cb288,0xc9321e9481eda34506ba6a9ffb42118c4b215fe2ae98adaa41cafb3a1c9f2ee7,146,true +2024-07-30 05:55:59.000 UTC,2024-07-30 00:00:00.000 UTC,2024-07-01 00:00:00.000 UTC,ReadySwap,20417432,ethereum,3294.5643999999998,Buy,63220.338506264,NEIRO,0xee2a03aa6dacf51c18679c516ad5283d8e7c2637,0.995,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,0.005,16.5556,0.005,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,NEIRO-WETH,0x3885fbe4cd8aed7b7e9625923927fa1ce30662a3,0xac3a26d1580104febcddb8ec96df42b46c28928d,0x4a468319d8711bb0a5ee6867cf8922b492a7d9c3c16ba37e137ed49810e619d5,263,true +2024-07-31 16:56:11.000 UTC,2024-07-31 00:00:00.000 UTC,2024-07-01 00:00:00.000 UTC,ReadySwap,20427865,ethereum,5267.304618285685,Sell,1.599341905461704,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,44048.834400221,NEIRO,0xee2a03aa6dacf51c18679c516ad5283d8e7c2637,0.0025,26.336523091428425,0.00799670952730852,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,NEIRO-WETH,0x3885fbe4cd8aed7b7e9625923927fa1ce30662a3,0xac3a26d1580104febcddb8ec96df42b46c28928d,0xbd333a302493f2858aec79108ee09f1ee7f9a63f72adc17abaf871e2ef0523c6,83,true +2024-07-10 06:45:35.000 UTC,2024-07-10 00:00:00.000 UTC,2024-07-01 00:00:00.000 UTC,ReadySwap,20274391,ethereum,154.77822,Buy,449.5044853880837,NATOR,0x6f483e2828da4373fc86ea31293137a4270f4762,0.04975,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,0.005,0.77778,0.00025,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,NATOR-WETH,0x983f144ff1a7ce824e26b02a103f6e9c1d7e3a3f,0xffa6eab550d571eb0c473142475a759e1492c7a3,0x5c0604a5d1540eaa06089c7429452077090c53dfb059c19056201278d5906eda,260,true +2024-07-16 01:31:23.000 UTC,2024-07-16 00:00:00.000 UTC,2024-07-01 00:00:00.000 UTC,ReadySwap,20315798,ethereum,3458.7294500000003,Buy,270291249.7936392,COOMER,0x494930dabcfa57748a4c4788c0054f723a789047,0.995,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,0.005,17.38055,0.005,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,COOMER-WETH,0xf44c7cb42e6d4f74568752b7b1443c319f97eaf3,0x0b7c57a13b1fcf185cbdf40382c721429b4352f0,0x38ae5b89b574fbb4cd97485249248c9896213be5779f9e0869791dab2bb4d056,14,true +2024-07-19 20:34:47.000 UTC,2024-07-19 00:00:00.000 UTC,2024-07-01 00:00:00.000 UTC,ReadySwap,20343000,ethereum,3484.6492,Buy,65598.387221542,SWAG,0x36c7188d64c44301272db3293899507eabb8ed43,0.995,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,0.005,17.5108,0.005,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,SWAG-WETH,0x0f388ecdbc128083bfe317b00de2c25fbe9f24d5,0x0b7c57a13b1fcf185cbdf40382c721429b4352f0,0x95796ac0ec0d3d903d7dd9146dbf77cc99317c24f24c0db9564c43bddf06cec8,69,true +2024-07-15 04:33:35.000 UTC,2024-07-15 00:00:00.000 UTC,2024-07-01 00:00:00.000 UTC,ReadySwap,20309551,ethereum,13271.588600000001,Buy,10476342.955435243,WOJAK,0x5026f006b85729a8b14553fae6af249ad16c9aab,3.98,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,0.005,66.6914,0.02,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,WETH-WOJAK,0x0f23d49bc92ec52ff591d091b3e16c937034496e,0x0b7c57a13b1fcf185cbdf40382c721429b4352f0,0x5443ab276759d1c5a0e7c61f05387731cbf1fc9de8528def209a3754964acc35,4,true +2024-07-29 16:21:47.000 UTC,2024-07-29 00:00:00.000 UTC,2024-07-01 00:00:00.000 UTC,ReadySwap,20413384,ethereum,527.7406279877619,Sell,0.15953465174962572,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,65772.866040966,SEX,0x92f04e0c56eef8b6bdbade5448105dc78087887d,0.0025,2.6387031399388072,0.000797673258748128,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,SEX-WETH,0x087edec2bab72f1bbc4fda1e431bea3cc5db5a9c,0x960f81aefeabb64250c17df87d5311e1814ab791,0xb0fde0cfac973a3683ee54a2c8b28ec5aaf60f1bfa69a554eee8c90c31edfbc0,258,true +2024-07-17 05:32:59.000 UTC,2024-07-17 00:00:00.000 UTC,2024-07-01 00:00:00.000 UTC,ReadySwap,20324179,ethereum,360.6876433328931,Sell,0.10276762476220265,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,10098040337.961311,PEEZY,0x69ee720c120ec7c9c52a625c04414459b3185f23,0.0025,1.8034382166644645,0.000513838123811013,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,PEEZY-WETH,0x06acf8b25ab8ce249f487d30d78be4fc021cff8a,0x9c3543ffc3dc675dceecaa430f74a1dc8fc0874b,0x158ed62055b4fd7487325df6ec8aab44ff9c0e05e1508caefe8384d6a283fd0c,343,true +2024-07-23 10:30:35.000 UTC,2024-07-23 00:00:00.000 UTC,2024-07-01 00:00:00.000 UTC,ReadySwap,20368644,ethereum,310.1347147333576,Sell,0.08803842335847233,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,1707251.6554004955,TRUMPZ,0x8c68a74a69e2cd2815cad9c0379fccb960f64cdd,0.0025,1.5506735736667858,0.000440192116792361,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,TRUMPZ-WETH,0xf5bc62f2f0ac3d5d18c564d74b9b810f284cf59f,0x404dc1f5f7286eb06854771e69b7789c7d81ea7c,0xa20b7ffb5f8da40eecc338b35fe91e10911485e6ba3d889ff5302dcb3ebdcd2e,25,true +2024-07-22 11:09:47.000 UTC,2024-07-22 00:00:00.000 UTC,2024-07-01 00:00:00.000 UTC,ReadySwap,20361682,ethereum,334.28769966243993,Sell,0.095642758338633,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,8363830.977371112,BEBE,0xe5d4032078f9c85b6290f2c96de2dc8e2f08f14f,0.0025,1.6714384983121995,0.000478213791693165,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,BEBE-WETH,0x542ef1edf02a4e1e7a48789faf090137fac47868,0x037d6d7ee801c624cd62bdf3203e0150dbd3f699,0xfb23b381e28d1f5604d407574d0043933e47005547ab794d34cbff46f213b414,24,true +2024-07-19 08:57:11.000 UTC,2024-07-19 00:00:00.000 UTC,2024-07-01 00:00:00.000 UTC,ReadySwap,20339524,ethereum,338.016425,Buy,176406375.92947543,BUMP,0xc423de90302f3a6d37df24f097f706089e18f95c,0.0995,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,0.005,1.6985750000000002,0.0005,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,BUMP-WETH,0xda739f15ce628702c9a63eea77fae41d3e81035b,0x9c3543ffc3dc675dceecaa430f74a1dc8fc0874b,0x7902c12c94bf505e968cd32eb84c216eba5f31df42c281e3cb780c60e5a874f5,282,true +2024-07-22 16:23:23.000 UTC,2024-07-22 00:00:00.000 UTC,2024-07-01 00:00:00.000 UTC,ReadySwap,20363239,ethereum,344.53765500000003,Buy,774928.712843622,HARRIS,0xc69aa0d3b6b0043a3a36ac9fa9b6c479b3a7e105,0.0995,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,0.005,1.7313450000000001,0.0005,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,HARRIS-WETH,0x8e8a5dd7960a428cced2b4e0c2054ea7888ec75e,0x9c3543ffc3dc675dceecaa430f74a1dc8fc0874b,0x8425d1571d54625747bcf03a1cdb759c0edf11671b99d173c58989f167f6e417,234,true +2024-07-18 23:47:23.000 UTC,2024-07-18 00:00:00.000 UTC,2024-07-01 00:00:00.000 UTC,ReadySwap,20336787,ethereum,3418.5911499999997,Buy,388009323.75188565,BTC,0x43fd9de06bb69ad771556e171f960a91c42d2955,0.995,WETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,0.005,17.17885,0.005,ETH,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,uniswap,2,BTC-WETH,0xc5f05ce6c07f203b82ad9e1ba84010729af351fc,0xac3a26d1580104febcddb8ec96df42b46c28928d,0x7fab2adbadc06f3ad4bb6d493c0cbb312c528bb1a217ebbf15b198ececda3d0a,827,true diff --git a/dbt_subprojects/dex/seeds/bot_trades/readyswap/schema.yml b/dbt_subprojects/dex/seeds/bot_trades/readyswap/schema.yml new file mode 100644 index 00000000000..a37643174a2 --- /dev/null +++ b/dbt_subprojects/dex/seeds/bot_trades/readyswap/schema.yml @@ -0,0 +1,13 @@ +version: 2 + +seeds: + - name: readyswap_ethereum_trades_seed + config: + column_types: + version: varchar + token_bought_address: varbinary + token_sold_address: varbinary + fee_token_address: varbinary + project_contract_address: varbinary + user: varbinary + tx_hash: varbinary diff --git a/dbt_subprojects/dex/seeds/trades/_schema.yml b/dbt_subprojects/dex/seeds/trades/_schema.yml index 7186b07390a..8ace02b89cd 100644 --- a/dbt_subprojects/dex/seeds/trades/_schema.yml +++ b/dbt_subprojects/dex/seeds/trades/_schema.yml @@ -1079,7 +1079,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: iziswap_scroll_base_trades_seed config: column_types: @@ -2098,7 +2098,7 @@ seeds: token_sold_address: varbinary token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 - block_date: timestamp + block_date: timestamp - name: velodrome_optimism_base_trades_seed config: @@ -2264,7 +2264,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: xchange_base_base_trades_seed config: column_types: @@ -2339,7 +2339,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: hashflow_optimism_base_trades_seed config: column_types: @@ -2369,7 +2369,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: baseswap_base_base_trades_seed config: column_types: @@ -2414,7 +2414,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: smardex_base_base_trades_seed config: column_types: @@ -2432,18 +2432,18 @@ seeds: - name: dackieswap_base_base_trades_seed config: - column_types: - blockchain: varchar - project: varchar - version: varchar - tx_hash: varbinary - evt_index: uint256 - block_number: uint256 - token_bought_address: varbinary - token_sold_address: varbinary - token_bought_amount_raw: uint256 - token_sold_amount_raw: uint256 - block_date: timestamp + column_types: + blockchain: varchar + project: varchar + version: varchar + tx_hash: varbinary + evt_index: uint256 + block_number: uint256 + token_bought_address: varbinary + token_sold_address: varbinary + token_bought_amount_raw: uint256 + token_sold_amount_raw: uint256 + block_date: timestamp - name: ramses_arbitrum_base_trades_seed config: @@ -2459,7 +2459,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: chainhop_optimism_base_trades_seed config: column_types: @@ -2474,7 +2474,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: fraxswap_arbitrum_base_trades_seed config: column_types: @@ -2534,7 +2534,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: apeswap_arbitrum_base_trades_seed config: column_types: @@ -2564,7 +2564,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: smardex_arbitrum_base_trades_seed config: column_types: @@ -2609,7 +2609,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: swaap_arbitrum_base_trades_seed config: column_types: @@ -2639,7 +2639,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: woofi_arbitrum_base_trades_seed config: column_types: @@ -2714,7 +2714,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: plantbaseswap_base_base_trades_seed config: column_types: @@ -2744,7 +2744,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: derpdex_base_base_trades_seed config: column_types: @@ -2759,7 +2759,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: torus_base_base_trades_seed config: column_types: @@ -2775,7 +2775,6 @@ seeds: token_sold_amount_raw: uint256 block_date: timestamp - - name: gridex_optimism_base_trades_seed config: column_types: @@ -2955,7 +2954,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: autotronic_base_base_trades_seed config: column_types: @@ -3015,7 +3014,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: sharkyswap_arbitrum_base_trades_seed config: column_types: @@ -3075,7 +3074,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: auragi_arbitrum_base_trades_seed config: column_types: @@ -3135,7 +3134,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: oasisswap_base_base_trades_seed config: column_types: @@ -3150,7 +3149,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: leetswap_v2_base_base_trades_seed config: column_types: @@ -3195,7 +3194,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: openocean_base_base_trades_seed config: column_types: @@ -3240,7 +3239,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: alienbase_base_base_trades_seed config: column_types: @@ -3255,7 +3254,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: swapbased_base_base_trades_seed config: column_types: @@ -3270,7 +3269,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: gridex_base_base_trades_seed config: column_types: @@ -3315,7 +3314,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: solidly_base_base_trades_seed config: column_types: @@ -3330,7 +3329,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: energon_base_base_trades_seed config: column_types: @@ -3345,7 +3344,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: voltswap_base_base_trades_seed config: column_types: @@ -3360,7 +3359,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: crescentswap_base_base_trades_seed config: column_types: @@ -3405,7 +3404,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: uniswap_zksync_base_trades_seed config: column_types: @@ -3420,7 +3419,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: uniswap_zora_base_trades_seed config: column_types: @@ -3435,7 +3434,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: syncswap_zksync_base_trades_seed config: column_types: @@ -3480,7 +3479,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: mute_zksync_base_trades_seed config: column_types: @@ -3540,7 +3539,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: zkswap_finance_zksync_base_trades_seed config: column_types: @@ -3555,7 +3554,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: gemswap_zksync_base_trades_seed config: column_types: @@ -3570,7 +3569,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: vesync_zksync_base_trades_seed config: column_types: @@ -3585,7 +3584,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: dracula_finance_zksync_base_trades_seed config: column_types: @@ -3735,7 +3734,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: smardex_polygon_base_trades_seed config: column_types: @@ -3765,7 +3764,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: horizondex_linea_base_trades_seed config: column_types: @@ -3780,7 +3779,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: dackieswap_v3_arbitrum_base_trades_seed config: column_types: @@ -3795,7 +3794,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: dackieswap_v2_arbitrum_base_trades_seed config: column_types: @@ -3810,7 +3809,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: thruster_blast_base_trades_seed config: column_types: @@ -4050,7 +4049,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: swaap_linea_base_trades_seed config: column_types: @@ -4065,7 +4064,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: swaap_mantle_base_trades_seed config: column_types: @@ -4080,7 +4079,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: swaap_scroll_base_trades_seed config: column_types: @@ -4109,8 +4108,8 @@ seeds: token_sold_address: varbinary token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 - block_date: timestamp - + block_date: timestamp + - name: dackieswap_v2_blast_base_trades_seed config: column_types: @@ -4139,8 +4138,8 @@ seeds: token_sold_address: varbinary token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 - block_date: timestamp - + block_date: timestamp + - name: spacefi_scroll_base_trades_seed config: column_types: @@ -4155,7 +4154,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: uniswap_mantle_base_trades_seed config: column_types: @@ -4200,7 +4199,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: tropicalswap_mantle_base_trades_seed config: column_types: @@ -4229,8 +4228,8 @@ seeds: token_sold_address: varbinary token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 - block_date: timestamp - + block_date: timestamp + - name: sushiswap_blast_base_trades_seed config: column_types: @@ -4245,7 +4244,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: dackieswap_v3_blast_base_trades_seed config: column_types: @@ -4275,7 +4274,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: swapblast_blast_base_trades_seed config: column_types: @@ -4305,7 +4304,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: yoshiexchange_fantom_base_trades_seed config: column_types: @@ -4350,7 +4349,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: icecreamswap_v2_blast_base_trades_seed config: column_types: @@ -4380,7 +4379,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: dragon_swap_kaia_base_trades_seed config: column_types: @@ -4395,7 +4394,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: klay_swap_kaia_base_trades_seed config: column_types: @@ -4410,7 +4409,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: neopin_kaia_base_trades_seed config: column_types: @@ -4425,7 +4424,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: defi_kingdoms_kaia_base_trades_seed config: column_types: @@ -4455,3 +4454,183 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp + + - name: infusion_base_base_trades_seed + config: + column_types: + blockchain: varchar + project: varchar + version: varchar + tx_hash: varbinary + evt_index: uint256 + block_number: uint256 + token_bought_address: varbinary + token_sold_address: varbinary + token_bought_amount_raw: uint256 + token_sold_amount_raw: uint256 + block_date: timestamp + + - name: flashliquidity_base_base_trades_seed + config: + column_types: + blockchain: varchar + project: varchar + version: varchar + tx_hash: varbinary + evt_index: uint256 + block_number: uint256 + token_bought_address: varbinary + token_sold_address: varbinary + token_bought_amount_raw: uint256 + token_sold_amount_raw: uint256 + block_date: timestamp + + - name: stablebase_base_base_trades_seed + config: + column_types: + blockchain: varchar + project: varchar + version: varchar + tx_hash: varbinary + evt_index: uint256 + block_number: uint256 + token_bought_address: varbinary + token_sold_address: varbinary + token_bought_amount_raw: uint256 + token_sold_amount_raw: uint256 + block_date: timestamp + + - name: saddle_finance_optimism_base_trades_seed + config: + column_types: + blockchain: varchar + project: varchar + version: varchar + tx_hash: varbinary + evt_index: uint256 + block_number: uint256 + token_bought_address: varbinary + token_sold_address: varbinary + token_bought_amount_raw: uint256 + token_sold_amount_raw: uint256 + block_date: timestamp + + - name: akronswap_base_base_trades_seed + config: + column_types: + blockchain: varchar + project: varchar + version: varchar + tx_hash: varbinary + evt_index: uint256 + block_number: uint256 + token_bought_address: varbinary + token_sold_address: varbinary + token_bought_amount_raw: uint256 + token_sold_amount_raw: uint256 + block_date: timestamp + + - name: katana_ronin_base_trades_seed + config: + column_types: + blockchain: varchar + project: varchar + version: varchar + tx_hash: varbinary + evt_index: uint256 + block_number: uint256 + token_bought_address: varbinary + token_sold_address: varbinary + token_bought_amount_raw: uint256 + token_sold_amount_raw: uint256 + block_date: timestamp + + - name: jetswap_polygon_base_trades_seed + config: + column_types: + blockchain: varchar + project: varchar + version: varchar + tx_hash: varbinary + evt_index: uint256 + block_number: uint256 + token_bought_address: varbinary + token_sold_address: varbinary + token_bought_amount_raw: uint256 + token_sold_amount_raw: uint256 + block_date: timestamp + + - name: elk_finance_gnosis_base_trades_seed + config: + column_types: + blockchain: varchar + project: varchar + version: varchar + tx_hash: varbinary + evt_index: uint256 + block_number: uint256 + token_bought_address: varbinary + token_sold_address: varbinary + token_bought_amount_raw: uint256 + token_sold_amount_raw: uint256 + block_date: timestamp + + - name: bridgers_optimism_base_trades_seed + config: + column_types: + blockchain: varchar + project: varchar + version: varchar + tx_hash: varbinary + evt_index: uint256 + block_number: uint256 + token_bought_address: varbinary + token_sold_address: varbinary + token_bought_amount_raw: uint256 + token_sold_amount_raw: uint256 + block_date: timestamp + + - name: levinswap_gnosis_base_trades_seed + config: + column_types: + blockchain: varchar + project: varchar + version: varchar + tx_hash: varbinary + evt_index: uint256 + block_number: uint256 + token_bought_address: varbinary + token_sold_address: varbinary + token_bought_amount_raw: uint256 + token_sold_amount_raw: uint256 + block_date: timestamp + + - name: gravity_finance_polygon_base_trades_seed + config: + column_types: + blockchain: varchar + project: varchar + version: varchar + tx_hash: varbinary + evt_index: uint256 + block_number: uint256 + token_bought_address: varbinary + token_sold_address: varbinary + token_bought_amount_raw: uint256 + token_sold_amount_raw: uint256 + block_date: timestamp + + - name: fluid_ethereum_base_trades_seed + config: + column_types: + blockchain: varchar + project: varchar + version: varchar + tx_hash: varbinary + evt_index: uint256 + block_number: uint256 + token_bought_address: varbinary + token_sold_address: varbinary + token_bought_amount_raw: uint256 + token_sold_amount_raw: uint256 + block_date: timestamp diff --git a/dbt_subprojects/dex/seeds/trades/akronswap_base_base_trades_seed.csv b/dbt_subprojects/dex/seeds/trades/akronswap_base_base_trades_seed.csv new file mode 100644 index 00000000000..c3e9900ab0d --- /dev/null +++ b/dbt_subprojects/dex/seeds/trades/akronswap_base_base_trades_seed.csv @@ -0,0 +1,3 @@ +blockchain,project,version,block_date,tx_hash,evt_index,token_bought_address,token_sold_address,block_number,token_bought_amount_raw,token_sold_amount_raw +base,akronswap_base,2,2024-12-02,0xba6515675bb20188399f976bef2f87592cec85d8cf9b897e95c64f5a7f18cbba,60,0x833589fcd6edb6e08f4c7c32d4f71b54bda02913,0x4200000000000000000000000000000000000006,23163282,5184505,1394212043972094 +base,akronswap_base,2,2024-09-18,0x1d295f4ed29ad01a711f9620931dd8c1bc9df385f773db070f33cfafdbf70ee1,88,0x833589fcd6edb6e08f4c7c32d4f71b54bda02913,0x4200000000000000000000000000000000000006,19930808,8774564,3791077958266666 \ No newline at end of file diff --git a/dbt_subprojects/dex/seeds/trades/balancer_ethereum_base_trades_seed.csv b/dbt_subprojects/dex/seeds/trades/balancer_ethereum_base_trades_seed.csv index b08148c48b3..52089a72c77 100644 --- a/dbt_subprojects/dex/seeds/trades/balancer_ethereum_base_trades_seed.csv +++ b/dbt_subprojects/dex/seeds/trades/balancer_ethereum_base_trades_seed.csv @@ -1,3 +1,4 @@ blockchain,project,version,block_date,tx_hash,evt_index,token_bought_address,token_sold_address,block_number,token_bought_amount_raw,token_sold_amount_raw ethereum,balancer,1,2020-08-02,0xac80f41cdfc018bfdc6d37f881fe3def377aa9fd3d0b794c3d7e7ee1e6501ce4,99,0x6b175474e89094c44da98b954eedeac495271d0f,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,10577678,25347466807281742558,65815288571622598 ethereum,balancer,2,2022-05-06,0xb6bba47d296682416f32fb4264cfe3fe2994284183081beafc8c36cc1e76b1f2,3,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,0xba100000625a3754423978a60c9317c58a424e3d,14725355,3755554997108104989,758723679950740258816 +ethereum,balancer,3,2024-12-11,0xa4909d720f14c0c4a89720150982a60768dc16bd30265cba6c660ab0cb0dbdb5,140,0xd4fa2d31b7968e448877f69a96de69f5de8cd23e,0x7bc3485026ac48b6cf9baf0a377477fff5703af8,21378232,452946,454359 \ No newline at end of file diff --git a/dbt_subprojects/dex/seeds/trades/balancer_gnosis_base_trades_seed.csv b/dbt_subprojects/dex/seeds/trades/balancer_gnosis_base_trades_seed.csv index f9f3f1084b5..c3aa2a57691 100644 --- a/dbt_subprojects/dex/seeds/trades/balancer_gnosis_base_trades_seed.csv +++ b/dbt_subprojects/dex/seeds/trades/balancer_gnosis_base_trades_seed.csv @@ -1,2 +1,3 @@ blockchain,project,version,block_date,tx_hash,evt_index,token_bought_address,token_sold_address,block_number,token_bought_amount_raw,token_sold_amount_raw gnosis,balancer,2,2023-01-20,0x70a7380d73bd8dc96aa2a2ec338f6a660df54e797bab507b5ee04c27e6433844,20,0xe91d153e0b41518a2ce8dd3d7944fa863463a97d,0xddafbb505ad214d7b80b1f830fccc89b60fb7a83,26059328,2811201702694397942,2811563 +gnosis,balancer,3,2024-12-09,0xde406d9adbc7ec5c0157990cbcb77a6eccb053321786b91de53a4c5a848bcfab,53,0xaf204776c7245bf4147c2612bf6e5972ee483701,0x7c16f0185a26db0ae7a9377f23bc18ea7ce5d644,37444463,4106199510945472,18921089727982 \ No newline at end of file diff --git a/dbt_subprojects/dex/seeds/trades/bridgers_optimism_base_trades_seed.csv b/dbt_subprojects/dex/seeds/trades/bridgers_optimism_base_trades_seed.csv new file mode 100644 index 00000000000..abf59da46e0 --- /dev/null +++ b/dbt_subprojects/dex/seeds/trades/bridgers_optimism_base_trades_seed.csv @@ -0,0 +1,2 @@ +blockchain,project,version,block_month,block_date,block_time,block_number,token_sold_amount_raw,token_bought_amount_raw,token_sold_address,token_bought_address,maker,taker,project_contract_address,tx_hash,evt_index +optimism,birdgers,1,2024-12-01 00:00,2024-12-19 00:00,2024-12-19 21:03,129521708,9447540,9335061,0x96985c5786b86cd8108313a9e3adb9d657164746,0x5551443863617577424555435056776a3173704e5268775a4b7562584d76432d527448727042724e7659495047767639,0xc7b2e791ee0491c8df611d5ccfd87b17a0cb9897,0xf956d9fa19656d8e5219fd6fa8ba6cb198094138,0xb685760ebd368a891f27ae547391f4e2a289895b,0x6e926a4373216290e37f83947a0fa32b836c51c2c152847df6e81f74b813946d,188 diff --git a/dbt_subprojects/dex/seeds/trades/elk_finance_gnosis_base_trades_seed.csv b/dbt_subprojects/dex/seeds/trades/elk_finance_gnosis_base_trades_seed.csv new file mode 100644 index 00000000000..e71a7ae9f61 --- /dev/null +++ b/dbt_subprojects/dex/seeds/trades/elk_finance_gnosis_base_trades_seed.csv @@ -0,0 +1,2 @@ +blockchain,project,version,block_date,tx_hash,evt_index,token_bought_address,token_sold_address,block_number,token_bought_amount_raw,token_sold_amount_raw +gnosis,elk_finance,1,2024-12-10,0xbed63f2d1d8fa78c1f6d03570b91e9f34cad5f053c1a9d3543f8677e4558e4be,101,0xe91d153e0b41518a2ce8dd3d7944fa863463a97d,0x9c58bacc331c9aa871afd802db6379a98e80cedb,37454567,87123664537934436,324953295387159 diff --git a/dbt_subprojects/dex/seeds/trades/flashliquidity_base_base_trades_seed.csv b/dbt_subprojects/dex/seeds/trades/flashliquidity_base_base_trades_seed.csv new file mode 100644 index 00000000000..e5d50a8bcc9 --- /dev/null +++ b/dbt_subprojects/dex/seeds/trades/flashliquidity_base_base_trades_seed.csv @@ -0,0 +1,3 @@ +blockchain,project,version,block_date,tx_hash,evt_index,token_bought_address,token_sold_address,block_number,token_bought_amount_raw,token_sold_amount_raw +base,flashliquidity_base,1,2024-01-02,0xe9bf79692277d80abe35da70d44e6a4fe1154bff25cd435fcf257f5981ed8f46,18,0x4200000000000000000000000000000000000006,0x833589fcd6edb6e08f4c7c32d4f71b54bda02913,8695071,2074983733705749,5000000 +base,flashliquidity_base,1,2024-01-10,0xcbd2ef2440ad8f360b33a58423960d9cd3073317448e6e5364e76af316776046,37,0x4200000000000000000000000000000000000006,0x833589fcd6edb6e08f4c7c32d4f71b54bda02913,9028475,2434495227355002,5652787 \ No newline at end of file diff --git a/dbt_subprojects/dex/seeds/trades/fluid_ethereum_base_trades_seed.csv b/dbt_subprojects/dex/seeds/trades/fluid_ethereum_base_trades_seed.csv new file mode 100644 index 00000000000..79406267b36 --- /dev/null +++ b/dbt_subprojects/dex/seeds/trades/fluid_ethereum_base_trades_seed.csv @@ -0,0 +1,3 @@ +blockchain,project,version,block_date,tx_hash,evt_index,token_bought_address,token_sold_address,block_number,token_bought_amount_raw,token_sold_amount_raw +ethereum,fluid,1,2024-12-10,0x6d3da988fdce7dec28e2e61cca6704cda8c9a42faf0a62d35f9a10765b59799c,350,0xdac17f958d2ee523a2206206994597c13d831ec7,0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48,21374285,99976540470,100000000000 +ethereum,fluid,1,2024-10-30,0x700f7f91ce515c42872e70ce896241c6feb4cdd3390ff40853e6131cfd9361bc,400,0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,21074822,144552151975089000000,171000000000000000000 \ No newline at end of file diff --git a/dbt_subprojects/dex/seeds/trades/gravity_finance_polygon_base_trades_seed.csv b/dbt_subprojects/dex/seeds/trades/gravity_finance_polygon_base_trades_seed.csv new file mode 100644 index 00000000000..56ffaf7b480 --- /dev/null +++ b/dbt_subprojects/dex/seeds/trades/gravity_finance_polygon_base_trades_seed.csv @@ -0,0 +1,2 @@ +blockchain,project,version,block_date,tx_hash,evt_index,token_bought_address,token_sold_address,block_number,token_bought_amount_raw,token_sold_amount_raw +polygon,gravity_finance,1,2024-11-17,0x83a1ea6fefce0f22da8a3afb07268ef334d32a46c32040c9f67882b781749057,587,0x1bfd67037b42cf73acf2047067bd4f2c47d9bfd6,0x03b54a6e9a984069379fae1a4fc4dbae93b3bccd,64393636,881,216474154607113 diff --git a/dbt_subprojects/dex/seeds/trades/infusion_base_base_trades_seed.csv b/dbt_subprojects/dex/seeds/trades/infusion_base_base_trades_seed.csv new file mode 100644 index 00000000000..9026a315cd2 --- /dev/null +++ b/dbt_subprojects/dex/seeds/trades/infusion_base_base_trades_seed.csv @@ -0,0 +1,2 @@ +blockchain,project,version,block_date,tx_hash,evt_index,token_bought_address,token_sold_address,block_number,token_bought_amount_raw,token_sold_amount_raw +base,infusion,1,2024-11-28,0x7d88692c8f071f5cc7c08451d7f2cc493f745949cbc05e6579e73d292df47eb1,77,0x4200000000000000000000000000000000000006,0x833589fcd6edb6e08f4c7c32d4f71b54bda02913,22989322,10575964385728786,38099604 \ No newline at end of file diff --git a/dbt_subprojects/dex/seeds/trades/jetswap_polygon_base_trades_seed.csv b/dbt_subprojects/dex/seeds/trades/jetswap_polygon_base_trades_seed.csv new file mode 100644 index 00000000000..74b5155a843 --- /dev/null +++ b/dbt_subprojects/dex/seeds/trades/jetswap_polygon_base_trades_seed.csv @@ -0,0 +1,2 @@ +blockchain,project,version,block_date,tx_hash,evt_index,token_bought_address,token_sold_address,block_number,token_bought_amount_raw,token_sold_amount_raw +polygon,jetswap,1,2024-12-05,0x0aa7125eef5aefd2ca7df0e8e9161bea1c33f61b62cd3974d7be6a3726fcebba,365,0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270,0xe188edda9acc0166dd7030023bd33a8c6be7a0ff,65113490,175557149854780174,573564828367 diff --git a/dbt_subprojects/dex/seeds/trades/katana_ronin_base_trades_seed.csv b/dbt_subprojects/dex/seeds/trades/katana_ronin_base_trades_seed.csv new file mode 100644 index 00000000000..a34825a4783 --- /dev/null +++ b/dbt_subprojects/dex/seeds/trades/katana_ronin_base_trades_seed.csv @@ -0,0 +1,5 @@ +blockchain,project,version,block_date,tx_hash,evt_index,token_bought_address,token_sold_address,block_number,token_bought_amount_raw,token_sold_amount_raw +ronin,katana,2,2024-01-17,0xca2c3b5d6aec890d5bfe1fb8616036a01b702948107fdb4a243453cfe5a6d86a,10,0x1b918543b518e34902e1e8dd76052bee43c762ff,0xe514d9deb7966c8be0ca922de8a064264ea6bcd4,31230074,12492104858888467232497,5109345881300390132 +ronin,katana,2,2023-03-01,0xcab674e07e3c5b0b6dd53b52971edabc929a2fd907b85d781f70bac74767c6e3,10,0xc99a6a985ed2cac1ef41640596c5a5f9f4e19ef5,0xe514d9deb7966c8be0ca922de8a064264ea6bcd4,22465731,1700000000000000,3070678253641756888 +ronin,katana,3,2024-12-19,0x92f922acbb1a4a80b2ad56d8b6ce2cc587f2851fac7b3e37582f7578db55ee4d,160,0xc6046fa4b8961b0e9d823bb3f2dde8fe161d547d,0xe514d9deb7966c8be0ca922de8a064264ea6bcd4,40907478,234401580938417717096,26553212520000000000 +ronin,katana,3,2024-12-19,0x340763e80131db74ce992733518944ad35d1290aaae53f5eeacaeb994057f49e,39,0xe514d9deb7966c8be0ca922de8a064264ea6bcd4,0x0b7007c13325c48911f73a2dad5fa5dcbf808adc,40908371,141505036347788395809,300000000 diff --git a/dbt_subprojects/dex/seeds/trades/levinswap_gnosis_base_trades_seed.csv b/dbt_subprojects/dex/seeds/trades/levinswap_gnosis_base_trades_seed.csv new file mode 100644 index 00000000000..614606ee402 --- /dev/null +++ b/dbt_subprojects/dex/seeds/trades/levinswap_gnosis_base_trades_seed.csv @@ -0,0 +1,2 @@ +blockchain,project,version,block_date,tx_hash,evt_index,token_bought_address,token_sold_address,block_number,token_bought_amount_raw,token_sold_amount_raw +gnosis,levinswap,1,2024-11-22,0x92f310ece1e89b668d91ef9993a2806e4a0d2e4bb2b2803701c05cb455cff397,8,0xc1014b2ad0a731a28c0b74890ad3c50837faa309,0xddafbb505ad214d7b80b1f830fccc89b60fb7a83,37159382,10000000000000000,508965 diff --git a/dbt_subprojects/dex/seeds/trades/saddle_finance_optimism_base_trades_seed.csv b/dbt_subprojects/dex/seeds/trades/saddle_finance_optimism_base_trades_seed.csv new file mode 100644 index 00000000000..a459ed8b479 --- /dev/null +++ b/dbt_subprojects/dex/seeds/trades/saddle_finance_optimism_base_trades_seed.csv @@ -0,0 +1,2 @@ +blockchain,project,version,block_month,block_date,block_time,block_number,token_sold_amount_raw,token_bought_amount_raw,token_sold_address,token_bought_address,maker,taker,project_contract_address,tx_hash,evt_index +optimism,saddle_finance,1,2022-08-01 00:00,2022-08-05 00:00,2022-08-05 19:11,17943155,74907384,74857799085655995549,0x0000000000000000000000000000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000000000000000000000000001,0xd131f1bcdd547e067af447dd3c36c99d6be9fdeb,0xf6c2e0adc659007ba7c48446f5a4e4e94dfe08b5,0xf6c2e0adc659007ba7c48446f5a4e4e94dfe08b5,0xbccdcd4ab61e5ad3384eb173156c3c0507d3bb3f2d2f5a406379e74aafbec38d,3 \ No newline at end of file diff --git a/dbt_subprojects/dex/seeds/trades/stablebase_base_base_trades_seed.csv b/dbt_subprojects/dex/seeds/trades/stablebase_base_base_trades_seed.csv new file mode 100644 index 00000000000..998c8e33f1b --- /dev/null +++ b/dbt_subprojects/dex/seeds/trades/stablebase_base_base_trades_seed.csv @@ -0,0 +1,2 @@ +blockchain,project,version,block_month,block_date,block_time,block_number,token_sold_amount_raw,token_bought_amount_raw,token_sold_address,token_bought_address,maker,taker,project_contract_address,tx_hash,evt_index +base,stablebase,1,2023-08-01,2023-08-28,2023-08-28 19:18:00.000,3230470,129976172599579374396,135180385,0x0000000000000000000000000000000000000000000000000000000000000001,0x0000000000000000000000000000000000000000000000000000000000000000,0x19fbc29d72476365a62151ffdbf4764e54774a81,0x8c59cc9b958635710957e751a9b4e77cd771baf2,0x8c59cc9b958635710957e751a9b4e77cd771baf2,0xc2dec669877f4edfcb7debd2eb23288a0fba8cd57d6f3fb3e45e8b15a6458d43,31 diff --git a/dbt_subprojects/dex/seeds/trades/zkswap_finance_zksync_base_trades_seed.csv b/dbt_subprojects/dex/seeds/trades/zkswap_finance_zksync_base_trades_seed.csv index efa17378d5e..cb949ab04ef 100644 --- a/dbt_subprojects/dex/seeds/trades/zkswap_finance_zksync_base_trades_seed.csv +++ b/dbt_subprojects/dex/seeds/trades/zkswap_finance_zksync_base_trades_seed.csv @@ -1,3 +1,5 @@ blockchain,project,version,block_date,tx_hash,evt_index,token_bought_address,token_sold_address,block_number,token_bought_amount_raw,token_sold_amount_raw zksync,zkswap_finance,1,2024-03-27,0xd9904a2f5ba6123080822d41c3392f43b5596df070405119282e3d3dacebb060,210,0x3355df6d4c9c3035724fd0e3914de96a5a83aaf4,0x493257fd37edb34451f62edf8d2a0c418852ba4c,30012651,94688371,94714471 -zksync,zkswap_finance,1,2024-03-27,0xd595017ca2937ee8117721601605d373d2b9db4bc4fc68af2d676a25aa6531cc,593,0x5aea5775959fbc2557cc8789bc1bf90a239d9a91,0x3355df6d4c9c3035724fd0e3914de96a5a83aaf4,29979948,5030613878243119,17996667 \ No newline at end of file +zksync,zkswap_finance,1,2024-03-27,0xd595017ca2937ee8117721601605d373d2b9db4bc4fc68af2d676a25aa6531cc,593,0x5aea5775959fbc2557cc8789bc1bf90a239d9a91,0x3355df6d4c9c3035724fd0e3914de96a5a83aaf4,29979948,5030613878243119,17996667 +zksync,zkswap_finance,3,2024-11-18,0x7615aa106eafd199cbc0a6a51e75c07c756385110479502c45b96bc0a4a39dd0,8,0x5aea5775959fbc2557cc8789bc1bf90a239d9a91,0x3355df6d4c9c3035724fd0e3914de96a5a83aaf4,49213495,193306889452386,600000 +zksync,zkswap_finance,3,2024-11-18,0xb564f0dc2228961852024f8ad26619bd44bf2e5bc916918e783b04650d5a1f80,19,0x3355df6d4c9c3035724fd0e3914de96a5a83aaf4,0x5aea5775959fbc2557cc8789bc1bf90a239d9a91,49255134,100000,32122756733450 \ No newline at end of file diff --git a/dbt_subprojects/dex/tests/generic/check_bot_trades_seed.sql b/dbt_subprojects/dex/tests/generic/check_bot_trades_seed.sql new file mode 100644 index 00000000000..446757bf1ba --- /dev/null +++ b/dbt_subprojects/dex/tests/generic/check_bot_trades_seed.sql @@ -0,0 +1,15 @@ +-- this tests checks a dex bot_trades model for every row in a seed file. +-- actual implementation in macros/test-helpers/check_seed.sql +{% test check_bot_trades_seed(model, seed_file, blockchain=None, filter=None) %} + + {%- if blockchain == 'solana' -%} + {%- set seed_matching_columns = ['blockchain', 'project', 'version', 'tx_id', 'tx_index', 'outer_instruction_index', 'inner_instruction_index'] -%} + {%- else -%} + {%- set seed_matching_columns = ['blockchain', 'project', 'version', 'tx_hash', 'evt_index',] -%} + {%- endif -%} + + {%- set seed_check_columns = ['fee_token_amount', 'fee_token_address', 'project_contract_address', 'token_bought_address', 'token_sold_address', 'user'] -%} + + {{ check_seed_macro(model, seed_file, seed_matching_columns,seed_check_columns,filter) }} + +{% endtest %} \ No newline at end of file diff --git a/dbt_subprojects/hourly_spellbook/README.md b/dbt_subprojects/hourly_spellbook/README.md index ae104440a3c..3c685b43f50 100644 --- a/dbt_subprojects/hourly_spellbook/README.md +++ b/dbt_subprojects/hourly_spellbook/README.md @@ -1,3 +1,3 @@ ## Hourly Spellbook -This is a DBT sub project for the all hourly models in spellbook +This is a DBT sub project for the all hourly models in spellbook. diff --git a/dbt_subprojects/hourly_spellbook/dbt_project.yml b/dbt_subprojects/hourly_spellbook/dbt_project.yml index 401361c36c8..ce172a90410 100644 --- a/dbt_subprojects/hourly_spellbook/dbt_project.yml +++ b/dbt_subprojects/hourly_spellbook/dbt_project.yml @@ -14,6 +14,9 @@ quoting: # profile: "spellbook-poc-tokens" profile: "spellbook-local" +flags: + require_certificate_validation: true + vars: DBT_ENV_CUSTOM_ENV_S3_BUCKET: "{{ env_var('DBT_ENV_CUSTOM_ENV_S3_BUCKET', 'local') }}" DBT_ENV_INCREMENTAL_TIME: "{{ env_var('DBT_ENV_INCREMENTAL_TIME', '1') }}" diff --git a/dbt_subprojects/hourly_spellbook/macros/sector/lending/lending_aave_compatible_supply.sql b/dbt_subprojects/hourly_spellbook/macros/sector/lending/lending_aave_compatible_supply.sql index 5320cf668bc..ab042cd9c11 100644 --- a/dbt_subprojects/hourly_spellbook/macros/sector/lending/lending_aave_compatible_supply.sql +++ b/dbt_subprojects/hourly_spellbook/macros/sector/lending/lending_aave_compatible_supply.sql @@ -141,6 +141,16 @@ src_LendingPool_evt_Withdraw as ( {% endif %} ), +{% if 'aave' in project %} +src_WrappedTokenGatewayV2_call_withdrawETH as ( + select * + from {{ source(project_decoded_as ~ '_' ~ blockchain, 'WrappedTokenGatewayV2_call_withdrawETH') }} + {% if is_incremental() %} + where {{ incremental_predicate('call_block_time') }} + {% endif %} +), +{% endif %} + src_LendingPool_evt_LiquidationCall as ( select * from {{ source(project_decoded_as ~ '_' ~ blockchain, 'LendingPool_evt_LiquidationCall') }} @@ -167,18 +177,30 @@ base_supply as ( union all select 'withdraw' as transaction_type, - reserve as token_address, - user as depositor, - cast(null as varbinary) as on_behalf_of, - to as withdrawn_to, + w.reserve as token_address, + w.user as depositor, + {% if 'aave' in project %} + cast(wrap.to as varbinary) + {% else %} + cast(null as varbinary) + {% endif %} as on_behalf_of, + w.to as withdrawn_to, cast(null as varbinary) as liquidator, - -1 * cast(amount as double) as amount, - contract_address, - evt_tx_hash, - evt_index, - evt_block_time, - evt_block_number - from src_LendingPool_evt_Withdraw + -1 * cast(w.amount as double) as amount, + w.contract_address, + w.evt_tx_hash, + w.evt_index, + w.evt_block_time, + w.evt_block_number + from src_LendingPool_evt_Withdraw w + {% if 'aave' in project %} + left join src_WrappedTokenGatewayV2_call_withdrawETH wrap + on w.evt_block_number = wrap.call_block_number + and w.evt_tx_hash = wrap.call_tx_hash + and w.to = wrap.contract_address + and w.amount = wrap.amount + and wrap.call_success + {% endif %} union all select 'deposit_liquidation' as transaction_type, @@ -225,7 +247,8 @@ from base_supply project, version, project_decoded_as = 'aave_v3', - decoded_contract_name = 'Pool' + decoded_contract_name = 'Pool', + decoded_wrapped_token_gateway_name = 'WrappedTokenGatewayV3' ) %} @@ -247,6 +270,16 @@ src_LendingPool_evt_Withdraw as ( {% endif %} ), +{% if 'aave' in project %} +src_WrappedTokenGatewayV3_call_withdrawETH as ( + select * + from {{ source(project_decoded_as ~ '_' ~ blockchain, decoded_wrapped_token_gateway_name ~ '_call_withdrawETH') }} + {% if is_incremental() %} + where {{ incremental_predicate('call_block_time') }} + {% endif %} +), +{% endif %} + src_LendingPool_evt_Repay as ( select * from {{ source(project_decoded_as ~ '_' ~ blockchain, decoded_contract_name ~ '_evt_Repay') }} @@ -282,18 +315,30 @@ base_supply as ( union all select 'withdraw' as transaction_type, - reserve as token_address, - user as depositor, - cast(null as varbinary) as on_behalf_of, - to as withdrawn_to, + w.reserve as token_address, + w.user as depositor, + {% if 'aave' in project %} + cast(wrap.to as varbinary) + {% else %} + cast(null as varbinary) + {% endif %} as on_behalf_of, + w.to as withdrawn_to, cast(null as varbinary) as liquidator, - -1 * cast(amount as double) as amount, - contract_address, - evt_tx_hash, - evt_index, - evt_block_time, - evt_block_number - from src_LendingPool_evt_Withdraw + -1 * cast(w.amount as double) as amount, + w.contract_address, + w.evt_tx_hash, + w.evt_index, + w.evt_block_time, + w.evt_block_number + from src_LendingPool_evt_Withdraw w + {% if 'aave' in project %} + left join src_WrappedTokenGatewayV3_call_withdrawETH wrap + on w.evt_block_number = wrap.call_block_number + and w.evt_tx_hash = wrap.call_tx_hash + and w.to = wrap.contract_address + and w.amount = wrap.amount + and wrap.call_success + {% endif %} union all select 'repay_with_atokens' as transaction_type, diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/balances/balancer_token_balance_changes.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/balances/balancer_token_balance_changes.sql index 7f531a769f3..b2955c5f4a7 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/balancer/balances/balancer_token_balance_changes.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/balances/balancer_token_balance_changes.sql @@ -16,7 +16,9 @@ ref('balancer_v2_gnosis_token_balance_changes'), ref('balancer_v2_optimism_token_balance_changes'), ref('balancer_v2_polygon_token_balance_changes'), - ref('balancer_v2_zkevm_token_balance_changes') + ref('balancer_v2_zkevm_token_balance_changes'), + ref('balancer_v3_ethereum_token_balance_changes'), + ref('balancer_v3_gnosis_token_balance_changes') ] %} SELECT * diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/balances/balancer_token_balance_changes_daily.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/balances/balancer_token_balance_changes_daily.sql index 8e199a25708..4ab6c62937e 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/balancer/balances/balancer_token_balance_changes_daily.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/balances/balancer_token_balance_changes_daily.sql @@ -16,7 +16,9 @@ ref('balancer_v2_gnosis_token_balance_changes_daily'), ref('balancer_v2_optimism_token_balance_changes_daily'), ref('balancer_v2_polygon_token_balance_changes_daily'), - ref('balancer_v2_zkevm_token_balance_changes_daily') + ref('balancer_v2_zkevm_token_balance_changes_daily'), + ref('balancer_v3_ethereum_token_balance_changes_daily'), + ref('balancer_v3_gnosis_token_balance_changes_daily') ] %} SELECT * diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/balances/ethereum/_schema.yml b/dbt_subprojects/hourly_spellbook/models/_project/balancer/balances/ethereum/_schema.yml index ac563c49277..9fe9fe54fe6 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/balancer/balances/ethereum/_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/balances/ethereum/_schema.yml @@ -128,4 +128,66 @@ models: description: "Daily total impact on token balance, in USD" - &daily_delta_eth name: daily_delta_eth - description: "Daily total impact on token balance, in ETH" \ No newline at end of file + description: "Daily total impact on token balance, in ETH" + + - name: balancer_v3_ethereum_token_balance_changes + meta: + blockchain: ethereum + project: balancer_v3 + contributors: viniabussafi + config: + tags: ['ethereum', 'bpt', 'supply', 'changes'] + description: > + Token Balance Changes on Balancer Pools. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - evt_tx_hash + - evt_index + - token_address + columns: + - *block_date + - *evt_block_time + - *evt_block_number + - *blockchain + - *evt_tx_hash + - *evt_index + - *pool_id + - *pool_address + - *pool_symbol + - *pool_type + - *version + - *token_address + - *token_symbol + - *delta_amount_raw + - *delta_amount + + - name: balancer_v3_ethereum_token_balance_changes_daily + meta: + blockchain: ethereum + project: balancer_v3 + contributors: viniabussafi + config: + tags: ['ethereum', 'bpt', 'supply', 'changes'] + description: > + Token Balance Changes on Balancer Pools, grouped by day. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - pool_id + - token_address + columns: + - *block_date + - *pool_id + - *pool_address + - *pool_symbol + - *version + - *blockchain + - *pool_type + - *token_address + - *token_symbol + - *daily_delta + - *daily_delta_usd + - *daily_delta_eth \ No newline at end of file diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/balances/ethereum/balancer_v3_ethereum_token_balance_changes.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/balances/ethereum/balancer_v3_ethereum_token_balance_changes.sql new file mode 100644 index 00000000000..83ee62ca4af --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/balances/ethereum/balancer_v3_ethereum_token_balance_changes.sql @@ -0,0 +1,19 @@ +{% set blockchain = 'ethereum' %} + +{{ config( + schema = 'balancer_v3_ethereum', + alias = 'token_balance_changes', + materialized = 'table', + file_format = 'delta' + ) +}} + +{{ + balancer_v3_compatible_token_balance_changes_macro( + blockchain = blockchain, + version = '3', + project_decoded_as = 'balancer_v3', + base_spells_namespace = 'balancer', + pool_labels_spell = source('labels', 'balancer_v3_pools') + ) +}} \ No newline at end of file diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/balances/ethereum/balancer_v3_ethereum_token_balance_changes_daily.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/balances/ethereum/balancer_v3_ethereum_token_balance_changes_daily.sql new file mode 100644 index 00000000000..7ad4d5fc051 --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/balances/ethereum/balancer_v3_ethereum_token_balance_changes_daily.sql @@ -0,0 +1,19 @@ +{% set blockchain = 'ethereum' %} + +{{ + config( + schema = 'balancer_v3_ethereum', + alias = 'token_balance_changes_daily', + materialized = 'table', + file_format = 'delta' + ) +}} + +{{ + balancer_v3_compatible_token_balance_changes_daily_agg_macro( + blockchain = blockchain, + version = '3', + project_decoded_as = 'balancer_v3', + base_spells_namespace = 'balancer' + ) +}} \ No newline at end of file diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/balances/gnosis/_schema.yml b/dbt_subprojects/hourly_spellbook/models/_project/balancer/balances/gnosis/_schema.yml index 42b0c73b982..790b9fa25ec 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/balancer/balances/gnosis/_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/balances/gnosis/_schema.yml @@ -97,4 +97,66 @@ models: description: "Daily total impact on token balance, in USD" - &daily_delta_eth name: daily_delta_eth - description: "Daily total impact on token balance, in eth" \ No newline at end of file + description: "Daily total impact on token balance, in eth" + + - name: balancer_v3_gnosis_token_balance_changes + meta: + blockchain: gnosis + project: balancer_v3 + contributors: viniabussafi + config: + tags: ['gnosis', 'bpt', 'supply', 'changes'] + description: > + Token Balance Changes on Balancer Pools. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - evt_tx_hash + - evt_index + - token_address + columns: + - *block_date + - *evt_block_time + - *evt_block_number + - *blockchain + - *evt_tx_hash + - *evt_index + - *pool_id + - *pool_address + - *pool_symbol + - *pool_type + - *version + - *token_address + - *token_symbol + - *delta_amount_raw + - *delta_amount + + - name: balancer_v3_gnosis_token_balance_changes_daily + meta: + blockchain: gnosis + project: balancer_v3 + contributors: viniabussafi + config: + tags: ['gnosis', 'bpt', 'supply', 'changes'] + description: > + Token Balance Changes on Balancer Pools, grouped by day. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - pool_id + - token_address + columns: + - *block_date + - *pool_id + - *pool_address + - *pool_symbol + - *version + - *blockchain + - *pool_type + - *token_address + - *token_symbol + - *daily_delta + - *daily_delta_usd + - *daily_delta_eth \ No newline at end of file diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/balances/gnosis/balancer_v3_gnosis_token_balance_changes.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/balances/gnosis/balancer_v3_gnosis_token_balance_changes.sql new file mode 100644 index 00000000000..17833ba59b0 --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/balances/gnosis/balancer_v3_gnosis_token_balance_changes.sql @@ -0,0 +1,19 @@ +{% set blockchain = 'gnosis' %} + +{{ config( + schema = 'balancer_v3_gnosis', + alias = 'token_balance_changes', + materialized = 'table', + file_format = 'delta' + ) +}} + +{{ + balancer_v3_compatible_token_balance_changes_macro( + blockchain = blockchain, + version = '3', + project_decoded_as = 'balancer_v3', + base_spells_namespace = 'balancer', + pool_labels_spell = source('labels', 'balancer_v3_pools') + ) +}} \ No newline at end of file diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/balances/gnosis/balancer_v3_gnosis_token_balance_changes_daily.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/balances/gnosis/balancer_v3_gnosis_token_balance_changes_daily.sql new file mode 100644 index 00000000000..09b28214e75 --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/balances/gnosis/balancer_v3_gnosis_token_balance_changes_daily.sql @@ -0,0 +1,19 @@ +{% set blockchain = 'gnosis' %} + +{{ + config( + schema = 'balancer_v3_gnosis', + alias = 'token_balance_changes_daily', + materialized = 'table', + file_format = 'delta' + ) +}} + +{{ + balancer_v3_compatible_token_balance_changes_daily_agg_macro( + blockchain = blockchain, + version = '3', + project_decoded_as = 'balancer_v3', + base_spells_namespace = 'balancer' + ) +}} \ No newline at end of file diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/balancer_bpt_prices.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/balancer_bpt_prices.sql index 0a1180a8013..1f59d4db7bb 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/balancer_bpt_prices.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/balancer_bpt_prices.sql @@ -16,7 +16,9 @@ ref('balancer_v2_optimism_bpt_prices'), ref('balancer_v2_avalanche_c_bpt_prices'), ref('balancer_v2_base_bpt_prices'), - ref('balancer_v2_zkevm_bpt_prices') + ref('balancer_v2_zkevm_bpt_prices'), + ref('balancer_v3_ethereum_bpt_prices'), + ref('balancer_v3_gnosis_bpt_prices') ] %} SELECT * diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/balancer_bpt_supply.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/balancer_bpt_supply.sql index e43ef846b55..3acb22256f3 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/balancer_bpt_supply.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/balancer_bpt_supply.sql @@ -16,7 +16,9 @@ ref('balancer_v2_optimism_bpt_supply'), ref('balancer_v2_avalanche_c_bpt_supply'), ref('balancer_v2_base_bpt_supply'), - ref('balancer_v2_zkevm_bpt_supply') + ref('balancer_v2_zkevm_bpt_supply'), + ref('balancer_v3_gnosis_bpt_supply'), + ref('balancer_v3_ethereum_bpt_supply') ] %} SELECT * diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/balancer_bpt_supply_changes.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/balancer_bpt_supply_changes.sql index e46a587b3b0..108a0053a89 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/balancer_bpt_supply_changes.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/balancer_bpt_supply_changes.sql @@ -16,7 +16,9 @@ ref('balancer_v2_gnosis_bpt_supply_changes'), ref('balancer_v2_optimism_bpt_supply_changes'), ref('balancer_v2_polygon_bpt_supply_changes'), - ref('balancer_v2_zkevm_bpt_supply_changes') + ref('balancer_v2_zkevm_bpt_supply_changes'), + ref('balancer_v3_ethereum_bpt_supply_changes'), + ref('balancer_v3_gnosis_bpt_supply_changes') ] %} SELECT * diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/balancer_bpt_supply_changes_daily.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/balancer_bpt_supply_changes_daily.sql index 5b593cef48a..84146e8a633 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/balancer_bpt_supply_changes_daily.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/balancer_bpt_supply_changes_daily.sql @@ -16,7 +16,9 @@ ref('balancer_v2_gnosis_bpt_supply_changes_daily'), ref('balancer_v2_optimism_bpt_supply_changes_daily'), ref('balancer_v2_polygon_bpt_supply_changes_daily'), - ref('balancer_v2_zkevm_bpt_supply_changes_daily') + ref('balancer_v2_zkevm_bpt_supply_changes_daily'), + ref('balancer_v3_ethereum_bpt_supply_changes_daily'), + ref('balancer_v3_gnosis_bpt_supply_changes_daily') ] %} SELECT * diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/balancer_transfers_bpt.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/balancer_transfers_bpt.sql index dda9c32ecb1..a629dbcfe88 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/balancer_transfers_bpt.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/balancer_transfers_bpt.sql @@ -16,7 +16,9 @@ ref('balancer_v2_gnosis_transfers_bpt'), ref('balancer_v2_optimism_transfers_bpt'), ref('balancer_v2_polygon_transfers_bpt'), - ref('balancer_v2_zkevm_transfers_bpt') + ref('balancer_v2_zkevm_transfers_bpt'), + ref('balancer_v3_ethereum_transfers_bpt'), + ref('balancer_v3_gnosis_transfers_bpt') ] %} SELECT * diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/ethereum/_schema.yml b/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/ethereum/_schema.yml index e9a905070ff..e113be8d1ee 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/ethereum/_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/ethereum/_schema.yml @@ -175,4 +175,134 @@ models: - *token_address - &daily_delta name: daily_delta - description: "Daily total impact on BPT supply" \ No newline at end of file + description: "Daily total impact on BPT supply" + + - name: balancer_v3_ethereum_transfers_bpt + meta: + blockchain: ethereum + project: balancer_v3 + contributors: viniabussafi + config: + tags: ['ethereum', 'bpt', 'transfers'] + description: > + Balancer Pool Token (BPT) transfer logs on Balancer, an automated portfolio manager and trading platform, on ethereum. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - evt_tx_hash + - evt_index + - block_date + columns: + - *blockchain + - *version + - *contract_address + - *block_date + - *block_month + - *evt_tx_hash + - *evt_index + - *evt_block_time + - *evt_block_number + - *from + - *to + - *value + + - name: balancer_v3_ethereum_bpt_prices + meta: + blockchain: ethereum + project: balancer_v3 + contributors: viniabussafi + config: + tags: ['ethereum', 'bpt', 'prices'] + description: > + Balancer Pool Token (BPT) daily price by pool on Balancer, an automated portfolio manager and trading platform. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - day + - contract_address + columns: + - *blockchain + - *day + - *version + - *decimals + - *contract_address + - *bpt_price + + - name: balancer_v3_ethereum_bpt_supply + meta: + blockchain: ethereum + project: balancer_v3 + contributors: viniabussafi + config: + tags: ['ethereum', 'bpt', 'supply'] + description: > + Balancer Pool Token (BPT) supply by pool on Balancer, an automated portfolio manager and trading platform. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - blockchain + - token_address + columns: + - *day + - *pool_type + - *version + - *blockchain + - *token_address + - *supply + + - name: balancer_v3_ethereum_bpt_supply_changes + meta: + blockchain: ethereum + project: balancer_v3 + contributors: viniabussafi + config: + tags: ['ethereum', 'bpt', 'supply', 'changes'] + description: > + Balancer Pool Token (BPT) supply change events. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - evt_tx_hash + - evt_index + - label + columns: + - *block_date + - *evt_block_time + - *evt_block_number + - *blockchain + - *evt_tx_hash + - *evt_index + - *pool_type + - *pool_symbol + - *version + - *label + - *token_address + - *delta_amount_raw + - *delta_amount + + - name: balancer_v3_ethereum_bpt_supply_changes_daily + meta: + blockchain: ethereum + project: balancer_v3 + contributors: viniabussafi + config: + tags: ['ethereum', 'bpt', 'supply', 'changes'] + description: > + Balancer Pool Token (BPT) supply change events. grouped by day + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - blockchain + - token_address + columns: + - *block_date + - *blockchain + - *pool_type + - *pool_symbol + - *version + - *token_address + - *daily_delta \ No newline at end of file diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/ethereum/balancer_v3_ethereum_bpt_prices.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/ethereum/balancer_v3_ethereum_bpt_prices.sql new file mode 100644 index 00000000000..4e44eedf294 --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/ethereum/balancer_v3_ethereum_bpt_prices.sql @@ -0,0 +1,21 @@ +{% set blockchain = 'ethereum' %} + +{{ + config( + schema = 'balancer_v3_ethereum', + alias = 'bpt_prices', + materialized = 'table', + file_format = 'delta' + ) +}} + + +{{ + balancer_v3_compatible_bpt_prices_macro( + blockchain = blockchain, + version = '3', + project_decoded_as = 'balancer_v3', + base_spells_namespace = 'balancer', + pool_labels_spell = source('labels', 'balancer_v3_pools') + ) +}} diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/ethereum/balancer_v3_ethereum_bpt_supply.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/ethereum/balancer_v3_ethereum_bpt_supply.sql new file mode 100644 index 00000000000..a484e1725b6 --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/ethereum/balancer_v3_ethereum_bpt_supply.sql @@ -0,0 +1,21 @@ +{% set blockchain = 'ethereum' %} + +{{ + config( + schema='balancer_v3_ethereum', + alias = 'bpt_supply', + materialized = 'table', + file_format = 'delta' + + ) +}} + +{{ + balancer_v3_compatible_bpt_supply_macro( + blockchain = blockchain, + version = '3', + project_decoded_as = 'balancer_v3', + base_spells_namespace = 'balancer', + pool_labels_spell = source('labels', 'balancer_v3_pools') + ) +}} \ No newline at end of file diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/ethereum/balancer_v3_ethereum_bpt_supply_changes.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/ethereum/balancer_v3_ethereum_bpt_supply_changes.sql new file mode 100644 index 00000000000..fa93184fdde --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/ethereum/balancer_v3_ethereum_bpt_supply_changes.sql @@ -0,0 +1,23 @@ +{% set blockchain = 'ethereum' %} + +{{ + config( + schema = 'balancer_v3_ethereum', + alias = 'bpt_supply_changes', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['block_date', 'evt_tx_hash', 'evt_index', 'label'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +{{ + balancer_v3_compatible_bpt_supply_changes_macro( + blockchain = blockchain, + version = '3', + project_decoded_as = 'balancer_v3', + base_spells_namespace = 'balancer', + pool_labels_spell = source('labels', 'balancer_v3_pools') + ) +}} \ No newline at end of file diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/ethereum/balancer_v3_ethereum_bpt_supply_changes_daily.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/ethereum/balancer_v3_ethereum_bpt_supply_changes_daily.sql new file mode 100644 index 00000000000..dbc197a5b48 --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/ethereum/balancer_v3_ethereum_bpt_supply_changes_daily.sql @@ -0,0 +1,19 @@ +{% set blockchain = 'ethereum' %} + +{{ + config( + schema = 'balancer_v3_ethereum', + alias = 'bpt_supply_changes_daily', + materialized = 'table', + file_format = 'delta' + ) +}} + +{{ + balancer_v3_compatible_bpt_supply_changes_daily_agg_macro( + blockchain = blockchain, + version = '3', + project_decoded_as = 'balancer_v3', + base_spells_namespace = 'balancer' + ) +}} \ No newline at end of file diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/ethereum/balancer_v3_ethereum_transfers_bpt.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/ethereum/balancer_v3_ethereum_transfers_bpt.sql new file mode 100644 index 00000000000..81c95ef01cd --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/ethereum/balancer_v3_ethereum_transfers_bpt.sql @@ -0,0 +1,22 @@ +{% set blockchain = 'ethereum' %} + +{{ + config( + schema = 'balancer_v3_ethereum', + alias = 'transfers_bpt', + partition_by = ['block_month'], + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['block_date', 'evt_tx_hash', 'evt_index'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +{{ + balancer_v3_compatible_transfers_bpt_macro( + blockchain = blockchain, + version = '3', + project_decoded_as = 'balancer_v3' + ) +}} \ No newline at end of file diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/gnosis/_schema.yml b/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/gnosis/_schema.yml index 0ce3d1ccc86..bf6e344d674 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/gnosis/_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/gnosis/_schema.yml @@ -175,4 +175,134 @@ models: - *token_address - &daily_delta name: daily_delta - description: "Daily total impact on BPT supply" \ No newline at end of file + description: "Daily total impact on BPT supply" + + - name: balancer_v3_gnosis_transfers_bpt + meta: + blockchain: gnosis + project: balancer_v3 + contributors: viniabussafi + config: + tags: ['gnosis', 'bpt', 'transfers'] + description: > + Balancer Pool Token (BPT) transfer logs on Balancer, an automated portfolio manager and trading platform, on gnosis. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - evt_tx_hash + - evt_index + - block_date + columns: + - *blockchain + - *version + - *contract_address + - *block_date + - *block_month + - *evt_tx_hash + - *evt_index + - *evt_block_time + - *evt_block_number + - *from + - *to + - *value + + - name: balancer_v3_gnosis_bpt_prices + meta: + blockchain: gnosis + project: balancer_v3 + contributors: viniabussafi + config: + tags: ['gnosis', 'bpt', 'prices'] + description: > + Balancer Pool Token (BPT) daily price by pool on Balancer, an automated portfolio manager and trading platform. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - day + - contract_address + columns: + - *blockchain + - *day + - *version + - *decimals + - *contract_address + - *bpt_price + + - name: balancer_v3_gnosis_bpt_supply + meta: + blockchain: gnosis + project: balancer_v3 + contributors: viniabussafi + config: + tags: ['gnosis', 'bpt', 'supply'] + description: > + Balancer Pool Token (BPT) supply by pool on Balancer, an automated portfolio manager and trading platform. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - blockchain + - token_address + columns: + - *day + - *pool_type + - *version + - *blockchain + - *token_address + - *supply + + - name: balancer_v3_gnosis_bpt_supply_changes + meta: + blockchain: gnosis + project: balancer_v3 + contributors: viniabussafi + config: + tags: ['gnosis', 'bpt', 'supply', 'changes'] + description: > + Balancer Pool Token (BPT) supply change events. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - evt_tx_hash + - evt_index + - label + columns: + - *block_date + - *evt_block_time + - *evt_block_number + - *blockchain + - *evt_tx_hash + - *evt_index + - *pool_type + - *pool_symbol + - *version + - *label + - *token_address + - *delta_amount_raw + - *delta_amount + + - name: balancer_v3_gnosis_bpt_supply_changes_daily + meta: + blockchain: gnosis + project: balancer_v3 + contributors: viniabussafi + config: + tags: ['gnosis', 'bpt', 'supply', 'changes'] + description: > + Balancer Pool Token (BPT) supply change events. grouped by day + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - blockchain + - token_address + columns: + - *block_date + - *blockchain + - *pool_type + - *pool_symbol + - *version + - *token_address + - *daily_delta \ No newline at end of file diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/gnosis/balancer_v3_gnosis_bpt_prices.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/gnosis/balancer_v3_gnosis_bpt_prices.sql new file mode 100644 index 00000000000..d35d5d9b55e --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/gnosis/balancer_v3_gnosis_bpt_prices.sql @@ -0,0 +1,21 @@ +{% set blockchain = 'gnosis' %} + +{{ + config( + schema = 'balancer_v3_gnosis', + alias = 'bpt_prices', + materialized = 'table', + file_format = 'delta' + ) +}} + + +{{ + balancer_v3_compatible_bpt_prices_macro( + blockchain = blockchain, + version = '3', + project_decoded_as = 'balancer_v3', + base_spells_namespace = 'balancer', + pool_labels_spell = source('labels', 'balancer_v3_pools') + ) +}} diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/gnosis/balancer_v3_gnosis_bpt_supply.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/gnosis/balancer_v3_gnosis_bpt_supply.sql new file mode 100644 index 00000000000..612c3fce8c3 --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/gnosis/balancer_v3_gnosis_bpt_supply.sql @@ -0,0 +1,21 @@ +{% set blockchain = 'gnosis' %} + +{{ + config( + schema='balancer_v3_gnosis', + alias = 'bpt_supply', + materialized = 'table', + file_format = 'delta' + + ) +}} + +{{ + balancer_v3_compatible_bpt_supply_macro( + blockchain = blockchain, + version = '3', + project_decoded_as = 'balancer_v3', + base_spells_namespace = 'balancer', + pool_labels_spell = source('labels', 'balancer_v3_pools') + ) +}} \ No newline at end of file diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/gnosis/balancer_v3_gnosis_bpt_supply_changes.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/gnosis/balancer_v3_gnosis_bpt_supply_changes.sql new file mode 100644 index 00000000000..d95ee336821 --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/gnosis/balancer_v3_gnosis_bpt_supply_changes.sql @@ -0,0 +1,23 @@ +{% set blockchain = 'gnosis' %} + +{{ + config( + schema = 'balancer_v3_gnosis', + alias = 'bpt_supply_changes', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['block_date', 'evt_tx_hash', 'evt_index', 'label'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +{{ + balancer_v3_compatible_bpt_supply_changes_macro( + blockchain = blockchain, + version = '3', + project_decoded_as = 'balancer_v3', + base_spells_namespace = 'balancer', + pool_labels_spell = source('labels', 'balancer_v3_pools') + ) +}} \ No newline at end of file diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/gnosis/balancer_v3_gnosis_bpt_supply_changes_daily.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/gnosis/balancer_v3_gnosis_bpt_supply_changes_daily.sql new file mode 100644 index 00000000000..7458210fe1f --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/gnosis/balancer_v3_gnosis_bpt_supply_changes_daily.sql @@ -0,0 +1,19 @@ +{% set blockchain = 'gnosis' %} + +{{ + config( + schema = 'balancer_v3_gnosis', + alias = 'bpt_supply_changes_daily', + materialized = 'table', + file_format = 'delta' + ) +}} + +{{ + balancer_v3_compatible_bpt_supply_changes_daily_agg_macro( + blockchain = blockchain, + version = '3', + project_decoded_as = 'balancer_v3', + base_spells_namespace = 'balancer' + ) +}} \ No newline at end of file diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/gnosis/balancer_v3_gnosis_transfers_bpt.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/gnosis/balancer_v3_gnosis_transfers_bpt.sql new file mode 100644 index 00000000000..b61c8780b0f --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/gnosis/balancer_v3_gnosis_transfers_bpt.sql @@ -0,0 +1,22 @@ +{% set blockchain = 'gnosis' %} + +{{ + config( + schema = 'balancer_v3_gnosis', + alias = 'transfers_bpt', + partition_by = ['block_month'], + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['block_date', 'evt_tx_hash', 'evt_index'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +{{ + balancer_v3_compatible_transfers_bpt_macro( + blockchain = blockchain, + version = '3', + project_decoded_as = 'balancer_v3' + ) +}} \ No newline at end of file diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/_schema.yml b/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/_schema.yml new file mode 100644 index 00000000000..15203c33c6f --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/_schema.yml @@ -0,0 +1,65 @@ +version: 2 + +models: + - name: balancer_v3_erc4626_token_mapping + meta: + blockchain: ethereum, gnosis + project: balancer + contributors: viniabussafi + config: + tags: ['ethereum', 'gnosis', 'token', 'mapping'] + description: > + Mapping of ERC4626 tokens, including aTokens and MetaMorpho tokens, and their corresponding underlying tokens. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - erc4626_token + columns: + - name: blockchain + description: "Blockchain." + - name: erc4626_token + description: "Contract address of the erc4626 token." + - name: erc4626_token_name + description: "Name of the erc4626 token." + - name: erc4626_token_symbol + description: "Symbol of the erc4626 token." + - name: underlying_token + description: "Contract address of the underlying token." + - name: underlying_token_symbol + description: "Symbol of the underlying token." + - name: token_decimals + description: "Decimal precision of the underlying token." + + - name: balancer_v3_erc4626_token_prices + meta: + blockchain: ethereum, gnosis + project: balancer + contributors: viniabussafi + config: + tags: ['ethereum', 'gnosis', 'token', 'pricing'] + description: > + Pricing information for ERC4626 tokens. Prices are derived from the ratio of underlying tokens deposited or withdrawn to shares issued or burned, multiplied by the underlying token price. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - minute + - wrapped_token + columns: + - name: minute + description: "Timestamp of the event, truncated to the nearest minute." + - name: blockchain + description: "Blockchain." + - name: wrapped_token + description: "Contract address of the wrapped token." + - name: underlying_token + description: "Contract address of the underlying token." + - name: erc4626_token_symbol + description: "Symbol of the erc4626 token." + - name: underlying_token_symbol + description: "Symbol of the underlying token." + - name: decimals + description: "Decimal precision for the token." + - name: median_price + description: "Median price of the static token, computed over the dataset." + - name: next_change + description: "Timestamp of the next expected pricing change or event affecting the price." diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/balancer_v3_erc4626_token_mapping.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/balancer_v3_erc4626_token_mapping.sql new file mode 100644 index 00000000000..00f666a601e --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/balancer_v3_erc4626_token_mapping.sql @@ -0,0 +1,32 @@ +{{ config( + schema = 'balancer_v3', + alias = 'erc4626_token_mapping', + post_hook='{{ expose_spells(blockchains = \'["ethereum", "gnosis"]\', + spell_type = "project", + spell_name = "balancer", + contributors = \'["viniabussafi"]\') }}' + ) +}} + +{% set balancer_models = [ + ref('balancer_v3_ethereum_erc4626_token_mapping'), + ref('balancer_v3_gnosis_erc4626_token_mapping') +] %} + +SELECT * +FROM ( + {% for model in balancer_models %} + SELECT + blockchain, + erc4626_token, + erc4626_token_name, + erc4626_token_symbol, + underlying_token, + underlying_token_symbol, + decimals + FROM {{ model }} + {% if not loop.last %} + UNION ALL + {% endif %} + {% endfor %} +) \ No newline at end of file diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/balancer_v3_erc4626_token_prices.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/balancer_v3_erc4626_token_prices.sql new file mode 100644 index 00000000000..33553280603 --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/balancer_v3_erc4626_token_prices.sql @@ -0,0 +1,35 @@ +{{ config( + schema = 'balancer_v3', + alias = 'erc4626_token_prices', + post_hook='{{ expose_spells(blockchains = \'["ethereum", "gnosis"]\', + spell_type = "project", + spell_name = "balancer", + contributors = \'["viniabussafi"]\') }}' + ) +}} + + +{% set balancer_models = [ + ref('balancer_v3_ethereum_erc4626_token_prices'), + ref('balancer_v3_gnosis_erc4626_token_prices') +] %} + +SELECT * +FROM ( + {% for model in balancer_models %} + SELECT + minute, + blockchain, + wrapped_token, + underlying_token, + erc4626_token_symbol, + underlying_token_symbol, + decimals, + median_price, + next_change + FROM {{ model }} + {% if not loop.last %} + UNION ALL + {% endif %} + {% endfor %} +) diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/ethereum/_schema.yml b/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/ethereum/_schema.yml new file mode 100644 index 00000000000..a12e45769be --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/ethereum/_schema.yml @@ -0,0 +1,65 @@ +version: 2 + +models: + - name: balancer_v3_ethereum_erc4626_token_mapping + meta: + blockchain: ethereum + project: balancer + contributors: viniabussafi + config: + tags: ['ethereum', 'token', 'mapping'] + description: > + Mapping of ERC4626 tokens on Ethereum, including aTokens and MetaMorpho tokens, and their corresponding underlying tokens. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - erc4626_token + columns: + - name: blockchain + description: "Blockchain." + - name: erc4626_token + description: "Contract address of the erc4626 token." + - name: erc4626_token_name + description: "Name of the erc4626 token." + - name: erc4626_token_symbol + description: "Symbol of the erc4626 token." + - name: underlying_token + description: "Contract address of the underlying token." + - name: underlying_token_symbol + description: "Symbol of the underlying token." + - name: decimals + description: "Decimal precision of the ERC4626 token." + + - name: balancer_v3_ethereum_erc4626_token_prices + meta: + blockchain: ethereum + project: balancer + contributors: viniabussafi + config: + tags: ['ethereum', 'token', 'prices'] + description: > + Pricing information for ERC4626 tokens on Ethereum. Prices are derived from the ratio of underlying tokens deposited or withdrawn to shares issued or burned, multiplied by the underlying token price. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - minute + - wrapped_token + columns: + - name: minute + description: "Timestamp of the event, truncated to the nearest minute." + - name: blockchain + description: "Blockchain." + - name: wrapped_token + description: "Contract address of the wrapped token." + - name: underlying_token + description: "Contract address of the underlying token." + - name: erc4626_token_symbol + description: "Symbol of the erc4626 token." + - name: underlying_token_symbol + description: "Symbol of the underlying token." + - name: decimals + description: "Decimal precision for the token." + - name: median_price + description: "Median price of the static token, computed over the dataset." + - name: next_change + description: "Timestamp of the next expected pricing change or event affecting the price." diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/ethereum/balancer_v3_ethereum_erc4626_token_mapping.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/ethereum/balancer_v3_ethereum_erc4626_token_mapping.sql new file mode 100644 index 00000000000..d939fcc5e9e --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/ethereum/balancer_v3_ethereum_erc4626_token_mapping.sql @@ -0,0 +1,70 @@ +{{ + config( + schema = 'balancer_v3_ethereum', + alias = 'erc4626_token_mapping', + materialized = 'table', + file_format = 'delta' + ) +}} + +WITH aave_tokens AS( +SELECT + b.staticaToken AS erc4626_token, + a.staticaTokenName AS erc4626_token_name, + a.staticaTokenSymbol AS erc4626_token_symbol, + b.underlying AS underlying_token, + t.symbol AS underlying_token_symbol, + t.decimals AS decimals +FROM {{ source('aave_ethereum', 'StaticATokenLM_evt_Initialized') }} a +JOIN {{ source('aave_ethereum', 'StaticATokenFactory_evt_StaticTokenCreated') }} b +ON b.staticaToken = a.contract_address +JOIN {{ source('aave_v3_ethereum', 'VariableDebtToken_evt_Initialized') }} c +ON a.aToken = c.contract_address +JOIN {{ source('tokens', 'erc20') }} t +ON t.blockchain = 'ethereum' +AND b.underlying = t.contract_address + +UNION + +SELECT + erc4626_token, + erc4626_token_name, + erc4626_token_symbol, + underlying_token, + underlying_token_symbol, + decimals +FROM (VALUES + (0xd4fa2d31b7968e448877f69a96de69f5de8cd23e, 'Static Aave Ethereum USDC', 'WaEthUSDC', 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48, 'USDC', 6), + (0x7bc3485026ac48b6cf9baf0a377477fff5703af8, 'Static Aave Ethereum USDT', 'WaEthUSDT', 0xdac17f958d2ee523a2206206994597c13d831ec7, 'USDT', 6), + (0x0bfc9d54fc184518a81162f8fb99c2eaca081202, 'Static Aave Ethereum WETH', 'WaEthWETH', 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, 'WETH', 18), + (0x0fe906e030a44ef24ca8c7dc7b7c53a6c4f00ce9, 'Static Aave Ethereum Lido WETH', 'waEthLidoWETH', 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, 'WETH', 18), + (0x775f661b0bd1739349b9a2a3ef60be277c5d2d29, 'Static Aave Ethereum Lido wstETH', 'waEthLidowstETH', 0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0, 'wstETH', 18), + (0x5F9D59db355b4A60501544637b00e94082cA575b, 'Static Aave Ethereum USDe', 'waEthUSDe', 0x4c9EDD5852cd905f086C759E8383e09bff1E68B3, 'USDe', 18) + ) AS temp_table (erc4626_token, erc4626_token_name, erc4626_token_symbol, underlying_token, underlying_token_symbol, decimals) +), + +morpho_tokens AS( +SELECT DISTINCT + a.metaMorpho AS erc4626_token, + a.name AS erc4626_token_name, + a.symbol AS erc4626_token_symbol, + a.asset AS underlying_token, + t.symbol AS underlying_token_symbol, + 18 AS decimals +FROM {{ source('metamorpho_factory_ethereum', 'MetaMorphoFactory_evt_CreateMetaMorpho') }} a +JOIN {{ source('tokens', 'erc20') }} t +ON t.blockchain = 'ethereum' +AND a.asset = t.contract_address +) + +SELECT + 'ethereum' AS blockchain, + * +FROM aave_tokens + +UNION + +SELECT + 'ethereum' AS blockchain, + * +FROM morpho_tokens \ No newline at end of file diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/ethereum/balancer_v3_ethereum_erc4626_token_prices.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/ethereum/balancer_v3_ethereum_erc4626_token_prices.sql new file mode 100644 index 00000000000..02d989db3be --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/ethereum/balancer_v3_ethereum_erc4626_token_prices.sql @@ -0,0 +1,67 @@ +{{ config( + schema = 'balancer_v3_ethereum', + alias = 'erc4626_token_prices', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['minute', 'wrapped_token'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.minute')] + ) +}} + + +WITH wrap_unwrap AS( + SELECT + evt_block_time, + wrappedToken, + CAST(depositedUnderlying AS DOUBLE) / CAST(mintedShares AS DOUBLE) AS ratio + FROM {{ source('balancer_v3_ethereum', 'Vault_evt_Wrap') }} + {% if is_incremental() %} + WHERE {{ incremental_predicate('evt_block_time') }} + {% endif %} + + UNION ALL + + SELECT + evt_block_time, + wrappedToken, + CAST(withdrawnUnderlying AS DOUBLE) / CAST(burnedShares AS DOUBLE) AS ratio + FROM {{ source('balancer_v3_ethereum', 'Vault_evt_Unwrap') }} + {% if is_incremental() %} + WHERE {{ incremental_predicate('evt_block_time') }} + {% endif %} + ), + + + price_join AS( + SELECT + w.evt_block_time, + m.underlying_token, + w.wrappedToken, + m.erc4626_token_symbol, + m.underlying_token_symbol, + m.decimals, + ratio * price AS adjusted_price + FROM wrap_unwrap w + JOIN {{ref('balancer_v3_ethereum_erc4626_token_mapping')}} m ON m.erc4626_token = w.wrappedToken + JOIN {{ source('prices', 'usd') }} p ON m.underlying_token = p.contract_address + AND p.blockchain = 'ethereum' + AND DATE_TRUNC('minute', w.evt_block_time) = DATE_TRUNC('minute', p.minute) + {% if is_incremental() %} + AND {{ incremental_predicate('p.minute') }} + {% endif %} + ) + +SELECT + p.evt_block_time AS minute, + 'ethereum' AS blockchain, + wrappedToken AS wrapped_token, + underlying_token, + erc4626_token_symbol, + underlying_token_symbol, + decimals, + APPROX_PERCENTILE(adjusted_price, 0.5) AS median_price, + LEAD(p.evt_block_time, 1, CURRENT_DATE + INTERVAL '1' day) OVER (PARTITION BY wrappedToken ORDER BY p.evt_block_time) AS next_change +FROM price_join p +GROUP BY 1, 2, 3, 4, 5, 6, 7 + diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/gnosis/_schema.yml b/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/gnosis/_schema.yml new file mode 100644 index 00000000000..efb3ece0f2b --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/gnosis/_schema.yml @@ -0,0 +1,65 @@ +version: 2 + +models: + - name: balancer_v3_gnosis_erc4626_token_mapping + meta: + blockchain: gnosis + project: balancer + contributors: viniabussafi + config: + tags: ['gnosis', 'token', 'mapping'] + description: > + Mapping of ERC4626 tokens on gnosis, including aTokens and MetaMorpho tokens, and their corresponding underlying tokens. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - erc4626_token + columns: + - name: blockchain + description: "Blockchain." + - name: erc4626_token + description: "Contract address of the erc4626 token." + - name: erc4626_token_name + description: "Name of the erc4626 token." + - name: erc4626_token_symbol + description: "Symbol of the erc4626 token." + - name: underlying_token + description: "Contract address of the underlying token." + - name: underlying_token_symbol + description: "Symbol of the underlying token." + - name: decimals + description: "Decimal precision of the ERC4626 token." + + - name: balancer_v3_gnosis_erc4626_token_prices + meta: + blockchain: gnosis + project: balancer + contributors: viniabussafi + config: + tags: ['gnosis', 'token', 'prices'] + description: > + Pricing information for ERC4626 tokens on gnosis. Prices are derived from the ratio of underlying tokens deposited or withdrawn to shares issued or burned, multiplied by the underlying token price. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - minute + - wrapped_token + columns: + - name: minute + description: "Timestamp of the event, truncated to the nearest minute." + - name: blockchain + description: "Blockchain." + - name: wrapped_token + description: "Contract address of the wrapped token." + - name: underlying_token + description: "Contract address of the underlying token." + - name: erc4626_token_symbol + description: "Symbol of the erc4626 token." + - name: underlying_token_symbol + description: "Symbol of the underlying token." + - name: decimals + description: "Decimal precision for the token." + - name: median_price + description: "Median price of the static token, computed over the dataset." + - name: next_change + description: "Timestamp of the next expected pricing change or event affecting the price." diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/gnosis/balancer_v3_gnosis_erc4626_token_mapping.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/gnosis/balancer_v3_gnosis_erc4626_token_mapping.sql new file mode 100644 index 00000000000..66d94189050 --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/gnosis/balancer_v3_gnosis_erc4626_token_mapping.sql @@ -0,0 +1,30 @@ +{{ + config( + schema = 'balancer_v3_gnosis', + alias = 'erc4626_token_mapping', + materialized = 'table', + file_format = 'delta' + ) +}} + +WITH aave_tokens AS( + +SELECT + erc4626_token, + erc4626_token_name, + erc4626_token_symbol, + underlying_token, + underlying_token_symbol, + decimals +FROM (VALUES + (0x7c16F0185A26Db0AE7a9377f23BC18ea7ce5d644, 'Static Aave Gnosis GNO', 'WaGnoGNO', 0x9C58BAcC331c9aa871AFD802DB6379a98e80CEdb, 'GNO', 18), + (0x773CDA0CADe2A3d86E6D4e30699d40bB95174ff2, 'Static Aave Gnosis wstETH', 'WaGnowstETH', 0x6c76971f98945ae98dd7d4dfca8711ebea946ea6, 'wstETH', 18), + (0x57f664882F762FA37903FC864e2B633D384B411A, 'Static Aave Gnosis WETH', 'WaGnoWETH', 0x6a023ccd1ff6f2045c3309768ead9e68f978f6e1, 'WETH', 18), + (0x51350d88c1bd32Cc6A79368c9Fb70373Fb71F375, 'Static Aave Gnosis USDC', 'waGnoUSDCe', 0x2a22f9c3b484c3629090FeED35F17Ff8F88f76F0, 'USDC', 6) + ) AS temp_table (erc4626_token, erc4626_token_name, erc4626_token_symbol, underlying_token, underlying_token_symbol, decimals) +) + +SELECT + 'gnosis' AS blockchain, + * +FROM aave_tokens \ No newline at end of file diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/gnosis/balancer_v3_gnosis_erc4626_token_prices.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/gnosis/balancer_v3_gnosis_erc4626_token_prices.sql new file mode 100644 index 00000000000..f7166ea170f --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/gnosis/balancer_v3_gnosis_erc4626_token_prices.sql @@ -0,0 +1,66 @@ +{{ config( + schema = 'balancer_v3_gnosis', + alias = 'erc4626_token_prices', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['minute', 'wrapped_token'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.minute')] + ) +}} + + +WITH wrap_unwrap AS( + SELECT + evt_block_time, + wrappedToken, + CAST(depositedUnderlying AS DOUBLE) / CAST(mintedShares AS DOUBLE) AS ratio + FROM {{ source('balancer_v3_gnosis', 'Vault_evt_Wrap') }} + {% if is_incremental() %} + WHERE {{ incremental_predicate('evt_block_time') }} + {% endif %} + + UNION ALL + + SELECT + evt_block_time, + wrappedToken, + CAST(withdrawnUnderlying AS DOUBLE) / CAST(burnedShares AS DOUBLE) AS ratio + FROM {{ source('balancer_v3_gnosis', 'Vault_evt_Unwrap') }} + {% if is_incremental() %} + WHERE {{ incremental_predicate('evt_block_time') }} + {% endif %} + ), + + + price_join AS( + SELECT + w.evt_block_time, + m.underlying_token, + w.wrappedToken, + m.erc4626_token_symbol, + m.underlying_token_symbol, + m.decimals, + ratio * price AS adjusted_price + FROM wrap_unwrap w + JOIN {{ref('balancer_v3_gnosis_erc4626_token_mapping')}} m ON m.erc4626_token = w.wrappedToken + JOIN {{ source('prices', 'usd') }} p ON m.underlying_token = p.contract_address + AND p.blockchain = 'gnosis' + AND DATE_TRUNC('minute', w.evt_block_time) = DATE_TRUNC('minute', p.minute) + {% if is_incremental() %} + AND {{ incremental_predicate('p.minute') }} + {% endif %} + ) + +SELECT + p.evt_block_time AS minute, + 'gnosis' AS blockchain, + wrappedToken AS wrapped_token, + underlying_token, + erc4626_token_symbol, + underlying_token_symbol, + decimals, + APPROX_PERCENTILE(adjusted_price, 0.5) AS median_price, + LEAD(p.evt_block_time, 1, CURRENT_DATE + INTERVAL '1' day) OVER (PARTITION BY wrappedToken ORDER BY p.evt_block_time) AS next_change +FROM price_join p +GROUP BY 1, 2, 3, 4, 5, 6, 7 diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/liquidity/balancer_liquidity.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/liquidity/balancer_liquidity.sql index a278ac524f6..f859bcde449 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/balancer/liquidity/balancer_liquidity.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/liquidity/balancer_liquidity.sql @@ -20,6 +20,8 @@ ref('balancer_v1_ethereum_liquidity') , ref('balancer_v2_base_liquidity') , ref('balancer_v2_zkevm_liquidity') , ref('balancer_cowswap_amm_liquidity') +, ref('balancer_v3_ethereum_liquidity') +, ref('balancer_v3_gnosis_liquidity') ] %} diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/liquidity/ethereum/_schema.yml b/dbt_subprojects/hourly_spellbook/models/_project/balancer/liquidity/ethereum/_schema.yml index 1bf694eaf01..0279d42c430 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/balancer/liquidity/ethereum/_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/liquidity/ethereum/_schema.yml @@ -93,4 +93,36 @@ models: - *protocol_liquidity_usd - *protocol_liquidity_eth - *pool_liquidity_usd - - *pool_liquidity_eth \ No newline at end of file + - *pool_liquidity_eth + + - name: balancer_v3_ethereum_liquidity + meta: + blockchain: ethereum + project: balancer_v3 + contributors: viniabussafi + config: + tags: ['ethereum', 'balancer', 'pools', 'liquidity'] + description: > + Balancer v3 pools liquidity by token in Ethereum. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - pool_id + - token_address + columns: + - *day + - *pool_id + - *pool_address + - *pool_symbol + - *version + - *blockchain + - *pool_type + - *token_address + - *token_symbol + - *token_balance_raw + - *token_balance + - *protocol_liquidity_usd + - *protocol_liquidity_eth + - *pool_liquidity_usd + - *pool_liquidity_eth \ No newline at end of file diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/liquidity/ethereum/balancer_v3_ethereum_liquidity.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/liquidity/ethereum/balancer_v3_ethereum_liquidity.sql new file mode 100644 index 00000000000..b47682074b2 --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/liquidity/ethereum/balancer_v3_ethereum_liquidity.sql @@ -0,0 +1,22 @@ + +{% set blockchain = 'ethereum' %} + +{{ + config( + schema = 'balancer_v3_ethereum', + alias = 'liquidity', + materialized = 'table', + file_format = 'delta' + ) +}} + + +{{ + balancer_v3_compatible_liquidity_macro( + blockchain = blockchain, + version = '3', + project_decoded_as = 'balancer_v3', + base_spells_namespace = 'balancer', + pool_labels_spell = source('labels', 'balancer_v3_pools') + ) +}} \ No newline at end of file diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/liquidity/gnosis/_schema.yml b/dbt_subprojects/hourly_spellbook/models/_project/balancer/liquidity/gnosis/_schema.yml index f03929d48b7..2441ab284f8 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/balancer/liquidity/gnosis/_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/liquidity/gnosis/_schema.yml @@ -9,7 +9,7 @@ models: config: tags: ['gnosis', 'balancer', 'pools', 'liquidity'] description: > - Balancer v2 pools liquidity by token in Arbitrum. + Balancer v2 pools liquidity by token in Gnosis. data_tests: - dbt_utils.unique_combination_of_columns: combination_of_columns: @@ -44,15 +44,53 @@ models: - &token_symbol name: token_symbol description: "Token symbol" - - name: token_balance_raw + - &token_balance_raw + name: token_balance_raw description: 'Raw balance of the token in the pool in the original currency' - - name: token_balance + - &token_balance + name: token_balance description: 'Scaled balance of the token in the pool in the original currency' - - name: protocol_liquidity_usd + - &protocol_liquidity_usd + name: protocol_liquidity_usd description: 'Liquidity of the token in the pool in USD, except BPTs' - - name: protocol_liquidity_eth + - &protocol_liquidity_eth + name: protocol_liquidity_eth description: 'Liquidity of the token in the pool in ETH, except BPTs' - - name: pool_liquidity_usd + - &pool_liquidity_usd + name: pool_liquidity_usd description: 'Liquidity of the token in the pool in USD, including BPTs' - - name: pool_liquidity_eth - description: 'Liquidity of the token in the pool in ETH, including BPTs' \ No newline at end of file + - &pool_liquidity_eth + name: pool_liquidity_eth + description: 'Liquidity of the token in the pool in ETH, including BPTs' + + - name: balancer_v3_gnosis_liquidity + meta: + blockchain: gnosis + project: balancer_v3 + contributors: viniabussafi + config: + tags: ['gnosis', 'balancer', 'pools', 'liquidity'] + description: > + Balancer v3 pools liquidity by token in Gnosis. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - pool_id + - token_address + columns: + - *day + - *pool_id + - *pool_address + - *pool_symbol + - *version + - *blockchain + - *pool_type + - *token_address + - *token_symbol + - *token_balance_raw + - *token_balance + - *protocol_liquidity_usd + - *protocol_liquidity_eth + - *pool_liquidity_usd + - *pool_liquidity_eth \ No newline at end of file diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/liquidity/gnosis/balancer_v3_gnosis_liquidity.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/liquidity/gnosis/balancer_v3_gnosis_liquidity.sql new file mode 100644 index 00000000000..8ab09e843dd --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/liquidity/gnosis/balancer_v3_gnosis_liquidity.sql @@ -0,0 +1,21 @@ + +{% set blockchain = 'gnosis' %} + +{{ + config( + schema = 'balancer_v3_gnosis', + alias = 'liquidity', + materialized = 'table', + file_format = 'delta' + ) +}} + +{{ + balancer_v3_compatible_liquidity_macro( + blockchain = blockchain, + version = '3', + project_decoded_as = 'balancer_v3', + base_spells_namespace = 'balancer', + pool_labels_spell = source('labels', 'balancer_v3_pools') + ) +}} diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/pools/balancer_pools_tokens_weights.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/pools/balancer_pools_tokens_weights.sql index d2e50c49ce9..d57a4b0de4a 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/balancer/pools/balancer_pools_tokens_weights.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/pools/balancer_pools_tokens_weights.sql @@ -9,14 +9,14 @@ }} {% set balancer_models = [ - ref('balancer_v2_arbitrum_pools_tokens_weights'), - ref('balancer_v2_avalanche_c_pools_tokens_weights'), - ref('balancer_v2_base_pools_tokens_weights'), - ref('balancer_v2_ethereum_pools_tokens_weights'), - ref('balancer_v2_gnosis_pools_tokens_weights'), - ref('balancer_v2_optimism_pools_tokens_weights'), - ref('balancer_v2_polygon_pools_tokens_weights'), - ref('balancer_v2_zkevm_pools_tokens_weights') + ref('balancer_arbitrum_pools_tokens_weights'), + ref('balancer_avalanche_c_pools_tokens_weights'), + ref('balancer_base_pools_tokens_weights'), + ref('balancer_ethereum_pools_tokens_weights'), + ref('balancer_gnosis_pools_tokens_weights'), + ref('balancer_optimism_pools_tokens_weights'), + ref('balancer_polygon_pools_tokens_weights'), + ref('balancer_zkevm_pools_tokens_weights') ] %} diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/pools/ethereum/_schema.yml b/dbt_subprojects/hourly_spellbook/models/_project/balancer/pools/ethereum/_schema.yml index 60856c24380..01d6a2e4146 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/balancer/pools/ethereum/_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/pools/ethereum/_schema.yml @@ -92,4 +92,25 @@ models: - name: start_time description: "LBP start time" - name: end_time - description: "LBP end time" \ No newline at end of file + description: "LBP end time" + + - name: balancer_v3_ethereum_pools_tokens_weights + meta: + blockchain: ethereum + project: balancer + contributors: viniabussafi + config: + tags: ['ethereum', 'balancer', 'pools', 'tokens', 'weights'] + description: > + Token weights in Balancer v3 pools. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - pool_id + - token_address + columns: + - *blockchain + - *version + - *pool_id + - *token_address + - *normalized_weight \ No newline at end of file diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/pools/ethereum/balancer_ethereum_pools_tokens_weights.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/pools/ethereum/balancer_ethereum_pools_tokens_weights.sql index 0396dc86424..7f8285ce1d9 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/balancer/pools/ethereum/balancer_ethereum_pools_tokens_weights.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/pools/ethereum/balancer_ethereum_pools_tokens_weights.sql @@ -4,23 +4,26 @@ ) }} - + +{% set balancer_models = [ + ref('balancer_v1_ethereum_pools_tokens_weights'), + ref('balancer_v2_ethereum_pools_tokens_weights'), + ref('balancer_v3_ethereum_pools_tokens_weights') +] %} + SELECT * -FROM -( - SELECT - blockchain, - version, - pool_id, - token_address, - CAST(normalized_weight as double) as normalized_weight - FROM {{ ref('balancer_v1_ethereum_pools_tokens_weights') }} - UNION - SELECT - blockchain, - version, - pool_id, - token_address, - CAST(normalized_weight as double) as normalized_weight - FROM {{ ref('balancer_v2_ethereum_pools_tokens_weights') }} +FROM ( + {% for model in balancer_models %} + SELECT + blockchain, + version, + pool_id, + token_address, + normalized_weight + FROM {{ model }} + {% if not loop.last %} + UNION ALL + {% endif %} + {% endfor %} ) +; diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/pools/ethereum/balancer_v3_ethereum_pools_tokens_weights.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/pools/ethereum/balancer_v3_ethereum_pools_tokens_weights.sql new file mode 100644 index 00000000000..7c442c53d95 --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/pools/ethereum/balancer_v3_ethereum_pools_tokens_weights.sql @@ -0,0 +1,61 @@ +{{ + config( + schema='balancer_v3_ethereum', + alias = 'pools_tokens_weights', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['pool_id', 'token_address'] + ) +}} + +-- +-- Balancer v3 Pools Tokens Weights +-- +WITH token_data AS ( + SELECT + pool, + ARRAY_AGG(FROM_HEX(json_extract_scalar(token, '$.token')) ORDER BY token_index) AS tokens + FROM ( + SELECT + pool, + tokenConfig, + SEQUENCE(1, CARDINALITY(tokenConfig)) AS token_index_array + FROM {{ source('balancer_v3_ethereum', 'Vault_evt_PoolRegistered') }} + ) AS pool_data + CROSS JOIN UNNEST(tokenConfig, token_index_array) AS t(token, token_index) + GROUP BY 1 + ), + +weighted_pool_factory AS ( + SELECT + call_create.output_pool AS pool_id, + t.pos AS pos, + t.token_address AS token_address, + t2.normalized_weight AS normalized_weight + FROM {{ source('balancer_v3_ethereum', 'WeightedPoolFactory_call_create') }} AS call_create + JOIN token_data td ON td.pool = call_create.output_pool + CROSS JOIN UNNEST(td.tokens) WITH ORDINALITY t(token_address, pos) + CROSS JOIN UNNEST(call_create.normalizedWeights) WITH ORDINALITY t2(normalized_weight, pos) + WHERE t.pos = t2.pos + {% if is_incremental() %} + AND call_create.call_block_time >= date_trunc('day', now() - interval '7' day) + {% endif %} +), + +normalized_weights AS ( + SELECT + pool_id, + token_address, + normalized_weight / POWER(10, 18) AS normalized_weight + FROM weighted_pool_factory +) + +SELECT + 'ethereum' AS blockchain, + '3' AS version, + w.pool_id, + w.token_address, + w.normalized_weight +FROM normalized_weights w +WHERE w.pool_id IS NOT NULL diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/pools/gnosis/_schema.yml b/dbt_subprojects/hourly_spellbook/models/_project/balancer/pools/gnosis/_schema.yml index 053513dd4ea..c0a72b7781c 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/balancer/pools/gnosis/_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/pools/gnosis/_schema.yml @@ -48,4 +48,25 @@ models: - *version - *pool_id - *token_address - - *normalized_weight \ No newline at end of file + - *normalized_weight + + - name: balancer_v3_gnosis_pools_tokens_weights + meta: + blockchain: gnosis + project: balancer + contributors: viniabussafi + config: + tags: ['gnosis', 'balancer', 'pools', 'tokens', 'weights'] + description: > + Token weights in Balancer v3 pools. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - pool_id + - token_address + columns: + - *blockchain + - *version + - *pool_id + - *token_address + - *normalized_weight \ No newline at end of file diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/pools/gnosis/balancer_gnosis_pools_tokens_weights.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/pools/gnosis/balancer_gnosis_pools_tokens_weights.sql index 4682ebab892..b0773310c4f 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/balancer/pools/gnosis/balancer_gnosis_pools_tokens_weights.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/pools/gnosis/balancer_gnosis_pools_tokens_weights.sql @@ -5,14 +5,25 @@ ) }} +{% set balancer_models = [ + ref('balancer_v2_gnosis_pools_tokens_weights'), + ref('balancer_v3_gnosis_pools_tokens_weights') +] %} + SELECT * -FROM -( - SELECT - blockchain, - version, - pool_id, - token_address, - normalized_weight - FROM {{ ref('balancer_v2_gnosis_pools_tokens_weights') }} -) \ No newline at end of file +FROM ( + {% for model in balancer_models %} + SELECT + blockchain, + version, + pool_id, + token_address, + normalized_weight + FROM {{ model }} + WHERE pool_id IS NOT NULL + {% if not loop.last %} + UNION ALL + {% endif %} + {% endfor %} +) +; diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/pools/gnosis/balancer_v3_gnosis_pools_tokens_weights.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/pools/gnosis/balancer_v3_gnosis_pools_tokens_weights.sql new file mode 100644 index 00000000000..fa93d6184ce --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/pools/gnosis/balancer_v3_gnosis_pools_tokens_weights.sql @@ -0,0 +1,61 @@ +{{ + config( + schema='balancer_v3_gnosis', + alias = 'pools_tokens_weights', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['pool_id', 'token_address'] + ) +}} + +-- +-- Balancer v3 Pools Tokens Weights +-- +WITH token_data AS ( + SELECT + pool, + ARRAY_AGG(FROM_HEX(json_extract_scalar(token, '$.token')) ORDER BY token_index) AS tokens + FROM ( + SELECT + pool, + tokenConfig, + SEQUENCE(1, CARDINALITY(tokenConfig)) AS token_index_array + FROM {{ source('balancer_v3_gnosis', 'Vault_evt_PoolRegistered') }} + ) AS pool_data + CROSS JOIN UNNEST(tokenConfig, token_index_array) AS t(token, token_index) + GROUP BY 1 + ), + +weighted_pool_factory AS ( + SELECT + call_create.output_pool AS pool_id, + t.pos AS pos, + t.token_address AS token_address, + t2.normalized_weight AS normalized_weight + FROM {{ source('balancer_v3_gnosis', 'WeightedPoolFactory_call_create') }} AS call_create + JOIN token_data td ON td.pool = call_create.output_pool + CROSS JOIN UNNEST(td.tokens) WITH ORDINALITY t(token_address, pos) + CROSS JOIN UNNEST(call_create.normalizedWeights) WITH ORDINALITY t2(normalized_weight, pos) + WHERE t.pos = t2.pos + {% if is_incremental() %} + AND call_create.call_block_time >= date_trunc('day', now() - interval '7' day) + {% endif %} +), + +normalized_weights AS ( + SELECT + pool_id, + token_address, + normalized_weight / POWER(10, 18) AS normalized_weight + FROM weighted_pool_factory +) + +SELECT + 'gnosis' AS blockchain, + '3' AS version, + w.pool_id, + w.token_address, + w.normalized_weight +FROM normalized_weights w +WHERE w.pool_id IS NOT NULL diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/protocol_fee/_schema.yml b/dbt_subprojects/hourly_spellbook/models/_project/balancer/protocol_fee/_schema.yml index d4a08fa601a..aab385185a8 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/balancer/protocol_fee/_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/protocol_fee/_schema.yml @@ -37,7 +37,10 @@ models: description: "Blockchain" - &pool_type name: pool_type - description: "Pool attributes, determined by the pool's factory" + description: "Pool attributes, determined by the pool's factory" + - &fee_type + name: fee_type + description: "Labels whether fee comes from swaps or yield for V3. V2 fees are labeled as 'v2'." - &token_address name: token_address description: "Contract address of the token in which protocol fees were collected" diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/protocol_fee/balancer_protocol_fee.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/protocol_fee/balancer_protocol_fee.sql index 37fef24dc85..d0cf6d8445c 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/balancer/protocol_fee/balancer_protocol_fee.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/protocol_fee/balancer_protocol_fee.sql @@ -8,7 +8,7 @@ ) }} -{% set balancer_v2_models = [ +{% set balancer_models = [ ref('balancer_v2_arbitrum_protocol_fee'), ref('balancer_v2_avalanche_c_protocol_fee'), ref('balancer_v2_base_protocol_fee'), @@ -17,19 +17,22 @@ ref('balancer_v2_optimism_protocol_fee'), ref('balancer_v2_polygon_protocol_fee'), ref('balancer_v2_zkevm_protocol_fee'), + ref('balancer_v3_ethereum_protocol_fee'), + ref('balancer_v3_gnosis_protocol_fee') ] %} SELECT * FROM ( - {% for protocol_fee in balancer_v2_models %} + {% for protocol_fee in balancer_models %} SELECT day, pool_id, pool_address, pool_symbol, - '2' AS version, + version, blockchain, pool_type, + fee_type, token_address, token_symbol, token_amount_raw, diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/protocol_fee/ethereum/_schema.yml b/dbt_subprojects/hourly_spellbook/models/_project/balancer/protocol_fee/ethereum/_schema.yml index 2de1a5b874b..edc8318cf02 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/balancer/protocol_fee/ethereum/_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/protocol_fee/ethereum/_schema.yml @@ -37,7 +37,10 @@ models: description: "Blockchain" - &pool_type name: pool_type - description: "Pool attributes, determined by the pool's factory" + description: "Pool attributes, determined by the pool's factory" + - &fee_type + name: fee_type + description: "Labels whether fee comes from swaps or yield for V3. V2 fees are labeled as 'v2'." - &token_address name: token_address description: "Contract address of the token in which protocol fees were collected" @@ -58,4 +61,37 @@ models: description: "Share of total fee that is directed to Balancer DAO's treasury, as per BIPs 19, 161 and 371" - &treasury_revenue_usd name: treasury_revenue_usd - description: "USD value of fee directed to Balancer DAO's treasury" \ No newline at end of file + description: "USD value of fee directed to Balancer DAO's treasury" + + - name: balancer_v3_ethereum_protocol_fee + meta: + blockchain: ethereum + project: balancer_v3 + contributors: viniabussafi + config: + tags: ['ethereum', 'revenue', 'fees'] + description: > + Daily Protocol Fee collected and Revenue by pool on Balancer, an automated portfolio manager and trading platform. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - pool_id + - fee_type + - token_address + columns: + - *day + - *pool_id + - *pool_address + - *pool_symbol + - *version + - *blockchain + - *pool_type + - *fee_type + - *token_address + - *token_symbol + - *token_amount_raw + - *token_amount + - *protocol_fee_collected_usd + - *treasury_share + - *treasury_revenue_usd \ No newline at end of file diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/protocol_fee/ethereum/balancer_v3_ethereum_protocol_fee.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/protocol_fee/ethereum/balancer_v3_ethereum_protocol_fee.sql new file mode 100644 index 00000000000..dafed52013e --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/protocol_fee/ethereum/balancer_v3_ethereum_protocol_fee.sql @@ -0,0 +1,20 @@ +{% set blockchain = 'ethereum' %} + +{{ + config( + schema='balancer_v3_ethereum', + alias = 'protocol_fee', + materialized = 'table', + file_format = 'delta' + ) +}} + +{{ + balancer_v3_compatible_protocol_fee_macro( + blockchain = blockchain, + version = '3', + project_decoded_as = 'balancer_v3', + base_spells_namespace = 'balancer', + pool_labels_spell = source('labels', 'balancer_v3_pools') + ) +}} diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/protocol_fee/gnosis/_schema.yml b/dbt_subprojects/hourly_spellbook/models/_project/balancer/protocol_fee/gnosis/_schema.yml index 3b1fa8ffdbe..51e384bdd3a 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/balancer/protocol_fee/gnosis/_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/protocol_fee/gnosis/_schema.yml @@ -38,6 +38,9 @@ models: - &pool_type name: pool_type description: "Pool attributes, determined by the pool's factory" + - &fee_type + name: fee_type + description: "Labels whether fee comes from swaps or yield for V3. V2 fees are labeled as 'v2'." - &token_address name: token_address description: "Contract address of the token in which protocol fees were collected" @@ -58,4 +61,37 @@ models: description: "Share of total fee that is directed to Balancer DAO's treasury, as per BIPs 19, 161 and 371" - &treasury_revenue_usd name: treasury_revenue_usd - description: "USD value of fee directed to Balancer DAO's treasury" \ No newline at end of file + description: "USD value of fee directed to Balancer DAO's treasury" + + - name: balancer_v3_gnosis_protocol_fee + meta: + blockchain: gnosis + project: balancer_v3 + contributors: viniabussafi + config: + tags: ['gnosis', 'revenue', 'fees'] + description: > + Daily Protocol Fee collected and Revenue by pool on Balancer, an automated portfolio manager and trading platform. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - pool_id + - fee_type + - token_address + columns: + - *day + - *pool_id + - *pool_address + - *pool_symbol + - *version + - *blockchain + - *pool_type + - *fee_type + - *token_address + - *token_symbol + - *token_amount_raw + - *token_amount + - *protocol_fee_collected_usd + - *treasury_share + - *treasury_revenue_usd \ No newline at end of file diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/protocol_fee/gnosis/balancer_v3_gnosis_protocol_fee.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/protocol_fee/gnosis/balancer_v3_gnosis_protocol_fee.sql new file mode 100644 index 00000000000..0630e6eec63 --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/protocol_fee/gnosis/balancer_v3_gnosis_protocol_fee.sql @@ -0,0 +1,20 @@ +{% set blockchain = 'gnosis' %} + +{{ + config( + schema='balancer_v3_gnosis', + alias = 'protocol_fee', + materialized = 'table', + file_format = 'delta' + ) +}} + +{{ + balancer_v3_compatible_protocol_fee_macro( + blockchain = blockchain, + version = '3', + project_decoded_as = 'balancer_v3', + base_spells_namespace = 'balancer', + pool_labels_spell = source('labels', 'balancer_v3_pools') + ) +}} diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/support/balancer_token_whitelist.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/support/balancer_token_whitelist.sql index 5727e1a0739..a063cb927cd 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/balancer/support/balancer_token_whitelist.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/support/balancer_token_whitelist.sql @@ -29,6 +29,8 @@ WITH whitelist_token as ( (0xe91d153e0b41518a2ce8dd3d7944fa863463a97d, 'WXDAI', 'gnosis'), (0x6a023ccd1ff6f2045c3309768ead9e68f978f6e1, 'WETH', 'gnosis'), (0x6c76971f98945ae98dd7d4dfca8711ebea946ea6, 'WSTETH', 'gnosis'), + (0xaf204776c7245bf4147c2612bf6e5972ee483701, 'SDAI', 'gnosis'), + (0x9c58bacc331c9aa871afd802db6379a98e80cedb, 'GNO', 'gnosis'), (0xdAC17F958D2ee523a2206206994597C13D831ec7, 'USDT', 'ethereum'), (0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48, 'USDC', 'ethereum'), (0x6B175474E89094C44Da98b954EedeAC495271d0F, 'DAI', 'ethereum'), diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer_cowswap_amm/_schema.yml b/dbt_subprojects/hourly_spellbook/models/_project/balancer_cowswap_amm/_schema.yml index bf1b22cdf8c..122bf017ff8 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/balancer_cowswap_amm/_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer_cowswap_amm/_schema.yml @@ -3,11 +3,11 @@ version: 2 models: - name: balancer_cowswap_amm_balances meta: - blockchain: arbitrum, ethereum, gnosis + blockchain: arbitrum, base, ethereum, gnosis project: balancer_cowswap_amm contributors: viniabussafi config: - tags: ['ethereum', 'gnosis', 'balancer', 'balances'] + tags: ['arbitrum', 'base', 'ethereum', 'gnosis', 'balancer', 'balances'] description: > ERC20 token rolling sum balances on Balancer, an automated portfolio manager and trading platform. columns: @@ -31,11 +31,11 @@ models: - name: balancer_cowswap_amm_liquidity meta: - blockchain: arbitrum, ethereum, gnosis + blockchain: arbitrum, base, ethereum, gnosis project: balancer_cowswap_amm contributors: viniabussafi config: - tags: ['ethereum', 'gnosis', 'balancer', 'pools', 'liquidity'] + tags: ['arbitrum', 'base', 'ethereum', 'gnosis', 'balancer', 'pools', 'liquidity'] description: > Balancer CoWSwap AMM pools liquidity by token in Ethereum. columns: diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer_cowswap_amm/balancer_cowswap_amm_balances.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer_cowswap_amm/balancer_cowswap_amm_balances.sql index 8fe94461c54..ced93887adc 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/balancer_cowswap_amm/balancer_cowswap_amm_balances.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer_cowswap_amm/balancer_cowswap_amm_balances.sql @@ -9,6 +9,7 @@ {% set b_cow_amm_models = [ ref('balancer_cowswap_amm_arbitrum_balances'), + ref('balancer_cowswap_amm_base_balances'), ref('balancer_cowswap_amm_ethereum_balances'), ref('balancer_cowswap_amm_gnosis_balances') ] %} diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer_cowswap_amm/balancer_cowswap_amm_liquidity.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer_cowswap_amm/balancer_cowswap_amm_liquidity.sql index e0c2bf825c8..f33020da31d 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/balancer_cowswap_amm/balancer_cowswap_amm_liquidity.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer_cowswap_amm/balancer_cowswap_amm_liquidity.sql @@ -8,6 +8,7 @@ {% set b_cow_amm_models = [ ref('balancer_cowswap_amm_arbitrum_liquidity'), + ref('balancer_cowswap_amm_base_liquidity'), ref('balancer_cowswap_amm_ethereum_liquidity'), ref('balancer_cowswap_amm_gnosis_liquidity') ] %} diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer_cowswap_amm/base/_schema.yml b/dbt_subprojects/hourly_spellbook/models/_project/balancer_cowswap_amm/base/_schema.yml new file mode 100644 index 00000000000..41ad1496b56 --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer_cowswap_amm/base/_schema.yml @@ -0,0 +1,80 @@ +version: 2 + +models: + - name: balancer_cowswap_amm_base_balances + meta: + blockchain: base + project: balancer_cowswap_amm + contributors: viniabussafi + config: + tags: ['base', 'balancer', 'balances'] + description: > + ERC20 token rolling sum balances on Balancer, an automated portfolio manager and trading platform. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - pool_address + - token_address + columns: + - &day + name: day + description: "UTC event block time truncated to the day mark" + data_tests: + - not_null + - &blockchain + name: blockchain + description: "" + - &pool_address + name: pool_address + description: "Balancer CoWSwap AMM pool contract address" + - &token_address + name: token_address + description: "Token contract address" + - &token_balance_raw + name: token_balance_raw + description: "Balance of a token" + + - name: balancer_cowswap_amm_base_liquidity + meta: + blockchain: base + project: balancer_cowswap_amm + contributors: viniabussafi + config: + tags: ['base', 'balancer', 'pools', 'liquidity'] + description: > + Balancer CoWSwap AMM pools liquidity by token in base. + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - pool_id + - token_address + columns: + - *day + - name: pool_id + - *pool_address + - name: pool_symbol + - name: version + - *blockchain + - name: pool_type + - *token_address + - &token_symbol + name: token_symbol + description: "Token symbol" + - *token_balance_raw + - &token_balance + name: token_balance + description: "Balance of the token in the pool" + - &protocol_liquidity_usd + name: protocol_liquidity_usd + description: "Protocol liquidity in USD" + - &protocol_liquidity_eth + name: protocol_liquidity_eth + description: "Protocol liquidity in ETH" + - &pool_liquidity_usd + name: pool_liquidity_usd + description: "Pool liquidity in USD" + - &pool_liquidity_eth + name: pool_liquidity_eth + description: "Pool liquidity in ETH" \ No newline at end of file diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer_cowswap_amm/base/balancer_cowswap_amm_base_balances.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer_cowswap_amm/base/balancer_cowswap_amm_base_balances.sql new file mode 100644 index 00000000000..fd438e86004 --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer_cowswap_amm/base/balancer_cowswap_amm_base_balances.sql @@ -0,0 +1,77 @@ +{{ + config( + schema = 'balancer_cowswap_amm_base', + alias = 'balances', + materialized = 'table', + file_format = 'delta' + ) +}} + +WITH pools AS ( + SELECT + bPool AS pools + FROM {{ source('b_cow_amm_base', 'BCoWFactory_evt_LOG_NEW_POOL') }} +), + +joins AS ( + SELECT + p.pools AS pool, + DATE_TRUNC('day', e.evt_block_time) AS day, + e.contract_address AS token, + SUM(CAST(value AS int256)) AS amount + FROM {{ source('erc20_base', 'evt_transfer') }} e + INNER JOIN pools p ON e."to" = p.pools + GROUP BY 1, 2, 3 +), + +exits AS ( + SELECT + p.pools AS pool, + DATE_TRUNC('day', e.evt_block_time) AS day, + e.contract_address AS token, + - SUM(CAST(value AS int256)) AS amount + FROM {{ source('erc20_base', 'evt_transfer') }} e + INNER JOIN pools p ON e."from" = p.pools + GROUP BY 1, 2, 3 +), + +daily_delta_balance_by_token AS ( + SELECT + pool, + day, + token, + SUM(COALESCE(amount, CAST(0 AS int256))) AS amount + FROM + (SELECT * + FROM joins j + UNION ALL + SELECT * + FROM exits e) foo + GROUP BY 1, 2, 3 +), + +cumulative_balance_by_token AS ( + SELECT + pool, + token, + day, + LEAD(day, 1, now()) OVER (PARTITION BY pool, token ORDER BY day) AS day_of_next_change, + SUM(amount) OVER (PARTITION BY pool, token ORDER BY day ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS cumulative_amount + FROM daily_delta_balance_by_token +), + +calendar AS ( + SELECT + date_sequence AS day + FROM unnest(sequence(date('2024-12-01'), date(now()), interval '1' day)) AS t(date_sequence) +) + +SELECT + c.day, + 'base' AS blockchain, + b.pool AS pool_address, + b.token AS token_address, + b.cumulative_amount AS token_balance_raw +FROM calendar c +LEFT JOIN cumulative_balance_by_token b ON b.day <= c.day AND c.day < b.day_of_next_change +WHERE b.pool IS NOT NULL diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer_cowswap_amm/base/balancer_cowswap_amm_base_liquidity.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer_cowswap_amm/base/balancer_cowswap_amm_base_liquidity.sql new file mode 100644 index 00000000000..7a9557b890f --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer_cowswap_amm/base/balancer_cowswap_amm_base_liquidity.sql @@ -0,0 +1,85 @@ +{% set blockchain = 'base' %} + +{{ + config( + schema='balancer_cowswap_amm_' + blockchain, + alias = 'liquidity', + materialized = 'table', + file_format = 'delta' + ) +}} + +WITH pool_labels AS ( + SELECT + address, + name + FROM {{ source('labels', 'balancer_cowswap_amm_pools') }} + WHERE blockchain = '{{blockchain}}' + ), + + prices AS ( + SELECT + date_trunc('day', minute) AS day, + contract_address AS token, + decimals, + AVG(price) AS price + FROM {{ source('prices', 'usd') }} + WHERE blockchain = '{{blockchain}}' + GROUP BY 1, 2, 3 + ), + + eth_prices AS( + SELECT + date_trunc('day', minute) AS day, + APPROX_PERCENTILE(price, 0.5) AS eth_price + FROM {{ source('prices', 'usd') }} + WHERE blockchain = '{{blockchain}}' + AND contract_address = 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 + GROUP BY 1 + ), + + cumulative_balance AS ( + SELECT + day, + pool_address, + token_address, + token_balance_raw + FROM {{ ref('balancer_cowswap_amm_base_balances') }} b + ), + + cumulative_usd_balance AS ( + SELECT + b.day, + b.pool_address, + b.token_address, + t.symbol, + token_balance_raw, + token_balance_raw / POWER(10, COALESCE(t.decimals, p1.decimals)) AS token_balance, + token_balance_raw / POWER(10, COALESCE(t.decimals, p1.decimals)) * COALESCE(p1.price, 0) AS protocol_liquidity_usd + FROM cumulative_balance b + LEFT JOIN {{ source('tokens', 'erc20') }} t ON t.contract_address = b.token_address + AND t.blockchain = '{{blockchain}}' + LEFT JOIN prices p1 ON p1.day = b.day + AND p1.token = b.token_address + ) + +SELECT + c.day, + c.pool_address AS pool_id, + c.pool_address, + p.name AS pool_symbol, + '1' AS version, + '{{blockchain}}' AS blockchain, + 'balancer_cowswap_amm' AS pool_type, + c.token_address, + c.symbol AS token_symbol, + c.token_balance_raw, + c.token_balance, + c.protocol_liquidity_usd, + (c.protocol_liquidity_usd) / e.eth_price AS protocol_liquidity_eth, + c.protocol_liquidity_usd AS pool_liquidity_usd, + (c.protocol_liquidity_usd) / e.eth_price AS pool_liquidity_eth +FROM cumulative_usd_balance c +LEFT JOIN pool_labels p ON p.address = c.pool_address +LEFT JOIN eth_prices e ON e.day = c.day +WHERE c.pool_address IS NOT NULL diff --git a/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/arbitrum/cow_protocol_arbitrum_batches.sql b/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/arbitrum/cow_protocol_arbitrum_batches.sql index 24679ceaacb..5b69f8d0065 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/arbitrum/cow_protocol_arbitrum_batches.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/arbitrum/cow_protocol_arbitrum_batches.sql @@ -16,41 +16,13 @@ }} WITH --- Find the PoC Query here: https://dune.com/queries/3840594 -solver_activation_events AS ( - SELECT - solver, - evt_block_number, - evt_index, - TRUE AS activated - FROM {{ source('gnosis_protocol_v2_arbitrum', 'GPv2AllowListAuthentication_evt_SolverAdded') }} - UNION - SELECT - solver, - evt_block_number, - evt_index, - FALSE AS activated - FROM {{ source('gnosis_protocol_v2_arbitrum', 'GPv2AllowListAuthentication_evt_SolverRemoved') }} - ), - ranked_solver_events as ( - select - rank() over (partition by solver order by evt_block_number desc, evt_index desc) as rk, - solver, - evt_block_number, - evt_index, - activated as active - from solver_activation_events -), -registered_solvers as ( - select solver as address, active - from ranked_solver_events - where rk = 1 -), batch_counts as ( select try_cast(date_trunc('day', s.evt_block_time) as date) as block_date, + s.evt_block_number, s.evt_block_time, s.evt_tx_hash, solver, + name, sum( case when selector != 0x2e1a7d4d -- unwrap @@ -66,12 +38,12 @@ batch_counts as ( {% if is_incremental() %} AND {{ incremental_predicate('i.evt_block_time') }} {% endif %} - join registered_solvers + join {{ ref('cow_protocol_arbitrum_solvers') }} on solver = address {% if is_incremental() %} WHERE {{ incremental_predicate('s.evt_block_time') }} {% endif %} - group by s.evt_tx_hash, solver, s.evt_block_time + group by s.evt_block_number, s.evt_block_time, s.evt_tx_hash, solver, name ), batch_values as ( @@ -98,6 +70,7 @@ batch_values as ( combined_batch_info as ( select b.block_date, + evt_block_number as block_number, evt_block_time as block_time, num_trades, dex_swaps, @@ -116,8 +89,9 @@ combined_batch_info as ( on b.evt_tx_hash = t.tx_hash inner join {{ source('arbitrum', 'transactions') }} tx on evt_tx_hash = hash + and evt_block_number = block_number {% if is_incremental() %} - AND {{ incremental_predicate('tx.block_time') }} + AND {{ incremental_predicate('block_time') }} {% endif %} where num_trades > 0 --! Exclude Withdraw Batches ) diff --git a/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/arbitrum/cow_protocol_arbitrum_solvers.sql b/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/arbitrum/cow_protocol_arbitrum_solvers.sql index dc2eb9fdbbe..f83aa055fab 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/arbitrum/cow_protocol_arbitrum_solvers.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/arbitrum/cow_protocol_arbitrum_solvers.sql @@ -36,39 +36,52 @@ registered_solvers as ( -- Manually inserting environment and name for each "known" solver known_solver_metadata (address, environment, name) as ( SELECT * - FROM (VALUES - (0xA70892d1Af41aBD2F648FEC74Ea2c17e56Ac3B9A, 'prod', 'Naive'), + FROM ( + VALUES + (0xA70892d1Af41aBD2F648FEC74Ea2c17e56Ac3B9A, 'prod', 'Naive'), (0xba36CEfb45d1CdD2Ae30a899C432c5081E095Ff8, 'prod', 'Baseline'), (0xF017C6F66D68d11AF00FD243494E3fa0EBf44C66, 'prod', 'Quasimodo'), - (0x001088C88be46346ED99856dcfA3a00Da7AAf212, 'prod', '1Inch'), - (0xc46Ac109FDe084192BE59C24C3680D818763b0fd, 'prod', 'ParaSwap'), - (0xD31E0CE8154Da6b8086d961eB3068Ef74C4322b6, 'prod', '0x'), - (0xAa224676d096B6Fc257F8C386C67d9e96e53AD59, 'prod', 'BalancerSOR'), - (0x5932b2c05172aAfE097CE0Fbd27d18a7d5A45eE1, 'prod', 'Furucombo'), - (0x3A485742Bd85e660e72dE0f49cC27AD7a62911B5, 'prod', 'SeaSolver'), + (0x001088C88be46346ED99856dcfA3a00Da7AAf212, 'prod', 'Gnosis_1inch'), + (0xc46Ac109FDe084192BE59C24C3680D818763b0fd, 'prod', 'Gnosis_ParaSwap'), + (0xD31E0CE8154Da6b8086d961eB3068Ef74C4322b6, 'prod', 'Gnosis_0x'), + (0xAa224676d096B6Fc257F8C386C67d9e96e53AD59, 'prod', 'Gnosis_BalancerSOR'), + (0x5932b2c05172aAfE097CE0Fbd27d18a7d5A45eE1, 'prod', 'Portus'), + (0x3A485742Bd85e660e72dE0f49cC27AD7a62911B5, 'prod', 'Seasolver'), (0x059aefdF9d9F47def37cF7066DA83fEB91fDd089, 'prod', 'Barter'), - (0x40798d2261f8b7F11BFa73623c99C876844dD05A, 'prod', 'OpenOcean'), + (0x40798d2261f8b7F11BFa73623c99C876844dD05A, 'prod', 'OpenOcean_Aggregator'), (0x0648548f891E1356f197070D009704e574182bfB, 'prod', 'Rizzolver'), (0x23e868881dfe0531358B8FE0cbec43FD860cbF33, 'prod', 'Rizzolver'), + (0x2692F7bFCB2e1a8575434b9511804266D9aeb628, 'prod', 'Velvet'), + (0x0148538e6cA813D41eA5988008Cdc9B72d4e65A7, 'prod', 'Laita'), + (0x1FA2FF499b327f53cD9a82BcAFE36093563E32e4, 'prod', 'Apollo'), + (0x0148538e6cA813D41eA5988008Cdc9B72d4e65A7, 'prod', 'Laita'), + (0x9C75aae1Bd2f96D7B4E67e8C5344f3304382276E, 'prod', 'Enso'), + (0x034F6Aca83F1900b0157b0123F514A29456eeA59, 'barn', 'Laita'), + (0x6bf97aFe2D2C790999cDEd2a8523009eB8a0823f, 'prod', 'Portus'), + (0xBB765c920f86e2A2654c4B82deB5BC2E092fF93b, 'barn', 'Portus'), + (0x5E06F88D28603f5bB106bD5C8AD93ce2E902d24b, 'barn', 'Apollo'), + (0x034F6Aca83F1900b0157b0123F514A29456eeA59, 'barn', 'Laita'), + (0x669Be18D403Be353C1B9EBC87225313Ec2560BF5, 'barn', 'Velvet'), (0x20dC1014E946Cf511Ee535D908eC9a1d75Dd66ce, 'barn', 'Naive'), (0x2e6822f4Ab355E386d1A4fd34947ACE0F6f344a7, 'barn', 'Baseline'), (0x03a65D265E0613326ca23f5E6A1a99Ab2F12600B, 'barn', 'Quasimodo'), - (0xee10E8D38150BEe3b0B32c41b74821d6e7Da485A, 'barn', '1Inch'), - (0x9C803d345615aDe1e5ae07A789968403fAc9171a, 'barn', 'ParaSwap'), - (0x69433b336952e84Db44EF40b16B338F139B8baA1, 'barn', '0x'), - (0xCED55FC88186f672105712fe177374cce4861FDF, 'barn', 'BalancerSOR'), - (0xE376a730037D8B495864FD5ed6373BE89643cD06, 'barn', 'Furucombo'), - (0x2633bd8e5FDf7C72Aca1d291CA11bdB717A6aa3d, 'barn', 'SeaSolver'), + (0xee10E8D38150BEe3b0B32c41b74821d6e7Da485A, 'barn', 'Gnosis_ParaSwap'), + (0x9C803d345615aDe1e5ae07A789968403fAc9171a, 'barn', 'Gnosis_ParaSwap'), + (0x69433b336952e84Db44EF40b16B338F139B8baA1, 'barn', 'Gnosis_0x'), + (0xCED55FC88186f672105712fe177374cce4861FDF, 'barn', 'Gnosis_BalancerSOR'), + (0xE376a730037D8B495864FD5ed6373BE89643cD06, 'barn', 'Portus'), + (0x2633bd8e5FDf7C72Aca1d291CA11bdB717A6aa3d, 'barn', 'Seasolver'), (0x7B0211286d8Dfdb717f4A2E5Fa5131eD911097e1, 'barn', 'Barter'), - (0xc8371B2898FBaEeAe658f9FaeE8ddeDA24e37012, 'barn', 'OpenOcean'), + (0xc8371B2898FBaEeAe658f9FaeE8ddeDA24e37012, 'barn', 'OpenOcean_Aggregator'), (0x2aeC288B42C99D2e8e984c5C324FB069f7705186, 'barn', 'Rizzolver'), (0x26B5e3bF135D3Dd05A220508dD61f25BF1A47cBD, 'barn', 'Rizzolver') - ) as _ + ) as _ ) -- Combining the metadata with current activation status for final table select solver as address, - case when environment is not null then environment else 'new' end as environment, - case when name is not null then name else 'Uncatalogued' end as name, + case when environment is not null then environment else 'new' end as environment, + case when name is not null then name else 'Uncatalogued' end as name, active from registered_solvers - left outer join known_solver_metadata on solver = address; +left outer join known_solver_metadata on solver = address + diff --git a/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/base/cow_protocol_base_batches.sql b/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/base/cow_protocol_base_batches.sql new file mode 100644 index 00000000000..89c3a314de9 --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/base/cow_protocol_base_batches.sql @@ -0,0 +1,99 @@ +{{ config( + schema = 'cow_protocol_base', + alias = 'batches', + materialized='incremental', + partition_by = ['block_date'], + unique_key = ['tx_hash'], + on_schema_change='sync_all_columns', + file_format ='delta', + incremental_strategy='merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], + post_hook='{{ expose_spells(blockchains = \'["base"]\', + spell_type = "project", + spell_name = "cow_protocol", + contributors = \'["felix"]\') }}' + ) +}} + +WITH +batch_counts as ( + select try_cast(date_trunc('day', s.evt_block_time) as date) as block_date, + s.evt_block_number, + s.evt_block_time, + s.evt_tx_hash, + solver, + name, + sum( + case + when selector != 0x2e1a7d4d -- unwrap + and selector != 0x095ea7b3 -- approval + then 1 + else 0 + end) as dex_swaps, + sum(case when selector = 0x2e1a7d4d then 1 else 0 end) as unwraps, + sum(case when selector = 0x095ea7b3 then 1 else 0 end) as token_approvals + from {{ source('gnosis_protocol_v2_base', 'GPv2Settlement_evt_Settlement') }} s + left outer join {{ source('gnosis_protocol_v2_base', 'GPv2Settlement_evt_Interaction') }} i + on i.evt_tx_hash = s.evt_tx_hash + {% if is_incremental() %} + AND {{ incremental_predicate('i.evt_block_time') }} + {% endif %} + join {{ ref('cow_protocol_base_solvers') }} + on solver = address + {% if is_incremental() %} + WHERE {{ incremental_predicate('s.evt_block_time') }} + {% endif %} + group by s.evt_block_number, s.evt_block_time, s.evt_tx_hash, solver, name +), + +batch_values as ( + select + tx_hash, + count(*) as num_trades, + sum(usd_value) as batch_value, + sum(fee_usd) as fee_value, + price as eth_price + from {{ source('cow_protocol_base', 'trades') }} + left outer join {{ source('prices', 'usd') }} as p + on p.contract_address = 0x4200000000000000000000000000000000000006 + {% if is_incremental() %} + and {{ incremental_predicate('minute') }} + {% endif %} + and p.minute = date_trunc('minute', block_time) + and blockchain = 'base' + {% if is_incremental() %} + WHERE {{ incremental_predicate('block_time') }} + {% endif %} + group by tx_hash, price +), + +combined_batch_info as ( + select + b.block_date, + evt_block_number as block_number, + evt_block_time as block_time, + num_trades, + dex_swaps, + batch_value, + solver as solver_address, + evt_tx_hash as tx_hash, + gas_price, + gas_used, + ((gas_price / pow(10, 9)) * gas_used * eth_price) / pow(10, 9) as tx_cost_usd, + fee_value, + 2 * bytearray_length(data) / 1024 as call_data_size, + unwraps, + token_approvals + from batch_counts b + join batch_values t + on b.evt_tx_hash = t.tx_hash + inner join {{ source('base', 'transactions') }} tx + on evt_tx_hash = hash + and evt_block_number = block_number + {% if is_incremental() %} + AND {{ incremental_predicate('block_time') }} + {% endif %} + where num_trades > 0 --! Exclude Withdraw Batches +) + +select * from combined_batch_info diff --git a/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/base/cow_protocol_base_schema.yml b/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/base/cow_protocol_base_schema.yml new file mode 100644 index 00000000000..ecc9d21b4f1 --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/base/cow_protocol_base_schema.yml @@ -0,0 +1,25 @@ +version: 2 + +models: + - name: cow_protocol_base_solvers + meta: + blockchain: base + project: cow_protocol + contributors: felix + config: + tags: ["base", "cow_protocol", "solver"] + description: > + CoW Protocol solvers list on Base Chain + + - name: cow_protocol_base_batches + meta: + blockchain: base + project: cow_protocol + contributors: felix + config: + tags: ["base", "cow_protocol", "trades", "dex", "aggregator", "auction"] + description: > + CoW Protocol enriched batches table on Base Chain + data_tests: + - unique: + column_name: tx_hash diff --git a/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/base/cow_protocol_base_solvers.sql b/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/base/cow_protocol_base_solvers.sql new file mode 100644 index 00000000000..a3eb28bc6f6 --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/base/cow_protocol_base_solvers.sql @@ -0,0 +1,68 @@ +{{ config( + schema = 'cow_protocol_base', + alias='solvers', + post_hook='{{ expose_spells(blockchains = \'["base"]\', + spell_type = "project", + spell_name = "cow_protocol", + contributors = \'["felix"]\') }}' +)}} + +WITH +-- Aggregate the solver added and removed events into a single table +-- with true/false for adds/removes respectively +solver_activation_events as ( + select solver, evt_block_number, evt_index, True as activated + from {{ source('gnosis_protocol_v2_base', 'GPv2AllowListAuthentication_evt_SolverAdded') }} + union + select solver, evt_block_number, evt_index, False as activated + from {{ source('gnosis_protocol_v2_base', 'GPv2AllowListAuthentication_evt_SolverRemoved') }} +), +-- Sorting by (evt_block_number, evt_index) allows us to pick the most recent activation status of each unique solver +ranked_solver_events as ( + select + rank() over (partition by solver order by evt_block_number desc, evt_index desc) as rk, + solver, + evt_block_number, + evt_index, + activated as active + from solver_activation_events +), +registered_solvers as ( + select solver, active + from ranked_solver_events + where rk = 1 +), +-- Manually inserting environment and name for each "known" solver +known_solver_metadata (address, environment, name) as ( + select * + from ( + VALUES + (0x8d98057b8c3d6c7cB02f1C1BE7E37D416F2D3e96, 'barn', 'Baseline'), + (0x351DfD19DfA0e3BfD3E7D9B22658C09e66Fd14AD, 'barn', 'Seasolver'), + (0xcE55eD17ddD7ED6E7eC396eaC772959A6D7252EA, 'barn', 'Naive'), + (0x8982b03D56de1F6f173d04A940B20A69F6A59239, 'barn', 'Gnosis_1inch'), + (0x5951400dE8fA58DA26Ab9402D2603ec0bD788273, 'barn', 'Gnosis_ParaSwap'), + (0x147d05987f3008A6C9Ec3E93A4ead430907ac3E1, 'barn', 'Gnosis_0x'), + (0x9451D27C993f7a61096BFC33e0241644a7566F66, 'barn', 'Gnosis_BalancerSOR'), + (0x0AC9287C83C2386A6a0bb27F847Ce59a0034183C, 'barn', 'Laita'), + (0x172FaCC5d970df43462b0f3aDe670d8cB86DC816, 'barn', 'ApeOut_1Inch'), + (0xBB765c920f86e2A2654c4B82deB5BC2E092fF93b, 'barn', 'Portus'), + (0x1a72876ebE781E42aB2Ee4278B539688D8B80E2D, 'prod', 'ApeOut_1Inch'), + (0x6bf97aFe2D2C790999cDEd2a8523009eB8a0823f, 'prod', 'Portus'), + (0x69d7F96dFD091652f317D0734A5F2B492ACcbE07, 'prod', 'Baseline'), + (0x4cb862E4821fea2dabBD1f0A69c17d52da2A58f6, 'prod', 'Seasolver'), + (0xF401ceF222F1CA2fE84a8C7BFC75A636A4542A74, 'prod', 'Naive'), + (0x8F7f754300B1ccfa37eA25fD48FB059af0F19e12, 'prod', 'Gnosis_1inch'), + (0xe321609c56aD89711EfB69c248ebe94922902F81, 'prod', 'Gnosis_ParaSwap'), + (0xbBcCE072fb1Bd2C096667E257322f47693D3dc96, 'prod', 'Gnosis_0x'), + (0x983aC485620E265730e367B2C7BCBf6Eb9d62A21, 'prod', 'Gnosis_BalancerSOR'), + (0x1A422923290fd16C2ED00ED16B4203cF4bb35d82, 'prod', 'Laita') + ) as _ +) +-- Combining the metadata with current activation status for final table +select solver as address, + case when environment is not null then environment else 'new' end as environment, + case when name is not null then name else 'Uncatalogued' end as name, + active +from registered_solvers +left outer join known_solver_metadata on solver = address diff --git a/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/cow_protocol_batches.sql b/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/cow_protocol_batches.sql index 5a13b752fa1..a45d21db499 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/cow_protocol_batches.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/cow_protocol_batches.sql @@ -73,4 +73,26 @@ FROM unwraps, token_approvals FROM {{ ref('cow_protocol_arbitrum_batches') }} + + UNION ALL + + SELECT + 'base' AS blockchain, + 'cow_protocol' AS project, + '1' AS version, + block_date, + block_time, + num_trades, + dex_swaps, + batch_value, + solver_address, + tx_hash, + gas_price, + gas_used, + tx_cost_usd, + fee_value, + call_data_size, + unwraps, + token_approvals + FROM {{ ref('cow_protocol_base_batches') }} ) diff --git a/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/ethereum/cow_protocol_ethereum_batches.sql b/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/ethereum/cow_protocol_ethereum_batches.sql index 743499aea18..5a37703d2ef 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/ethereum/cow_protocol_ethereum_batches.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/ethereum/cow_protocol_ethereum_batches.sql @@ -1,6 +1,6 @@ {{ config( + schema = 'cow_protocol_ethereum', alias = 'batches', - materialized='incremental', partition_by = ['block_date'], unique_key = ['tx_hash'], @@ -8,10 +8,10 @@ file_format ='delta', incremental_strategy='merge', incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], - post_hook='{{ expose_spells(\'["ethereum"]\', - "project", - "cow_protocol", - \'["bh2smith", "gentrexha"]\') }}' + post_hook='{{ expose_spells(blockchains = \'["ethereum"]\', + spell_type = "project", + spell_name = "cow_protocol", + contributors = \'["bh2smith", "gentrexha"]\') }}' ) }} @@ -39,7 +39,7 @@ batch_counts as ( {% if is_incremental() %} AND {{ incremental_predicate('i.evt_block_time') }} {% endif %} - join cow_protocol_ethereum.solvers + join {{ ref('cow_protocol_ethereum_solvers') }} on solver = address {% if is_incremental() %} WHERE {{ incremental_predicate('s.evt_block_time') }} @@ -90,6 +90,7 @@ combined_batch_info as ( on b.evt_tx_hash = t.tx_hash inner join {{ source('ethereum', 'transactions') }} tx on evt_tx_hash = hash + and evt_block_number = block_number {% if is_incremental() %} AND {{ incremental_predicate('block_time') }} {% endif %} diff --git a/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/ethereum/cow_protocol_ethereum_solvers.sql b/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/ethereum/cow_protocol_ethereum_solvers.sql index a97515ed8be..5f9bc304b90 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/ethereum/cow_protocol_ethereum_solvers.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/ethereum/cow_protocol_ethereum_solvers.sql @@ -1,10 +1,10 @@ {{ config( + schema = 'cow_protocol_ethereum', alias='solvers', - - post_hook='{{ expose_spells(\'["ethereum"]\', - "project", - "cow_protocol", - \'["bh2smith", "gentrexha"]\') }}' + post_hook='{{ expose_spells(blockchains = \'["ethereum"]\', + spell_type = "project", + spell_name = "cow_protocol", + contributors = \'["bh2smith", "gentrexha"]\') }}' )}} -- Find the PoC Query here: https://dune.com/queries/1276806 @@ -105,7 +105,7 @@ known_solver_metadata (address, environment, name) as ( (0xD1508A211D98bb81195dC1F9533eDcdf68aDF036, 'prod', 'Furucombo'), (0x8646Ee3c5e82b495Be8F9FE2f2f213701EeD0edc, 'prod', 'Seasolver_v2'), (0x9528e8c42F7e109bADED964E2D927fD5B6ca71E9, 'prod', 'Odos'), - (0x755BaE1cd46C9C27A3230AeF0CE923BDa13d29F7, 'prod', 'FractalSolver'), + (0x755BaE1cd46C9C27A3230AeF0CE923BDa13d29F7, 'prod', 'Fractal'), (0x8F70A86c1309d8B1F5BefC58948e7386Fd495875, 'prod', 'Tsolver'), (0xbAda55BaBEE5D2B7F3B551f9da846838760E068C, 'prod', 'Project_Blanc'), (0xA883710b6DBf008a1CC25722C54583E35884a209, 'prod', 'Horadrim'), @@ -116,6 +116,18 @@ known_solver_metadata (address, environment, name) as ( (0x2224eAaCC7c2DBf85d5355BAb9E9271e01d30b55, 'prod', 'Sector_Finance'), (0x9DFc9Bb0FfF2dc96728D2bb94eaCee6ba3592351, 'prod', 'Rizzolver'), (0x6bf97aFe2D2C790999cDEd2a8523009eB8a0823f, 'prod', 'Portus'), + (0x95480d3f27658e73b2785d30beb0c847d78294c7, 'prod', 'Fractal'), + (0x00806DaA2Cfe49715eA05243FF259DeB195760fC, 'prod', 'Quasilabs'), + (0x28B1bd44996105b5c14c4dE41093226Ff78A4eB1, 'prod', '0x'), + (0x04B89dBce06e7Aa2F4BBA78969ADD4576eB94788, 'prod', 'ApeOut_1Inch'), + (0xbada5552a3e5e2fb57db982e29257821a2cf192d, 'prod', 'Project_Blanc'), + (0x34717040928D7fd8154d4612f3228EFf14521023, 'prod', 'Laita'), + (0xBab555BaBEe5d867983902bC8db8F707157245Be, 'barn', 'Project_Blanc'), + (0x854490ef1d402D4f6fce05aBefE1C676eB0DCD74, 'barn', 'ApeOut_1Inch'), + (0xBB765c920f86e2A2654c4B82deB5BC2E092fF93b, 'barn', 'Portus'), + (0xcC73072B53697911Ff394ae01D3de59c9900b0b0, 'barn', '0x'), + (0xd0bA1b1782fbdE45edAb392428f60e14827D08EC, 'barn', 'Laita'), + (0x7E2eF26AdccB02e57258784957922AEEFEe807e5, 'barn', 'Quasilabs'), (0x5131590ca2E9D3edC182581352b289dcaE83430c, 'barn', 'Portus'), (0x2a2883ade8ce179265f12fc7b48a4b50b092f1fd, 'barn', 'Fractal'), (0x26B5e3bF135D3Dd05A220508dD61f25BF1A47cBD, 'barn', 'Rizzolver'), @@ -124,7 +136,7 @@ known_solver_metadata (address, environment, name) as ( (0x2c3A1c33d96C9DcA1c34EB234B1e65F79dEaE60e, 'barn', 'Horadrim'), (0xa5559C2E1302c5Ce82582A6b1E4Aec562C2FbCf4, 'barn', 'Project_Blanc'), (0xa432cea087311d7cd07925d70f799eE94E7893a4, 'barn', 'Tsolver'), - (0xAb11302CB4f7C417e527A4d39C22Aa9f04EdB07D, 'barn', 'FractalSolver'), + (0xAb11302CB4f7C417e527A4d39C22Aa9f04EdB07D, 'barn', 'Fractal'), (0xf13eaf9093a210EBdaBa581f5448ffA545EE2E65, 'barn', 'Odos'), (0x94aEF67903bFe8Bf65193A78074C887ba901d043, 'barn', 'Seasolver_v2'), (0x279fb872beaF64E94890376725C423c0820eDA97, 'barn', 'Furucombo'), diff --git a/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/gnosis/cow_protocol_gnosis_batches.sql b/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/gnosis/cow_protocol_gnosis_batches.sql index 4654c7053ab..354ef3d9446 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/gnosis/cow_protocol_gnosis_batches.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/gnosis/cow_protocol_gnosis_batches.sql @@ -19,6 +19,7 @@ WITH -- Find the PoC Query here: https://dune.com/queries/1722419 batch_counts as ( select try_cast(date_trunc('day', s.evt_block_time) as date) as block_date, + s.evt_block_number, s.evt_block_time, s.evt_tx_hash, solver, @@ -38,12 +39,12 @@ batch_counts as ( {% if is_incremental() %} AND {{ incremental_predicate('i.evt_block_time') }} {% endif %} - join cow_protocol_gnosis.solvers + join {{ ref('cow_protocol_gnosis_solvers') }} on solver = address {% if is_incremental() %} WHERE {{ incremental_predicate('s.evt_block_time') }} {% endif %} - group by s.evt_tx_hash, solver, s.evt_block_time, name + group by s.evt_block_number, s.evt_tx_hash, solver, s.evt_block_time, name ), batch_values as ( @@ -70,6 +71,7 @@ batch_values as ( combined_batch_info as ( select b.block_date, + evt_block_number as block_number, evt_block_time as block_time, num_trades, dex_swaps, @@ -88,6 +90,7 @@ combined_batch_info as ( on b.evt_tx_hash = t.tx_hash inner join {{ source('gnosis', 'transactions') }} tx on evt_tx_hash = hash + and evt_block_number = block_number {% if is_incremental() %} AND {{ incremental_predicate('tx.block_time') }} {% endif %} diff --git a/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/gnosis/cow_protocol_gnosis_solvers.sql b/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/gnosis/cow_protocol_gnosis_solvers.sql index ca24dd452be..a68d5d4acd3 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/gnosis/cow_protocol_gnosis_solvers.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/gnosis/cow_protocol_gnosis_solvers.sql @@ -42,7 +42,7 @@ known_solver_metadata (address, environment, name) as ( (0x508bCC23C1a808A9c41D10E2FCB544Ffb76ae3E5, 'barn', 'MIP'), (0x7942a2b3540d1eC40B2740896f87aEcB2a588731, 'barn', 'Quasimodo'), (0x26029B63C7DBD0C4C04D7226C3e7de5EAb3DB3D8, 'barn', 'Gnosis_1inch'), - (0x52ac5B5e85De9aa72ef5925989Fc419AA04EB15b, 'barn', 'SeaSolver'), + (0x52ac5B5e85De9aa72ef5925989Fc419AA04EB15b, 'barn', 'Seasolver'), (0xf794f31976a9a1d866cadfecde8984e656395a70, 'barn', 'Quasilabs'), (0x449944c987d622cd8db9c150fd4ecdfe4435b836, 'barn', 'Naive'), (0x9aaceb30c5b0e676a6b20d0c6be68f58bc7d8659, 'barn', 'Baseline'), @@ -60,16 +60,18 @@ known_solver_metadata (address, environment, name) as ( (0xC088aea818dE69CeC696054682098ABa804b4FC9, 'barn', 'Gnosis_1inch'), (0x4930a9012e8677ae764e44f2b46af8087a1f9f8e, 'barn', 'Gnosis_BalancerSOR'), (0x8e600b399Da9c46255ccac98764987cF81837a66, 'barn', 'Enso'), - (0xC8D2f12a9505a82C4f6994204f4BbF095183E63A, 'barn', 'SeaSolver'), - (0x67be9614C4E0FCdA95AFC66a95B5BDAFb55fa362, 'barn', 'Furucombo'), - (0x53F5378A6f8bb24333aD8D68FD28816504a467b2, 'barn', 'CopiumCapital'), + (0xC8D2f12a9505a82C4f6994204f4BbF095183E63A, 'barn', 'Seasolver'), + (0x67be9614C4E0FCdA95AFC66a95B5BDAFb55fa362, 'barn', 'Portus'), + (0x53F5378A6f8bb24333aD8D68FD28816504a467b2, 'barn', 'Copium_Capital'), (0xC4dd6355Fbc6Eb108FD1C100389789C5B1A9A980, 'barn', 'Barter'), - (0x4398129426Cb1377E9E10395b8dfBDa153c7Fe7D, 'barn', 'FractalSolver'), - (0x727EB77c6f84ef148403f641aA32d75b7f6902A7, 'prod', 'FractalSolver'), + (0x4398129426Cb1377E9E10395b8dfBDa153c7Fe7D, 'barn', 'Fractal'), + (0xBB765c920f86e2A2654c4B82deB5BC2E092fF93b, 'barn', 'Portus'), + (0x6bf97aFe2D2C790999cDEd2a8523009eB8a0823f, 'prod', 'Portus'), + (0x727EB77c6f84ef148403f641aA32d75b7f6902A7, 'prod', 'Fractal'), (0x0a360134553feED49FE5eb273074d80B6e45941F, 'prod', 'Barter'), - (0xb4694FE6590acd1281Dc34a966bbAE224559BaD4, 'prod', 'CopiumCapital'), - (0x227FDA1D5970dF605D785Bf5F2F8899d5fdF8624, 'prod', 'Furucombo'), - (0xE3068acB5b5672408eADaD4417e7d3BA41D4FEBe, 'prod', 'SeaSolver'), + (0xb4694FE6590acd1281Dc34a966bbAE224559BaD4, 'prod', 'Copium_Capital'), + (0x227FDA1D5970dF605D785Bf5F2F8899d5fdF8624, 'prod', 'Portus'), + (0xE3068acB5b5672408eADaD4417e7d3BA41D4FEBe, 'prod', 'Seasolver'), (0x12c53cdD1ef150E1cd291DD210b761acFADA6B9C, 'prod', 'Enso'), (0xf671d28fef15e5eafc21898c2814b1b4cd88bc9a, 'prod', 'Gnosis_BalancerSOR'), (0x056545021B39790eFb0a074827e7FddCb751A179, 'prod', 'Gnosis_1inch'), @@ -86,7 +88,7 @@ known_solver_metadata (address, environment, name) as ( (0x5D665472e2026C405aAc65cC652470a1B8FCff08, 'prod', 'Baseline'), (0xe71D3324E17E99B56c294067370D45111bc968D6, 'prod', 'Quasimodo'), (0xa7c4C18106e92Cea479627D02FAb583D987f17d9, 'prod', 'Gnosis_1inch'), - (0xfaBBDf8a77005C00edBe0000bDC000644c024322, 'prod', 'CopiumCapital'), + (0xfaBBDf8a77005C00edBe0000bDC000644c024322, 'prod', 'Copium_Capital'), (0x68dEE65bB88d919463495E5CeA9870a81f1e9413, 'service', 'Withdraw'), (0xa03be496e67ec29bc62f01a428683d7f9c204930, 'service', 'Withdraw'), (0x7524942F9283FBFa8F17b05CC0a9cBde397d25b3, 'test', 'Test 1') diff --git a/dbt_subprojects/hourly_spellbook/models/_project/lido/accounting/ethereum/lido_accounting_ethereum_other_expenses.sql b/dbt_subprojects/hourly_spellbook/models/_project/lido/accounting/ethereum/lido_accounting_ethereum_other_expenses.sql index 0a2f233dc5d..288a999e1c1 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/lido/accounting/ethereum/lido_accounting_ethereum_other_expenses.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/lido/accounting/ethereum/lido_accounting_ethereum_other_expenses.sql @@ -18,13 +18,13 @@ with tokens AS ( select * from (values (0x5A98FcBEA516Cf06857215779Fd812CA3beF1B32), --LDO - (0x6B175474E89094C44Da98b954EedeAC495271d0F), --DAI - (0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48), --USDC + (0x6B175474E89094C44Da98b954EedeAC495271d0F), --DAI + (0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48), --USDC (0xdAC17F958D2ee523a2206206994597C13D831ec7), -- USDT - (0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2), --WETH - (0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0), --MATIC - (0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84), --stETH - (0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0) --wstETH + (0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2), --WETH + (0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0), --MATIC + (0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84), --stETH + (0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0) --wstETH ) as tokens(address)), @@ -99,7 +99,7 @@ dai_referral_payments_addr AS ( steth_referral_payments_addr AS ( SELECT _recipient AS address FROM {{source('lido_ethereum','AllowedRecipientsRegistry_RevShare_evt_RecipientAdded')}} ), -/* + stonks as ( select * from (values ('STETH→DAI', 0x3e2D251275A92a8169A3B17A2C49016e2de492a7), @@ -114,24 +114,7 @@ stonks as ( ) as list(namespace, address) ), -cow_settlement as ( - select * from (values - (0x9008D19f58AAbD9eD0D60971565AA8510560ab41) - ) as list(address) -), -stonks_orders_txns as ( - select evt_tx_hash - from {{source('lido_ethereum', 'steth_evt_Transfer')}} - where "from" in ( - select cast(replace(topic1, 0x000000000000000000000000, 0x) as varbinary) as order_addr - from {{source('ethereum', 'logs')}} l - join stonks s on l.contract_address = s.address - and l.topic0 = 0x96a6d5477fba36522dca4102be8b3785435baf902ef6c4edebcb99850630c75f -- Stonks Deployed - ) - and to in (select address from cow_settlement) -), -*/ other_expenses_txns AS ( SELECT evt_block_time, @@ -160,8 +143,10 @@ other_expenses_txns AS ( SELECT 0x0000000000000000000000000000000000000000 UNION ALL SELECT address FROM diversifications_addresses + UNION ALL + SELECT address FROM stonks ) - -- AND evt_tx_hash NOT IN (select evt_tx_hash from stonks_orders_txns) + UNION ALL --ETH outflow SELECT @@ -199,4 +184,3 @@ other_expenses_txns AS ( FROM other_expenses_txns WHERE contract_address IN (SELECT address FROM tokens) and value != 0 - diff --git a/dbt_subprojects/hourly_spellbook/models/_project/lido/accounting/ethereum/lido_accounting_ethereum_other_income.sql b/dbt_subprojects/hourly_spellbook/models/_project/lido/accounting/ethereum/lido_accounting_ethereum_other_income.sql index 4ab559548b4..255876b67f4 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/lido/accounting/ethereum/lido_accounting_ethereum_other_income.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/lido/accounting/ethereum/lido_accounting_ethereum_other_income.sql @@ -16,13 +16,13 @@ with tokens AS ( select * from (values (0x5A98FcBEA516Cf06857215779Fd812CA3beF1B32), --LDO - (0x6B175474E89094C44Da98b954EedeAC495271d0F), --DAI - (0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48), --USDC + (0x6B175474E89094C44Da98b954EedeAC495271d0F), --DAI + (0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48), --USDC (0xdAC17F958D2ee523a2206206994597C13D831ec7), -- USDT - (0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2), --WETH - (0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0), --MATIC - (0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84), --stETH - (0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0) --wstETH + (0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2), --WETH + (0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0), --MATIC + (0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84), --stETH + (0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0) --wstETH ) as tokens(address)), @@ -91,15 +91,6 @@ select * from (values dai_referral_payments_addr AS ( SELECT _recipient AS address FROM {{source('lido_ethereum','AllowedRecipientsRegistry_evt_RecipientAdded')}} - WHERE - ( - NOT EXISTS (SELECT _recipient FROM {{source('lido_ethereum','AllowedRecipientsRegistry_evt_RecipientRemoved')}}) - OR ( - EXISTS (SELECT _recipient FROM {{source('lido_ethereum','AllowedRecipientsRegistry_evt_RecipientRemoved')}}) - AND - _recipient NOT IN (SELECT _recipient FROM {{source('lido_ethereum','AllowedRecipientsRegistry_evt_RecipientRemoved')}}) - ) - ) UNION ALL SELECT 0xaf8aE6955d07776aB690e565Ba6Fbc79B8dE3a5d --rhino ), @@ -107,7 +98,7 @@ dai_referral_payments_addr AS ( steth_referral_payments_addr AS ( SELECT _recipient AS address FROM {{source('lido_ethereum','AllowedRecipientsRegistry_RevShare_evt_RecipientAdded')}} ), -/* + stonks as ( select * from (values ('STETH→DAI', 0x3e2D251275A92a8169A3B17A2C49016e2de492a7), @@ -139,7 +130,7 @@ stonks_orders_txns as ( ) and to in (select address from cow_settlement) ), -*/ + other_income_txns AS ( SELECT evt_block_time, @@ -167,7 +158,7 @@ other_income_txns AS ( UNION ALL SELECT address FROM diversifications_addresses ) - -- AND evt_tx_hash NOT IN (select evt_tx_hash from stonks_orders_txns) + AND evt_tx_hash NOT IN (select evt_tx_hash from stonks_orders_txns) UNION ALL --ETH staked by DAO @@ -251,3 +242,4 @@ SELECT * from ( from_base64(evt_tx_hash) FROM stsol_income ) WHERE amount_token != 0 + diff --git a/dbt_subprojects/hourly_spellbook/models/_project/lido/accounting/ethereum/lido_accounting_ethereum_revenue.sql b/dbt_subprojects/hourly_spellbook/models/_project/lido/accounting/ethereum/lido_accounting_ethereum_revenue.sql index 9847c63cf48..eab910a900a 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/lido/accounting/ethereum/lido_accounting_ethereum_revenue.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/lido/accounting/ethereum/lido_accounting_ethereum_revenue.sql @@ -20,6 +20,7 @@ select * from (values (0x3e40d73eb977dc6a537af587d48316fee66e9c8c, 'Aragon'), (0x55032650b14df07b85bF18A3a3eC8E0Af2e028d5, 'NO (Curated)'), (0xaE7B191A31f627b4eB1d4DaC64eaB9976995b433, 'NO (DVT)'), +(0xdA7dE2ECdDfccC6c3AF10108Db212ACBBf9EA83F, 'NO (CSM)'), (0x8B3f33234ABD88493c0Cd28De33D583B70beDe35, 'InsuranceFund') ) as list(address, name) ), @@ -77,9 +78,9 @@ protocol_fee_distribution AS ( 0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84 AS token, lido_rewards AS total, protocol_fee.points AS protocol_fee, - protocol_fee_distribution.insurance_points AS insurance_fee, - protocol_fee_distribution.operators_points AS operators_fee, - protocol_fee_distribution.treasury_points AS treasury_fee, + --protocol_fee_distribution.insurance_points AS insurance_fee, + --protocol_fee_distribution.operators_points AS operators_fee, + --protocol_fee_distribution.treasury_points AS treasury_fee, (1 - protocol_fee.points)*lido_rewards AS depositors_revenue, protocol_fee.points*protocol_fee_distribution.treasury_points*lido_rewards AS treasury_revenue, protocol_fee.points*protocol_fee_distribution.insurance_points*lido_rewards AS insurance_revenue, @@ -96,9 +97,6 @@ protocol_fee_distribution AS ( 0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84 AS token, oracle_txns.treasury_revenue + oracle_txns.operators_revenue + oracle_txns.insurance_revenue AS total, protocol_fee.points AS protocol_fee, - protocol_fee_distribution.insurance_points AS insurance_fee, - protocol_fee_distribution.operators_points AS operators_fee, - protocol_fee_distribution.treasury_points AS treasury_fee, 10*(1 - protocol_fee.points)*(oracle_txns.treasury_revenue + oracle_txns.operators_revenue + oracle_txns.insurance_revenue) AS depositors_revenue, oracle_txns.treasury_revenue AS treasury_revenue, oracle_txns.insurance_revenue AS insurance_revenue, diff --git a/dbt_subprojects/hourly_spellbook/models/_project/safe/arbitrum/safe_arbitrum_schema.yml b/dbt_subprojects/hourly_spellbook/models/_project/safe/arbitrum/safe_arbitrum_schema.yml index bdda09eab40..269628b66e5 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/safe/arbitrum/safe_arbitrum_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_project/safe/arbitrum/safe_arbitrum_schema.yml @@ -149,49 +149,3 @@ models: - &amount_usd name: amount_usd description: "USD amount of transferred ETH" - - - name: safe_arbitrum_balances - data_tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - day - - address - - token_address - meta: - blockchain: arbitrum - project: safe - contributors: safeintern - config: - tags: ['safe', 'arbitrum'] - description: “Safe addresses balances” - columns: - - name: day - - name: blockchain - - name: address - - &token_symbol - name: token_symbol - description: "Symbol for the token" - - &token_address - name: token_address - description: "Address for the token" - - &token_standard - name: token_standard - description: "Standard for the token" - - &token_id - name: token_id - description: "ID for the token" - - &balance - name: balance - description: "Balance for the user" - - &balance_usd - name: balance_usd - description: "USD value of balance for the user" - - &last_updated - name: last_updated - description: "UTC timestamp when data was last updated" - - &next_update - name: next_update - description: "UTC timestamp when data is next updated" - - &unique_key_id - name: unique_key_id - description: " unique key" diff --git a/dbt_subprojects/hourly_spellbook/models/_project/safe/avalanche_c/safe_avalanche_c_schema.yml b/dbt_subprojects/hourly_spellbook/models/_project/safe/avalanche_c/safe_avalanche_c_schema.yml index c446cffc6c0..9cbdd4f86d7 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/safe/avalanche_c/safe_avalanche_c_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_project/safe/avalanche_c/safe_avalanche_c_schema.yml @@ -80,7 +80,7 @@ models: name: value description: "Value of transaction" - &gas - name: gas + name: gas description: "Gas limit set for transaction" - &execution_gas_used name: execution_gas_used @@ -148,4 +148,4 @@ models: - *trace_address - &amount_usd name: amount_usd - description: "USD amount of transferred AVAX" \ No newline at end of file + description: "USD amount of transferred AVAX" diff --git a/dbt_subprojects/hourly_spellbook/models/_project/safe/ethereum/_schema.yml b/dbt_subprojects/hourly_spellbook/models/_project/safe/ethereum/_schema.yml index 501fd6d00ac..ea8bb76b964 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/safe/ethereum/_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_project/safe/ethereum/_schema.yml @@ -154,51 +154,3 @@ models: - &threshold name: threshold description: "Number of signer threshold" - - - name: safe_ethereum_balances - data_tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - day - - blockchain - - address - - token_address - - meta: - blockchain: ethereum - project: safe - contributors: safeintern - config: - tags: ['safe', 'ethereum'] - description: “Safe addresses balances” - columns: - - name: day - - name: blockchain - - name: address - - &token_symbol - name: token_symbol - description: "Symbol for the token" - - &token_address - name: token_address - description: "Address for the token" - - &token_standard - name: token_standard - description: "Standard for the token" - - &token_id - name: token_id - description: "ID for the token" - - &balance - name: balance - description: "Balance for the user" - - &balance_usd - name: balance_usd - description: "USD value of balance for the user" - - &last_updated - name: last_updated - description: "UTC timestamp when data was last updated" - - &next_update - name: next_update - description: "UTC timestamp when data is next updated" - - &unique_key_id - name: unique_key_id - description: " unique key" diff --git a/dbt_subprojects/hourly_spellbook/models/_project/safe/linea/safe_linea_safes.sql b/dbt_subprojects/hourly_spellbook/models/_project/safe/linea/safe_linea_safes.sql index ff805dcb211..e60f2d7ac53 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/safe/linea/safe_linea_safes.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/safe/linea/safe_linea_safes.sql @@ -16,7 +16,7 @@ ) }} -{% set project_start_date = '2024-02-24' %} +{% set project_start_date = '2023-07-01' %} select 'linea' as blockchain, diff --git a/dbt_subprojects/hourly_spellbook/models/_project/safe/linea/safe_linea_schema.yml b/dbt_subprojects/hourly_spellbook/models/_project/safe/linea/safe_linea_schema.yml index a08fbe09642..28ec16f2da1 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/safe/linea/safe_linea_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_project/safe/linea/safe_linea_schema.yml @@ -147,3 +147,4 @@ models: - &output name: output description: "Output data" + diff --git a/dbt_subprojects/hourly_spellbook/models/_project/safe/optimism/safe_optimism_schema.yml b/dbt_subprojects/hourly_spellbook/models/_project/safe/optimism/safe_optimism_schema.yml index f7ea3fc9a8e..ab2bcca3a16 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/safe/optimism/safe_optimism_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_project/safe/optimism/safe_optimism_schema.yml @@ -149,48 +149,3 @@ models: - &amount_usd name: amount_usd description: "USD amount of transferred ETH" - - - name: safe_optimism_balances - data_tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - day - - blockchain - - address - - token_address - meta: - blockchain: optimism - project: safe - contributors: safeintern - config: - tags: ['safe', 'optimism'] - description: “Safe addresses balances” - columns: - - name: day - - name: blockchain - - name: address - - &token_symbol - name: token_symbol - description: "Symbol for the token" - - &token_address - name: token_address - description: "Address for the token" - - &token_standard - name: token_standard - description: "Standard for the token" - - &token_id - name: token_id - description: "ID for the token" - - &balance - name: balance - description: "Balance for the user" - - &balance_usd - name: balance_usd - description: "USD value of balance for the user" - - &last_updated - name: last_updated - description: "UTC timestamp when data was last updated" - - &next_update - name: next_update - description: "UTC timestamp when data is next updated" - diff --git a/dbt_subprojects/hourly_spellbook/models/_project/safe/polygon/safe_polygon_schema.yml b/dbt_subprojects/hourly_spellbook/models/_project/safe/polygon/safe_polygon_schema.yml index c65d6199675..2d30451c537 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/safe/polygon/safe_polygon_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_project/safe/polygon/safe_polygon_schema.yml @@ -119,7 +119,7 @@ models: name: value description: "Value of transaction" - &gas - name: gas + name: gas description: "Gas limit set for transaction" - &execution_gas_used name: execution_gas_used @@ -151,50 +151,3 @@ models: - &output name: output description: "Output data" - - - name: safe_polygon_balances - data_tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - day - - blockchain - - address - - token_address - meta: - blockchain: polygon - project: safe - contributors: safeintern - config: - tags: ['safe', 'polygon'] - description: “Safe addresses balances” - columns: - - name: day - - name: blockchain - - name: address - - &token_symbol - name: token_symbol - description: "Symbol for the token" - - &token_address - name: token_address - description: "Address for the token" - - &token_standard - name: token_standard - description: "Standard for the token" - - &token_id - name: token_id - description: "ID for the token" - - &balance - name: balance - description: "Balance for the user" - - &balance_usd - name: balance_usd - description: "USD value of balance for the user" - - &last_updated - name: last_updated - description: "UTC timestamp when data was last updated" - - &next_update - name: next_update - description: "UTC timestamp when data is next updated" - - &unique_key_id - name: unique_key_id - description: " unique key" diff --git a/dbt_subprojects/hourly_spellbook/models/_project/safe/ronin/safe_ronin_safes.sql b/dbt_subprojects/hourly_spellbook/models/_project/safe/ronin/safe_ronin_safes.sql index ac8b5622cdf..1e16b748588 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/safe/ronin/safe_ronin_safes.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/safe/ronin/safe_ronin_safes.sql @@ -16,7 +16,7 @@ ) }} -{% set project_start_date = '2024-06-30' %} +{% set project_start_date = '2021-01-01' %} select 'ronin' as blockchain, diff --git a/dbt_subprojects/hourly_spellbook/models/_project/safe/scroll/safe_scroll_schema.yml b/dbt_subprojects/hourly_spellbook/models/_project/safe/scroll/safe_scroll_schema.yml index e5c5aec30ca..f33f34b7dc2 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/safe/scroll/safe_scroll_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_project/safe/scroll/safe_scroll_schema.yml @@ -158,4 +158,4 @@ models: description: "Output data" - &method name: method - description: "Function method" \ No newline at end of file + description: "Function method" diff --git a/dbt_subprojects/hourly_spellbook/models/_sector/blobs/ethereum/blobs_based_submitters.sql b/dbt_subprojects/hourly_spellbook/models/_sector/blobs/ethereum/blobs_based_submitters.sql index c9f31f4afab..ee1d13174de 100644 --- a/dbt_subprojects/hourly_spellbook/models/_sector/blobs/ethereum/blobs_based_submitters.sql +++ b/dbt_subprojects/hourly_spellbook/models/_sector/blobs/ethereum/blobs_based_submitters.sql @@ -3,4 +3,11 @@ alias = 'based_submitters' )}} -SELECT evt_tx_hash AS tx_hash, evt_block_number AS block_number, 'Taiko' AS entity FROM {{ source('taikoxyz_ethereum', 'TaikoL1_evt_BlockProposed')}} \ No newline at end of file +SELECT DISTINCT tx_hash, block_number, entity +FROM ( + SELECT evt_tx_hash AS tx_hash, evt_block_number AS block_number, 'Taiko' AS entity FROM {{ source('taikoxyz_ethereum', 'TaikoL1_evt_BlockProposed')}} + + UNION ALL + + SELECT evt_tx_hash AS tx_hash, evt_block_number AS block_number, 'Taiko' AS entity FROM {{ source('taikoxyz_ethereum', 'TaikoL1_evt_BlockProposedV2')}} + ) \ No newline at end of file diff --git a/dbt_subprojects/hourly_spellbook/models/_sector/blobs/ethereum/blobs_submitters.sql b/dbt_subprojects/hourly_spellbook/models/_sector/blobs/ethereum/blobs_submitters.sql index 1a97acf2768..4542d4d8391 100644 --- a/dbt_subprojects/hourly_spellbook/models/_sector/blobs/ethereum/blobs_submitters.sql +++ b/dbt_subprojects/hourly_spellbook/models/_sector/blobs/ethereum/blobs_submitters.sql @@ -57,6 +57,7 @@ SELECT address , (0x8cda8351236199af7532bad53d683ddd9b275d89, 'RACE', 'RACEecosystem') , (0x7f9d9c1bce1062e1077845ea39a0303429600a06, 'Binary', 'thebinaryhldgs') , (0x4d875acfd836eb3d8a2f25ba03de16c97ec9fc0f, 'PandaSea', 'pandaseaweb3') + , (0xf4559766b24402f0fff8fc5a6835d5f6e837aed3, 'PandaSea', 'pandaseaweb3') , (0xf7ca543d652e38692fd12f989eb55b5327ec9a20, 'Shape', 'Shape_L2') , (0xde794bec196832474f2f218135bfd0f7ca7fb038, 'Swan Chain', 'swan_chain') , (0x67a44ce38627f46f20b1293960559ed85dd194f1, 'Polynomial', 'PolynomialFi') @@ -76,4 +77,5 @@ SELECT address , (0xb6cf39ee72e0127e6ea6059e38b8c197227a6ac7, 'Morph', 'MorphL2') , (0x2986bf308d0684ad77cd32ee1c60429e6573b5af, 'R0AR Chain', 'th3r0ar') , (0x2f60a5184c63ca94f82a27100643dbabe4f3f7fd, 'Unichain', 'unichain') + , (0xf854cd5b26bfd73d51236c0122798907ed65b1f2, 'Swell', 'swellnetworkio') ) AS x(address, entity, x_username) \ No newline at end of file diff --git a/dbt_subprojects/hourly_spellbook/models/_sector/cex/addresses/chains/cex_evms_addresses.sql b/dbt_subprojects/hourly_spellbook/models/_sector/cex/addresses/chains/cex_evms_addresses.sql index dacb8ab17e9..18acb039b82 100644 --- a/dbt_subprojects/hourly_spellbook/models/_sector/cex/addresses/chains/cex_evms_addresses.sql +++ b/dbt_subprojects/hourly_spellbook/models/_sector/cex/addresses/chains/cex_evms_addresses.sql @@ -5,7 +5,7 @@ post_hook='{{ expose_spells(\'["ethereum", "arbitrum", "avalanche_c", "bnb", "fantom", "optimism", "polygon", "zksync", "zora", "celo", "base"]\', "sector", "cex", - \'["hildobby", "soispoke", "web3_data", "msilb7", "Henrystats", "sankinyue"]\') }}')}} + \'["hildobby", "soispoke", "web3_data", "msilb7", "Henrystats", "sankinyue", "synthquest"]\') }}')}} SELECT address, cex_name, distinct_name, added_by, added_date FROM (VALUES @@ -150,6 +150,7 @@ FROM (VALUES , (0x4230c402c08cb66dcf3820649a115e54661fce9d, 'Bybit', 'Bybit 8', 'hildobby', date '2023-11-15') , (0x3d5202a0564de9b05ecd07c955bcca964585ea03, 'Bybit', 'Bybit 9', 'hildobby', date '2024-05-09') , (0x1e32760a3285550278aeafa776e5641bc581c845, 'Bybit', 'Bybit 10', 'hildobby', date '2024-10-06') + , (0x88a1493366d48225fc3cefbdae9ebb23e323ade3, 'Bybit', 'Bybit 11', 'synthquest', date '2024-11-27') , (0xab97925eb84fe0260779f58b7cb08d77dcb1ee2b, 'Bybit', 'Bybit Gas Supplier 1', 'hildobby', date '2023-11-15') , (0xa95b83af96d0b8a90bd507f2bd82ad8f3dbb86bc, 'Bybit', 'Bybit Gas Supplier 2', 'hildobby', date '2023-11-20') , (0xf65d698d18bc37bf36e4c8d4fe4f051ef570e2b6, 'Bybit', 'Bybit Gas Supplier 3', 'hildobby', date '2023-11-23') @@ -260,6 +261,30 @@ FROM (VALUES , (0x3dd87411a3754deea8cc52c4cf57e2fc254924cc, 'Coinbase', 'Coinbase 56', 'hildobby', date '2024-05-04') , (0x441cacfd43856409b163b90e094bb42aeb70a70e, 'Coinbase', 'Coinbase 57', 'hildobby', date '2024-05-25') , (0xa14d57f5ea867572b0d239798d2c1dde13153902, 'Coinbase', 'Coinbase 58', 'hildobby', date '2024-05-25') + , (0x9ebe8ae7dbc0285b04e93dab86a081ca32ccf52e, 'Coinbase', 'Coinbase 59', 'synthquest', date '2024-11-27') + , (0x3dc474a2a65507f32b05c5f80d852515b25b2134, 'Coinbase', 'Coinbase 60', 'synthquest', date '2024-11-27') + , (0xcf63fc571adcec4fd4a750ecacc3af1f5b748101, 'Coinbase', 'Coinbase 61', 'synthquest', date '2024-11-27') + , (0x00aac037c2ca137972f963693d38a57d0e9f7475, 'Coinbase', 'Coinbase 62', 'synthquest', date '2024-11-27') + , (0x60eb0250e3a428a51ccb1e44e0aadbd1fd213ff3, 'Coinbase', 'Coinbase 63', 'synthquest', date '2024-11-27') + , (0x336307f2d8390035ba926a61a86b45ca9dc91e57, 'Coinbase', 'Coinbase 64', 'synthquest', date '2024-11-27') + , (0x57a7560d0ec28065762203c0d633943298eac7c0, 'Coinbase', 'Coinbase 65', 'synthquest', date '2024-11-27') + , (0x0b0a5886664376f59c351ba3f598c8a8b4d0a6f3, 'Coinbase', 'Coinbase 66', 'synthquest', date '2024-11-27') + , (0xee81b5afc73cf528778e0ed98622e434e5efadb4, 'Coinbase', 'Coinbase 67', 'synthquest', date '2024-11-27') + , (0x9b4fc9e22b46487f0810ef5dfa230b9f139e5179, 'Coinbase', 'Coinbase 68', 'synthquest', date '2024-11-27') + , (0x95f90ce2e3abaed29eeebdb42e1fdb146e0f848a, 'Coinbase', 'Coinbase 69', 'synthquest', date '2024-11-27') + , (0x122fdd9fecbc82f7d4237c0549a5057e31c8ef8d, 'Coinbase', 'Coinbase 70', 'synthquest', date '2024-11-27') + , (0x8196f70b2c17ba58d8ef56ad62087ee8231be33a, 'Coinbase', 'Coinbase 71', 'synthquest', date '2024-11-27') + , (0xadbbe373b5b5f72c59c0311cffbded51f0c5f434, 'Coinbase', 'Coinbase 72', 'synthquest', date '2024-11-27') + , (0x67857ee12929e74082f1cae64ef4221830c39113, 'Coinbase', 'Coinbase 73', 'synthquest', date '2024-11-27') + , (0xa2908f1758d1cc3990f4a2da8dea0aa2ecf1b913, 'Coinbase', 'Coinbase 74', 'synthquest', date '2024-11-27') + , (0xd451e3919950963e9c1ca2f78a987dbd7937c0fb, 'Coinbase', 'Coinbase 75', 'synthquest', date '2024-11-27') + , (0x27724b0d4fb98a89a092e6a4adbc09154c182637, 'Coinbase', 'Coinbase 76', 'synthquest', date '2024-11-27') + , (0x7c310a03f4cfa19f7f3d7f36dd3e05828629fa78, 'Coinbase', 'Coinbase 77', 'synthquest', date '2024-11-27') + , (0x21bd501f86a0b5ce0907651df3368da905b300a9, 'Coinbase', 'Coinbase 78', 'synthquest', date '2024-11-27') + , (0x7c41fdced2ea646ed85665d1a9b28e6632b61c41, 'Coinbase', 'Coinbase 79', 'synthquest', date '2024-11-27') + , (0x607094ed3a8361bb5e94dd21bcbef2997b687478, 'Coinbase', 'Coinbase 80', 'synthquest', date '2024-11-27') + , (0x1b4c15b991543a6082213a88276e7a83c9985676, 'Coinbase', 'Coinbase 81', 'synthquest', date '2024-11-27') + , (0xd5c41fd4a31eaaf5559ffcc60ec051fcb8ecc375, 'Coinbase', 'Coinbase 82', 'synthquest', date '2024-11-27') , (0xa090e606e30bd747d4e6245a1517ebe430f0057e, 'Coinbase', 'Coinbase Miscellaneous', 'hildobby', date '2022-08-28') , (0xf6874c88757721a02f47592140905c4336dfbc61, 'Coinbase', 'Coinbase Commerce', 'hildobby', date '2022-08-28') , (0x881d4032abe4188e2237efcd27ab435e81fc6bb1, 'Coinbase', 'Coinbase Commerce 2', 'hildobby', date '2022-08-28') diff --git a/dbt_subprojects/hourly_spellbook/models/_sector/gas/fees/gas_fees.sql b/dbt_subprojects/hourly_spellbook/models/_sector/gas/fees/gas_fees.sql index 68da93059b2..f2aaab6c006 100644 --- a/dbt_subprojects/hourly_spellbook/models/_sector/gas/fees/gas_fees.sql +++ b/dbt_subprojects/hourly_spellbook/models/_sector/gas/fees/gas_fees.sql @@ -45,6 +45,7 @@ , "mantle" , "optimism" , "polygon" + , "ronin" , "scroll" , "sei" , "tron" @@ -89,7 +90,7 @@ FROM {% endfor %} UNION ALL - + SELECT blockchain , block_month @@ -113,4 +114,4 @@ FROM , cast (NULL AS double) AS gas_limit -- this concept doesn't exist in solana , cast (NULL AS double) AS gas_limit_usage -- this concept doesn't exist in solana FROM {{ source('gas_solana', 'fees') }} -) \ No newline at end of file +) diff --git a/dbt_subprojects/hourly_spellbook/models/_sector/gas/fees/ronin/gas_ronin_fees.sql b/dbt_subprojects/hourly_spellbook/models/_sector/gas/fees/ronin/gas_ronin_fees.sql new file mode 100644 index 00000000000..310d86d1355 --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_sector/gas/fees/ronin/gas_ronin_fees.sql @@ -0,0 +1,17 @@ +{% set blockchain = 'ronin' %} + +{{ config( + schema = 'gas_' + blockchain + ,alias = 'fees' + ,partition_by = ['block_month'] + ,materialized = 'incremental' + ,file_format = 'delta' + ,incremental_strategy='merge' + ,unique_key = ['block_month', 'tx_hash'] + ,incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] + ) +}} + +{{ + gas_fees(blockchain = blockchain) +}} diff --git a/dbt_subprojects/hourly_spellbook/models/_sector/gas/fees/ronin/gas_ronin_schema.yml b/dbt_subprojects/hourly_spellbook/models/_sector/gas/fees/ronin/gas_ronin_schema.yml new file mode 100644 index 00000000000..696e8a9dfc7 --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_sector/gas/fees/ronin/gas_ronin_schema.yml @@ -0,0 +1,31 @@ +version: 2 + +models: + - name: gas_ronin_fees + meta: + blockchain: ronin + sector: gas + contributors: 0xRob, soispoke + config: + tags: ['ronin', 'gas', 'fees'] + description: > + Gas Fees on Ethereum + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_month + - block_number + - tx_hash + - check_seed: + seed_file: ref('evm_gas_fees') + filter: + blockchain: ronin + match_columns: + - blockchain + - tx_hash + check_columns: + - tx_fee_raw + - dbt_utils.expression_is_true: + expression: "tx_fee_raw = reduce(map_values(tx_fee_breakdown_raw),uint256 '0',(s, x) -> s + x,s -> s)" + config: + where: "block_time > now() - interval '7' day" diff --git a/dbt_subprojects/hourly_spellbook/models/_sector/lending/borrow/zksync/_schema.yml b/dbt_subprojects/hourly_spellbook/models/_sector/lending/borrow/zksync/_schema.yml index bc19690a235..02e1156a4f7 100644 --- a/dbt_subprojects/hourly_spellbook/models/_sector/lending/borrow/zksync/_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_sector/lending/borrow/zksync/_schema.yml @@ -122,3 +122,39 @@ models: - *project_contract_address - *tx_hash - *evt_index + + - name: aave_v3_zksync_base_borrow + meta: + blockchain: zksync + sector: lending + project: aave + contributors: tomfutago + config: + tags: ['lending', 'borrow', 'aave', 'aave', 'zksync'] + description: "Aave v3 borrow transactions on zkSync" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - transaction_type + - token_address + - tx_hash + - evt_index + - check_lending_base_borrow_seed: + seed_file: ref('aave_zksync_base_borrow_seed') + columns: + - *blockchain + - *project + - *version + - *transaction_type + - *token_address + - *borrower + - *on_behalf_of + - *repayer + - *liquidator + - *amount + - *block_month + - *block_time + - *block_number + - *project_contract_address + - *tx_hash + - *evt_index diff --git a/dbt_subprojects/hourly_spellbook/models/_sector/lending/borrow/zksync/lending_zksync_base_borrow.sql b/dbt_subprojects/hourly_spellbook/models/_sector/lending/borrow/zksync/lending_zksync_base_borrow.sql index dbf3b1513d0..319851e2ca1 100644 --- a/dbt_subprojects/hourly_spellbook/models/_sector/lending/borrow/zksync/lending_zksync_base_borrow.sql +++ b/dbt_subprojects/hourly_spellbook/models/_sector/lending/borrow/zksync/lending_zksync_base_borrow.sql @@ -8,7 +8,8 @@ {% set models = [ - ref('zerolend_zksync_base_borrow') + ref('zerolend_zksync_base_borrow'), + ref('aave_v3_zksync_base_borrow') ] %} diff --git a/dbt_subprojects/hourly_spellbook/models/_sector/lending/borrow/zksync/platforms/aave_v3_zksync_base_borrow.sql b/dbt_subprojects/hourly_spellbook/models/_sector/lending/borrow/zksync/platforms/aave_v3_zksync_base_borrow.sql new file mode 100644 index 00000000000..3005353d5c0 --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_sector/lending/borrow/zksync/platforms/aave_v3_zksync_base_borrow.sql @@ -0,0 +1,19 @@ +{{ + config( + schema = 'aave_v3_zksync', + alias = 'base_borrow', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transaction_type', 'token_address', 'tx_hash', 'evt_index'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] + ) +}} + +{{ + lending_aave_v3_compatible_borrow( + blockchain = 'zksync', + project = 'aave', + version = '3' + ) +}} diff --git a/dbt_subprojects/hourly_spellbook/models/_sector/lending/flashloans/_schema.yml b/dbt_subprojects/hourly_spellbook/models/_sector/lending/flashloans/_schema.yml index 66d8e027203..894c67705cc 100644 --- a/dbt_subprojects/hourly_spellbook/models/_sector/lending/flashloans/_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_sector/lending/flashloans/_schema.yml @@ -3,12 +3,12 @@ version: 2 models: - name: lending_flashloans meta: - blockchain: ethereum, celo, polygon, optimism, base, arbitrum, avalanche_c, fantom, gnosis, scroll, zksync + blockchain: ethereum, celo, polygon, optimism, base, arbitrum, avalanche_c, fantom, gnosis, zksync, zksync sector: lending project: aave contributors: tomfutago, hildobby config: - tags: ['lending', 'flashloans', 'aave', 'ethereum', 'celo', 'polygon', 'optimism', 'base', 'arbitrum', 'avalanche_c', 'fantom', 'gnosis', 'scroll', 'zksync'] + tags: ['lending', 'flashloans', 'aave', 'ethereum', 'celo', 'polygon', 'optimism', 'base', 'arbitrum', 'avalanche_c', 'fantom', 'gnosis', 'zksync', 'zksync'] description: "All lending transactions involving flashloans transactions" data_tests: - dbt_utils.unique_combination_of_columns: @@ -86,3 +86,34 @@ models: description: "Event index" data_tests: - not_null + + - name: aave_v3_zksync_base_flashloans + meta: + blockchain: zksync + sector: lending + project: aave + contributors: tomfutago + config: + tags: ['lending', 'flashloans', 'aave', 'zksync'] + description: "Aave v3 flashloans transactions on zkSync" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - evt_index + - check_lending_base_flashloans_seed: + seed_file: ref('aave_zksync_base_flashloans_seed') + columns: + - *blockchain + - *project + - *version + - *recipient + - *amount + - *fee + - *token_address + - *project_contract_address + - *block_month + - *block_time + - *block_number + - *tx_hash + - *evt_index diff --git a/dbt_subprojects/hourly_spellbook/models/_sector/lending/flashloans/zksync/lending_zksync_base_flashloans.sql b/dbt_subprojects/hourly_spellbook/models/_sector/lending/flashloans/zksync/lending_zksync_base_flashloans.sql index ad81e72af5a..943eeea517b 100644 --- a/dbt_subprojects/hourly_spellbook/models/_sector/lending/flashloans/zksync/lending_zksync_base_flashloans.sql +++ b/dbt_subprojects/hourly_spellbook/models/_sector/lending/flashloans/zksync/lending_zksync_base_flashloans.sql @@ -8,7 +8,8 @@ {% set models = [ - ref('zerolend_zksync_base_flashloans') + ref('zerolend_zksync_base_flashloans'), + ref('aave_v3_zksync_base_flashloans') ] %} diff --git a/dbt_subprojects/hourly_spellbook/models/_sector/lending/flashloans/zksync/platforms/aave_v3_zksync_base_flashloans.sql b/dbt_subprojects/hourly_spellbook/models/_sector/lending/flashloans/zksync/platforms/aave_v3_zksync_base_flashloans.sql new file mode 100644 index 00000000000..821ae724b6c --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_sector/lending/flashloans/zksync/platforms/aave_v3_zksync_base_flashloans.sql @@ -0,0 +1,19 @@ +{{ + config( + schema = 'aave_v3_zksync', + alias = 'base_flashloans', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['tx_hash', 'evt_index'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] + ) +}} + +{{ + lending_aave_v3_compatible_flashloans( + blockchain = 'zksync', + project = 'aave', + version = '3' + ) +}} diff --git a/dbt_subprojects/hourly_spellbook/models/_sector/lending/supply/ethereum/platforms/aave_lido_v3_ethereum_base_supply.sql b/dbt_subprojects/hourly_spellbook/models/_sector/lending/supply/ethereum/platforms/aave_lido_v3_ethereum_base_supply.sql index 2d19eebd8c1..4e30a0cd6a6 100644 --- a/dbt_subprojects/hourly_spellbook/models/_sector/lending/supply/ethereum/platforms/aave_lido_v3_ethereum_base_supply.sql +++ b/dbt_subprojects/hourly_spellbook/models/_sector/lending/supply/ethereum/platforms/aave_lido_v3_ethereum_base_supply.sql @@ -15,6 +15,7 @@ blockchain = 'ethereum', project = 'aave_lido', version = '3', - decoded_contract_name = 'LidoPool' + decoded_contract_name = 'LidoPool', + decoded_wrapped_token_gateway_name = 'LidoWrappedTokenGatewayV3' ) }} diff --git a/dbt_subprojects/hourly_spellbook/models/_sector/lending/supply/zksync/_schema.yml b/dbt_subprojects/hourly_spellbook/models/_sector/lending/supply/zksync/_schema.yml index e5b4b2c38a4..ec65df69324 100644 --- a/dbt_subprojects/hourly_spellbook/models/_sector/lending/supply/zksync/_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_sector/lending/supply/zksync/_schema.yml @@ -122,3 +122,39 @@ models: - *project_contract_address - *tx_hash - *evt_index + + - name: aave_v3_zksync_base_supply + meta: + blockchain: zksync + sector: lending + project: aave + contributors: tomfutago + config: + tags: ['lending', 'supply', 'aave', 'zksync'] + description: "Aave v3 supply transactions on zkSync" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - transaction_type + - token_address + - tx_hash + - evt_index + - check_lending_base_supply_seed: + seed_file: ref('aave_zksync_base_supply_seed') + columns: + - *blockchain + - *project + - *version + - *transaction_type + - *token_address + - *depositor + - *on_behalf_of + - *withdrawn_to + - *liquidator + - *amount + - *block_month + - *block_time + - *block_number + - *project_contract_address + - *tx_hash + - *evt_index diff --git a/dbt_subprojects/hourly_spellbook/models/_sector/lending/supply/zksync/lending_zksync_base_supply.sql b/dbt_subprojects/hourly_spellbook/models/_sector/lending/supply/zksync/lending_zksync_base_supply.sql index 4cbc152960f..831f1cc0f72 100644 --- a/dbt_subprojects/hourly_spellbook/models/_sector/lending/supply/zksync/lending_zksync_base_supply.sql +++ b/dbt_subprojects/hourly_spellbook/models/_sector/lending/supply/zksync/lending_zksync_base_supply.sql @@ -8,7 +8,8 @@ {% set models = [ - ref('zerolend_zksync_base_supply') + ref('zerolend_zksync_base_supply'), + ref('aave_v3_zksync_base_supply') ] %} diff --git a/dbt_subprojects/hourly_spellbook/models/_sector/lending/supply/zksync/platforms/aave_v3_zksync_base_supply.sql b/dbt_subprojects/hourly_spellbook/models/_sector/lending/supply/zksync/platforms/aave_v3_zksync_base_supply.sql new file mode 100644 index 00000000000..9b51483bad5 --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_sector/lending/supply/zksync/platforms/aave_v3_zksync_base_supply.sql @@ -0,0 +1,19 @@ +{{ + config( + schema = 'aave_v3_zksync', + alias = 'base_supply', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transaction_type', 'token_address', 'tx_hash', 'evt_index'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] + ) +}} + +{{ + lending_aave_v3_compatible_supply( + blockchain = 'zksync', + project = 'aave', + version = '3' + ) +}} diff --git a/dbt_subprojects/hourly_spellbook/models/_sector/staking/ethereum/staking_ethereum_flows.sql b/dbt_subprojects/hourly_spellbook/models/_sector/staking/ethereum/staking_ethereum_flows.sql index db36a29b6a5..dd6b3a7f087 100644 --- a/dbt_subprojects/hourly_spellbook/models/_sector/staking/ethereum/staking_ethereum_flows.sql +++ b/dbt_subprojects/hourly_spellbook/models/_sector/staking/ethereum/staking_ethereum_flows.sql @@ -18,6 +18,19 @@ WITH invalid_pubkeys AS ( , (0x86f473a006c566f1648a82c74cdfbd4a3cb2ea04eb2e0d49ef381ab2562576888554ef3d39e56996f24c804abb489600) , (0x8c69edd7a8e8da5330787952a1ad5075516e6fd4bda1586d62dd64701f7628d5229eb7f929017dea9ae6995f9c69ef5e) , (0x80a29e569e8ced0be1fff42c845a59449aecf8a2503542e4e76763ccc0265e683e2d5d46618cc829349293ed08ff49ff) + , (0xb913a27913c8a74c05cc31c1a690ecad05a59e405bd7c5e8f6eab8e426e041a98b26cf40b04356b4d92ac20a56b7dcae) + , (0x86af099d9134b2994b835cced1fadfb4587dddfc4010470db9d8875cffd9e5a62a197db7d9c0266fb67c5175feb7ef51) + , (0x8107543db1d5c69be127b3eb84c0f7b8157b892482f7e98b85b83d9a6be75e7c24a645df6283d46b16285862530cad77) + , (0x8e05d99c557001d06f8240d46899b829a8cc77ac57b3d16359279cad707cfe5f223a3374987ab73a379ee358dd05d524) + , (0xaebf3fbab24f55df829e2bc939bb987cbdb3edea7d4cb8877e422f1185d03a22f3a0f6449a1d6d1b912ec09ed11f2bb3) + , (0xac3a0887866d5d45555904e2cb35e1b89b4c338c19001b0cc1184c9f95c5a731ccef70dc4c4fed7709c2106042a119c9) + , (0xa03840dd6af6555442e3fc0d62de8dde77970f45175ea9926327372b5c83542f67cdd06e14e1daa44a3ae23e4d8eef52) + , (0x828116d0d2e945f1483ec7c6c135a8e00814588879e9a12a67c42268c339388b6f796f6c858e673f6000f5d028b913da) + , (0x816827749a5194cf8389419e88d87f6786436daaa5546b92c68af015f0b7e17c66f4bb30b18872f3f051c2bc213ecaab) + , (0xa0ab932b24d80a7a96f0fb32ce2aa724625eb090c70cb9c977f0bc5909503629155335be021e58b245e11a77c847a11c) + , (0x8d135f9185f635be5e3d738c835a02d5efab05bc5fa38ce4cb6d02156446aa3cc1ce9cc38576ec519af815dc39d52c81) + , (0x8151e62f956cf1562007d9620fd4e91c029fb43959d1a7d1d2168c2943d65a3ef31764d1cc2d2540fb26ce86efad2ffd) + , (0x9714e943c81d802f3c858f284fff25779818a903c034a3de42da7a2b63ae6632c52b2be0982007e8090d0d334f8cf656) --, (0x00) -- This is a dummy pubkey used to refresh the table ) AS temp_table (pubkey) ) diff --git a/dbt_subprojects/hourly_spellbook/seeds/_sector/gas/evm_gas_fees.csv b/dbt_subprojects/hourly_spellbook/seeds/_sector/gas/evm_gas_fees.csv index fce13ac3d2e..887d7dfc46f 100644 --- a/dbt_subprojects/hourly_spellbook/seeds/_sector/gas/evm_gas_fees.csv +++ b/dbt_subprojects/hourly_spellbook/seeds/_sector/gas/evm_gas_fees.csv @@ -62,3 +62,7 @@ zora,Legacy,0xfd5f8df99b747f27303ec22f764a847b9211a7e0f9fbcd13f18301026b28aa99,3 zora,126,0xa694bccb978690204cc9445f8e9c2695f19f87cf1d7923ce4dd5b7122cd69d47,0 zora,AccessList,0x8d1029a6cbb3ec0047371c17e888381f95023487743eeb6597ab65d4c8954fbc,175028874886 zora,DynamicFee,0x92c43dbc36d7234e6cab7b3793b573d9b20a810c4403ae9e5900706a2f9e20a7,47040291290076 +ronin,DynamicFee,0x85a8cdb97b8920934ec8f555db172dd91ebcc95fe7d1e409a1b9b02f41485b7d,14880820000000000 +ronin,AccessList,0xb56e7dfc8d745f6e9d1c99a90f4ae874e541c8c6b38002ed80b3c2965d46aaa3,420000000000000 +ronin,Legacy,0x587223185b0f498faf0715de5855a98a4aae330c17330a22fb9c64636beb38d8,71333000000000 +ronin,100,0x438c07ec4094b9a335fe641ab7ba73e13d18f5113fffca04f8e2d0f82144cdfe,1074820000000000 diff --git a/dbt_subprojects/hourly_spellbook/seeds/_sector/lending/_schema.yml b/dbt_subprojects/hourly_spellbook/seeds/_sector/lending/_schema.yml index f434216529b..213fd274c94 100644 --- a/dbt_subprojects/hourly_spellbook/seeds/_sector/lending/_schema.yml +++ b/dbt_subprojects/hourly_spellbook/seeds/_sector/lending/_schema.yml @@ -168,6 +168,20 @@ seeds: token_address: varbinary borrower: varbinary amount: double + - name: aave_zksync_base_borrow_seed + config: + column_types: + blockchain: varchar + project: varchar + version: varchar + block_number: bigint + block_time: timestamp + tx_hash: varbinary + evt_index: bigint + transaction_type: varchar + token_address: varbinary + borrower: varbinary + amount: double - name: aave_arbitrum_base_supply_seed config: @@ -337,6 +351,20 @@ seeds: token_address: varbinary depositor: varbinary amount: double + - name: aave_zksync_base_supply_seed + config: + column_types: + blockchain: varchar + project: varchar + version: varchar + block_number: bigint + block_time: timestamp + tx_hash: varbinary + evt_index: bigint + transaction_type: varchar + token_address: varbinary + depositor: varbinary + amount: double - name: aave_arbitrum_base_flashloans_seed config: @@ -494,6 +522,19 @@ seeds: token_address: varbinary recipient: varbinary amount: double + - name: aave_zksync_base_flashloans_seed + config: + column_types: + blockchain: varchar + project: varchar + version: varchar + block_number: bigint + block_time: timestamp + tx_hash: varbinary + evt_index: bigint + token_address: varbinary + recipient: varbinary + amount: double - name: moola_celo_base_borrow_seed config: diff --git a/dbt_subprojects/hourly_spellbook/seeds/_sector/lending/aave_zksync_base_borrow_seed.csv b/dbt_subprojects/hourly_spellbook/seeds/_sector/lending/aave_zksync_base_borrow_seed.csv new file mode 100644 index 00000000000..37a024abb8c --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/seeds/_sector/lending/aave_zksync_base_borrow_seed.csv @@ -0,0 +1,4 @@ +blockchain,project,version,block_number,block_time,tx_hash,evt_index,transaction_type,token_address,borrower,amount +zksync,aave,3,51909048,2024-12-22 12:56:09.000 UTC,0x087a9163c4b4c34a26adb3155ad62de8883d413fdfeb1236f84b6260bec9da48,7,borrow,0x1d17cbcf0d6d143135ae902365d2e5e2a16538d4,0x72fe12b5127162f8f3d1eec3f9d232c98a032f23,110000000 +zksync,aave,3,51750031,2024-12-20 11:29:08.000 UTC,0x3a7548fe223e51d74cd4cd2bedcf9122e4853f4209cac2c49e7e9b068c90ebf2,18,borrow_liquidation,0x1d17cbcf0d6d143135ae902365d2e5e2a16538d4,0xd3b2a586180c9e306b38848d31e82f9e17d76f0c,-2770807444 +zksync,aave,3,51907646,2024-12-22 12:30:24.000 UTC,0xac913e1cb652b2aaf1aab9e886803c2d27a45f2ebd2b564548b8c5c2012d5021,14,repay,0x1d17cbcf0d6d143135ae902365d2e5e2a16538d4,0x5ba9811dff37ca8639272d509dcadfe5bec4bff7,-4100000 diff --git a/dbt_subprojects/hourly_spellbook/seeds/_sector/lending/aave_zksync_base_flashloans_seed.csv b/dbt_subprojects/hourly_spellbook/seeds/_sector/lending/aave_zksync_base_flashloans_seed.csv new file mode 100644 index 00000000000..d7129e1a2c0 --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/seeds/_sector/lending/aave_zksync_base_flashloans_seed.csv @@ -0,0 +1,4 @@ +blockchain,project,version,block_number,block_time,tx_hash,evt_index,token_address,recipient,amount +zksync,aave,3,51741885,2024-12-20 09:08:30.000 UTC,0x37aa4e84eb810f3cce179819b68a37acdd53104d799e60a851e75f5775faab24,28,0x1d17cbcf0d6d143135ae902365d2e5e2a16538d4,0x41c914a4a619b7969137551904a537db16905d1f,2504231355 +zksync,aave,3,51741825,2024-12-20 09:07:29.000 UTC,0x0fa867dd6cccb34159b8bfee8a1757a1af6a3e37f7f2af2f58caab044e684826,28,0x1d17cbcf0d6d143135ae902365d2e5e2a16538d4,0x41c914a4a619b7969137551904a537db16905d1f,210563615 +zksync,aave,3,51692496,2024-12-19 18:24:06.000 UTC,0x433e9869c81ae380c4ab360ad6a14a1d56e22a1adf7734b5415bb31485aac494,32,0x493257fd37edb34451f62edf8d2a0c418852ba4c,0x41c914a4a619b7969137551904a537db16905d1f,15509265 diff --git a/dbt_subprojects/hourly_spellbook/seeds/_sector/lending/aave_zksync_base_supply_seed.csv b/dbt_subprojects/hourly_spellbook/seeds/_sector/lending/aave_zksync_base_supply_seed.csv new file mode 100644 index 00000000000..28c24921051 --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/seeds/_sector/lending/aave_zksync_base_supply_seed.csv @@ -0,0 +1,5 @@ +blockchain,project,version,block_number,block_time,tx_hash,evt_index,transaction_type,token_address,depositor,amount +zksync,aave,3,51910059,2024-12-22 13:14:37.000 UTC,0xf9fd60b0434f3b32e6f71bffa3d931f570f67fb79e9d5a3856e864c3d413d729,8,deposit,0x5a7d6b2f92c77fad6ccabd7ee0624e64907eaf3e,0xb34247a2ff891caec36375d0e58f95f8d9bf38d6,100000000000000000000 +zksync,aave,3,51750031,2024-12-20 11:29:08.000 UTC,0x3a7548fe223e51d74cd4cd2bedcf9122e4853f4209cac2c49e7e9b068c90ebf2,18,deposit_liquidation,0x5a7d6b2f92c77fad6ccabd7ee0624e64907eaf3e,0xd3b2a586180c9e306b38848d31e82f9e17d76f0c,-1.9198338954322615e+22 +zksync,aave,3,51215930,2024-12-13 18:06:30.000 UTC,0x8f3e895a74a183300d417869bcaac0edf03a65a9d737af686d222a63967e76f6,8,repay_with_atokens,0x1d17cbcf0d6d143135ae902365d2e5e2a16538d4,0x8a8a757c4c3cbb85450dfb70e61fbcbae3994054,-491998467 +zksync,aave,3,51908987,2024-12-22 12:55:05.000 UTC,0x1bf91b597c04a36bcb2d9e7c7e7c3260eb79ebe62f47a6746f5c615511e075dc,26,withdraw,0x5aea5775959fbc2557cc8789bc1bf90a239d9a91,0xd5f6c8d402e0a0222f7fa132f9e80fdcc074df5c,-20000005150310010 diff --git a/dbt_subprojects/nft/README.md b/dbt_subprojects/nft/README.md index 0b38ebded01..eb055932640 100644 --- a/dbt_subprojects/nft/README.md +++ b/dbt_subprojects/nft/README.md @@ -1,3 +1,3 @@ ## Daily Spellbook -This is a DBT sub project for the all the NFT related models in spellbook. +This is a DBT sub project for the all the NFT related models in spellbook diff --git a/dbt_subprojects/nft/dbt_project.yml b/dbt_subprojects/nft/dbt_project.yml index f26a684eeb9..7fd0b4eb5c3 100644 --- a/dbt_subprojects/nft/dbt_project.yml +++ b/dbt_subprojects/nft/dbt_project.yml @@ -14,6 +14,9 @@ quoting: # profile: "spellbook-poc-tokens" profile: "spellbook-local" +flags: + require_certificate_validation: true + vars: DBT_ENV_CUSTOM_ENV_S3_BUCKET: "{{ env_var('DBT_ENV_CUSTOM_ENV_S3_BUCKET', 'local') }}" DBT_ENV_INCREMENTAL_TIME: "{{ env_var('DBT_ENV_INCREMENTAL_TIME', '1') }}" diff --git a/dbt_subprojects/nft/models/_sector/trades/chains/ronin/nft_ronin_base_trades.sql b/dbt_subprojects/nft/models/_sector/trades/chains/ronin/nft_ronin_base_trades.sql new file mode 100644 index 00000000000..83f699e3415 --- /dev/null +++ b/dbt_subprojects/nft/models/_sector/trades/chains/ronin/nft_ronin_base_trades.sql @@ -0,0 +1,49 @@ +{{ config( + schema = 'nft_ronin', + alias = 'base_trades', + materialized = 'view' + ) +}} +-- (project, project_version, model) +{% set nft_models = [ + ref('mavis_ronin_base_trades') +] %} + +with base_union as ( +SELECT * FROM ( +{% for nft_model in nft_models %} + SELECT + blockchain, + project, + project_version, + block_time, + block_date, + block_month, + block_number, + tx_hash, + project_contract_address, + trade_category, + trade_type, + buyer, + seller, + nft_contract_address, + nft_token_id, + nft_amount, + price_raw, + currency_contract, + platform_fee_amount_raw, + royalty_fee_amount_raw, + platform_fee_address, + royalty_fee_address, + sub_tx_trade_id, + tx_from, + tx_to, + tx_data_marker + FROM {{ nft_model }} + {% if not loop.last %} + UNION ALL + {% endif %} + {% endfor %} + ) +) +select * from base_union diff --git a/dbt_subprojects/nft/models/_sector/trades/chains/ronin/platforms/_schema.yml b/dbt_subprojects/nft/models/_sector/trades/chains/ronin/platforms/_schema.yml new file mode 100644 index 00000000000..9da694d9865 --- /dev/null +++ b/dbt_subprojects/nft/models/_sector/trades/chains/ronin/platforms/_schema.yml @@ -0,0 +1,12 @@ +version: 2 + +models: + - name: mavis_ronin_base_trades + meta: + blockchain: ronin + sector: nft + project: mavis_ronin + contributors: ['peterrliem' ] + config: + tags: [ 'ronin', 'nft', 'trades', 'mavis' ] + description: "mavis marketplace base trades" diff --git a/dbt_subprojects/nft/models/_sector/trades/chains/ronin/platforms/mavis_ronin_base_trades.sql b/dbt_subprojects/nft/models/_sector/trades/chains/ronin/platforms/mavis_ronin_base_trades.sql new file mode 100644 index 00000000000..d7ef5b9c292 --- /dev/null +++ b/dbt_subprojects/nft/models/_sector/trades/chains/ronin/platforms/mavis_ronin_base_trades.sql @@ -0,0 +1,92 @@ +{{ config( + schema = 'mavis_ronin', + alias = 'base_trades', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['block_number','tx_hash','sub_tx_trade_id'], + ) +}} + + +with trade_details as ( + +select + evt_block_time as block_time, + evt_block_date as block_date, + evt_block_number as block_number, + evt_tx_hash as tx_hash, + evt_tx_from as tx_from, + evt_tx_to as tx_to, + evt_index, + contract_address, + COALESCE(FROM_HEX(json_extract_scalar(json_parse(cast(concat('[', array_join(receivedAllocs, ','), ']') as varchar)),'$[5].recipient')),FROM_HEX(json_extract_scalar(json_parse(json_extract_scalar("order", '$.info')), '$.maker'))) as seller, + FROM_HEX(json_extract_scalar("order", '$.recipient')) as buyer, + json_extract_scalar(json_parse(json_extract_scalar("order", '$.info')), '$.kind') as kind, + cast(json_extract_scalar(replace(json_extract_scalar(json_parse(json_extract_scalar("order", '$.info')),'$.assets[0]'),'\\', ''),'$.erc') as double) as erc, + FROM_HEX(json_extract_scalar(replace(json_extract_scalar(json_parse(json_extract_scalar("order", '$.info')),'$.assets[0]'),'\\', ''),'$.addr')) as nft_contract_address, + cast(json_extract_scalar(replace(json_extract_scalar(json_parse(json_extract_scalar("order", '$.info')),'$.assets[0]'),'\\', ''),'$.id') as double) as nft_token_id, + case + when cast(json_extract_scalar(replace(json_extract_scalar(json_parse(json_extract_scalar("order", '$.info')),'$.assets[0]'),'\\', ''),'$.quantity') as double) = 0 then 1 + else cast(json_extract_scalar(replace(json_extract_scalar(json_parse(json_extract_scalar("order", '$.info')),'$.assets[0]'),'\\', ''),'$.quantity') as double) + end as quantity, + FROM_HEX(json_extract_scalar(json_parse(json_extract_scalar("order", '$.info')), '$.paymentToken')) as currency_address, + CAST(json_extract_scalar("order", '$.realPrice') AS DOUBLE) as price_raw, + CAST(json_extract_scalar(json_parse(json_extract_scalar("order", '$.info')), '$.baseUnitPrice') AS DOUBLE) as base_unit_price_raw, + FROM_HEX(json_extract_scalar("order", '$.refunder')) as refunder, + FROM_HEX(json_extract_scalar(json_parse(cast(concat('[', array_join(receivedAllocs, ','), ']') as varchar)),'$[1].recipient')) as platform_address, + CAST(json_extract_scalar(json_parse(cast(concat('[', array_join(receivedAllocs, ','), ']') as varchar)),'$[1].value') AS DOUBLE) as platform_fee_amount_raw, + FROM_HEX(json_extract_scalar(json_parse(cast(concat('[', array_join(receivedAllocs, ','), ']') as varchar)),'$[2].recipient')) as axie_treasury_address, + CAST(json_extract_scalar(json_parse(cast(concat('[', array_join(receivedAllocs, ','), ']') as varchar)),'$[2].ratio') AS DOUBLE) as axie_fee_raw, + CAST(json_extract_scalar(json_parse(cast(concat('[', array_join(receivedAllocs, ','), ']') as varchar)),'$[2].value') AS DOUBLE) as axie_fee_amount_raw, + FROM_HEX(json_extract_scalar(json_parse(cast(concat('[', array_join(receivedAllocs, ','), ']') as varchar)),'$[3].recipient')) as ronin_treasury_address, + CAST(json_extract_scalar(json_parse(cast(concat('[', array_join(receivedAllocs, ','), ']') as varchar)),'$[3].ratio') AS DOUBLE) as ronin_fee, + CAST(json_extract_scalar(json_parse(cast(concat('[', array_join(receivedAllocs, ','), ']') as varchar)),'$[3].value') AS DOUBLE) as ronin_treasury_fee_amount_raw, + FROM_HEX(json_extract_scalar(json_parse(cast(concat('[', array_join(receivedAllocs, ','), ']') as varchar)),'$[4].recipient')) as creator_royalty_address, + CAST(json_extract_scalar(json_parse(cast(concat('[', array_join(receivedAllocs, ','), ']') as varchar)),'$[4].ratio') AS DOUBLE) as creator_royalty_fee, + CAST(json_extract_scalar(json_parse(cast(concat('[', array_join(receivedAllocs, ','), ']') as varchar)),'$[4].value') AS DOUBLE) as creator_royalty_fee_amount_raw, + CAST(json_extract_scalar(json_parse(cast(concat('[', array_join(receivedAllocs, ','), ']') as varchar)),'$[5].ratio')AS DOUBLE) AS seller_percentage_fee, + CAST(json_extract_scalar(json_parse(cast(concat('[', array_join(receivedAllocs, ','), ']') as varchar)),'$[5].value')AS DOUBLE) AS seller_amount_raw + FROM + {{ source('mavis_marketplace_ronin','MavisMarketPlace_evt_OrderMatched') }} + {% if is_incremental() %} + WHERE {{incremental_predicate('evt_block_time')}} + {% endif %} + ), + +base_trades as ( + + select + 'ronin' as blockchain, + 'mavis market' as project, + 'v1' as project_version, + block_time, + cast(date_trunc('day', block_time) as date) as block_date, + cast(date_trunc('month', block_time) as date) as block_month, + block_number, + nft_contract_address, + nft_token_id, + quantity as nft_amount, + seller, + buyer, + 'buy' as trade_category, + 'secondary' as trade_type, + price_raw, + currency_address as currency_contract, + contract_address as project_contract_address, + tx_hash, + platform_address as platform_fee_address, + platform_fee_amount_raw, + creator_royalty_address as royalty_fee_address, + creator_royalty_fee_amount_raw as royalty_fee_amount_raw, + axie_fee_amount_raw, + ronin_treasury_fee_amount_raw, + evt_index as sub_tx_trade_id + FROM trade_details + ) + +-- this will be removed once tx_from and tx_to are available in the base event tables +{{ add_nft_tx_data('base_trades', 'ronin') }} + + + diff --git a/dbt_subprojects/nft/models/_sector/trades/nft_base_trades.sql b/dbt_subprojects/nft/models/_sector/trades/nft_base_trades.sql index d9d70881f68..5454934eb2e 100644 --- a/dbt_subprojects/nft/models/_sector/trades/nft_base_trades.sql +++ b/dbt_subprojects/nft/models/_sector/trades/nft_base_trades.sql @@ -27,6 +27,7 @@ ,ref('nft_blast_base_trades') ,ref('nft_fantom_base_trades') ,ref('nft_nova_base_trades') + ,ref('nft_ronin_base_trades') ] %} with base_union as ( diff --git a/dbt_subprojects/nft/models/_sector/trades/nft_trades.sql b/dbt_subprojects/nft/models/_sector/trades/nft_trades.sql index d060f52e9f5..ba3ffe325d1 100644 --- a/dbt_subprojects/nft/models/_sector/trades/nft_trades.sql +++ b/dbt_subprojects/nft/models/_sector/trades/nft_trades.sql @@ -2,7 +2,7 @@ schema = 'nft', alias = 'trades', materialized = 'view', - post_hook='{{ expose_spells(\'["ethereum","solana","bnb","optimism","arbitrum","polygon","zksync", "blast"]\', + post_hook='{{ expose_spells(\'["ethereum","solana","bnb","optimism","arbitrum","polygon","zksync", "blast", "ronin", "nova"]\', "sector", "nft", \'["soispoke","0xRob", "hildobby"]\') }}') diff --git a/dbt_subprojects/nft/models/_sector/transfers/_schema.yml b/dbt_subprojects/nft/models/_sector/transfers/_schema.yml index e28d91c834d..1c470216126 100644 --- a/dbt_subprojects/nft/models/_sector/transfers/_schema.yml +++ b/dbt_subprojects/nft/models/_sector/transfers/_schema.yml @@ -471,3 +471,25 @@ models: - *token_standard - *transfer_type - *unique_transfer_id + + - name: nft_ronin_transfers + meta: + blockchain: ronin + sector: nft + contributors: petertherock + config: + tags: [ 'nft', 'transfers' ] + description: > + NFT transfers + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - evt_index + - token_id + - amount + columns: + # only listing columns that have tests here for simplicity + - *token_standard + - *transfer_type + - *unique_transfer_id diff --git a/dbt_subprojects/nft/models/_sector/transfers/chains/nft_ronin_transfers.sql b/dbt_subprojects/nft/models/_sector/transfers/chains/nft_ronin_transfers.sql new file mode 100644 index 00000000000..6bd78b2fd49 --- /dev/null +++ b/dbt_subprojects/nft/models/_sector/transfers/chains/nft_ronin_transfers.sql @@ -0,0 +1,24 @@ +{{ + config( + schema="nft_ronin", + alias="transfers", + partition_by=["block_month"], + materialized="incremental", + file_format="delta", + incremental_strategy="merge", + incremental_predicates=[ + incremental_predicate("DBT_INTERNAL_DEST.block_time") + ], + unique_key=["tx_hash", "evt_index", "token_id", "amount"], + ) +}} + +{{ + nft_transfers( + blockchain="ronin", + base_transactions=source("ronin", "transactions"), + erc721_transfers=source("erc721_ronin", "evt_transfer"), + erc1155_single=source("erc1155_ronin", "evt_transfersingle"), + erc1155_batch=source("erc1155_ronin", "evt_transferbatch"), + ) +}} diff --git a/dbt_subprojects/nft/models/_sector/transfers/nft_transfers.sql b/dbt_subprojects/nft/models/_sector/transfers/nft_transfers.sql index 721069b7ae1..7f4ffc9fd75 100644 --- a/dbt_subprojects/nft/models/_sector/transfers/nft_transfers.sql +++ b/dbt_subprojects/nft/models/_sector/transfers/nft_transfers.sql @@ -8,7 +8,7 @@ incremental_strategy = 'merge', incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], unique_key = ['tx_hash', 'evt_index', 'token_id', 'amount'], - post_hook='{{ expose_spells(\'["ethereum", "bnb", "avalanche_c", "gnosis", "optimism", "arbitrum", "polygon", "fantom", "goerli", "base", "celo", "zksync", "zora", "scroll", "linea", "blast", "mantle"]\', + post_hook='{{ expose_spells(\'["ethereum", "bnb", "avalanche_c", "gnosis", "optimism", "arbitrum", "polygon", "fantom", "goerli", "base", "celo", "zksync", "zora", "scroll", "linea", "blast", "mantle", "sei", "ronin"]\', "sector", "nft", \'["hildobby", "0xRob", "rantum","petertherock"]\') }}' @@ -34,6 +34,7 @@ ,ref('nft_blast_transfers') ,ref('nft_mantle_transfers') ,ref('nft_sei_transfers') +,ref('nft_ronin_transfers') ] %} SELECT * diff --git a/dbt_subprojects/solana/README.md b/dbt_subprojects/solana/README.md index 2fee156a2d1..9b3ec39f43f 100644 --- a/dbt_subprojects/solana/README.md +++ b/dbt_subprojects/solana/README.md @@ -1,3 +1,3 @@ ## Solana subproject -This is a DBT subproject for the main lineages of Solana data. \ No newline at end of file +This is a DBT subproject for the main lineages of Solana data diff --git a/dbt_subprojects/solana/dbt_project.yml b/dbt_subprojects/solana/dbt_project.yml index ed3a13af12f..9daa19b0fee 100644 --- a/dbt_subprojects/solana/dbt_project.yml +++ b/dbt_subprojects/solana/dbt_project.yml @@ -13,6 +13,9 @@ quoting: # This setting configures which "profile" dbt uses for this project. profile: "spellbook-local" +flags: + require_certificate_validation: true + vars: DBT_ENV_CUSTOM_ENV_S3_BUCKET: "{{ env_var('DBT_ENV_CUSTOM_ENV_S3_BUCKET', 'local') }}" DBT_ENV_INCREMENTAL_TIME: "{{ env_var('DBT_ENV_INCREMENTAL_TIME', '1') }}" diff --git a/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/_schema.yml b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/_schema.yml index 6e9faa06c60..fb74d1ec172 100644 --- a/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/_schema.yml +++ b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/_schema.yml @@ -454,7 +454,7 @@ models: - check_bot_trades_seed: seed_file: ref('tirador_solana_trades_seed') blockchain: solana - + - name: unibot_solana_bot_trades meta: blockchain: solana @@ -498,7 +498,7 @@ models: - check_bot_trades_seed: seed_file: ref('mev_x_solana_trades_seed') blockchain: solana - + - name: alpha_dex_solana_bot_trades meta: blockchain: solana @@ -578,7 +578,7 @@ models: - check_bot_trades_seed: seed_file: ref('pinkpunk_solana_trades_seed') blockchain: solana - + - name: falcon_solana_bot_trades meta: blockchain: solana @@ -598,7 +598,7 @@ models: - outer_instruction_index - inner_instruction_index - check_bot_trades_seed: - seed_file: ref('falcon_solana_trades_seed') + seed_file: ref('falcon_solana_trades_seed') blockchain: solana - name: bloom_solana_bot_trades @@ -643,4 +643,137 @@ models: - inner_instruction_index - check_bot_trades_seed: seed_file: ref('autosnipe_solana_trades_seed') - blockchain: solana \ No newline at end of file + blockchain: solana + + - name: bitfoot_solana_bot_trades + meta: + blockchain: solana + sector: dex + project: bitfoot + contributors: whale_hunter + config: + tags: ["solana", "dex", "bitfoot", "trades"] + description: > + Bitfoot trades on Solana + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - tx_id + - tx_index + - outer_instruction_index + - inner_instruction_index + - check_bot_trades_seed: + seed_file: ref('bitfoot_solana_trades_seed') + blockchain: solana + + - name: tradewiz_solana_bot_trades + meta: + blockchain: solana + sector: dex + project: tradewiz + contributors: whale_hunter + config: + tags: ["solana", "dex", "tradewiz", "trades"] + description: > + Tradewiz trades on Solana + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - tx_id + - tx_index + - outer_instruction_index + - inner_instruction_index + - check_bot_trades_seed: + seed_file: ref('tradewiz_solana_trades_seed') + blockchain: solana + + + - name: cswap_solana_bot_trades + meta: + blockchain: solana + sector: dex + project: ChainSwap + contributors: whale_hunter + config: + tags: ["solana", "dex", "cswap", "trades"] + description: > + ChainSwap trades on Solana + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - tx_id + - tx_index + - outer_instruction_index + - inner_instruction_index + - check_bot_trades_seed: + seed_file: ref('cswap_solana_trades_seed') + blockchain: solana + + - name: prophetbots_solana_bot_trades + meta: + blockchain: solana + sector: dex + project: prophetbots + contributors: whale_hunter + config: + tags: ["solana", "dex", "prophetbots", "trades"] + description: > + ProphetBots trades on Solana + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - tx_id + - tx_index + - outer_instruction_index + - inner_instruction_index + - check_bot_trades_seed: + seed_file: ref('prophetbots_solana_trades_seed') + blockchain: solana + + - name: nova_solana_bot_trades + meta: + blockchain: solana + sector: dex + project: nova + contributors: whale_hunter + config: + tags: ["solana", "dex", "nova", "trades"] + description: > + Nova trades on Solana + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - tx_id + - tx_index + - outer_instruction_index + - inner_instruction_index + - check_bot_trades_seed: + seed_file: ref('nova_solana_trades_seed') + blockchain: solana + + - name: sanji_solana_bot_trades + meta: + blockchain: solana + sector: dex + project: sanji + contributors: whale_hunter + config: + tags: ["solana", "dex", "sanji", "trades"] + description: > + Sanji trades on Solana + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - tx_id + - tx_index + - outer_instruction_index + - inner_instruction_index + - check_bot_trades_seed: + seed_file: ref('sanji_solana_trades_seed') + blockchain: solana diff --git a/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/dex_solana_bot_trades.sql b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/dex_solana_bot_trades.sql index 45a86ca4054..a047ad493be 100644 --- a/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/dex_solana_bot_trades.sql +++ b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/dex_solana_bot_trades.sql @@ -35,6 +35,10 @@ , ref('looter_solana_bot_trades') , ref('wifbot_solana_bot_trades') , ref('autosnipe_solana_bot_trades') + , ref('bitfoot_solana_bot_trades') + , ref('tradewiz_solana_bot_trades') + , ref('prophetbots_solana_bot_trades') + , ref('sanji_solana_bot_trades') ] %} {% for bot in solana_trading_bot %} diff --git a/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/autosnipe_solana_bot_trades.sql b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/autosnipe_solana_bot_trades.sql index 97d8d471ae9..d332abc1af8 100644 --- a/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/autosnipe_solana_bot_trades.sql +++ b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/autosnipe_solana_bot_trades.sql @@ -10,7 +10,7 @@ ) }} -{% set project_start_date = '2024-11-13' %} +{% set project_start_date = '2024-05-22' %} {% set fee_receiver_1 = 'CWEfC6fLi552zE2KFxhPiBAZUWdT78gMd8NGENik2zfE' %} {% set wsol_token = 'So11111111111111111111111111111111111111112' %} diff --git a/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/bitfoot_solana_bot_trades.sql b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/bitfoot_solana_bot_trades.sql new file mode 100644 index 00000000000..4213660df7b --- /dev/null +++ b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/bitfoot_solana_bot_trades.sql @@ -0,0 +1,152 @@ +{{ config( + alias = 'bot_trades', + schema = 'bitfoot_solana', + partition_by = ['block_month'], + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], + unique_key = ['blockchain', 'tx_id', 'tx_index', 'outer_instruction_index', 'inner_instruction_index'] + ) +}} + +{% set project_start_date = '2024-11-21' %} +{% set fee_receiver_1 = 'BzmpLvrhZHKoXV7CW9F1AVPnie3hNh2JK3BRdHL4Zcya' %} +{% set wsol_token = 'So11111111111111111111111111111111111111112' %} + +WITH + allFeePayments AS ( + SELECT + tx_id, + 'SOL' AS feeTokenType, + balance_change / 1e9 AS fee_token_amount, + '{{wsol_token}}' AS fee_token_mint_address + FROM + {{ source('solana','account_activity') }} + WHERE + {% if is_incremental() %} + {{ incremental_predicate('block_time') }} + {% else %} + block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + AND tx_success + AND balance_change > 0 + AND ( + address = '{{fee_receiver_1}}' + ) + ), + botTrades AS ( + SELECT + trades.block_time, + CAST(date_trunc('day', trades.block_time) AS date) AS block_date, + CAST(date_trunc('month', trades.block_time) AS date) AS block_month, + 'solana' AS blockchain, + amount_usd, + IF( + token_sold_mint_address = '{{wsol_token}}', + 'Buy', + 'Sell' + ) AS type, + token_bought_amount, + token_bought_symbol, + token_bought_mint_address AS token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_mint_address AS token_sold_address, + fee_token_amount * price AS fee_usd, + fee_token_amount, + IF(feeTokenType = 'SOL', 'SOL', symbol) AS fee_token_symbol, + fee_token_mint_address AS fee_token_address, + project, + version, + token_pair, + project_program_id AS project_contract_address, + trader_id AS user, + trades.tx_id, + tx_index, + outer_instruction_index, + inner_instruction_index + FROM + {{ ref('dex_solana_trades') }} AS trades + JOIN allFeePayments AS feePayments ON trades.tx_id = feePayments.tx_id + LEFT JOIN {{ source('prices', 'usd') }} AS feeTokenPrices ON ( + feeTokenPrices.blockchain = 'solana' + AND fee_token_mint_address = toBase58 (feeTokenPrices.contract_address) + AND date_trunc('minute', block_time) = minute + {% if is_incremental() %} + AND {{ incremental_predicate('minute') }} + {% else %} + AND minute >= TIMESTAMP '{{project_start_date}}' + {% endif %} + ) + JOIN {{ source('solana','transactions') }} AS transactions ON ( + trades.tx_id = id + {% if is_incremental() %} + AND {{ incremental_predicate('transactions.block_time') }} + {% else %} + AND transactions.block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + ) + WHERE + trades.trader_id != '{{fee_receiver_1}}' -- Exclude trades signed by FeeWallet + AND transactions.signer != '{{fee_receiver_1}}' -- Exclude trades signed by FeeWallet + {% if is_incremental() %} + AND {{ incremental_predicate('trades.block_time') }} + {% else %} + AND trades.block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + ), + highestInnerInstructionIndexForEachTrade AS ( + SELECT + tx_id, + outer_instruction_index, + MAX(inner_instruction_index) AS highestInnerInstructionIndex + FROM + botTrades + GROUP BY + tx_id, + outer_instruction_index + ) +SELECT + block_time, + block_date, + block_month, + 'Bitfoot' as bot, + blockchain, + amount_usd, + type, + token_bought_amount, + token_bought_symbol, + token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_address, + fee_usd, + fee_token_amount, + fee_token_symbol, + fee_token_address, + project, + version, + token_pair, + project_contract_address, + user, + botTrades.tx_id, + tx_index, + botTrades.outer_instruction_index, + COALESCE(inner_instruction_index, 0) AS inner_instruction_index, + IF( + inner_instruction_index = highestInnerInstructionIndex, + true, + false + ) AS is_last_trade_in_transaction +FROM + botTrades + JOIN highestInnerInstructionIndexForEachTrade ON ( + botTrades.tx_id = highestInnerInstructionIndexForEachTrade.tx_id + AND botTrades.outer_instruction_index = highestInnerInstructionIndexForEachTrade.outer_instruction_index + ) +ORDER BY + block_time DESC, + tx_index DESC, + outer_instruction_index DESC, + inner_instruction_index DESC diff --git a/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/cswap_solana_bot_trades.sql b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/cswap_solana_bot_trades.sql new file mode 100644 index 00000000000..22c84a1da47 --- /dev/null +++ b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/cswap_solana_bot_trades.sql @@ -0,0 +1,152 @@ +{{ config( + alias = 'bot_trades', + schema = 'cswap', + partition_by = ['block_month'], + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], + unique_key = ['blockchain', 'tx_id', 'tx_index', 'outer_instruction_index', 'inner_instruction_index'] + ) +}} + +{% set project_start_date = '2024-12-06' %} +{% set fee_receiver_1 = 'CSWAP5SpPcVjvpsA1H2n2HjNjMsRaPnZuX8H8bVJN5wy' %} +{% set wsol_token = 'So11111111111111111111111111111111111111112' %} + +WITH + allFeePayments AS ( + SELECT + tx_id, + 'SOL' AS feeTokenType, + balance_change / 1e9 AS fee_token_amount, + '{{wsol_token}}' AS fee_token_mint_address + FROM + {{ source('solana','account_activity') }} + WHERE + {% if is_incremental() %} + {{ incremental_predicate('block_time') }} + {% else %} + block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + AND tx_success + AND balance_change > 0 + AND ( + address = '{{fee_receiver_1}}' + ) + ), + botTrades AS ( + SELECT + trades.block_time, + CAST(date_trunc('day', trades.block_time) AS date) AS block_date, + CAST(date_trunc('month', trades.block_time) AS date) AS block_month, + 'solana' AS blockchain, + amount_usd, + IF( + token_sold_mint_address = '{{wsol_token}}', + 'Buy', + 'Sell' + ) AS type, + token_bought_amount, + token_bought_symbol, + token_bought_mint_address AS token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_mint_address AS token_sold_address, + fee_token_amount * price AS fee_usd, + fee_token_amount, + IF(feeTokenType = 'SOL', 'SOL', symbol) AS fee_token_symbol, + fee_token_mint_address AS fee_token_address, + project, + version, + token_pair, + project_program_id AS project_contract_address, + trader_id AS user, + trades.tx_id, + tx_index, + outer_instruction_index, + inner_instruction_index + FROM + {{ ref('dex_solana_trades') }} AS trades + JOIN allFeePayments AS feePayments ON trades.tx_id = feePayments.tx_id + LEFT JOIN {{ source('prices', 'usd') }} AS feeTokenPrices ON ( + feeTokenPrices.blockchain = 'solana' + AND fee_token_mint_address = toBase58 (feeTokenPrices.contract_address) + AND date_trunc('minute', block_time) = minute + {% if is_incremental() %} + AND {{ incremental_predicate('minute') }} + {% else %} + AND minute >= TIMESTAMP '{{project_start_date}}' + {% endif %} + ) + JOIN {{ source('solana','transactions') }} AS transactions ON ( + trades.tx_id = id + {% if is_incremental() %} + AND {{ incremental_predicate('transactions.block_time') }} + {% else %} + AND transactions.block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + ) + WHERE + trades.trader_id != '{{fee_receiver_1}}' -- Exclude trades signed by FeeWallet + AND transactions.signer != '{{fee_receiver_1}}' -- Exclude trades signed by FeeWallet + {% if is_incremental() %} + AND {{ incremental_predicate('trades.block_time') }} + {% else %} + AND trades.block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + ), + highestInnerInstructionIndexForEachTrade AS ( + SELECT + tx_id, + outer_instruction_index, + MAX(inner_instruction_index) AS highestInnerInstructionIndex + FROM + botTrades + GROUP BY + tx_id, + outer_instruction_index + ) +SELECT + block_time, + block_date, + block_month, + 'ChainSwap' as bot, + blockchain, + amount_usd, + type, + token_bought_amount, + token_bought_symbol, + token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_address, + fee_usd, + fee_token_amount, + fee_token_symbol, + fee_token_address, + project, + version, + token_pair, + project_contract_address, + user, + botTrades.tx_id, + tx_index, + botTrades.outer_instruction_index, + COALESCE(inner_instruction_index, 0) AS inner_instruction_index, + IF( + inner_instruction_index = highestInnerInstructionIndex, + true, + false + ) AS is_last_trade_in_transaction +FROM + botTrades + JOIN highestInnerInstructionIndexForEachTrade ON ( + botTrades.tx_id = highestInnerInstructionIndexForEachTrade.tx_id + AND botTrades.outer_instruction_index = highestInnerInstructionIndexForEachTrade.outer_instruction_index + ) +ORDER BY + block_time DESC, + tx_index DESC, + outer_instruction_index DESC, + inner_instruction_index DESC diff --git a/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/nova_solana_bot_trades.sql b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/nova_solana_bot_trades.sql new file mode 100644 index 00000000000..2508b0dfedc --- /dev/null +++ b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/nova_solana_bot_trades.sql @@ -0,0 +1,152 @@ +{{ config( + alias = 'bot_trades', + schema = 'nova_solana', + partition_by = ['block_month'], + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], + unique_key = ['blockchain', 'tx_id', 'tx_index', 'outer_instruction_index', 'inner_instruction_index'] + ) +}} + +{% set project_start_date = '2024-11-30' %} +{% set fee_receiver_1 = 'noVaE91mUL5jTb8e9Vf6dqJdNPzJpEQ3uAdnQ8h4nVz' %} +{% set wsol_token = 'So11111111111111111111111111111111111111112' %} + +WITH + allFeePayments AS ( + SELECT + tx_id, + 'SOL' AS feeTokenType, + balance_change / 1e9 AS fee_token_amount, + '{{wsol_token}}' AS fee_token_mint_address + FROM + {{ source('solana','account_activity') }} + WHERE + {% if is_incremental() %} + {{ incremental_predicate('block_time') }} + {% else %} + block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + AND tx_success + AND balance_change > 0 + AND ( + address = '{{fee_receiver_1}}' + ) + ), + botTrades AS ( + SELECT + trades.block_time, + CAST(date_trunc('day', trades.block_time) AS date) AS block_date, + CAST(date_trunc('month', trades.block_time) AS date) AS block_month, + 'solana' AS blockchain, + amount_usd, + IF( + token_sold_mint_address = '{{wsol_token}}', + 'Buy', + 'Sell' + ) AS type, + token_bought_amount, + token_bought_symbol, + token_bought_mint_address AS token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_mint_address AS token_sold_address, + fee_token_amount * price AS fee_usd, + fee_token_amount, + IF(feeTokenType = 'SOL', 'SOL', symbol) AS fee_token_symbol, + fee_token_mint_address AS fee_token_address, + project, + version, + token_pair, + project_program_id AS project_contract_address, + trader_id AS user, + trades.tx_id, + tx_index, + outer_instruction_index, + inner_instruction_index + FROM + {{ ref('dex_solana_trades') }} AS trades + JOIN allFeePayments AS feePayments ON trades.tx_id = feePayments.tx_id + LEFT JOIN {{ source('prices', 'usd') }} AS feeTokenPrices ON ( + feeTokenPrices.blockchain = 'solana' + AND fee_token_mint_address = toBase58 (feeTokenPrices.contract_address) + AND date_trunc('minute', block_time) = minute + {% if is_incremental() %} + AND {{ incremental_predicate('minute') }} + {% else %} + AND minute >= TIMESTAMP '{{project_start_date}}' + {% endif %} + ) + JOIN {{ source('solana','transactions') }} AS transactions ON ( + trades.tx_id = id + {% if is_incremental() %} + AND {{ incremental_predicate('transactions.block_time') }} + {% else %} + AND transactions.block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + ) + WHERE + trades.trader_id != '{{fee_receiver_1}}' -- Exclude trades signed by FeeWallet + AND transactions.signer != '{{fee_receiver_1}}' -- Exclude trades signed by FeeWallet + {% if is_incremental() %} + AND {{ incremental_predicate('trades.block_time') }} + {% else %} + AND trades.block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + ), + highestInnerInstructionIndexForEachTrade AS ( + SELECT + tx_id, + outer_instruction_index, + MAX(inner_instruction_index) AS highestInnerInstructionIndex + FROM + botTrades + GROUP BY + tx_id, + outer_instruction_index + ) +SELECT + block_time, + block_date, + block_month, + 'Nova' as bot, + blockchain, + amount_usd, + type, + token_bought_amount, + token_bought_symbol, + token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_address, + fee_usd, + fee_token_amount, + fee_token_symbol, + fee_token_address, + project, + version, + token_pair, + project_contract_address, + user, + botTrades.tx_id, + tx_index, + botTrades.outer_instruction_index, + COALESCE(inner_instruction_index, 0) AS inner_instruction_index, + IF( + inner_instruction_index = highestInnerInstructionIndex, + true, + false + ) AS is_last_trade_in_transaction +FROM + botTrades + JOIN highestInnerInstructionIndexForEachTrade ON ( + botTrades.tx_id = highestInnerInstructionIndexForEachTrade.tx_id + AND botTrades.outer_instruction_index = highestInnerInstructionIndexForEachTrade.outer_instruction_index + ) +ORDER BY + block_time DESC, + tx_index DESC, + outer_instruction_index DESC, + inner_instruction_index DESC diff --git a/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/prophetbots_solana_bot_trades.sql b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/prophetbots_solana_bot_trades.sql new file mode 100644 index 00000000000..c52feb51754 --- /dev/null +++ b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/prophetbots_solana_bot_trades.sql @@ -0,0 +1,154 @@ +{{ config( + alias = 'bot_trades', + schema = 'prophetbots_solana', + partition_by = ['block_month'], + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], + unique_key = ['blockchain', 'tx_id', 'tx_index', 'outer_instruction_index', 'inner_instruction_index'] + ) +}} + +{% set project_start_date = '2024-12-02' %} +{% set fee_receiver_1 = '55vkTc7nZoUQM92AfQG7T8bkNKD4TbWeBPRg8KjyUZre' %} -- TeamFeeWallet +{% set fee_receiver_2 = 'Hgckz7Sv8Q5grhLXxDFXGaJD6StPE7Yu8gz611nn1wKS' %} -- RevshareFeeWallet +{% set wsol_token = 'So11111111111111111111111111111111111111112' %} + +WITH + allFeePayments AS ( + SELECT + tx_id, + 'SOL' AS feeTokenType, + sum(balance_change) / 1e9 AS fee_token_amount, + '{{wsol_token}}' AS fee_token_mint_address + FROM + {{ source('solana','account_activity') }} + WHERE + {% if is_incremental() %} + {{ incremental_predicate('block_time') }} + {% else %} + block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + AND tx_success + AND balance_change > 0 + AND (address = '{{fee_receiver_1}}' OR address = '{{fee_receiver_2}}') + GROUP BY tx_id + ), + botTrades AS ( + SELECT + trades.block_time, + CAST(date_trunc('day', trades.block_time) AS date) AS block_date, + CAST(date_trunc('month', trades.block_time) AS date) AS block_month, + 'solana' AS blockchain, + amount_usd, + IF( + token_sold_mint_address = '{{wsol_token}}', + 'Buy', + 'Sell' + ) AS type, + token_bought_amount, + token_bought_symbol, + token_bought_mint_address AS token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_mint_address AS token_sold_address, + fee_token_amount * price AS fee_usd, + fee_token_amount, + IF(feeTokenType = 'SOL', 'SOL', symbol) AS fee_token_symbol, + fee_token_mint_address AS fee_token_address, + project, + version, + token_pair, + project_program_id AS project_contract_address, + trader_id AS user, + trades.tx_id, + tx_index, + outer_instruction_index, + inner_instruction_index + FROM + {{ ref('dex_solana_trades') }} AS trades + JOIN allFeePayments AS feePayments ON trades.tx_id = feePayments.tx_id + LEFT JOIN {{ source('prices', 'usd') }} AS feeTokenPrices ON ( + feeTokenPrices.blockchain = 'solana' + AND fee_token_mint_address = toBase58 (feeTokenPrices.contract_address) + AND date_trunc('minute', block_time) = minute + {% if is_incremental() %} + AND {{ incremental_predicate('minute') }} + {% else %} + AND minute >= TIMESTAMP '{{project_start_date}}' + {% endif %} + ) + JOIN {{ source('solana','transactions') }} AS transactions ON ( + trades.tx_id = id + {% if is_incremental() %} + AND {{ incremental_predicate('transactions.block_time') }} + {% else %} + AND transactions.block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + ) + WHERE + trades.trader_id != '{{fee_receiver_1}}' -- Exclude trades signed by FeeWallet + AND trades.trader_id != '{{fee_receiver_2}}' -- Exclude trades signed by FeeWallet + AND transactions.signer != '{{fee_receiver_1}}' -- Exclude trades signed by FeeWallet + AND transactions.signer != '{{fee_receiver_2}}' -- Exclude trades signed by FeeWallet + {% if is_incremental() %} + AND {{ incremental_predicate('trades.block_time') }} + {% else %} + AND trades.block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + ), + highestInnerInstructionIndexForEachTrade AS ( + SELECT + tx_id, + outer_instruction_index, + MAX(inner_instruction_index) AS highestInnerInstructionIndex + FROM + botTrades + GROUP BY + tx_id, + outer_instruction_index + ) +SELECT + block_time, + block_date, + block_month, + 'ProphetBots' as bot, + blockchain, + amount_usd, + type, + token_bought_amount, + token_bought_symbol, + token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_address, + fee_usd, + fee_token_amount, + fee_token_symbol, + fee_token_address, + project, + version, + token_pair, + project_contract_address, + user, + botTrades.tx_id, + tx_index, + botTrades.outer_instruction_index, + COALESCE(inner_instruction_index, 0) AS inner_instruction_index, + IF( + inner_instruction_index = highestInnerInstructionIndex, + true, + false + ) AS is_last_trade_in_transaction +FROM + botTrades + JOIN highestInnerInstructionIndexForEachTrade ON ( + botTrades.tx_id = highestInnerInstructionIndexForEachTrade.tx_id + AND botTrades.outer_instruction_index = highestInnerInstructionIndexForEachTrade.outer_instruction_index + ) +ORDER BY + block_time DESC, + tx_index DESC, + outer_instruction_index DESC, + inner_instruction_index DESC diff --git a/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/sanji_solana_bot_trades.sql b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/sanji_solana_bot_trades.sql new file mode 100644 index 00000000000..03cc106c17b --- /dev/null +++ b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/sanji_solana_bot_trades.sql @@ -0,0 +1,152 @@ +{{ config( + alias = 'bot_trades', + schema = 'sanji_solana', + partition_by = ['block_month'], + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], + unique_key = ['blockchain', 'tx_id', 'tx_index', 'outer_instruction_index', 'inner_instruction_index'] + ) +}} + +{% set project_start_date = '2024-11-21' %} +{% set fee_receiver_1 = '4E64WX4EARRMfHsvL4ZXbrbpiPcBUyrC62uawGofhdNN' %} +{% set wsol_token = 'So11111111111111111111111111111111111111112' %} + +WITH + allFeePayments AS ( + SELECT + tx_id, + 'SOL' AS feeTokenType, + balance_change / 1e9 AS fee_token_amount, + '{{wsol_token}}' AS fee_token_mint_address + FROM + {{ source('solana','account_activity') }} + WHERE + {% if is_incremental() %} + {{ incremental_predicate('block_time') }} + {% else %} + block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + AND tx_success + AND balance_change > 0 + AND ( + address = '{{fee_receiver_1}}' + ) + ), + botTrades AS ( + SELECT + trades.block_time, + CAST(date_trunc('day', trades.block_time) AS date) AS block_date, + CAST(date_trunc('month', trades.block_time) AS date) AS block_month, + 'solana' AS blockchain, + amount_usd, + IF( + token_sold_mint_address = '{{wsol_token}}', + 'Buy', + 'Sell' + ) AS type, + token_bought_amount, + token_bought_symbol, + token_bought_mint_address AS token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_mint_address AS token_sold_address, + fee_token_amount * price AS fee_usd, + fee_token_amount, + IF(feeTokenType = 'SOL', 'SOL', symbol) AS fee_token_symbol, + fee_token_mint_address AS fee_token_address, + project, + version, + token_pair, + project_program_id AS project_contract_address, + trader_id AS user, + trades.tx_id, + tx_index, + outer_instruction_index, + inner_instruction_index + FROM + {{ ref('dex_solana_trades') }} AS trades + JOIN allFeePayments AS feePayments ON trades.tx_id = feePayments.tx_id + LEFT JOIN {{ source('prices', 'usd') }} AS feeTokenPrices ON ( + feeTokenPrices.blockchain = 'solana' + AND fee_token_mint_address = toBase58 (feeTokenPrices.contract_address) + AND date_trunc('minute', block_time) = minute + {% if is_incremental() %} + AND {{ incremental_predicate('minute') }} + {% else %} + AND minute >= TIMESTAMP '{{project_start_date}}' + {% endif %} + ) + JOIN {{ source('solana','transactions') }} AS transactions ON ( + trades.tx_id = id + {% if is_incremental() %} + AND {{ incremental_predicate('transactions.block_time') }} + {% else %} + AND transactions.block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + ) + WHERE + trades.trader_id != '{{fee_receiver_1}}' -- Exclude trades signed by FeeWallet + AND transactions.signer != '{{fee_receiver_1}}' -- Exclude trades signed by FeeWallet + {% if is_incremental() %} + AND {{ incremental_predicate('trades.block_time') }} + {% else %} + AND trades.block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + ), + highestInnerInstructionIndexForEachTrade AS ( + SELECT + tx_id, + outer_instruction_index, + MAX(inner_instruction_index) AS highestInnerInstructionIndex + FROM + botTrades + GROUP BY + tx_id, + outer_instruction_index + ) +SELECT + block_time, + block_date, + block_month, + 'Sanji' as bot, + blockchain, + amount_usd, + type, + token_bought_amount, + token_bought_symbol, + token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_address, + fee_usd, + fee_token_amount, + fee_token_symbol, + fee_token_address, + project, + version, + token_pair, + project_contract_address, + user, + botTrades.tx_id, + tx_index, + botTrades.outer_instruction_index, + COALESCE(inner_instruction_index, 0) AS inner_instruction_index, + IF( + inner_instruction_index = highestInnerInstructionIndex, + true, + false + ) AS is_last_trade_in_transaction +FROM + botTrades + JOIN highestInnerInstructionIndexForEachTrade ON ( + botTrades.tx_id = highestInnerInstructionIndexForEachTrade.tx_id + AND botTrades.outer_instruction_index = highestInnerInstructionIndexForEachTrade.outer_instruction_index + ) +ORDER BY + block_time DESC, + tx_index DESC, + outer_instruction_index DESC, + inner_instruction_index DESC diff --git a/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/tradewiz_solana_bot_trades.sql b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/tradewiz_solana_bot_trades.sql new file mode 100644 index 00000000000..5227bed50b8 --- /dev/null +++ b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/tradewiz_solana_bot_trades.sql @@ -0,0 +1,152 @@ +{{ config( + alias = 'bot_trades', + schema = 'tradewiz', + partition_by = ['block_month'], + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], + unique_key = ['blockchain', 'tx_id', 'tx_index', 'outer_instruction_index', 'inner_instruction_index'] + ) +}} + +{% set project_start_date = '2024-11-27' %} +{% set fee_receiver_1 = '97VmzkjX9w8gMFS2RnHTSjtMEDbifGXBq9pgosFdFnM' %} +{% set wsol_token = 'So11111111111111111111111111111111111111112' %} + +WITH + allFeePayments AS ( + SELECT + tx_id, + 'SOL' AS feeTokenType, + balance_change / 1e9 AS fee_token_amount, + '{{wsol_token}}' AS fee_token_mint_address + FROM + {{ source('solana','account_activity') }} + WHERE + {% if is_incremental() %} + {{ incremental_predicate('block_time') }} + {% else %} + block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + AND tx_success + AND balance_change > 0 + AND ( + address = '{{fee_receiver_1}}' + ) + ), + botTrades AS ( + SELECT + trades.block_time, + CAST(date_trunc('day', trades.block_time) AS date) AS block_date, + CAST(date_trunc('month', trades.block_time) AS date) AS block_month, + 'solana' AS blockchain, + amount_usd, + IF( + token_sold_mint_address = '{{wsol_token}}', + 'Buy', + 'Sell' + ) AS type, + token_bought_amount, + token_bought_symbol, + token_bought_mint_address AS token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_mint_address AS token_sold_address, + fee_token_amount * price AS fee_usd, + fee_token_amount, + IF(feeTokenType = 'SOL', 'SOL', symbol) AS fee_token_symbol, + fee_token_mint_address AS fee_token_address, + project, + version, + token_pair, + project_program_id AS project_contract_address, + trader_id AS user, + trades.tx_id, + tx_index, + outer_instruction_index, + inner_instruction_index + FROM + {{ ref('dex_solana_trades') }} AS trades + JOIN allFeePayments AS feePayments ON trades.tx_id = feePayments.tx_id + LEFT JOIN {{ source('prices', 'usd') }} AS feeTokenPrices ON ( + feeTokenPrices.blockchain = 'solana' + AND fee_token_mint_address = toBase58 (feeTokenPrices.contract_address) + AND date_trunc('minute', block_time) = minute + {% if is_incremental() %} + AND {{ incremental_predicate('minute') }} + {% else %} + AND minute >= TIMESTAMP '{{project_start_date}}' + {% endif %} + ) + JOIN {{ source('solana','transactions') }} AS transactions ON ( + trades.tx_id = id + {% if is_incremental() %} + AND {{ incremental_predicate('transactions.block_time') }} + {% else %} + AND transactions.block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + ) + WHERE + trades.trader_id != '{{fee_receiver_1}}' -- Exclude trades signed by FeeWallet + AND transactions.signer != '{{fee_receiver_1}}' -- Exclude trades signed by FeeWallet + {% if is_incremental() %} + AND {{ incremental_predicate('trades.block_time') }} + {% else %} + AND trades.block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + ), + highestInnerInstructionIndexForEachTrade AS ( + SELECT + tx_id, + outer_instruction_index, + MAX(inner_instruction_index) AS highestInnerInstructionIndex + FROM + botTrades + GROUP BY + tx_id, + outer_instruction_index + ) +SELECT + block_time, + block_date, + block_month, + 'Tradewiz' as bot, + blockchain, + amount_usd, + type, + token_bought_amount, + token_bought_symbol, + token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_address, + fee_usd, + fee_token_amount, + fee_token_symbol, + fee_token_address, + project, + version, + token_pair, + project_contract_address, + user, + botTrades.tx_id, + tx_index, + botTrades.outer_instruction_index, + COALESCE(inner_instruction_index, 0) AS inner_instruction_index, + IF( + inner_instruction_index = highestInnerInstructionIndex, + true, + false + ) AS is_last_trade_in_transaction +FROM + botTrades + JOIN highestInnerInstructionIndexForEachTrade ON ( + botTrades.tx_id = highestInnerInstructionIndexForEachTrade.tx_id + AND botTrades.outer_instruction_index = highestInnerInstructionIndexForEachTrade.outer_instruction_index + ) +ORDER BY + block_time DESC, + tx_index DESC, + outer_instruction_index DESC, + inner_instruction_index DESC diff --git a/dbt_subprojects/solana/models/_sector/dex/dex_solana_base_trades.sql b/dbt_subprojects/solana/models/_sector/dex/dex_solana_base_trades.sql index 41a99ad235b..d3dba42ca27 100644 --- a/dbt_subprojects/solana/models/_sector/dex/dex_solana_base_trades.sql +++ b/dbt_subprojects/solana/models/_sector/dex/dex_solana_base_trades.sql @@ -25,6 +25,8 @@ , ref('pumpdotfun_solana_base_trades') ] %} +-- excluded: , ref('sanctum_router_base_trades') + {% for dex in solana_dexes %} SELECT blockchain @@ -51,7 +53,7 @@ SELECT FROM {{ dex }} {% if is_incremental() %} -WHERE +WHERE {{incremental_predicate('block_time')}} {% endif %} {% if not loop.last %} diff --git a/dbt_subprojects/solana/models/_sector/dex/lifinity/lifinity_v1_base_trades.sql b/dbt_subprojects/solana/models/_sector/dex/lifinity/lifinity_v1_base_trades.sql index c5ac3d3a3ff..8c012e3a950 100644 --- a/dbt_subprojects/solana/models/_sector/dex/lifinity/lifinity_v1_base_trades.sql +++ b/dbt_subprojects/solana/models/_sector/dex/lifinity/lifinity_v1_base_trades.sql @@ -45,7 +45,7 @@ WITH order by COALESCE(tr_2.inner_instruction_index, 0) asc) as first_transfer_out FROM {{ source('lifinity_amm_solana', 'lifinity_amm_call_swap') }} sp INNER JOIN {{ ref('tokens_solana_transfers') }} tr_1 - ON tr_1.tx_id = sp.call_tx_id + ON tr_1.tx_id = sp.call_tx_id AND tr_1.action = 'transfer' AND tr_1.outer_instruction_index = sp.call_outer_instruction_index AND ((sp.call_is_inner = false AND tr_1.inner_instruction_index = 1) OR (sp.call_is_inner = true AND tr_1.inner_instruction_index = sp.call_inner_instruction_index + 1)) @@ -57,7 +57,7 @@ WITH {% endif %} --swap out can be either 2nd or 3rd transfer. INNER JOIN {{ ref('tokens_solana_transfers') }} tr_2 - ON tr_2.tx_id = sp.call_tx_id + ON tr_2.tx_id = sp.call_tx_id AND tr_2.action = 'transfer' AND tr_2.outer_instruction_index = sp.call_outer_instruction_index AND ((sp.call_is_inner = false AND (tr_2.inner_instruction_index = 2 OR tr_2.inner_instruction_index = 3)) OR (sp.call_is_inner = true AND (tr_2.inner_instruction_index = sp.call_inner_instruction_index + 2 OR tr_2.inner_instruction_index = sp.call_inner_instruction_index + 3)) diff --git a/dbt_subprojects/solana/models/_sector/dex/lifinity/lifinity_v2_base_trades.sql b/dbt_subprojects/solana/models/_sector/dex/lifinity/lifinity_v2_base_trades.sql index 49c39380a2a..8586e303b62 100644 --- a/dbt_subprojects/solana/models/_sector/dex/lifinity/lifinity_v2_base_trades.sql +++ b/dbt_subprojects/solana/models/_sector/dex/lifinity/lifinity_v2_base_trades.sql @@ -45,7 +45,7 @@ WITH order by COALESCE(tr_2.inner_instruction_index, 0) asc) as first_transfer_out FROM {{ source('lifinity_amm_v2_solana', 'lifinity_amm_v2_call_swap') }} sp INNER JOIN {{ ref('tokens_solana_transfers') }} tr_1 - ON tr_1.tx_id = sp.call_tx_id + ON tr_1.tx_id = sp.call_tx_id AND tr_1.action = 'transfer' AND tr_1.outer_instruction_index = sp.call_outer_instruction_index AND ((sp.call_is_inner = false AND tr_1.inner_instruction_index = 1) OR (sp.call_is_inner = true AND tr_1.inner_instruction_index = sp.call_inner_instruction_index + 1)) @@ -57,7 +57,7 @@ WITH {% endif %} --swap out can be either 2nd or 3rd transfer. INNER JOIN {{ ref('tokens_solana_transfers') }} tr_2 - ON tr_2.tx_id = sp.call_tx_id + ON tr_2.tx_id = sp.call_tx_id AND tr_2.action = 'transfer' AND tr_2.outer_instruction_index = sp.call_outer_instruction_index AND ((sp.call_is_inner = false AND (tr_2.inner_instruction_index = 2 OR tr_2.inner_instruction_index = 3)) OR (sp.call_is_inner = true AND (tr_2.inner_instruction_index = sp.call_inner_instruction_index + 2 OR tr_2.inner_instruction_index = sp.call_inner_instruction_index + 3)) diff --git a/dbt_subprojects/solana/models/_sector/dex/sanctum_router/sanctum_router_base_trades.sql b/dbt_subprojects/solana/models/_sector/dex/sanctum_router/sanctum_router_base_trades.sql new file mode 100644 index 00000000000..c7de77c37c3 --- /dev/null +++ b/dbt_subprojects/solana/models/_sector/dex/sanctum_router/sanctum_router_base_trades.sql @@ -0,0 +1,204 @@ +{{ + config( + schema = 'sanctum_router', + tags = ['prod_exclude'], + alias = 'base_trades', + partition_by = ['block_month'], + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], + unique_key = ['tx_id', 'outer_instruction_index', 'inner_instruction_index', 'tx_index','block_month'], + pre_hook='{{ enforce_join_distribution("PARTITIONED") }}' + ) +}} + +{% set project_start_date = '2023-02-03' %} +{% set dev_start_date = "date_trunc('day', now() - interval '7' day)" %} + +WITH swap_via_stake AS ( + SELECT + call_block_time as block_time + , call_block_slot as block_slot + , call_tx_signer as trader_id + , call_tx_id as tx_id + , call_outer_instruction_index as outer_instruction_index + , COALESCE(call_inner_instruction_index, 0) as inner_instruction_index + , call_tx_index as tx_index + , account_srcTokenFrom as token_sold_vault + , account_destTokenTo as token_bought_vault + , account_srcTokenMint as token_sold_mint_address + , account_destTokenMint as token_bought_mint_address + , bytearray_to_bigint(bytearray_reverse(bytearray_substring(call_data, 2, 8))) AS token_sold_amount_raw + , CASE + WHEN call_outer_executing_account = 'stkitrT1Uoy18Dk1fTrgPw8W6MVzoCfYoAFT4MLsmhq' THEN 'direct' + ELSE call_outer_executing_account + END as trade_source + , 'mintTo' as amount_type + FROM {{ source('sanctum_router_solana', 'stakedex_call_SwapViaStake') }} + WHERE 1=1 + {% if is_incremental() %} + AND {{incremental_predicate('call_block_time')}} + {% else %} + AND call_block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} +), + +prefund_swap_via_stake AS ( + SELECT + call_block_time as block_time + , call_block_slot as block_slot + , call_tx_signer as trader_id + , call_tx_id as tx_id + , call_outer_instruction_index as outer_instruction_index + , COALESCE(call_inner_instruction_index, 0) as inner_instruction_index + , call_tx_index as tx_index + , account_srcTokenFrom as token_sold_vault + , account_destTokenTo as token_bought_vault + , account_srcTokenMint as token_sold_mint_address + , account_destTokenMint as token_bought_mint_address + , bytearray_to_bigint(bytearray_reverse(bytearray_substring(call_data, 2, 8))) AS token_sold_amount_raw + , CASE + WHEN call_outer_executing_account = 'stkitrT1Uoy18Dk1fTrgPw8W6MVzoCfYoAFT4MLsmhq' THEN 'direct' + ELSE call_outer_executing_account + END as trade_source + , 'transferChecked' as amount_type + FROM {{ source('sanctum_router_solana', 'stakedex_call_PrefundSwapViaStake') }} + WHERE 1=1 + {% if is_incremental() %} + AND {{incremental_predicate('call_block_time')}} + {% else %} + AND call_block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} +), + +stake_wrapped_sol AS ( + SELECT + call_block_time as block_time + , call_block_slot as block_slot + , call_tx_signer as trader_id + , call_tx_id as tx_id + , call_outer_instruction_index as outer_instruction_index + , COALESCE(call_inner_instruction_index, 0) as inner_instruction_index + , call_tx_index as tx_index + , account_wsolFrom as token_sold_vault + , account_destTokenTo as token_bought_vault + , account_wsolMint as token_sold_mint_address + , account_destTokenMint as token_bought_mint_address + , bytearray_to_bigint(bytearray_reverse(bytearray_substring(call_data, 2, 8))) AS token_sold_amount_raw + , CASE + WHEN call_outer_executing_account = 'stkitrT1Uoy18Dk1fTrgPw8W6MVzoCfYoAFT4MLsmhq' THEN 'direct' + ELSE call_outer_executing_account + END as trade_source + , 'transferChecked' as amount_type + FROM {{ source('sanctum_router_solana', 'stakedex_call_StakeWrappedSol') }} + WHERE 1=1 + {% if is_incremental() %} + AND {{incremental_predicate('call_block_time')}} + {% else %} + AND call_block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} +), + +withdraw_deposit AS ( + SELECT + w.call_block_time as block_time + , w.call_block_slot as block_slot + , w.call_tx_signer as trader_id + , w.call_tx_id as tx_id + , w.call_outer_instruction_index as outer_instruction_index + , COALESCE(w.call_inner_instruction_index, 0) as inner_instruction_index + , w.call_tx_index as tx_index + , w.account_srcTokenFrom as token_sold_vault + , d.account_destTokenTo as token_bought_vault + , w.account_srcTokenMint as token_sold_mint_address + , d.account_destTokenMint as token_bought_mint_address + , bytearray_to_bigint(bytearray_reverse(bytearray_substring(w.call_data, 2, 8))) AS token_sold_amount_raw + , CASE + WHEN w.call_outer_executing_account = 'stkitrT1Uoy18Dk1fTrgPw8W6MVzoCfYoAFT4MLsmhq' THEN 'direct' + ELSE w.call_outer_executing_account + END as trade_source + , 'transferChecked' as amount_type + FROM {{ source('sanctum_router_solana', 'stakedex_call_PrefundWithdrawStake') }} w + INNER JOIN {{ source('sanctum_router_solana', 'stakedex_call_DepositStake') }} d + ON w.call_tx_id = d.call_tx_id + AND w.call_outer_instruction_index = d.call_outer_instruction_index + AND w.call_inner_instruction_index < d.call_inner_instruction_index + WHERE 1=1 + {% if is_incremental() %} + AND {{incremental_predicate('w.call_block_time')}} + {% else %} + AND w.call_block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} +), + +all_trades AS ( + SELECT * FROM swap_via_stake + UNION ALL + SELECT * FROM prefund_swap_via_stake + UNION ALL + SELECT * FROM stake_wrapped_sol + UNION ALL + SELECT * FROM withdraw_deposit +), + +token_amounts AS ( + SELECT + ic.tx_id, + ic.outer_instruction_index, + ic.inner_instruction_index, + bytearray_to_bigint(bytearray_reverse(bytearray_substring(ic.data, 2, 8))) AS amount_bought, + ROW_NUMBER() OVER ( + PARTITION BY ic.tx_id, ic.outer_instruction_index + ORDER BY + CASE + WHEN b.amount_type = 'mintTo' THEN ic.inner_instruction_index + ELSE -ic.inner_instruction_index + END + ) as rn + FROM all_trades b + INNER JOIN {{ source('solana','instruction_calls') }} ic + ON ic.tx_id = b.tx_id + AND ic.outer_instruction_index = b.outer_instruction_index + AND ic.block_slot = b.block_slot + WHERE 1=1 + AND ic.executing_account = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' + AND ( + (b.amount_type = 'mintTo' AND bytearray_substring(ic.data, 1, 1) = 0x07 AND ELEMENT_AT(ic.account_arguments, 1) = b.token_bought_mint_address) + OR + (b.amount_type = 'transferChecked' AND bytearray_substring(ic.data, 1, 1) = 0x0c AND ELEMENT_AT(ic.account_arguments, 2) = b.token_bought_mint_address AND ELEMENT_AT(ic.account_arguments, 3) = b.token_bought_vault) + ) + {% if is_incremental() %} + AND {{incremental_predicate('ic.block_time')}} + {% else %} + AND ic.block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} +) + +SELECT + 'solana' as blockchain + , 'sanctum_router' as project + , 1 as version + , CAST(date_trunc('month', b.block_time) AS DATE) as block_month + , b.block_time + , b.block_slot + , b.trade_source + , CAST(t.amount_bought as uint256) as token_bought_amount_raw + , CAST(b.token_sold_amount_raw as uint256) as token_sold_amount_raw + , CAST(NULL as double) as fee_tier + , b.token_bought_mint_address + , b.token_sold_mint_address + , b.token_bought_vault + , b.token_sold_vault + , CAST(NULL as varchar) as project_program_id + , 'stkitrT1Uoy18Dk1fTrgPw8W6MVzoCfYoAFT4MLsmhq' as project_main_id + , b.trader_id + , b.tx_id + , CAST(b.outer_instruction_index as integer) as outer_instruction_index + , CAST(b.inner_instruction_index as integer) as inner_instruction_index + , b.tx_index +FROM all_trades b +INNER JOIN token_amounts t + ON b.tx_id = t.tx_id + AND b.outer_instruction_index = t.outer_instruction_index + AND t.rn = 1 diff --git a/dbt_subprojects/solana/models/_sector/dex/sanctum_router/sanctum_router_trades.sql b/dbt_subprojects/solana/models/_sector/dex/sanctum_router/sanctum_router_trades.sql new file mode 100644 index 00000000000..9580d25e6c4 --- /dev/null +++ b/dbt_subprojects/solana/models/_sector/dex/sanctum_router/sanctum_router_trades.sql @@ -0,0 +1,14 @@ + {{ + config( + schema = 'sanctum_router', + alias = 'trades', + post_hook='{{ expose_spells(\'["solana"]\', + "project", + "sanctum_router", + \'["senyor-kodi"]\') }}' + ) +}} + +-- backwards compatible view so we don't break any user queries +select * from {{ref('dex_solana_trades')}} +where project = 'sanctum_router' and version = 1 \ No newline at end of file diff --git a/dbt_subprojects/solana/models/_sector/dex/sanctum_router/schema.yml b/dbt_subprojects/solana/models/_sector/dex/sanctum_router/schema.yml new file mode 100644 index 00000000000..65523f108c0 --- /dev/null +++ b/dbt_subprojects/solana/models/_sector/dex/sanctum_router/schema.yml @@ -0,0 +1,92 @@ +version: 2 + +models: + - name: sanctum_router_base_trades + meta: + blockchain: solana + sector: dex + project: sanctum + contributors: [ senyor-kodi ] + config: + tags: ['solana','dex'] + description: > + Sanctum Router trades on Solana + data_tests: + - check_columns_solana_dex_trades + - dbt_utils.unique_combination_of_columns: + combination_of_columns: [ 'tx_id', 'outer_instruction_index', 'inner_instruction_index', 'tx_index', 'block_month' ] + + - name: sanctum_router_trades + meta: + blockchain: solana + sector: dex + project: sanctum + contributors: [ senyor-kodi ] + config: + tags: ['solana','dex'] + description: > + Sanctum Router trades on Solana + columns: + - &blockchain + name: blockchain + description: "Blockchain which the DEX is deployed" + - &project + name: project + description: "Project name of the DEX" + - &version + name: version + description: "Version of the contract built and deployed by the DEX project" + - &block_month + name: block_month + description: "UTC event block month of each DEX trade" + - &block_time + name: block_time + description: "UTC event block time of each DEX trade" + - &block_slot + name: block_slot + description: "block slot of each DEX trade" + - &trade_source + name: trade_source + description: "Was the trade a direct call to the dexor did it go through another program like Jupiter (Dex Aggregator)" + - &token_bought_amount_raw + name: token_bought_amount_raw + description: "Raw value of the token bought at time of execution in the original currency" + - &token_sold_amount_raw + name: token_sold_amount_raw + description: "Raw value of the token sold at time of execution in the original currency" + - &fee_tier + name: fee_tier + description: "dexfee tier (fee %)" + - &token_bought_mint_address + name: token_bought_address + description: "token mint address of the token bought" + - &token_sold_mint_address + name: token_sold_address + description: "token mint address of the token sold" + - &token_bought_vault + name: token_bought_vault + description: "token associated address for thedex, of the token bought" + - &token_sold_vault + name: token_sold_vault + description: "token associated address for thedex, of the token sold" + - &project_program_id + name: project_program_id + description: "pool program id of the project" + - &project_main_id + name: project_main_id + description: "main program id of the project" + - &trader_id + name: trader_id + description: "id (address) of trader who purchased a token" + - &tx_id + name: tx_id + description: "Unique transaction id value tied to each transaction on the DEX" + - &outer_instruction_index + name: outer_instruction_index + description: "top level instruction index for a given transaction id" + - &inner_instruction_index + name: inner_instruction_index + description: "inner instruction index for a given transaction id" + - &tx_index + name: tx_index + description: "index of the transaction in the block slot" \ No newline at end of file diff --git a/dbt_subprojects/solana/models/_sector/dex/sanctum_router/sources.yml b/dbt_subprojects/solana/models/_sector/dex/sanctum_router/sources.yml new file mode 100644 index 00000000000..9814e5d2ceb --- /dev/null +++ b/dbt_subprojects/solana/models/_sector/dex/sanctum_router/sources.yml @@ -0,0 +1,19 @@ +version: 2 + +sources: + - name: sanctum_router_solana + description: "Sanctum Router decoded contract calls on Solana" + freshness: # default freshness + warn_after: { count: 12, period: hour } + error_after: { count: 24, period: hour } + tables: + - name: stakedex_call_SwapViaStake + loaded_at_field: call_block_time + - name: stakedex_call_PrefundSwapViaStake + loaded_at_field: call_block_time + - name: stakedex_call_StakeWrappedSol + loaded_at_field: call_block_time + - name: stakedex_call_PrefundWithdrawStake + loaded_at_field: call_block_time + - name: stakedex_call_DepositStake + loaded_at_field: call_block_time diff --git a/dbt_subprojects/solana/seeds/bitfoot/bitfoot_solana_trades_seed.csv b/dbt_subprojects/solana/seeds/bitfoot/bitfoot_solana_trades_seed.csv new file mode 100644 index 00000000000..2dfe16fe5fe --- /dev/null +++ b/dbt_subprojects/solana/seeds/bitfoot/bitfoot_solana_trades_seed.csv @@ -0,0 +1,21 @@ +block_time,block_date,block_month,bot,blockchain,amount_usd,type,token_bought_amount,token_bought_symbol,token_bought_address,token_sold_amount,token_sold_symbol,token_sold_address,fee_usd,fee_token_amount,fee_token_symbol,fee_token_address,project,version,token_pair,project_contract_address,user,tx_id,tx_index,outer_instruction_index,inner_instruction_index,is_last_trade_in_transaction +2024-11-27 11:39:41.000 UTC,2024-11-27,2024-11-01,Bitfoot,solana,11.689425,Buy,709.813803,Aejo,B16bhVYwE9zQVjbYpnnmvfN7qJFDe21nx5iQC5LJpump,0.0495,SOL,So11111111111111111111111111111111111111112,0.078519875,0.0003325,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-Aejo,7tdNR3TNw13wGDz2PBynb9T6t39oskvzNiTvKCnVN4bw,HZidTvr4nRwhPBJvSb842rtBsedtigFWPMfwZfUSWsA7,52E6dhvq1DCqdjqVAxqJ3CLaJd1qSDMUqAhAzyjB3Gx2U8XWHH3T9YkzzSfGv6YYF5ArePxEDwCpuGncJM3WQ3CU,1097,8,2,true +2024-11-28 04:22:56.000 UTC,2024-11-28,2024-11-01,Bitfoot,solana,6.04981532776,Sell,0.025230692,SOL,So11111111111111111111111111111111111111112,200.217182,TRIP,8JZ2R6dzfCeiAvcJ7H1G6hy8x5pBQryHZcWiVY2spump,0.03720642282,0.000155169,SOL,So11111111111111111111111111111111111111112,raydium,4,TRIP-SOL,58JdqNRYCQthSzKY1rZ9LzaK6UNkKhbQgN5kBtyEGoLL,4KsknATdHdgfU1Wi6kakxPRa2TDg4HCXfoc66b6JXp3M,3av3ivTmU1DZCHG7c5LSMzpg5g4o212opYZmuHDY6UEG5SVf1ZBmSVySZQequCwTTgGrgcu9PhB8PQYvZpbNcQzS,2297,6,1,true +2024-11-23 11:40:07.000 UTC,2024-11-23,2024-11-01,Bitfoot,solana,9.86582145959,Sell,0.038428783,SOL,So11111111111111111111111111111111111111112,1099.306621,Mustard,22Xeo6diWfJrScaoVFzgkwzrCByPukK45fdwkJyrpump,0.06560760823,0.000255551,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-Mustard,5JbknNv534djG9TeCUMpLevedino2c1WrYB9pqGkyqLe,3VGaybHr8dvZbfTjJrGPLC4WhFUwZgfzXMUHeiymmHRt,2pmYAXnT8hTQzwsfYKVprXvSqcy7aKYedE5AScecSgkngkKmoncXSfM8kwHCYNBgXpvM9ZsB2VS9oK29BABJKSd2,1347,6,1,true +2024-11-25 16:04:04.000 UTC,2024-11-25,2024-11-01,Bitfoot,solana,0.24297570000000002,Buy,17.043396,blob,DgG9sM56ZcVidBV8bNArQPm93a2rmjzHkrrUntGSpump,0.00099,SOL,So11111111111111111111111111111111111111112,0.0015093945000000002,0.00000615,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-blob,7Y3oLPPrBsXGNYNaZLmhRZExFChXP84z2w1oHBjHTwCa,qjmNJ3PrUjCipauKuVtL1wefYC2kP2qq7PpmUVJdunH,VK5kFKKoSwLTfoU2Ra8ygD1ysh3YbAuN8L34RFDQewdwRGtB7R11Sm9bEWCU3rgM4Ehaj7jRwFx4iM17DmB4AYd,329,8,2,true +2024-11-25 00:40:46.000 UTC,2024-11-25,2024-11-01,Bitfoot,solana,7.53405404689,Buy,737146.667049,FCOCK,D7g7pFmuK5SPwQSvPJHgmg83dDVkSQonGqLz87Lkpump,0.030055667,SOL,So11111111111111111111111111111111111111112,0.05111361836,0.000203908,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-FCOCK,3C2YwGLpG6JuKjYJ6NsWAg5HYj7TnuXpGiBTcJzX5VPf,GnHVcSJQCpfiYAid2Vd9B6X12AWavdfuLTz6oMTiqP1A,27nAYJAyFXV3FbrR7rj26F74C9WDhd8ULNxCdnuSsjLpDnTMrcyPANbmWXMqWER2L4B8qkz6XbgxnbqYXZQibXej,1477,4,5,true +2024-11-26 18:15:44.000 UTC,2024-11-26,2024-11-01,Bitfoot,solana,11.6310085968,Sell,0.05097072,SOL,So11111111111111111111111111111111111111112,361734.413897,EDNA,CKrqbYKSUD1NQT4UE2EzVGGJAatvu28u8Ko4RdXypump,0.07369418869,0.000322951,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-EDNA,AKfD3c7b9ZQx7PgxbYEVfECnPQSkP16UmsqywAJk1weN,JAZfgjSioeg9CBV6N8L2BWrvLbGrtY5xfbPwvvUYKuFV,QcLdxmZCdmMVn3giuGdCL8HVanXY5PUTGQ3aPVWU4wtASqmv3MxYxky1uvVFBM98Hgr12P9z5QWKdaaRJU51odB,841,4,3,true +2024-11-23 22:52:04.000 UTC,2024-11-23,2024-11-01,Bitfoot,solana,1.2420067715,Sell,0.00487157,SOL,So11111111111111111111111111111111111111112,167202.885023,WINDY,4F1PHzeTp83Vg9nPWiZRYUV8sYHfTLcCDvWc53TJpump,0.007869286699999999,0.000030866,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,WINDY-SOL,,14nXezfdCTFzJ65C5NBbPvVB13oCE5cH8sX38unVYor1,5A1aCmEo46dX248DsDP9uT8j1Qu5vv4BHD1uyzfedX1TtFTQEhF98WqmcJxWGnA1ccMW8xJXH9N8W7MoGfuGDGCT,472,4,3,true +2024-11-25 05:25:32.000 UTC,2024-11-25,2024-11-01,Bitfoot,solana,12.34330347028,Sell,0.048612908,SOL,So11111111111111111111111111111111111111112,4496.168468,HYPR∞,FEiphCSAqjAxvtyMxj8boFTABrZBFyngfyrZueqeMw3q,0.07591147270000001,0.00029897,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-HYPR∞,83j8apUzRtpZwPiEdr31TxyGpA1NRLouLXxLMX8DM2iS,DgGzDWQYitL241ejctUaKQmZCRWiepqP67rsJQw9perf,3WA2P1q3BPcnSECH7EzFYiG9PsLvu6FpLH1S9mAUvuRXXFmhHtgBhiKaDNzHuAere8cWj5eLFy7xVcQBxZmkWj9K,1152,6,1,true +2024-11-23 06:29:14.000 UTC,2024-11-23,2024-11-01,Bitfoot,solana,2.03463991424,Sell,0.007840012,SOL,So11111111111111111111111111111111111111112,34.959386,FATHA,EWWDzCwq4UYW3ERTXbdgd6X6sdkKHFMJqRz1ZiFcpump,0.013530334719999999,0.000052136,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-FATHA,Am1SqWAHhaKWS4H9uwHweeYxCaECR5yDYZiX1jD9RVMP,BperhBq7YoWvWDCQnQrcp55mD6kVDwJ2zQrdSmfwWxYY,3XcpyEkiGpWRLWRsSyyHjmgqHPFk1tL9ASoZcte8wNQK6vZ5mm7xZBPLZdrT3ocHxWa4PLrfFpbpgL16MjWSMuBk,312,6,1,true +2024-11-23 00:02:40.000 UTC,2024-11-23,2024-11-01,Bitfoot,solana,5.72728636454,Sell,0.022308598,SOL,So11111111111111111111111111111111111111112,1841.951928,LEA,8SpPaFLycx897D6sowPZkEkcNdDahzRZb5itr6D8pump,0.03522284254,0.000137198,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-LEA,4ZF5Dd2KzXFE6ECFpKjcNYh48Ee1UvqiBRsVXk8EBmyT,57HvLnB3QecbktLXvxftJ1dNQ1WXnWs3RaV4mQoMwidh,4p8F6VfbMKqm8YyPgGfy7u9focAihhaVDFEBHPV5dpYyXodHjSFpxwtiBQDavEmzTazzoZLM9w6yJZCesuCYp3Gs,259,6,1,true +2024-11-22 23:19:11.000 UTC,2024-11-22,2024-11-01,Bitfoot,solana,205.32150744042,Sell,0.804614419,SOL,So11111111111111111111111111111111111111112,8657386.523431,Print,2cTbxqtyGr8C18iUPF4ditpjTyQiD5FXFF89bw9epump,1.2501000261000002,0.004898895,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-Print,Dt3nPfcQkV5i3xJUSKwox69srxtLBz1UVa9MChurqsez,48D6W1Z2p9FjhcHZi5rSbHuAzbhNHU2w4HeWKneM9NSn,39aJjXEPv9Gu5vzsXCwuEJgZ3Fr9y3UQgkrmoPwMZhas6eJDRYB2JsicR6jEhjhiu5kzwXqb3VCCa7vn2pJGFa2g,1869,4,3,true +2024-11-23 20:12:47.000 UTC,2024-11-23,2024-11-01,Bitfoot,solana,17.04803946804,Sell,0.067060182,SOL,So11111111111111111111111111111111111111112,287334.915975,Wiki,DuEGP63NvXRN1SyonCjsNpdxypMFnYsAzeRJbV9pump,0.113369409,0.00044595,SOL,So11111111111111111111111111111111111111112,raydium,4,Wiki-SOL,69fDvj22wF9DcebHvoD9wMqiFp6ueEGvKtxWcb9esHpm,12ZGFLbq86ryeEfuoeC6T49bZkTUai2EstDx1m81sfnk,5bSHtWqepdHhU14Krbn6wSgW1NX8TXXzfWngXs8R7qPb7S9gzXKFSrLGz4o5ZAbinGpzg5HPX9U2c34aFQ9FSPe9,41,6,1,true +2024-11-26 21:58:56.000 UTC,2024-11-26,2024-11-01,Bitfoot,solana,2.2846230000000003,Buy,63236.629215,AOC,2auaVtspPBW6biCkNw25VhAWmc39CurFSwtf8zRhpump,0.0099,SOL,So11111111111111111111111111111111111111112,0.014192355000000002,0.0000615,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-AOC,7w5f9fJd7274ADWAsMJ37qe7fy5d3BjNm19X74M4dn45,8RoZvSFwX3zKMHSyKVQ5BwqgGPhfxoeptkgHQy8gi2Ec,3ndjZVkEThqeY8jLZ8hwp9HG7DhQwWxghn4Mup6KSyGmBTaBvaCrwZS8HqdLtAarTN4LW4QsT9BWP2HitweMHeDy,426,9,2,true +2024-11-26 21:45:44.000 UTC,2024-11-26,2024-11-01,Bitfoot,solana,0.9725261359999999,Sell,0.0042236,SOL,So11111111111111111111111111111111111111112,204.969806,JAK,FBbnzHwJ1WHYwP425cqMNb2t7o7sm6AXQjsQ3sZRpump,0.00622438832,0.000027032,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-JAK,fYxohhysXCovowRnA184Bg5F8hb5EZUQeqFfUNH3SdB,79Ppegxb8QuNzma1KAfNKg26ZcNg1hpdkru7WKMnzZjn,2JqLMdq54vYFJhirQQZNQYSpC2GruQMxULaxcGairzhDBuSk4ES5Q7K1bWwPRr8xcNrHPwnQzNDBneVbkjJ1rYsF,1284,6,1,true +2024-11-23 14:49:56.000 UTC,2024-11-23,2024-11-01,Bitfoot,solana,129.83355,Buy,254676.289256,LOXE,Hdh5UdSUrCRCiqJoYKmgdJ25cubXqpxqkQgkXZdypump,0.495,SOL,So11111111111111111111111111111111111111112,0.8065417500000001,0.003075,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-LOXE,6dQVmJmwLZTKYwUKft6AHe3KqobkWFde8TbEZCt2dCbs,7zmFhq7LacJFGAH5PwVJrcnhczAAGTYCBa5g4Q5auFtL,z3PYDJuTgfBDbXyWMCaCeo1cWmN7ino5thDfGkZgfon1p2uD86QH3mnVdZJX5oHtGcpABqUt8hmCotW91BqX8Ef,1013,9,2,true +2024-11-25 01:26:39.000 UTC,2024-11-25,2024-11-01,Bitfoot,solana,58.51027910046,Sell,0.237585898,SOL,So11111111111111111111111111111111111111112,6336.104156,OVERSEER,3LP15DWcq1YmVw9gvnmjB1SJGmiScMm4CUX2dYf7HRV5,0.35983814931,0.001461153,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-OVERSEER,CVB7RXBYVaB6zyrW7edRaMwQo7CrPJ12QsZjgBC6muUB,92w6P8WBtUoA56iEiojd7bRQEtjWEuT5JEGEx24ysr93,4GKcxGm37qNJsg7YuSNZVfa52bCfYyQ6zBF2uFo6QasPCiUbL4gEjyB3osaFYkukhZnH4RZHDLQzgFFUkEMkkUW4,1641,6,1,true +2024-11-25 14:22:24.000 UTC,2024-11-25,2024-11-01,Bitfoot,solana,4.886838,Buy,49122.72145,BURN,7XcpJgx42Ax7oVtg1EbJTf31guAcgVnU7K4B2vG6pump,0.0198,SOL,So11111111111111111111111111111111111111112,0.03159168,0.000128,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-BURN,FeNMa3en5StkPJYXyv6yUDxbQXoVi3YDQf5whKtokntE,71aUVZrnjwrJSgGYQknJiNVEL3CRPiWNMYXjG7t5sJ9S,5W4m5SYypyyZ6ohaSrHxjkMo7JwzuJ29NCZt6yjbWCfKXzPL8gSbGsv5KuFW1g5q6iF4UEHJRighMfWhysPVsgr,416,9,2,true +2024-11-27 20:19:24.000 UTC,2024-11-27,2024-11-01,Bitfoot,solana,7.938256304599999,Sell,0.033172822,SOL,So11111111111111111111111111111111111111112,1551637.81624,Devika,524V8wH1E9a5uY5swiZMK2sLFRu9JMPTvctrnH17pump,0.07938251040000001,0.000331728,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-Devika,56v84bhXnpckT6uHzd5hbm2VvMG38oube2n369ro6oEi,HuMWfZnd74V2uv7RosiyK9pBVjzK9UMmrnjKb3Gg4ons,368qxfv512er4fXDCcRkSEjW9BsrWGR1TU6aHPqFUne2indtrHiRrZizn6yEb5QXyXdoforNoE7m2o5LeByew35Q,1228,6,1,true +2024-11-28 03:51:26.000 UTC,2024-11-28,2024-11-01,Bitfoot,solana,0.34270006716,Sell,0.001427679,SOL,So11111111111111111111111111111111111111112,6918.361444,Brooks,2i21MzKS78AJBUhRyXCYQZUhvLdtyC19XzKKBfGypump,0.00342681104,0.000014276,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-Brooks,D8UZSBfGnUzczobBu2bFUENyRoofNZeDPgSd1JAzoBdL,3jWX6wQQeVtT3yRhKw7n1pnpDZEFwNqfkuzmyFdcUpwV,4rmDWqxyP6cw9iatme7zoSq895Xjk86ffM9SU5NVZp5senxwWeEP6VVbLJHBZ1xaPFypjDmqw13FKt75oSWAGvrj,1314,6,1,true +2024-11-27 19:33:15.000 UTC,2024-11-27,2024-11-01,Bitfoot,solana,11.88,Buy,45555.61198,EFAI,8ZtMMAm42U27efFJ3nPaCvsJ6FGNgG3YJNtLJR93pump,0.0495,SOL,So11111111111111111111111111111111111111112,0.0798,0.0003325,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-EFAI,3eckL39THW9181eLT6Ry71Nuj34pfctbEs4CHQuouvYJ,Cu6zE46JYtpkaKDk5qKt95vvjJsMzn9byydB6zSbLUMS,DMSFEFYmKaY7BQjmp6qo16aoUaogSKZrFWbtJzYRgjDjDfK6fKerfyS7KQemLeSyzvAyaHgNcbnqAvvftMFUDE8,1971,9,2,true diff --git a/dbt_subprojects/solana/seeds/cswap/cswap_solana_trades_seed.csv b/dbt_subprojects/solana/seeds/cswap/cswap_solana_trades_seed.csv new file mode 100644 index 00000000000..012bac505d7 --- /dev/null +++ b/dbt_subprojects/solana/seeds/cswap/cswap_solana_trades_seed.csv @@ -0,0 +1,21 @@ +block_time,block_date,block_month,bot,blockchain,amount_usd,type,token_bought_amount,token_bought_symbol,token_bought_address,token_sold_amount,token_sold_symbol,token_sold_address,fee_usd,fee_token_amount,fee_token_symbol,fee_token_address,project,version,token_pair,project_contract_address,user,tx_id,tx_index,outer_instruction_index,inner_instruction_index,is_last_trade_in_transaction +2024-12-08 17:53:40.000 UTC,2024-12-08,2024-12-01,ChainSwap,solana,236.41,Buy,5166634.046655,RON,ArVrcEbaLhZPdvfxa4PdXBykhSUTDbKYqKfd6m5DPVvd,1,SOL,So11111111111111111111111111111111111111112,0.70923,0.003,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-RON,6w6ogSTWjpxwNvtBFgNGMyYguxdbxp13yEX2oLtozS9T,FvQ614xsLAfD8TxSszCydwhRJzGECDQBgY1oXaeWPk9P,2vmFMnKPV7SQMAPMuTX6cRsmwiRRYrk3vZAaJ4uM1A6K2T3sMsoLakb6zF6sXQW5TnMF1TYQxvesyb8rPJzSSbT3,2693,4,1,true +2024-12-08 00:56:13.000 UTC,2024-12-08,2024-12-01,ChainSwap,solana,631.0501005872401,Sell,2.638389918,SOL,So11111111111111111111111111111111111111112,101040.940582,LIMITLESS,44o1iDPGuzHxQgDrPE3HRb2WXwGLsBsY7yMttX47pump,2.04393445538,0.008545591,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-LIMITLESS,14YuCFitrqHrPTzP1hP5fF1pQpnSoQNVucRnzJbYyMB7,8uciVcc4zoGmEQf1ys1ztrLMwPZiBNfGshG2BNrBjQGk,2QZ9boZwkssx1KPm1MDnNaL1pSZk8bawqShH2ACe6YmzJboaAjGFzk6ad8SSWFdb57pSqEhzQzgeEirWQDsimW8k,938,2,1,true +2024-12-09 22:47:21.000 UTC,2024-12-09,2024-12-01,ChainSwap,solana,3.4000866542,Sell,0.01588306,SOL,So11111111111111111111111111111111111111112,32.65,GRIFFAIN,KENJSUYLASHUMfHyy5o4Hp2FdNqZg1AsUPhfH2kYvEP,0.01081438826,0.000050518,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-GRIFFAIN,CpsMssqi3P9VMvNqxrdWVbSBCwyUHbGgNcrw7MorBq3g,DoKCDiii9JAevz8fW9PM8gagkuuHGSaAzMBsfZarNhUt,mTcDV84pRnFFu2JZJpFDjWRdDdotiEoKTu82yu6HeGZbouVy6UDkDtJetkn5JauBmmb5pi7DaMo8Bk7e888w5Nu,1771,2,1,true +2024-12-07 10:11:03.000 UTC,2024-12-07,2024-12-01,ChainSwap,solana,2.39099107707,Sell,0.010026381,SOL,So11111111111111111111111111111111111111112,827830824.8232,SHIKOKU,5Jng6jkLKU1o8BNrCzTEMXMFvPjNJZTpdWR3Hq4RHJb6,0.02362689219,0.000099077,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-SHIKOKU,FyQuZLz6LLJxKhSwXkMpZ5Po6G8bcRv8Ub2s3paU74pC,oN3T43asj7TyEViAgQaFdMmmsScScDNZ6C6V4UeuhXA,LFWJiVrsVbktPzNg2soY96n8NShX6eAae2UP8oK8Fo7BuqbCUX4hwNVfkPH9VYbrzAmBnjAQbGknCz6UvDANe8a,1826,2,1,true +2024-12-08 01:44:03.000 UTC,2024-12-08,2024-12-01,ChainSwap,solana,237.46446197876,Sell,0.994324018,SOL,So11111111111111111111111111111111111111112,2665.625316,GRIFFAIN,KENJSUYLASHUMfHyy5o4Hp2FdNqZg1AsUPhfH2kYvEP,0.71856949706,0.003008833,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-GRIFFAIN,CpsMssqi3P9VMvNqxrdWVbSBCwyUHbGgNcrw7MorBq3g,DkGiBk9TAUUm42rDcPWQqRstMWB4pRvN9WxuBm91WX98,5ZNNzu8kj4QFjSYXVKpTdrztYYd2UHW1dAsDtVc8g3P9Ra2fpS9nzTVthvhXcYw3NVttQ4enHcMCGJpcQd6HFYJ2,49,2,1,true +2024-12-08 13:54:49.000 UTC,2024-12-08,2024-12-01,ChainSwap,solana,134.775385344,Buy,10618804.080094,KITTY,7TgVhQwYofgkUHrKqyX6NWc4iVb2nnG87xxU3M3pump,0.568672512,SOL,So11111111111111111111111111111111111111112,0.3555,0.0015,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-KITTY,89WiiZ66AfCsEckK4YhLwxVYZhAPmDcaePkzdnXeHbBP,Ex9E6pWf8CXyUby5TubhGkxuCk7NZnLJhyD65D5qidvq,2XkLYLPszv9nWBzYbY2jepTQ4JT2bkcvpkNPSKhyAj7FTfbAoj8tLABwmRwU7ZM2PHW2vyM3o8v6hr6BboYxcSpF,1369,2,4,true +2024-12-10 23:42:51.000 UTC,2024-12-10,2024-12-01,ChainSwap,solana,642.24,Buy,2557653.017448,NORM,H4WLmYEc1Q9Fk8cbvieqiqc8ALbYA5W2bhbKdkJE2bth,3,SOL,So11111111111111111111111111111111111111112,1.92672,0.009,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-NORM,CYSLB654GfgYE1gQBe9TNbnyZB2kKFTPd5bweM5vLBGw,A9wB4BddvvsKnGM3BTJSWjhQ4ibs7piBtCXd5bdhJZVY,37Jpm6RfG9joRi9KtGKNF91rnEMHrocD128SRGaNmPkBCpVT6cwRkpDE9Yv3vhq1DbPH6sVbabn4mrr9xE8gxxEq,1747,5,1,true +2024-12-10 01:33:26.000 UTC,2024-12-10,2024-12-01,ChainSwap,solana,10770.450408761199,Sell,49.14871958,SOL,So11111111111111111111111111111111111111112,81469.171522,GRIFFAIN,KENJSUYLASHUMfHyy5o4Hp2FdNqZg1AsUPhfH2kYvEP,32.43617846748,0.148015782,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-GRIFFAIN,CpsMssqi3P9VMvNqxrdWVbSBCwyUHbGgNcrw7MorBq3g,88XssAnXed7S4JGS4CFbR7isBtTUbk7CWRtWEbiwCWYX,4FtUdRsx4FKj5kWJDWxsjL3vakYEcWrUUdC2UwS9rcGCyv452zqhJTPF3wBURsYeq6FiHVuBzSXsFfNZqwyoRUEk,98,2,1,true +2024-12-10 22:21:04.000 UTC,2024-12-10,2024-12-01,ChainSwap,solana,105.91416678052,Sell,0.497062919,SOL,So11111111111111111111111111111111111111112,546.471895,GRIFFAIN,KENJSUYLASHUMfHyy5o4Hp2FdNqZg1AsUPhfH2kYvEP,0.32020319996,0.001502737,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-GRIFFAIN,CpsMssqi3P9VMvNqxrdWVbSBCwyUHbGgNcrw7MorBq3g,BYCcoE7DoBN8e3SijRC7rhTnjeGsWPZxNJYb3pYY6EiG,3v7TwmmYUrkuETW5f7MciiP5rdQSXVnpigson5hZEgwi2ELRasKMkwowr7JnrJ1waC6hv3grfLDjgkAfJtzBEEaj,2187,2,1,true +2024-12-11 04:55:07.000 UTC,2024-12-11,2024-12-01,ChainSwap,solana,24.38229109238,Sell,0.111344831,SOL,So11111111111111111111111111111111111111112,1142698.17840853,G.O.A.T,9ko9A8Fc7yRTrYxmtQDAk36WAeLtczrsPmaf5yH1RPTS,0.07536503271999999,0.000344164,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-G.O.A.T,3dzEMpvw7MZm8vq9nKKqxnc7fCUpSqUQEAbRweZQArmR,8igyY1CBBC8VnkcXjPtdMQmfdtc1uTQ7Xsd6tiuj7bgv,ySQVVBRdFDEUYJfT6Ed2kQKNTXHy4yWrYzcPmgm5h4F3yuSHbiSyLE2BownRAe6S8NeZsDJ1AGG3Q5by2EoCpZq,1556,4,1,true +2024-12-09 22:13:27.000 UTC,2024-12-09,2024-12-01,ChainSwap,solana,542.30566942638,Buy,7730247.791584,Mario Bros,Hbdb8rSS7NdpDeuVx5NYUyR9VMKPAmo2nVim2pyDpump,2.508119829,SOL,So11111111111111111111111111111111111111112,1.29732,0.006,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-Mario Bros,qc2ZDKTXxJ26EWEQKGWPJdfUP5UotNjzt7gNyQvogu5,2v7nLcvVde3fXASST46xX8u1qdcffAXXGtJLZfKD29sH,3uWWHnQSKPwtbPLBEDjdHCcUkvQa6gFvC6RQHcyEC91cMJgB9Bncr4GduNPvmJV3PW3MAA31AKJ7V94iYa359Sqf,2225,1,4,true +2024-12-08 17:03:15.000 UTC,2024-12-08,2024-12-01,ChainSwap,solana,117.94,Buy,890505.749209,Luffy,9yP5HSq8HK3aN49D8GwJoYbuFGcKnRuvQNmYxrRJpump,0.5,SOL,So11111111111111111111111111111111111111112,0.35382,0.0015,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-Luffy,tz5JL88F5tvAUPJE9RbShYB8z16LcpqHL4emmJw6ten,FV3Tt7JtCQ7w6WKsbZxP5r2AN9sX7LCjZroWMJpoKjp3,4g2bQ2m8L8HpJDts6MiSs8sQdH6okXXJPCaEmNhzTj9P3UnmL2RJpx9C9v1txXfaEZGMu7RKY8zyax2VbFz4NmnH,508,5,1,true +2024-12-10 16:03:14.000 UTC,2024-12-10,2024-12-01,ChainSwap,solana,403.94903408934,Sell,1.953426346,SOL,So11111111111111111111111111111111111111112,4982686.673278,Kawaī,csdwe8ZRjbchjCWdeSZ8GSNw4XWbRzmCewzD9dUpump,1.3224425222099998,0.006395099,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-Kawaī,4VZSRvRECysU1R75kkHqeqnGzgqcBKsL9MaQ5fbgR56E,8BXTUKqo2nws3HJ5SwQHzSH6bECyP5mMyPvj2MuHJdef,8Sd4aEp14mkpVvUW5bdySG2Ee2a9K86pWjyJgw3hKTchE4H1WvjcCjVuhTihHDSGxbHREgpRTFXkmtZuK2menvC,2154,2,1,true +2024-12-07 15:50:02.000 UTC,2024-12-07,2024-12-01,ChainSwap,solana,234.91497195601,Sell,0.978771601,SOL,So11111111111111111111111111111111111111112,115245.068956,VIRGIN,2MtX583jbXXKnE4BvghsEi4ud3uQJEkJVnt7oWc3pump,0.7168522676,0.00298676,SOL,So11111111111111111111111111111111111111112,raydium,4,VIRGIN-SOL,3CLYXZAcAFBjqAfAwxeSUrpbx2ACZyfnGjZ1WvZ1utYj,88XssAnXed7S4JGS4CFbR7isBtTUbk7CWRtWEbiwCWYX,2v49qpLkXkUySc4uyGLQWWQ3TqPsTDTT7zCQLxNQdRWbWWQJEdCJoUaj6jVK4gUAtu9JwWzLv5qrjkw5yT2xx8XU,265,2,1,true +2024-12-10 00:31:19.000 UTC,2024-12-10,2024-12-01,ChainSwap,solana,213.85821178848,Sell,0.977771634,SOL,So11111111111111111111111111111111111111112,1731.008892,GRIFFAIN,KENJSUYLASHUMfHyy5o4Hp2FdNqZg1AsUPhfH2kYvEP,0.65331532768,0.002986994,SOL,So11111111111111111111111111111111111111112,meteora,2,SOL-GRIFFAIN,EN5ji4DsJCaLNXzkJVEX9sgsN6XMxq5ssLkCxgiDJiM9,GPqcYH2yP1w4LPpQN65mDcU5CdBbRmS4QvVAJP8Lo4x7,4DNXtgt1kp3UheG49gSQcfwSNnXuRo4jV1qXZ2azpLznwYUkwos5AH1x3EfPiMcCfguh9CnTkUL1qUzihcnMiuF9,535,2,1,true +2024-12-10 11:43:17.000 UTC,2024-12-10,2024-12-01,ChainSwap,solana,3143.608268642,Sell,14.5544158,SOL,So11111111111111111111111111111111111111112,1212813.794696,yumi,FhbqJtDE5XXk9Netjvrx5nhmnXxFRAS9eoGLwMi2pump,16.44982237489,0.076160111,SOL,So11111111111111111111111111111111111111112,meteora,2,yumi-SOL,5SeoX3xAe7F9xxDxXVLvRyRtYfSi8yaB5NakpJt7DHEL,DkGiBk9TAUUm42rDcPWQqRstMWB4pRvN9WxuBm91WX98,1NfcHQvucLuAGsfTpz1cM3UG8WPL4RCe3BCqk2AzXf6KbFpqHC6q1Ez1UQbD3ksvAQL3dKQ8MsFJyWp1KApqE3i,642,2,2,false +2024-12-10 03:05:28.000 UTC,2024-12-10,2024-12-01,ChainSwap,solana,851.474647641,Sell,3.997533557,SOL,So11111111111111111111111111111111111111112,5151.222836,GRIFFAIN,KENJSUYLASHUMfHyy5o4Hp2FdNqZg1AsUPhfH2kYvEP,2.585950995,0.012140615,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-GRIFFAIN,CpsMssqi3P9VMvNqxrdWVbSBCwyUHbGgNcrw7MorBq3g,BYCcoE7DoBN8e3SijRC7rhTnjeGsWPZxNJYb3pYY6EiG,3YpZyrUnMJYW28pVc6nfwVbMHXfUeD7iAgt2nJ5JmUxURT4urXGrxtsJyamkfU4cgeAgv18QPCteguiEYAxixN4d,1867,2,1,true +2024-12-10 01:05:46.000 UTC,2024-12-10,2024-12-01,ChainSwap,solana,6466.025441846759,Sell,29.630764558,SOL,So11111111111111111111111111111111111111112,49584.452082,GRIFFAIN,KENJSUYLASHUMfHyy5o4Hp2FdNqZg1AsUPhfH2kYvEP,19.09584824328,0.087507324,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-GRIFFAIN,CpsMssqi3P9VMvNqxrdWVbSBCwyUHbGgNcrw7MorBq3g,DkGiBk9TAUUm42rDcPWQqRstMWB4pRvN9WxuBm91WX98,vsBxekU3cg4LGUYs4vRCSsdVzdKZUWQZEMZzr6ooXcwTVuCnoK66xjUnyb7m4zZm5DfMpPSrgEgdVAcwZ46Tq5Z,990,2,1,true +2024-12-10 18:46:45.000 UTC,2024-12-10,2024-12-01,ChainSwap,solana,220.71725077265,Sell,1.047990365,SOL,So11111111111111111111111111111111111111112,60094.458308,yumi,FhbqJtDE5XXk9Netjvrx5nhmnXxFRAS9eoGLwMi2pump,0.63149955291,0.002998431,SOL,So11111111111111111111111111111111111111112,raydium,4,yumi-SOL,EvWxeXEmTgMVXLfqcugKvCDQ5yZPGHt8iq9N6ELWKf6,Cq6FCvEqBmfsSa89377vNH1H1b7NDJmqNZMvAw74HRYS,2w59JeJdbzDfABXkmC3ZSohbEgnssKGGhXqVtpWC3FWoVGiqv752SpSeatUZTVvSSNhr8zVbyVRHYEaGpsBvD8Gv,1074,2,1,true +2024-12-09 17:28:52.000 UTC,2024-12-09,2024-12-01,ChainSwap,solana,673.83,Buy,541278.944723,POLYBOT,CXLsXyGNRznVaJRKCcv7Cne3sbxGRBy4BdQMo3Tjpump,3,SOL,So11111111111111111111111111111111111111112,2.02149,0.009,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-POLYBOT,69hWrBg3g86BmRhJ8zAZGz2zP53CyKHCaBoFvqkarqm7,DkGiBk9TAUUm42rDcPWQqRstMWB4pRvN9WxuBm91WX98,4xzRFQPbqB3wJZPNgJLpqT91gJ5a2y1Yh4HUzwzhUr2NzNM7jhZhSWWSCyWYMBoFPBzy1cRFUuPC5TX1CHZ3Rs8D,2003,4,1,true diff --git a/dbt_subprojects/solana/seeds/nova/nova_solana_trades_seed.csv b/dbt_subprojects/solana/seeds/nova/nova_solana_trades_seed.csv new file mode 100644 index 00000000000..e71fe551768 --- /dev/null +++ b/dbt_subprojects/solana/seeds/nova/nova_solana_trades_seed.csv @@ -0,0 +1,21 @@ +block_time,block_date,block_month,bot,blockchain,amount_usd,type,token_bought_amount,token_bought_symbol,token_bought_address,token_sold_amount,token_sold_symbol,token_sold_address,fee_usd,fee_token_amount,fee_token_symbol,fee_token_address,project,version,token_pair,project_contract_address,user,tx_id,tx_index,outer_instruction_index,inner_instruction_index,is_last_trade_in_transaction +2024-12-06 10:52:09.000 UTC,2024-12-06,2024-12-01,Nova,solana,2.336895,Buy,29376.95995,Queef,6sBcBA44i4g1m6UBMfkyn4rQKv1wag7UqB5yng7Cpump,0.0099,SOL,So11111111111111111111111111111111111111112,0.023605,0.0001,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-Queef,CCCSXX9vERWwdpT7tGKWjUiYJjzhYd4wJqMeFo2j1ZB5,6UmQuA1koenTdJ6WRtraYneA7WhJC9YopVY8deUhfhR4,5tZLEggJ183v2X1fvJm7VhrAzJ7LBMVEKR3cT9YFoHyFFzuamyMgwsWTQ1M2FoKgPDdkavNoXVqooNVhaQx2542N,832,6,1,true +2024-12-04 19:50:20.000 UTC,2024-12-04,2024-12-01,Nova,solana,126.45952852578002,Sell,0.544005543,SOL,So11111111111111111111111111111111111111112,2290980.376444,Int,3rq9pxbn9b3pBmQZEwyDieh5QgwF77wVSZprwYhqpump,1.25194912884,0.005385654,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-Int,BYDqrvBUWN9bEHHS5gRYpvxmht6GssAa2nFRA7cTcuCu,3daw5AUQXuQE8BwWevn9CSE5uKby28yu2oHJasB3dQLr,DxaqUyVNMhGXnb1SPrhb59F2bDKhuiZeJZseegjA8jcoU2eEKgZS3ZdWeoZjqsXAWsLar2WyFuDvVDfUSm4vnm4,1626,4,3,true +2024-12-06 12:54:28.000 UTC,2024-12-06,2024-12-01,Nova,solana,11.511921556419999,Buy,364304.938888,entry,3uZPvXaHH3ky2Vv9w1tkwEDtKYWqDCJ12WuE7FEppump,0.049537078,SOL,So11111111111111111111111111111111111111112,0.11619499999999999,0.0005,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-entry,DzEyLM8zFnqq3XNSVbyNxHNYAWpm8FmP3VnAJ51Nj8ye,4EGs99ECwUkwE4nxxapRyC4hdjX8aP9CdWwoJTV4KUX1,5r4wH4jMEofRzP9Sai7YoBATFhVxHhixoEfQUfoPhBninZbyMaNMj6jVUujrrG9NT2e2i62VzAa5vXKTz5q7WbNT,828,4,5,true +2024-12-11 08:26:32.000 UTC,2024-12-11,2024-12-01,Nova,solana,240.96468838129,Sell,1.091671673,SOL,So11111111111111111111111111111111111111112,17017539.00197,Fuji,2xV8eMGgZtLuiGE8gkpQzHLwoJt1PEZ1y5k7hU15pump,2.38555029077,0.010807549,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-Fuji,AoJzpdNa5msoNtAzPjBvDXGBjDLnMT7W3uL6ziUztrvB,D7RRsBqadacKN2iHwRPhAwmxkAegekmU6e5EJTXksEPH,2Qei2PVABjF9kwLkKMWqqPviCXFn5WxaQQXKdPkwuuQXM6bSbtdzuQ5zEqEjGVxu9F1Z1yQx5b9U2SGnheeybsyZ,1614,4,3,true +2024-12-11 09:06:42.000 UTC,2024-12-11,2024-12-01,Nova,solana,3.4589988938399996,Sell,0.015617658,SOL,So11111111111111111111111111111111111111112,12162.93127,o1,2wPCNPVRat4ZVFLK2cWFf7FxNKQJP1SUC9rv3FRXpump,0.03458986048,0.000156176,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-o1,9ji9mLEJXf8BYVs4fMFoTLHhxpyamGZYJRUETPczx1Dh,EkN1h43qTCbGhmCmL9qM6NCsXLXyinFjuuVQ1n6bmPsT,3c5GnTmKH5oWh7wdZd3j6mpKMAe213SvMstxH872pCgYm4Z7utiFjrpzBRMrdpbA42yGUpTw3AZLZY2LWTSb6yRt,567,4,1,true +2024-12-06 03:34:54.000 UTC,2024-12-06,2024-12-01,Nova,solana,239.75219680254,Buy,2766765.95187,MPIGGY,DEj74N1Zfs2qWJ4QdsUj2dBUGXTJvgSM2rGnvPnZJMzQ,0.999217291,SOL,So11111111111111111111111111111111111111112,2.3994,0.01,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-MPIGGY,,EF3Xy3e9zEhsucRjYixgBkPhohdJqwQ5PnbqskoRS5tH,4aR72MtDtnwGi99va776UEM4d4Y1ERLq4XsURXjTXM2PSEfLdmZN3jDkH7vwnGRMgyMmWUixwtn19mf1rTv8HMhS,63,4,5,true +2024-12-08 03:16:53.000 UTC,2024-12-08,2024-12-01,Nova,solana,238.54049999999998,Buy,177792.733025,BRAH,EjNADFFKpKJHqEPp1GLzx2ECjFL2d65J3pcGhbP4pump,0.99,SOL,So11111111111111111111111111111111111111112,2.4095,0.01,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-BRAH,4xSk39qGUvkf3H7JusDcVRfwV8enoGnswS8a8G91e6bT,4BxjftWJs2pWeEjMNiJeiB2wXKSapnxfZMWnDbj9ZmdX,5mkESD7H2Z1Djg1YnMJFBD2DH7eFRhGtWNsZsxo1neNFhDnVn3DpEMf4JmaRs9TYonZLZQRpDMdFFQr7g9EjDyP8,171,7,1,true +2024-12-09 02:52:56.000 UTC,2024-12-09,2024-12-01,Nova,solana,2.3050340978399997,Sell,0.009967284,SOL,So11111111111111111111111111111111111111112,3882.064707008,SDOGE,2ARPkfifeN9cQyPAmEcNie5KUHApMykCQHb7R1ib5txe,0.02305014672,0.000099672,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-SDOGE,Hj1bx6VEQU7bRkaZLJpoNWgpofg3nLExKrH53e8zYnqd,BcSgJcT2GdkxQcibP8uvj8gGUj8yQREp57AXZvZXDB43,F5dwis6oXVHFWCGVjznZsoMDjhSbbnjSUMPopdjx1G2bucZ5VDAmDZ93BKTCtoyLFhTWgXfRY5w3Af2YnwECiAj,602,4,1,true +2024-12-07 14:06:49.000 UTC,2024-12-07,2024-12-01,Nova,solana,124.16807477799999,Sell,0.5194013,SOL,So11111111111111111111111111111111111111112,87590.427802,SOLDIER,GGUxJxZqUDfNbnzQqdCnrEzUX7LuCA9usdAkkSfApump,1.24168074778,0.005194013,SOL,So11111111111111111111111111111111111111112,raydium,4,SOLDIER-SOL,3wReKYqb76AqStpVTZHGefrqAMH1yTv8nk4PqZyFwyeW,EWhcbXDKx2gTEXxiYuEnJ7YtfRgna4XMwdW7ELzEiQNs,21NuyTNeNhXjVPNFkEN7RVFDjFUg2uESqzVxQeS9BHGoq1dQuTFfxEvDrXEDifswMxwt5FY5SPNKBpg4p8om6DX8,801,4,1,true +2024-12-11 17:09:29.000 UTC,2024-12-11,2024-12-01,Nova,solana,166.62935509779,Sell,0.724822111,SOL,So11111111111111111111111111111111111111112,163580.068884,FKT,EHziSfC9bfpCGWpiYHSkYhBQTXsKpBJTsn5z5EyKpump,1.66629352569,0.007248221,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-FKT,55Vyv9QAKxSVX4nmufZQCKXk5WA1VnEgGcvtyav8R5ey,CtZtEjTVVbPnoHwfyxMSfei9uTLe7ts7yVKKKDkejeno,GCTUUUNMXRJ7xEU2rxFciEQGAadqUS8owS4pH6SD84KmESPFxEDBiTPurBiqsstCEpuKP6utxrnvRFNWovEH17x,1214,4,1,true +2024-12-11 04:15:16.000 UTC,2024-12-11,2024-12-01,Nova,solana,65.15147218416,Sell,0.297876153,SOL,So11111111111111111111111111111111111111112,653440.556033,BERNZY,DvgkpHBUfH5UE9ed4A7PfaBdE2yKpQ9pscyFrQwEpump,0.65151460592,0.002978761,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-BERNZY,3NBi4gcQZBj4mvG3GVhmoPaY1i4Pg4MvsgdR7g5AKNnV,6Eo8a9FxjpFNL8R6HZ2Rp6v4ZUustoLaeVehahjY817j,2Bwom76L4yFpEuEWAfdaG8THkUhQQck3b4i7arHAHFTDHhck2LEgZnPoSTHN9XPQs94oDPpFiFs1jgYr3ub8p4MH,1197,4,1,true +2024-12-11 06:57:55.000 UTC,2024-12-11,2024-12-01,Nova,solana,186.61399539676,Sell,0.847551982,SOL,So11111111111111111111111111111111111111112,161919.644767,BrettAI,CHLiroKnCmzoAJ37236F2Y5nGmpEkC1cQoa8L1AGpump,1.8661397734200003,0.008475519,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-BrettAI,4YorehZjDUSVcXfs222Y1DrbBVvpRMq17ZFNpgXd45Bb,8coN8Dq9R71tFoKjXVo1hjnH1gFRkRgvrjzcg4vkwx3E,54H2coEwVA5VWEhxa1o6DXY7ccZV9J4G1kxtLKLZ5wLnne9MpbPBZWoT8KTozUX1pPZATD8VnqDwdkEajs3SxTih,241,4,1,true +2024-12-11 13:39:47.000 UTC,2024-12-11,2024-12-01,Nova,solana,67.34178,Buy,276547.749475,KOVU,Acud16jqA9j1Hc83JrHYeiN2BpK8LYYQ1h6FGnYrpump,0.297,SOL,So11111111111111111111111111111111111111112,0.68022,0.003,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-KOVU,EFp41LWtiEzaVFiYhMema8ETHwJfx3fvdMJ2EAbUq37E,92v3iTUKvr4NZ9MSeQitRdu7BkifeCMXVJiuggtkE8uu,4FknfwQaCiHskhDbUTzramrFvSZjgTHR8RfYMeYg6F9JkDN5DRsxygpJpzQMbKHHWj9YEoKXwTiCgXnDsQ6vcguY,1283,7,1,true +2024-12-11 17:54:24.000 UTC,2024-12-11,2024-12-01,Nova,solana,40.909980354720005,Sell,0.178771108,SOL,So11111111111111111111111111111111111111112,1664280.240719,LilysBed,HKrM8f2DCGqVa2mgPwJb5oAevbqmursDEMnA4hszpump,0.40500858372,0.001769833,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-LilysBed,GMBSFRKSzvg61egswdhLPCS2GVcDPkregSSzTLzBRMpk,GnEuZhJp51vf23kwYNktiHmTjbHVNNGYNorxwi9uY5Q2,4v78BzGfCW7BPE5aSM1ir6B3rYBhiPWkFbvBj3g2ehVWN24Uqfa2DhnbZqFgd1KVE8jMhpX9gndAseHTLjVy1BRt,655,4,3,true +2024-12-12 05:09:56.000 UTC,2024-12-12,2024-12-01,Nova,solana,45.46674,Buy,318421.086978,Frog,8si8aCqGyzW2faCEHMbwKxLGMzbPQdjccSWhrYUVpump,0.198,SOL,So11111111111111111111111111111111111111112,0.45926,0.002,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-Frog,21Bnj82WEr4ZQzmSHmARYZeU6Mgm3ipFTVU7JhD8XbDz,DbczwqpdHtALaWHpDWCYRzuTaowbPdRX6vgg6oBMJLFe,4JwzNgbWwDmXV7F717t4xZ7MGyoEXFhtW1HYgWKi28oqmjbHLTDvfxWgAYNJAsUkJbBBr8Ps5qe2rs5iK23ZFBNs,1755,7,1,true +2024-12-08 22:05:34.000 UTC,2024-12-08,2024-12-01,Nova,solana,117.54818121,Buy,4480224.629267,FART,2gcS7doQQb3jisCaPeAtcA6xFEXkY9s12j1157xbpump,0.49914302,SOL,So11111111111111111111111111111111111111112,1.1775,0.005,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-FART,Esc6woR2gGtBzeswbWWuZasGF2RNb8yESG2jFEFdBaPv,2vz8yVLLS6QFboK9xtpKv24tu7GUo7SHgXZDiBzSPby8,3f9QmZUeuHToi6u1gmudS92DvmjJk1LMY1oXJvuuxSHsNA9t3cUbqNvh2uvWP8ZSk7ER9QBzY5NZ1TiyVmDg31Ws,1088,4,5,true +2024-12-09 00:22:55.000 UTC,2024-12-09,2024-12-01,Nova,solana,11.660715,Buy,104953.750318,Aaliyah,BkAUZGUSfUtxPgRJJ2JDDk1XdM72zEsf4ozsmB1Spump,0.0495,SOL,So11111111111111111111111111111111111111112,0.117785,0.0005,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-Aaliyah,CzW4ZoCyA5oDkxL8qhH9n9rKfaPZrVjJp6yuDX6LdHkC,DbczwqpdHtALaWHpDWCYRzuTaowbPdRX6vgg6oBMJLFe,5UxvyhvrKKezVbpVbQFLN2eeAB4uqrBGzaUbWLzcgdfZzpxAchGegviV1159VWyBPVTaVpCKbCVRr3zHXG6gHvkB,1853,7,1,true +2024-12-05 23:26:17.000 UTC,2024-12-05,2024-12-01,Nova,solana,237.2832,Buy,413016.040553,TIME,8oLsaCFngYG6vaRDCbFZTqWuBiz3swAL3RH4unXZpump,0.99,SOL,So11111111111111111111111111111111111111112,2.3968000000000003,0.01,SOL,So11111111111111111111111111111111111111112,raydium,4,TIME-SOL,G5pWpEtvAQCQAxEnyHDWrg8W1JFSp5hwPqYjtCAyrgdM,5URGB13Skm7oKyJgCgMpPU755veJajtHHuovQKMHrrrY,5T8GbHUH7C8JxGqCvM4miEzPYfT2SGhcC9iMsuKWxso4BwZZxLWxLGikw99ckFhKrsz9nwwsp7Csmpmdj9ijuGVv,962,7,1,true +2024-12-04 03:25:55.000 UTC,2024-12-04,2024-12-01,Nova,solana,118.7494441513,Buy,2884988.076315,Jarritos,chVWsF9er1J2umikgjrCxcMojdVn3yeszEuTjiEpump,0.498319111,SOL,So11111111111111111111111111111111111111112,1.1915,0.005,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-Jarritos,,DcpvApMJBJY7UnxxNpiFo8s6V97jBg1usvPcAcroAKQR,3UG11MTv2UabeSPkn9abzj6QM4RvKeyHqQLKBDLQ1MNJGBHjzyodBbpHYz6CDNGTQMNEBJwh3urx1ztFU6Ki68SH,2241,4,5,true +2024-12-11 23:26:18.000 UTC,2024-12-11,2024-12-01,Nova,solana,131.57564682496,Sell,0.578024192,SOL,So11111111111111111111111111111111111111112,14727345.799435,XENA,3Yxasmk23oCReSebfhkjMHvEQyVPnSr4fvBMVMKgpump,1.30259878957,0.005722439,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,XENA-SOL,6oQreXqmsB6twE8f9phvMoDdequxjVigF2sHAjMbSXmM,3ENRG3FZp3nwcGDv7hMJ9VPTEAo1qVEdPgrkL9NoknNP,31PX7xburMDvWiieFyUhnQ7cf9LTLxk5MeKrudhVii3jVD9NQTYxZzbciiA6gWHZLhwNjcHP82Q39Pfh1opeR3bZ,1314,4,3,true diff --git a/dbt_subprojects/solana/seeds/prophetbots/prophetbots_solana_trades_seed.csv b/dbt_subprojects/solana/seeds/prophetbots/prophetbots_solana_trades_seed.csv new file mode 100644 index 00000000000..a197c0d8b1c --- /dev/null +++ b/dbt_subprojects/solana/seeds/prophetbots/prophetbots_solana_trades_seed.csv @@ -0,0 +1,21 @@ +block_time,block_date,block_month,bot,blockchain,amount_usd,type,token_bought_amount,token_bought_symbol,token_bought_address,token_sold_amount,token_sold_symbol,token_sold_address,fee_usd,fee_token_amount,fee_token_symbol,fee_token_address,project,version,token_pair,project_contract_address,user,tx_id,tx_index,outer_instruction_index,inner_instruction_index,is_last_trade_in_transaction +2024-12-05 16:53:54.000 UTC,2024-12-05,2024-12-01,ProphetBots,solana,11.381475,Buy,208793.948484,Luma,ATnB3fxu6HGjieMtQYJgK4kVVyyZVdVXFigF67pLpump,0.0475,SOL,So11111111111111111111111111111111111111112,0.599025,0.0025,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-Luma,4V1fmQBuj5Zy9qkr5sBqip4UXyirfzVybWgqMGf4hYgB,BxqQCDXfuUJaCw51cQmzXpfYSAt7vKSyHR1WeGtxMfBD,5KYz3YEmBxtqqHrqLvQcrSERc6XDzVntNomZSkmFGwmQ419Jo9L8DHKwxgmWdmpSMLBMhu9XC3CH4z3Bxyvdx1aJ,669,8,0,true +2024-12-05 17:07:09.000 UTC,2024-12-05,2024-12-01,ProphetBots,solana,10.77747650966,Sell,0.045045041,SOL,So11111111111111111111111111111111111111112,533.792777,,ZK6mVzkrj9uqEfyFnCwYCLaW1SJkpdevAujqrpkpump,0.5388735742599999,0.002252251,SOL,So11111111111111111111111111111111111111112,raydium,4,,26e6nfrCFsG2z2i2iePrF2bd2M9SiTKUfPhc5PjRfo85,7dCS2PCbi6xxEcd2UP4WX1vJHtkXuBCRT1PRLVkEJGqR,2VnjsoeVPSVAXpp9KatV7SxEx8apm156x7jupbDH6uMjkRU3jZqFVFsXFekXdXUCFxW1j4ABghWGVAWyz9pUWmD8,127,3,0,true +2024-12-03 16:28:35.000 UTC,2024-12-03,2024-12-01,ProphetBots,solana,10.603900000000001,Buy,134166.826871,빌리,D2HR3Hs8eyD1uj8WKpxw1qwpBchPLMUxwC6PVv3Rpump,0.0475,SOL,So11111111111111111111111111111111111111112,0.5581,0.0025,SOL,So11111111111111111111111111111111111111112,raydium,4,빌리-SOL,DGY9fRjKYnbRqjyRXcHugjqhv7wScdtt2umsrbU2H3AH,FpzkRxf5DZroddaQUQDDhHuEaksAnyQ4foWEYgLorGUL,3WYyKHY9HEqZxeVDmKC3tw6UiaDNmQZmuE7riX3F1ndzBNn1HfusUBQkTZDhR1zRYYMHD1nSfBSTQop67uofZd9C,415,8,0,true +2024-12-06 15:10:45.000 UTC,2024-12-06,2024-12-01,ProphetBots,solana,11.268424999999999,Buy,129045.650649,KENTA,GupH283BAzrWbYH5WfXpm1DxrDuacDaANWjWzeKjpump,0.0475,SOL,So11111111111111111111111111111111111111112,0.593075,0.0025,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-KENTA,FG7UJVJyuybqGbss85BvjVnsN8iUjyuWdz9Jn1a6ptbz,7dCS2PCbi6xxEcd2UP4WX1vJHtkXuBCRT1PRLVkEJGqR,5Nqmh81Mf55wqFt8WeiMPmLotbyvjNWCzjuxCU5gdpfuHtVetUjE3rzSi96jbeVHozRvTjtbL8k9aehyATXeH78E,1422,8,0,true +2024-12-09 17:19:41.000 UTC,2024-12-09,2024-12-01,ProphetBots,solana,2.136835,Buy,17473.63405,WOLF,EpPk97NPq4FnEAXnVgmXtfzQMkvsctc67mkhfyN8pump,0.0095,SOL,So11111111111111111111111111111111111111112,0.11246500000000001,0.0005,SOL,So11111111111111111111111111111111111111112,raydium,4,WOLF-SOL,6zWWGQWWvzTRcZTQrMf4NQJsJssVMBvQm3RvLNENdKD9,7dCS2PCbi6xxEcd2UP4WX1vJHtkXuBCRT1PRLVkEJGqR,2u12GokXffjurqYJYX4WQdnKWppBnS37LcvqrKq47Spg4TYh2ZWuso5WLKajpgcqpiEDaN2W6nRimrHZGseXhwmz,1951,9,0,true +2024-12-09 23:26:11.000 UTC,2024-12-09,2024-12-01,ProphetBots,solana,101.63727,Buy,110764.467679,LANA,EsciG7G8g8xVeg9dpy8yJCAavrWNDaykmoMERU8f4Lhv,0.4655,SOL,So11111111111111111111111111111111111111112,5.34933,0.0245,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-LANA,8wont5zeLweXUNPU9ntUDb1nfA87t8THvQ9o6SSPZ5xw,BnLwsxtMBqeVSnvub5WMeys8HH51zjLAgLp6zwZsytE9,4jwVMkhhhsTo8igckryRqhF2LpQGkhzrbZyKzT2F6fvjdyHAL6BNkGNCtwhBFhNVGWFT6YZVzxhq1LGeU7CtnMct,165,9,0,true +2024-12-09 23:26:16.000 UTC,2024-12-09,2024-12-01,ProphetBots,solana,31.113449999999997,Buy,33360.555797,LANA,EsciG7G8g8xVeg9dpy8yJCAavrWNDaykmoMERU8f4Lhv,0.1425,SOL,So11111111111111111111111111111111111111112,1.63755,0.0075,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-LANA,8wont5zeLweXUNPU9ntUDb1nfA87t8THvQ9o6SSPZ5xw,Dn6kWtwBVRWd7rXtCo2718rUfXUTLgoL452BvGSy6a2U,xopZtoxfufcNxRqcToE14p1M6V5C8EPAxTHW1WCCFTNeBXPPmEdPJpEgX84buqiNFxcAoXvbtFMTw6U9yLgqYpv,1980,9,0,true +2024-12-04 03:39:56.000 UTC,2024-12-04,2024-12-01,ProphetBots,solana,21.546407681999998,Sell,0.090341332,SOL,So11111111111111111111111111111111111111112,10151.01789,CHAINSAW,7nFvyQr2mwHLjBBECj3MsUxeAbP2D89p7Tx6bQtBpump,1.104251661,0.004629986,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-CHAINSAW,Eg4hFsUc2MwiBumykUe5dnQws37M3P3WzdGFKpQuqp5t,4Q2nw5FenKdW21hbK3n3VYHmwH7fZqnsC4wMQUyRoc35,3JAxGbnUjSRUe2T4jiDfMGmNvaZ9hFojzSexQw1Ki8NKEuPWJRJMCpMcgDfq9R3CyMwywH9JE7RcTfJDHZdA66Bt,1410,3,0,true +2024-12-04 00:56:14.000 UTC,2024-12-04,2024-12-01,ProphetBots,solana,169.404,Buy,359939.716201,ASHLEY,B2GoHwUP5zdPb7NhmvS8fVWcW7AkFE3KD3Rns12Mcpe4,0.7125,SOL,So11111111111111111111111111111111111111112,8.915999999999999,0.0375,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-ASHLEY,AFWtVR884tYLm5XXybRnNP8KZz6pavM7dcWmQUZEpwcw,DBRKwVjWGvZNKFnhuZCv6AHZohbDqBd9Am6khga6UcJA,L3N81RscW5kZqJ4HbD9YpB3tZtd3zohhgrtgykjnjv242R8EUMJTYYShe4J7uVsJ6KJBj8u5kDNeT1kzfLmAAbG,1994,9,0,true +2024-12-09 23:26:06.000 UTC,2024-12-09,2024-12-01,ProphetBots,solana,103.7115,Buy,128256.133394,LANA,EsciG7G8g8xVeg9dpy8yJCAavrWNDaykmoMERU8f4Lhv,0.475,SOL,So11111111111111111111111111111111111111112,5.458500000000001,0.025,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-LANA,8wont5zeLweXUNPU9ntUDb1nfA87t8THvQ9o6SSPZ5xw,Hc7ntYHQ22bxMdjhcWrBhD539u1S2CWjiQe8vvEqFbdS,5VdcNFNTEG4sf5U7hZywQGjixquR1yGaCfmuhRSUvEr3WR9fw6zA5f3V4qpTPAaK4AkBKmJtqWtj4pfsFNLwG3bs,1480,9,0,true +2024-12-04 17:41:44.000 UTC,2024-12-04,2024-12-01,ProphetBots,solana,10.831425,Buy,61992.280328,PABLO,s48HTTPaaPga5AUXaWHXUvQbo1ASmrt3ypparC1pump,0.0475,SOL,So11111111111111111111111111111111111111112,0.570075,0.0025,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-PABLO,EzjDsgyNcg5QGHVJABaensJ5aeRKpcqa8x9E6CAUdQzA,FZdJmNuuGBDPkd3uevTiPW5tHcMPcCGdVBuu78yCqPCy,Qz4BFs896AYCUCp9SoAebd55yaZTCah4FmP89CWpBZkT1TjrFgYj2uFzQzKxfidAhg5tEBBPiSFwn2brGp6Z2zA,1240,8,0,true +2024-12-04 17:41:35.000 UTC,2024-12-04,2024-12-01,ProphetBots,solana,10.831425,Buy,85020.722187,PABLO,s48HTTPaaPga5AUXaWHXUvQbo1ASmrt3ypparC1pump,0.0475,SOL,So11111111111111111111111111111111111111112,0.570075,0.0025,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-PABLO,EzjDsgyNcg5QGHVJABaensJ5aeRKpcqa8x9E6CAUdQzA,GK1dN6LKFGmS1dhYcjBnLi5zDBThdasCsQ9TwsndNwAX,593qPy9oKsywzormU8Airf7zHmPL3ZvzFMgJTPQjbTEdktatLMKU1rMft9beRQRoGKqegv7d15ccKnqhsje3LxxY,1464,8,0,true +2024-12-05 20:23:43.000 UTC,2024-12-05,2024-12-01,ProphetBots,solana,10.9611,Buy,152919.975464,CHILLKITTY,8sDdRLs9yLcjrKijAQTZTAQAyAHqw7jXsYBF9Ugipump,0.0475,SOL,So11111111111111111111111111111111111111112,0.5769,0.0025,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-CHILLKITTY,ASR4CbtEQxegoavEVK9qb9eAbrWi5JBfffHRTQrXLrh2,7dCS2PCbi6xxEcd2UP4WX1vJHtkXuBCRT1PRLVkEJGqR,ea3qhrUjuaM4vBLxfWYjgKYbdTKNoAAHegPNNfAz7oe3fLYcwufh1vAcKmnwCyPMLT45qGyZFRur3ucnwVdiSdn,362,9,0,true +2024-12-09 16:21:24.000 UTC,2024-12-09,2024-12-01,ProphetBots,solana,53.430375,Buy,101861.130337,OCUS,F1ivEAt4ZmFhLeRs2LiLG3956TkzqF9YR23rKPMPpump,0.2375,SOL,So11111111111111111111111111111111111111112,2.812125,0.0125,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-OCUS,5FsRuKzNb5xPtUGRC7XSpS4YxeVREwXXgX8QojB2JueL,AVyFf2NNrCjf3b8comQvZ4bpPWZcgJ29pGS8UV5i6QJd,2UCrtGwkpwNQLVAtBHuyqTycki9cWYyRWqBxykUNTFmxi1FxbciNiCtkcjGJ13mEUePxGTDgSYvKA5mFq3wACWLV,369,8,0,true +2024-12-07 17:24:14.000 UTC,2024-12-07,2024-12-01,ProphetBots,solana,114.4085,Buy,180095.388017,$TEREZA,9sqa899GR5UqAusC4nikGKRiVxi2d9MsNJcKLfAKpump,0.475,SOL,So11111111111111111111111111111111111111112,6.0215000000000005,0.025,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-$TEREZA,HJNjqkhhsYn27kkT1ULy6rSoVCNG4RaQ5r8VS7xfvWZE,DBRKwVjWGvZNKFnhuZCv6AHZohbDqBd9Am6khga6UcJA,5HADhaBjPjCagLjbHRnoKrGAt1d1k87zedme4idYBLJBV7wYQ491MYyVSYnUjvdFbK6kZLaZVN1EPf5soxupiMH3,1928,8,0,true +2024-12-08 13:05:41.000 UTC,2024-12-08,2024-12-01,ProphetBots,solana,2.23763,Buy,13629.95139,SKICHILL,FTE6GymYs7Q38Sjj3wu6RpAKvGyssMzM3j1wkhjUpump,0.0095,SOL,So11111111111111111111111111111111111111112,0.11777,0.0005,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-SKICHILL,Hsqh3aSb9e7azfCVENW4JFPSiQ2668uY2eEYV4SyokTN,6JxrWa9ZDbrB756kTxk3iHQLY3B2p6Jm3AAcEsZUMh2w,41fxVaks6CjNgt21i9UWo9w1xT4rxD5W8Def5pjnnA3f5PDZ9YAcbnGTDNwYYe1pvYqncLAGsUWqSxTAFQsyztVR,932,8,0,true +2024-12-07 17:43:47.000 UTC,2024-12-07,2024-12-01,ProphetBots,solana,12.71012795631,Sell,0.052710687,SOL,So11111111111111111111111111111111111111112,17489.675256,$TEREZA,9sqa899GR5UqAusC4nikGKRiVxi2d9MsNJcKLfAKpump,0.66360471006,0.002752062,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-$TEREZA,HJNjqkhhsYn27kkT1ULy6rSoVCNG4RaQ5r8VS7xfvWZE,BeWmKAhLsMBzqJto1gwFza6UZbDcxFx24Drr9Lzsqiy5,3XXKYQTWoRkqHx2hGBXJpiBCUmvCzmhyXTrzZqo9LdwFVLmUomrudfo9vTKdUXfAz6tuCZoYSj5vwCxFXYC3My6i,186,3,0,true +2024-12-04 19:34:09.000 UTC,2024-12-04,2024-12-01,ProphetBots,solana,110.29499999999999,Buy,384509.740192,FranceCTO,5rLBiuBHD3hPY3Lk5NinJWgW8nXJaGwwMBtdoNvxpump,0.475,SOL,So11111111111111111111111111111111111111112,5.805,0.025,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-FranceCTO,AD3NnBV7YqdWfuDtHatoGj1GcVgivbzv8jHDmiNZdNWS,5FZJAxJPRLFXwT81NV7c4DkpL83dd1F3MscoAzzekJet,4efvwKH5brMVbame7Uvh35rQEBRV6W3SkyjVk9YWhSBV14NCvU6S6qXsWQnyxk2KY5KRVX6Dja13BLLW1AjwrTbY,219,9,0,true +2024-12-04 03:32:27.000 UTC,2024-12-04,2024-12-01,ProphetBots,solana,49.769169999999995,Buy,48037.908896,CHAINSAW,7nFvyQr2mwHLjBBECj3MsUxeAbP2D89p7Tx6bQtBpump,0.209,SOL,So11111111111111111111111111111111111111112,2.61943,0.011,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-CHAINSAW,Eg4hFsUc2MwiBumykUe5dnQws37M3P3WzdGFKpQuqp5t,wv1cUoRGjXqmnH4mMyAkLPMuUpZHUygCENG6f2KBdTx,3nwNf8SKMc7CFgEFpd3mPRvYgRxdvoQYCuyc8tHbi4HXR8XPeG1BJb8QQuhr9HYjrSmJjVsKfHpkVtZZwk54iGYM,1714,9,0,true +2024-12-04 03:32:31.000 UTC,2024-12-04,2024-12-01,ProphetBots,solana,11.311175,Buy,10419.082351,CHAINSAW,7nFvyQr2mwHLjBBECj3MsUxeAbP2D89p7Tx6bQtBpump,0.0475,SOL,So11111111111111111111111111111111111111112,0.595325,0.0025,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-CHAINSAW,Eg4hFsUc2MwiBumykUe5dnQws37M3P3WzdGFKpQuqp5t,BV3wm6iLVJtDTxC57pWLQYgCcrxnHhsaeNLWQjWVUhws,2D64xoBUAktDMyiWzJRpvW21jfhPn9pJGofAqMEPkM55Ks7XqwSH3d98yQ8N8GbPqxQPvtmcgdu19FsWmz9Rfobd,124,9,0,true diff --git a/dbt_subprojects/solana/seeds/sanji/sanji_solana_trades_seed.csv b/dbt_subprojects/solana/seeds/sanji/sanji_solana_trades_seed.csv new file mode 100644 index 00000000000..379c07d13cc --- /dev/null +++ b/dbt_subprojects/solana/seeds/sanji/sanji_solana_trades_seed.csv @@ -0,0 +1,21 @@ +block_time,block_date,block_month,bot,blockchain,amount_usd,type,token_bought_amount,token_bought_symbol,token_bought_address,token_sold_amount,token_sold_symbol,token_sold_address,fee_usd,fee_token_amount,fee_token_symbol,fee_token_address,project,version,token_pair,project_contract_address,user,tx_id,tx_index,outer_instruction_index,inner_instruction_index,is_last_trade_in_transaction +2024-12-15 07:06:47.000 UTC,2024-12-15,2024-12-01,Sanji,solana,2.12730476036,Sell,0.009734612,SOL,So11111111111111111111111111111111111111112,632.120372,timmy,4MH3cmHGELMSWeWsYVQJFgb9tmed26ZTUVQ3jkANpump,0.014851298800000001,0.00006796,SOL,So11111111111111111111111111111111111111112,raydium,4,timmy-SOL,a5cEyYEG1RaBTpsY1QapYKDv6ixvbD6CVkisSvT5Ufo,7rqre26G9XjaEjbwtSHCU97LoU1KY7LGAthXNDyygLUD,4GdbkGaaMWoPM14vJsNWCMQ4vpnMKzJAow2ZZEXe1BnGtzoMyBq5GfLBK8X6W1XihZBPV7x677z47DAtYvv7Qwt4,1263,5,0,true +2024-12-14 21:57:46.000 UTC,2024-12-14,2024-12-01,Sanji,solana,10.8765,Buy,108399.066862,ROJO,HANuXquoXxPQuUdWq2pSonH3GUwjfwg9wwxeP8do6bWV,0.05,SOL,So11111111111111111111111111111111111111112,0.0761355,0.00035,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-ROJO,27gMxh6F68GoctWNp3YyLhrMwaZsLzwK6WDLyVQCQUmd,FAZuZgyYsYQjkJD6o3YaVwz4MdvitFDWoA4DvWmR8mS5,62qqXEMGk6uiSLBfscjbcLP7aAPHtK7uvmUmxq5akQ7FE6eHeM5axrZk6J18Wc11GstxEdgoMEKn8akZwApXjmDM,1632,6,0,true +2024-12-13 23:30:55.000 UTC,2024-12-13,2024-12-01,Sanji,solana,1.25854035633,Sell,0.005622751,SOL,So11111111111111111111111111111111111111112,19013.576389,ipod,5wQPBazUaVtMTqtAGXYPdDSenxDqM5vJiDsEfov7pump,0.007536356100000001,0.00003367,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-ipod,A7LAumFoyJFTR8V9ChoSP8iSpquVacpZHva1oZ2JqS16,8Z4zvnXqR7bgJttHKpAP2SUa1TuzmXjqLj7pEbEzMmkd,2kgteAdXaZYthVsUoxHGmQGJKBGbgEahA4nGSaYh3eqzYVGKm6ovtm3UynpcKqSPX21Zdz6GfyEnGtUDdShRS2FB,2946,3,2,true +2024-12-07 16:58:50.000 UTC,2024-12-07,2024-12-01,Sanji,solana,190.39411413672,Sell,0.786817564,SOL,So11111111111111111111111111111111111111112,856847975790.57,DNA,DiSetnR7k57wmfvywJhUVjPwWfg54SdQKxQdJEBYW23B,1.3498394538,0.00557831,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-DNA,45L3EuUJKyqhkNDfocrd3yAZu8nzMPXiHtwhjCvidgua,B273T7o6o1Cn9uy4uByzKxpHGqqALAPo9JuZBp9ctZbK,5vBFyx35NGM1Z8r8iB8TLDpVA3mK7LhqqUu5E2iTbJU6UNxPxmMFTTwspqa2Zh6FUKizddQVH2vtEQELWz3rLXbS,617,5,0,true +2024-12-06 01:33:22.000 UTC,2024-12-06,2024-12-01,Sanji,solana,2.48840085109,Sell,0.010124917,SOL,So11111111111111111111111111111111111111112,2.5,USDT,Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB,0.0174201776,0.00007088,SOL,So11111111111111111111111111111111111111112,raydium,4,USDT-SOL,7XawhbbxtsRcQA8KTkHT9f9nc6d69UwqCDh6U5EEbEmX,EYzmfW4iqDGNhgTiyA71ETMLnSRPJEKykYzDwNWBQFYv,5sY1pA9d1NY7byu4pK6FAtNGjASU51zv5guRb31HNws5pGVg88XEpMNbPULSCo3GbYhbzgRgKynyejhxfWNodBHg,895,5,0,true +2024-12-07 06:41:44.000 UTC,2024-12-07,2024-12-01,Sanji,solana,0.0774845692,Sell,0.00032884,SOL,So11111111111111111111111111111111111111112,6503.817475,Trump47,PfzhpjdDd2rHLRLWyTQBbqB6KBJfx8yVVGqSYkq5bqC,0.000541949,0.0000023,SOL,So11111111111111111111111111111111111111112,raydium,4,Trump47-SOL,2kcuRFMvJvqe82E7byJBCDMn4LT4zNFb2FpPhVbdqCw2,BLZ2UfxRoJ8arGKgAtArQ1SDFDttFA8c6v4qyPGpZLaq,4MNycd2wXRvzR8hikbS5Wsudn3tmf2vHjzxsuXSk5fvBzWW5oYFGLfv7pH1Pdo1eTL2kno7jwsDbVEFz5izKRboM,1480,5,0,true +2024-12-12 22:57:10.000 UTC,2024-12-12,2024-12-01,Sanji,solana,45.932176694949995,Sell,0.201342115,SOL,So11111111111111111111111111111111111111112,7151571.722822,JAILFORJAY,3KSkAdFbPHfGREVEo3DcGDBHEdZ8Ey3zGgFSajYVpump,0.1618422659,0.00070943,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-JAILFORJAY,Exj9V36qy1esrknFo4SAi8728BEGcrXPLwquDHfLtNqZ,8ChErCicUoNVmKbMuzVzoSoVn9s9Fkrsf8f2PoFKWrbZ,5un9ZXyeZfrYrEutX3dVG2dY76GWViTmVR4KVhfKBJQoqixsW2aZisRr31mEz86pfhoUoTWnVsqBqW5qrpyL8RPX,164,3,2,true +2024-12-12 03:19:52.000 UTC,2024-12-12,2024-12-01,Sanji,solana,67.28554651878,Sell,0.293643827,SOL,So11111111111111111111111111111111111111112,629457.273508496,CHILLSLUT,4F33vogWv87XcpGYL4pPXBfmXc5XBEKqPTVYrJrFpump,0.4643155476,0.00202634,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-CHILLSLUT,CYHPMpq6paZHLe24um42WPQMNRGNGTK4Q2LgDFWPZEdS,Ghcb5NXNE8KwvRYob3b8oGy6g5GF9z3Gd4rfrujCRAuL,TckxHyY7orvMD2Aidin1yWhpZM6L614TP8wV4zJTxN1nwgpSmS9AXyzrhG5i7vNp7DJvuurs1aQwPXyqwKEvHc1,757,5,0,true +2024-12-08 02:52:58.000 UTC,2024-12-08,2024-12-01,Sanji,solana,200.38093529355,Sell,0.831697735,SOL,So11111111111111111111111111111111111111112,1748801.699025,T51,4zGCj2Rq16sp3fFdzZHbVUdAqeS4p9buThjKKRQGpump,1.4026679577,0.00582189,SOL,So11111111111111111111111111111111111111112,raydium,4,T51-SOL,GAjizQ2pXjkT962BU9ge7iKkaJtVYvQyHvPfV4vVR9YN,4o3DSxj7rj6mJUNYYCy4vm3dKDwteZVR27K1XT8eSrqu,4BwNnddS7SJpi2oUGH4F9KWo4sQp7RoHERbJtn7eevAshAToZagzR4neQHc867ueKvFa2aU7PmYS3L3xJtEJnbyN,1722,5,0,true +2024-12-07 16:58:51.000 UTC,2024-12-07,2024-12-01,Sanji,solana,7.07179338996,Sell,0.029224702,SOL,So11111111111111111111111111111111111111112,3750224.749119,USA,69kdRLyP5DTRkpHraaSZAQbWmAwzF9guKjZfzMXzcbAs,0.0494800704,0.00020448,SOL,So11111111111111111111111111111111111111112,raydium,4,USA-SOL,HKprCtGbnh1j8xeQggzWhhVd3kwDUdphqPqDP8vMay8b,7wyuQVaYkPxu7oTp1juBXCpmjXM1JvjtBH2bDmWWjddp,xXHQ2v53E2fDymBmad8vQtQZCapEX3MFMr2k5vLgB3vjZV5sdKFtxnGaL8e7JrnYLLcA4cT5t2BbnYZGfhdaDqP,391,5,0,true +2024-12-01 04:48:17.000 UTC,2024-12-01,2024-12-01,Sanji,solana,1.5498037895799999,Sell,0.006555299,SOL,So11111111111111111111111111111111111111112,2707.23956,SNOOPY,CSh9t2fx2TAE25AiZ9oagdcuHomTQoCE1PGxaMjfpump,0.0112039438,0.00004739,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-SNOOPY,6NZ8USQQCiy2dAe6Qg7GZGMRS1z86qq2iH8bokD271ht,BcGqkk3QVi4XmN4BN4deJSvGL1ss8AwiM3n1L7BouFr1,47fBahJ11QJTSkcn2qqdMTc69nQ53yZW5yqu48DzTiLckYu2hwMJATMmQsjhoAGVUDSsUphocrPsFmH7VgL6nEUb,987,5,0,true +2024-12-12 06:28:07.000 UTC,2024-12-12,2024-12-01,Sanji,solana,93.99705161856001,Sell,0.408540732,SOL,So11111111111111111111111111111111111111112,2598.06085,APPLE,H33XL6HHDReCVRgSApZpsXM7Hy7JGyLztRJaGxjapump,0.6579804832,0.00285979,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-APPLE,BEMi9yKdXLL9rNY43cU8CVxZZP4hmr7w7odwtxAMKAzD,vv7iSWi5CFuP9GCv1ufASHBDz6kFNDEWq5nhnpKaLUt,3xS9c2bGTWoTkXfFtRriP8DYTUTm29tqdkpEvCWLe6KJtMDdqvJjgmer3QWffWVYijwkp9ouDTBVVfvjKLmeRnZc,1708,5,0,true +2024-12-04 03:46:15.000 UTC,2024-12-04,2024-12-01,Sanji,solana,7.153499999999999,Buy,99989.752594,JIZZ,Ggx1nVeY23M16r2YqgeJfXMqA5WCGmTQN8RqhaXWPbTL,0.03,SOL,So11111111111111111111111111111111111111112,0.0500745,0.00021,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-JIZZ,EhY8JFCUyPuqJpdNiU9shKjToQb1b6qycmMwdx1o2LSv,2fBwpC4QGeExBWDfpGSqTNMC8xqWMu4Q8gSJYDYiSxta,3QUbFCvFCRDcarhnprUfwDpMFd5mJc7Mp9RXAyqRmmgJWydnQgaBe8i9VgyjKDp3JbL2JwUjqBQhN8qzgd65ugGa,1605,6,0,true +2024-12-12 14:40:20.000 UTC,2024-12-12,2024-12-01,Sanji,solana,4.125138145739999,Sell,0.017878638,SOL,So11111111111111111111111111111111111111112,234.904987,TRUST,EqeEBGHQhQy6SqeaJcnqAsNs3qaG19sdF89Xsarpump,0.02884125,0.000125,SOL,So11111111111111111111111111111111111111112,raydium,4,TRUST-SOL,9dkWXEmCvQGLazzbWZiSDExoPKiw7HkwPSM5bJW8qymL,BtZ1iVeH6h98fgi88pF6qj9oG41v42n3yndpSMDif4kh,5fx2StwS691CMAcJgk7jSPwuUVg1nuWtyKbdfrTNVg62r3uqzejo8yH3o4vYGUGht2yG84HXTJEEFSFtMkcgcqk7,3037,5,0,true +2024-12-12 00:13:26.000 UTC,2024-12-12,2024-12-01,Sanji,solana,3.06566549352,Sell,0.013495622,SOL,So11111111111111111111111111111111111111112,476869.372056,AWWTIC,BPcCs1fer87KzqgkHHCvR36SkfDqaEcLGxt62fkkpump,0.0214620768,0.00009448,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-AWWTIC,4icnNdfDN3FyzTpXBBJWZ5BRHnjvLRAkgK5QhhxDHSD7,8UWDczTGjzjnwmQ3Ah6jcN5qPxCT9oWB3BKhfWyW9G6R,59nJmeny6UzHEeRdUMG1UhVY1xE74yJrR7o9rLauHfPUAsg2yR38oK3mM8sDGtYV8uxXAFmFtmTqH7zmW4FQtLuj,1926,5,0,true +2024-12-12 20:06:07.000 UTC,2024-12-12,2024-12-01,Sanji,solana,6.8361,Buy,37511.994306,CHAINSAW,7nFvyQr2mwHLjBBECj3MsUxeAbP2D89p7Tx6bQtBpump,0.03,SOL,So11111111111111111111111111111111111111112,0.047852700000000005,0.00021,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-CHAINSAW,Eg4hFsUc2MwiBumykUe5dnQws37M3P3WzdGFKpQuqp5t,AQLntiBeqNvynXjrWJv4MSmMFURSfrSbasjUbqwHyWN1,uhCyivWoQUksTryEegnTYxRjrXAp3aeBWRyc8q8Kr99FPj3m1rGZm8tq67fRsbqBSkUs6y4NL7jFGhMEoG9Ke5v,2138,6,0,true +2024-12-13 20:05:17.000 UTC,2024-12-13,2024-12-01,Sanji,solana,0.67938346075,Sell,0.003043151,SOL,So11111111111111111111111111111111111111112,2200.998928,EVOLVE,HQ7NoKrgxcep1hSnNKGbWRtpMf59As5eVKeuwyCzpump,0.0043690025,0.00001957,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-EVOLVE,6J3DXzGB9Ndw795pAfH65HQSDo4MwgRbFDpSF27L3g4S,9zxuSu9cp5euiHaB9NAZ1Y6PhtASWmpetDhvrAUhZBZm,44UWzYjiCcsG6RS81CdCbzQjFaih8ppkkxedMUoZJ2qroSn8Tqov1EXzQfiPvh8cPABK3sCXCdmBppoHSXMFxTFx,1962,5,0,true +2024-12-12 20:47:31.000 UTC,2024-12-12,2024-12-01,Sanji,solana,0.01325559392,Sell,0.000057814,SOL,So11111111111111111111111111111111111111112,0.00000341,WETH,7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs,0.0000940048,4.1e-7,SOL,So11111111111111111111111111111111111111112,raydium,4,WETH-SOL,4yrHms7ekgTBgJg77zJ33TsWrraqHsCXDtuSZqUsuGHb,6VvTvxNoZzHVgivqeFrzBcKK8N9ckMGbMTxcNgbB8MVo,2YjFHGk3YnWdLukUzUmZBZhtQbh7rhoVtSxDDEKtuCVqun85E2DG7tE13D8S9XuiEs58PbfHcBF7BJ61DKWY8wyP,1634,5,0,true +2024-12-12 13:26:56.000 UTC,2024-12-12,2024-12-01,Sanji,solana,0.0017850892199999999,Sell,0.000007698,SOL,So11111111111111111111111111111111111111112,4.5e-7,WETH,7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs,0.000013681509999999998,5.9e-8,SOL,So11111111111111111111111111111111111111112,raydium,4,WETH-SOL,4yrHms7ekgTBgJg77zJ33TsWrraqHsCXDtuSZqUsuGHb,6VvTvxNoZzHVgivqeFrzBcKK8N9ckMGbMTxcNgbB8MVo,FQBE9S8LZTiSvtMCU6qYwtRbvDCG2syeLGXUMq2whe4ALcYHNixAYxSsNY67F3QLACHYjhM1HojoeU7nPvko9J8,1019,5,0,true +2024-12-01 00:19:25.000 UTC,2024-12-01,2024-12-01,Sanji,solana,11.9225,Buy,345972.31649,GRINCHWIF,BoQPkPXdNqRuwyPpkC47Ac9mCk2WwhbgbDG5dt7spump,0.05,SOL,So11111111111111111111111111111111111111112,0.08345749999999999,0.00035,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-GRINCHWIF,ALkGqJ7inoN4n2wW6exur43YQRSHZ5dP3DpQ879DwM85,77PPF9tCqn3PsrYs7WhgKEpy76b3Uzh1i4B93BmoSq2G,4caUnR34GpNUDzeYWDWJZQEP7B6rycCLAoL6sDnYuzDF8ti7wXqsxDqoYuocumX4B7Nmzup8RyZxschkB9ZAQ2tu,1180,6,0,true diff --git a/dbt_subprojects/solana/seeds/tradewiz/tradewiz_solana_trades_seed.csv b/dbt_subprojects/solana/seeds/tradewiz/tradewiz_solana_trades_seed.csv new file mode 100644 index 00000000000..b3d981bede7 --- /dev/null +++ b/dbt_subprojects/solana/seeds/tradewiz/tradewiz_solana_trades_seed.csv @@ -0,0 +1,21 @@ +block_time,block_date,block_month,bot,blockchain,amount_usd,type,token_bought_amount,token_bought_symbol,token_bought_address,token_sold_amount,token_sold_symbol,token_sold_address,fee_usd,fee_token_amount,fee_token_symbol,fee_token_address,project,version,token_pair,project_contract_address,user,tx_id,tx_index,outer_instruction_index,inner_instruction_index,is_last_trade_in_transaction +2024-12-03 03:41:57.000 UTC,2024-12-03,2024-12-01,Tradewiz,solana,5.10029703516,Buy,130284.164414,VIBE,AB4oELjeXLyeV3t3evMgq3zXrxXAJ1WdRy9qgfinH1oq,0.022402148,SOL,So11111111111111111111111111111111111111112,0.04940438999999999,0.000217,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,VIBE-SOL,AKtxTJHHtyDTBUerXQhWQSY4L8oBreBqPHkiPbkyoL3s,8dRLn2NMHsN7Fu1nxCbfQDujQ4wyPaqmnfqHyfVvBnmj,5xYqUmnvW78WSa1VL9G3H2fkRcBbaGRfr95iDTH9JWNTAheT7pnNguneMDzkge9Bqs5KTK8boRHKHPupBtW4hBL1,1139,7,4,true +2024-12-07 15:17:10.000 UTC,2024-12-07,2024-12-01,Tradewiz,solana,2.1149015703,Sell,0.008739985,SOL,So11111111111111111111111111111111111111112,312509.10149,CELLAI3,5q4maTRYm1ZPuFZqFzwYRJ7jAA5xkprmndJdGHUnpjwT,0.0209373195,0.000086525,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-CELLAI3,ARUgR3UzG2KCXWAXQNSHdPuuZ5Spmmm8vTENUn3UK4HU,F6coj9TDxLDw1wSFYsQMPmA2iPYhNxu17qBSEZ8vZuDm,5769zBmZrWqPGqWU9QA2LH5CrjPnJTWePmtC8bgTtciupjiLNuNaYuLS3FEkN7eThaQj57NcTc1Hz39VnkdtDgbB,2030,3,2,true +2024-12-06 19:47:39.000 UTC,2024-12-06,2024-12-01,Tradewiz,solana,5.72664660432,Buy,103332.858778,PAWBLEMS,4fLAZZCA3Mrbj6Wa9PkTUHfUWu3JE2RqGHvDrXiMpump,0.023872964,SOL,So11111111111111111111111111111111111111112,0.047976000000000005,0.0002,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-PAWBLEMS,kLCF7gruvuMfBLvwSL4XZQK2ENKYKm97LFuLAKkxC5b,DksfCf1U4arH6eq9KJJJtHDiYypi3gzwnxbup2266uae,szuK2Sdz9ps9Go88t1FVjFRezggBdh1RqWETVD8voF78mJm97H3pnt6EYrN9aUmYHUmGAvKfrTs46tJfC2F1GCt,1583,5,4,true +2024-12-06 11:48:01.000 UTC,2024-12-06,2024-12-01,Tradewiz,solana,65.36809866600001,Sell,0.279350849,SOL,So11111111111111111111111111111111111111112,371324.880761,HYPHAL,2gsxJ1fyLi3kzvjQx8Wd8y323Ptigzj9ti54grHkpump,0.658593702,0.002814503,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-HYPHAL,2YeDSYdr9mMvEtiWskGvHbt6WSZ6wHW9xGi8DuB9GjdJ,Ed1rA4YjgtJMExjQ6sjWrEEj7xaeL6f4yvT39sm8fZo8,3VN42UsvXsxqnUDiTDQaHhrWmGCwoWnfJJWyPbz7nvja5n9EZohisb7ZR4ojD3LzDG8rquC74kJY3Z3bHac6FYqh,64,4,0,true +2024-12-03 06:01:15.000 UTC,2024-12-03,2024-12-01,Tradewiz,solana,12.54215028618,Sell,0.055040814,SOL,So11111111111111111111111111111111111111112,434296.831722,Pooch,csrNabqJ6eKoueCiVxGWTTbN3Bri1MhwbwoCN2Wpump,0.12432632773999999,0.000545602,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-Pooch,H82eA83r3Djyt1s4T6213puNzM1As8w2tCSYjgv6kjFz,66gfZJ3yVCxhRY3VvSKxTYhrW4HAUvhbVFRCRrgoATkE,3hhXSyxnoA3U1eYsY2P8EjAqen3mWBscPoPK4pudmobfENN1VKCzAHKPaBQRk4S98W9fB41tm4MgUJ1NE4F4ZjNt,413,3,2,true +2024-12-02 18:50:09.000 UTC,2024-12-02,2024-12-01,Tradewiz,solana,33.5145,Buy,1090000.477547,FWILL,8aMmdyEH97qmtxge5odgJE45KwwXQkaSZEjM13EDpump,0.15,SOL,So11111111111111111111111111111111111111112,0.335145,0.0015,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-FWILL,5QiczEwrbzHNooa54TVkt4oe2HFHLd9u2TCJNX46TJjj,A3kLfkrESnvmZUs54BKYS48bPq4DJT11psfFC5ADMSwS,op8TBkDy4D5gr7xX4VCiC6VvEXCuYV4zo3fhHCEJMFu4Athih23wEzHw24tA1WmjQd4eZ4swA8o7Dii6fk1vC6j,181,6,0,true +2024-12-02 05:59:04.000 UTC,2024-12-02,2024-12-01,Tradewiz,solana,0.012848601869999999,Sell,0.000056277,SOL,So11111111111111111111111111111111111111112,58135.635755705,LIR,Agdtmev8iBbBJZjXDf6u18M51Bu173gsJTzcWB1patsJ,0.00012876684,5.64e-7,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-LIR,84PapxynnSyNL7LRg4vKg41SVrmU2NqRxaudeQe1NYUb,9gxBDddAvsVUmcLAwJWhnKr5dMN8rWkdqn8ZZ4V272bo,3UBAiPDUWx2jpU4H7u3VV4LkkYXMjxUtbnK2uj71mkHb2T22iWFxvtAnjac4rwQA5itbZb9VahYM4XRbvpEEyxdr,552,4,0,true +2024-12-02 20:48:46.000 UTC,2024-12-02,2024-12-01,Tradewiz,solana,174.81549384187,Buy,14986480.13779,FAITH,CK3TMoqHy5ApzRwooxbxMAbpGDK2w6KpQMdv2rDhpump,0.782137237,SOL,So11111111111111111111111111111111111111112,1.6763249999999998,0.0075,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-FAITH,5PBojHVrS9C6F6kjTosfVEUoBzED8PCxpFdeouWzDQbd,2kNoYHNtpaefWZ3JptWug7H7pyzXZXYYTQufNbnt3Zzy,3gPFS1BtQArtTN2hZwbrUxKETHiHRts4YCcCEZqFxoGo9E8zpYztsjdtNsUmbK14qNT7VdieNJXbY9tBTembavCB,413,7,4,true +2024-12-02 18:06:48.000 UTC,2024-12-02,2024-12-01,Tradewiz,solana,30.016174407599998,Buy,1809787.710499,ART,CuSXYspmP7khJiov8Kr3XaExcuhPadVDHGm3K3rvpump,0.13517146,SOL,So11111111111111111111111111111111111111112,0.29361128496,0.001322216,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-ART,GD5CvxQZwKLfqMpvMTeLkTecnMVZGNPXnUk597W1j8hb,H9kHjTaJqVrrSuZGwJWgQnjyhVmGANpqsA6eoqbbZrTk,2SZ1av6twfq14Um3gM8KuRopdqdJpDtESqidS725tKMiDMa1zQu2wnr76JMsbXZMrH5LiUyGv9XPUqMkmwbjW4S9,2628,5,4,true +2024-12-01 23:25:30.000 UTC,2024-12-01,2024-12-01,Tradewiz,solana,12.139543894200001,Buy,1715893.906365,Bio AI,7LL7cbEfKLMiH4oUmfnfYgAhUnnVRWGeksE6iXjDpump,0.050942274,SOL,So11111111111111111111111111111111111111112,0.2383,0.001,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-Bio AI,76BfryV9K9e9o8zF69csrqFLaar2PpdYZ8hN7ZRE4Y3e,H5PQNrAj7uKYK44ksRqym8sAfuasNC4xHJZW88WbzDyT,3YXaTrff9qmYHko2ZD5veVtAcF7XfJa8eCmFBmMtV5dLdowbCn2D2ArfkymQ2ZLon5ExhEYr5qbM54JJbE4NiZtU,475,7,4,true +2024-12-03 20:40:46.000 UTC,2024-12-03,2024-12-01,Tradewiz,solana,148.38664547177999,Buy,17917109.708311,WILDMNKY,75fv3J8gw9mp64ZVcAXjmr1qT8PqJjE1Cc4ocjmCpump,0.645552273,SOL,So11111111111111111111111111111111111111112,1.3791600000000002,0.006,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,WILDMNKY-SOL,7SV8yk5hXtcXNqgohc9tJMdmAbBnLpbKr8oURHdh8s8g,4Nw2v6XZJgaWHmtETqMWtQyTHaGDtQZ27x3otcvjQAHT,ep8K6Nvu25kw1yVWqENPHv2Y4mGRW5T7kMBxeXnmujd6WoDxzSfVtqASa2fz5toNTyX1JDWecAoMHxTdEsXnkxU,601,7,4,true +2024-12-03 00:15:12.000 UTC,2024-12-03,2024-12-01,Tradewiz,solana,5.12252529562,Sell,0.022631993,SOL,So11111111111111111111111111111111111111112,27129.461569,anthrupad,2okJ4wqqDFFD2Tce3QaU8L866KxBJzJXVoMtLR1ppump,0.052636498700000006,0.000232555,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-anthrupad,FAfDgkWFexH1BA2D1i5pc2uRR8ZYcvt8jY84CK7e9My8,31M2cNExVg8bwB2HwzAzA1w9pHwLeP67ejygZ44UB1UR,2HryhZK2dRLqZeTowRQ4Rd7BGwL9ekAgyjDuaFvYAJyyVZHn5C81cTGGc66eMRg9MhiiWEdU7j1yWKfJDjdfbMRU,499,4,0,true +2024-12-07 18:47:05.000 UTC,2024-12-07,2024-12-01,Tradewiz,solana,47.17441114759,Sell,0.195040357,SOL,So11111111111111111111111111111111111111112,12392.36946,AFITR,83Ur4XYc5QyRNBshoW2Yu9cCLyNDV9s5krBu11JWDxxq,0.47612907671000004,0.001968533,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-AFITR,5JtbDjPqfN6K4mDF2c5rvJZXXryQbihjViSP2XoMohSV,8uAied3jRqG1mPRzqsmLaeRDz3F22BkarmfgAvoqNWN,3Lr37rTZUVk9m1iYz3h8sg6Dt4dMHm4PhLmuPUe7G1Z3tMxraN54M8boZMP5wdXGqs8NGQPHMDaXLZoKAq1zMZLE,238,4,0,true +2024-12-01 18:04:29.000 UTC,2024-12-01,2024-12-01,Tradewiz,solana,32.99628642063,Buy,438388.5076,Metanoia,2dPFQnktvPKZe3hjkstWfJx8tDrH8FW9xoiBjZMEpump,0.139218963,SOL,So11111111111111111111111111111111111111112,0.2986326,0.00126,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-Metanoia,FpTruBXx6UcyBiVr2Rj7UMf9tNTpJgTyGpXynpuo9HzA,GhqrMrC4tY8zTDvWHiHG7ag4MWPqQ7qLZmeochY6aosY,29TPJAT4vP7rUmMETneBknCmH8UpzdeFaB6ZpJTmzVobE6kTou8KBgqvPPLb588ettce6HRVFUPcSbuSrRJpJnzG,620,5,4,true +2024-12-01 02:27:09.000 UTC,2024-12-01,2024-12-01,Tradewiz,solana,19.69581542709,Sell,0.083524089,SOL,So11111111111111111111111111111111111111112,313146.63071,GSC,F86FtKmg8vnaCfDoJF7U21NbmLprVazE3L2PshmCpump,0.26366694273,0.001118133,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-GSC,7H6MS1nqg9Y6NN8srD9UCovDQwVxuZaozgXrMT7kcH61,35cx6mhp2Nsi33d7QfwnqVrYoEcyWpc17PtgMrCnwfxt,5K5isZKhK8mwM4rZ7akSejvwByViNxZ5GcCMcsqWENmT42WkJ4kUoYsAJQkeq73pwiEBgjwEoUEgRNB8jCt9Bugp,541,4,0,true +2024-12-04 17:48:52.000 UTC,2024-12-04,2024-12-01,Tradewiz,solana,29.19816884426,Sell,0.128270302,SOL,So11111111111111111111111111111111111111112,1239313.36229,Pretty,8pTpjjcq5pG7NXDm99NinoT1vRoH99X7s3C1Go3upump,0.30598138415,0.001344205,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-Pretty,HBiCDY9CVNWENM8vTkHekJoNAeaLZAJoHr7EwvmAf5WY,GhqrMrC4tY8zTDvWHiHG7ag4MWPqQ7qLZmeochY6aosY,53KrU2unKY95pnSKSq3empC6woBXPxQShDv3EmpDNnn1knesLfxHtCetCkbuNPRWPXr3tj3WKuu8B63Ypawx8yvb,977,3,2,true +2024-12-04 04:50:48.000 UTC,2024-12-04,2024-12-01,Tradewiz,solana,77.97821513972,Buy,1428724.561159,eigenrobot,9qpaeuNMNWwHfa7keQ51D5VJNt2jessw8khxWis5pump,0.327832402,SOL,So11111111111111111111111111111111111111112,0.7135800000000001,0.003,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-eigenrobot,7Ys5V2wmjz3LihubgfnCdSZnwEUvBNBXXLvpAWZLRiS5,5q853P8PLeYiE5PjXg24kQ9nXrf5Qn6r55A9urS4hYF6,2XPV2bKhVjYGjuLGWhxjUK69mPFqyfFYcBM6HTSnErYLxHP1cNSksWp4i3VbF7QesYJtQnPvtt5aixEbkr137nz1,959,7,4,true +2024-12-04 13:04:31.000 UTC,2024-12-04,2024-12-01,Tradewiz,solana,0.00010256337,Sell,4.41e-7,SOL,So11111111111111111111111111111111111111112,117382.719111186,FCI,7s9q7HcfMhhf4XoFtHUzJWyAPAN3mSEmBDfB17iM67QJ,9.3028e-7,4e-9,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-FCI,8AfbS9Ji49Jj4UkZmm4whYACyUN8QQQa1dsj9JuYQjFs,EcpfuULFUmouh7XU4uESrksywAwoND2PBu7T3LJwXJmM,4N2Fw8hjiaKSBHnkc7nbH4C6TbjFtpE5RHas2uQKkJvNVUSbwUuTST6GhTueLsrMJe4ho9Sr13xm3V1QQtNzGcSf,460,4,0,true +2024-12-04 20:35:20.000 UTC,2024-12-04,2024-12-01,Tradewiz,solana,46.792,Buy,66517.719092,convo,KnrmAHo1wW2fGqVXcSZSpo6kmiKam5vNbDByrURpump,0.2,SOL,So11111111111111111111111111111111111111112,0.46792,0.002,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-convo,Exy58ud7t8LHN1EBnrcRRwRQmz1uSUC3hQF9oHpM1Box,5CEbKj8WbqKkah7nhYxkXGvN97xvz5hxd8fQjYnW5NTV,rNFm4bvTJvPVtqQGoBhyFBPhFbJftPVxoasZccwEhaaJqBA4GMVurr3aJTexbDm4p673RSnpTHpnmxLshHmGEK6,38,5,0,true +2024-12-06 07:59:32.000 UTC,2024-12-06,2024-12-01,Tradewiz,solana,47.796,Buy,8548.498569,PIZZAGUY,5cN4dWZKqxrpwCCBcwHpsAgus1s7WWyRaguR8YbRiECY,0.2,SOL,So11111111111111111111111111111111111111112,0.47796,0.002,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-PIZZAGUY,FgYufZ6c7NpcMvRnbB6tYupsEoyiPCtBw9dZ3bVo8kHE,1EjTzPniAGBxzvi4TBfocfq4Zxuj2GCK42aWnNJEoSS,619fmC5opZwwwAnnci5snSqtVcp9cqPYW2SAiwq8DZQrPVS8F1cLDZW9fzwxdjBYbBKZtBTeMyA9rjeCkLU1U7uE,1700,6,0,true diff --git a/dbt_subprojects/tokens/README.md b/dbt_subprojects/tokens/README.md new file mode 100644 index 00000000000..f5a7e541b34 --- /dev/null +++ b/dbt_subprojects/tokens/README.md @@ -0,0 +1,3 @@ +## Tokens subproject + +This is a DBT subproject for the main lineages of tokens data diff --git a/dbt_subprojects/tokens/dbt_project.yml b/dbt_subprojects/tokens/dbt_project.yml index 9ec35c4c768..4ab163deb41 100644 --- a/dbt_subprojects/tokens/dbt_project.yml +++ b/dbt_subprojects/tokens/dbt_project.yml @@ -14,6 +14,9 @@ quoting: # profile: "spellbook-poc-tokens" profile: "spellbook-local" +flags: + require_certificate_validation: true + vars: DBT_ENV_CUSTOM_ENV_S3_BUCKET: "{{ env_var('DBT_ENV_CUSTOM_ENV_S3_BUCKET', 'local') }}" DBT_ENV_INCREMENTAL_TIME: "{{ env_var('DBT_ENV_INCREMENTAL_TIME', '1') }}" diff --git a/dbt_subprojects/tokens/models/prices/_schema.yml b/dbt_subprojects/tokens/models/prices/_schema.yml index 3e50acf4bd5..0774a3dfa3f 100644 --- a/dbt_subprojects/tokens/models/prices/_schema.yml +++ b/dbt_subprojects/tokens/models/prices/_schema.yml @@ -195,6 +195,11 @@ models: config: tags: [ 'prices', 'stability' ] description: "List of trusted tokens across blockchains" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - contract_address - name: prices_usd_trusted_tokens meta: diff --git a/dbt_subprojects/tokens/models/prices/arbitrum/prices_arbitrum_tokens.sql b/dbt_subprojects/tokens/models/prices/arbitrum/prices_arbitrum_tokens.sql index 0d231d726fc..31b062b768d 100644 --- a/dbt_subprojects/tokens/models/prices/arbitrum/prices_arbitrum_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/arbitrum/prices_arbitrum_tokens.sql @@ -229,6 +229,6 @@ FROM ('usdm-mountain-protocol-usd', 'arbitrum', 'USDM', 0x59d9356e565ab3a36dd77763fc0d87feaf85508c, 18), ('usdz-anzen-usdz', 'arbitrum', 'USDZ', 0x5018609ab477cc502e170a5accf5312b86a4b94f, 18), ('trb-tellor', 'arbitrum', 'TRB', 0xd58d345fd9c82262e087d2d0607624b410d88242, 18), - ('mor-morpheusai', 'arbitrum', 'MOR', 0x092baadb7def4c3981454dd9c0a0d7ff07bcfc86, 18) - + ('mor-morpheusai', 'arbitrum', 'MOR', 0x092baadb7def4c3981454dd9c0a0d7ff07bcfc86, 18), + ('usdx-usdxmoney-usdx', 'arbitrum', 'USDX', 0xf3527ef8dE265eAa3716FB312c12847bFBA66Cef, 18) ) as temp (token_id, blockchain, symbol, contract_address, decimals) diff --git a/dbt_subprojects/tokens/models/prices/avalanche_c/prices_avalanche_c_tokens.sql b/dbt_subprojects/tokens/models/prices/avalanche_c/prices_avalanche_c_tokens.sql index b32b0651bd6..6fa223a52c3 100644 --- a/dbt_subprojects/tokens/models/prices/avalanche_c/prices_avalanche_c_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/avalanche_c/prices_avalanche_c_tokens.sql @@ -92,5 +92,19 @@ FROM ('hon-heroes-of-nft','avalanche_c','HON',0xed2b42d3c9c6e97e11755bb37df29b6375ede3eb,18), ('bawls-bawls-onu','avalanche_c','BAWLS',0x2da8312e2c08b79104c6b18ba26bc7065abec704,18), ('shrap-shrapnel', 'avalanche_c', 'SHRAP', 0xd402298a793948698b9a63311404fbbee944eafd, 18), - ('bal-balancer', 'avalanche_c', 'BAL', 0xe15bcb9e0ea69e6ab9fa080c4c4a5632896298c3, 18) + ('bal-balancer', 'avalanche_c', 'BAL', 0xe15bcb9e0ea69e6ab9fa080c4c4a5632896298c3, 18), + ('ausd-agora-dollar', 'avalanche_c', 'AUSD', 0x00000000eFE302BEAA2b3e6e1b18d08D69a9012a, 6), + ('stg-stargatetoken', 'avalanche_c', 'STG', 0x2F6F07CDcf3588944Bf4C42aC74ff24bF56e7590, 18), + --('tus-treasure-under-sea', 'avalanche_c', 'TUS', 0xf693248f96fe03422fea95ac0afbbbc4a8fdd172, 18), + --('cra-crabada', 'avalanche_c', 'CRA', 0xa32608e873f9ddef944b24798db69d80bbb4d1ed, 18), + ('gmx-gmx', 'avalanche_c', 'GMX', 0x62edc0692bd897d2295872a9ffcac5425011c661, 18), + ('klo-kalao', 'avalanche_c', 'KLO', 0xb27c8941a7df8958a1778c0259f76d1f8b711c35, 18), + ('solvbtc-solv-protocol-solvbtc', 'avalanche_c', 'SolvBTC', 0xbc78d84ba0c46dfe32cf2895a19939c86b81a777, 18), + ('sb-snowbank', 'avalanche_c', 'SB', 0x7d1232b90d3f809a54eeaeebc639c62df8a8942f, 9), + ('euroc-euro-coin', 'avalanche_c', 'EURC', 0xC891EB4cbdEFf6e073e859e987815Ed1505c2ACD, 6), + ('renbtc-renbtc', 'avalanche_c', 'renBTC', 0xdbf31df14b66535af65aac99c32e9ea844e14501, 8), + ('arena-the-arena', 'avalanche_c', 'ARENA', 0xb8d7710f7d8349a506b75dd184f05777c82dad0c, 18), + ('zro-layerzero', 'avalanche_c', 'ZRO', 0x6985884c4392d348587b19cb9eaaf157f13271cd, 18), + ('beam-beam-eth', 'avalanche_c', 'BEAM', 0x62d0a8458ed7719fdaf978fe5929c6d342b0bfce, 18) + ) as temp (token_id, blockchain, symbol, contract_address, decimals) diff --git a/dbt_subprojects/tokens/models/prices/base/prices_base_tokens.sql b/dbt_subprojects/tokens/models/prices/base/prices_base_tokens.sql index 7891a6ece06..00c4e28e4b5 100644 --- a/dbt_subprojects/tokens/models/prices/base/prices_base_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/base/prices_base_tokens.sql @@ -190,6 +190,18 @@ FROM ('alf-alf', 'base', 'ALF',0x26f1bb40ea88b46ceb21557dc0ffac7b7c0ad40f, 18), ('tad1-tadpole', 'base', 'TAD',0x55027a5b06f4340cc4c82dcc74c90ca93dcb173e, 18), ('blue-blue-guy', 'base', 'BLUE',0x891502ba08132653151f822a3a430198f1844115, 18), - ('alb-alienbase', 'base', 'ALB',0x1dd2d631c92b1acdfcdd51a0f7145a50130050c4, 18) - + ('alb-alienbase', 'base', 'ALB',0x1dd2d631c92b1acdfcdd51a0f7145a50130050c4, 18), + ('clark-coinbase-mascot','base','CLARK',0x5f7373Fa845692b1dD7bfaE576D6c743482bf26a, 18), + ('gyd-gyro-dollar','base','GYD',0xca5d8f8a8d49439357d3cf46ca2e720702f132b8, 18), + ('virtual-virtual-protocol', 'base', 'VIRTUAL', 0x0b3e328455c4059EEb9e3f84b5543F74E24e7E1b, 18), + ('bomb-fbomb', 'base', 'BOMB', 0x74ccbe53f77b08632ce0cb91d3a545bf6b8e0979, 18), + ('play9-play', 'base', 'PLAY', 0x7404ac09adf614603d9c16a7ce85a1101f3514ba, 18), + ('champ-super-champs', 'base', 'CHAMP', 0xeb6d78148f001f3aa2f588997c5e102e489ad341, 18), + ('euroc-euro-coin', 'base', 'EURC', 0x60a3e35cc302bfa44cb288bc5a4f316fdb1adb42, 6), + ('fai-freysa', 'base', 'FAI', 0xb33ff54b9f7242ef1593d2c9bcd8f9df46c77935, 18), + ('ogn-origin-protocol', 'base', 'OGN', 0x7002458b1df59eccb57387bc79ffc7c29e22e6f7, 18), + ('usdt-tether', 'base', 'USDT', 0xfde4c96c8593536e31f229ea8f37b2ada2699bb2, 6), + ('klima-klimadao', 'base', 'KLIMA', 0xdcefd8c8fcc492630b943abcab3429f12ea9fea2, 9), + ('yfi-yearnfinance', 'base', 'YFI', 0x9eaf8c1e34f05a589eda6bafdf391cf6ad3cb239, 18) + --('well-moonwell' ,'base', 'WELL', 0xa88594d404727625a9437c3f886c7643872296ae, 18) ) as temp (token_id, blockchain, symbol, contract_address, decimals) diff --git a/dbt_subprojects/tokens/models/prices/boba/_schema.yml b/dbt_subprojects/tokens/models/prices/boba/_schema.yml new file mode 100644 index 00000000000..1a0a161aad8 --- /dev/null +++ b/dbt_subprojects/tokens/models/prices/boba/_schema.yml @@ -0,0 +1,29 @@ +version: 2 + +models: + - name: prices_boba_tokens + meta: + blockchain: boba + sector: prices + contributors: hosuke + config: + tags: ['prices', 'tokens', 'usd', 'boba'] + description: "Price tokens on Boba Network EVM chain" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - contract_address + columns: + - name: token_id + description: "Id of the token at coinpaprika. This id is required to pull the price feed data. NOTE: Not all tokens are listed at coinpaprika - consider using price data from DEX sources in this case or submit a listing request at coinpaprika." + - name: blockchain + description: "Native blockchain of the token, if any" + data_tests: + - accepted_values: + values: [ "boba" ] + - name: contract_address + description: "Contract address of the token, if any" + - name: symbol + description: "Token symbol" + - name: decimals + description: "Number of decimals for the token contract" diff --git a/dbt_subprojects/tokens/models/prices/boba/prices_boba_tokens.sql b/dbt_subprojects/tokens/models/prices/boba/prices_boba_tokens.sql new file mode 100644 index 00000000000..8480d16c5c2 --- /dev/null +++ b/dbt_subprojects/tokens/models/prices/boba/prices_boba_tokens.sql @@ -0,0 +1,28 @@ +{% set blockchain = 'boba' %} + +{{ config( + schema = 'prices_' + blockchain, + alias = 'tokens', + materialized = 'table', + file_format = 'delta', + tags = ['static'] + ) +}} + +SELECT + token_id + , '{{ blockchain }}' as blockchain + , symbol + , contract_address + , decimals +FROM +( + VALUES + ('usdt-tether', 'USDT', 0x5DE1677344D3Cb0D7D465c10b72A8f60699C062d, 6) + , ('usdc-usd-coin', 'USDC', 0x66a2A913e447d6b4BF33EFbec43aAeF87890FBbc, 6) + , ('eth-ethereum', 'WETH', 0xdeaddeaddeaddeaddeaddeaddeaddeaddead0000, 18) + , ('boba-boba-network', 'BOBA', 0xa18bF3994C0Cc6E3b63ac420308E5383f53120D7, 18) + , ('dai-dai', 'DAI', 0xf74195Bb8a5cf652411867c5C2C5b8C2a402be35, 18) + , ('frax-frax', 'FRAX', 0x7562F525106F5d54E891e005867Bf489B5988CD9, 18) + , ('bnb-binance-coin', 'BNB', 0x68ac1623ACf9eB9F88b65B5F229fE3e2c0d5789E, 18) +) as temp (token_id, symbol, contract_address, decimals) diff --git a/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql b/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql index f2e49568891..61dafea3763 100644 --- a/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql @@ -1864,7 +1864,14 @@ FROM ('oas-oases-chain', 'ethereum', 'OAS', 0x89885fc1f76c3f4cc719640e33c315227da7003a, 18), ('sidus-sidus', 'ethereum', 'SIDUS', 0x549020a9Cb845220D66d3E9c6D9F9eF61C981102, 18), ('mcg-metalcore', 'ethereum', 'MCG', 0xc9E503562d0Db0A2629288a5D3b1c94Ea7741869, 18), - ('mavia-heroes-of-mavia', 'ethereum', 'MAVIA', 0x24fcfc492c1393274b6bcd568ac9e225bec93584, 18) + ('mavia-heroes-of-mavia', 'ethereum', 'MAVIA', 0x24fcfc492c1393274b6bcd568ac9e225bec93584, 18), + ('shrub-shrub', 'ethereum', 'SHRUB', 0x3b991130eae3cca364406d718da22fa1c3e7c256, 18), + ('sbr-strategic-bitcoin-reserve', 'ethereum', 'SBR', 0xd6203889c22d9fe5e938a9200f50fdffe9dd8e02, 9), + ('sigma2-sigma', 'ethereum', 'SIGMA', 0x18a8D75F70eAEad79B5A55903D036ce337F623A5, 18), + ('mstr-mstr2100', 'ethereum', 'MSTR', 0x42069026EAC8Eee0Fd9b5f7aDFa4f6E6D69a2B39, 9), + ('usdl-lift-dollar', 'ethereum', 'USDL', 0xbdC7c08592Ee4aa51D06C27Ee23D5087D65aDbcD, 18), + ('usr-resolv-usr', 'ethereum', 'USR', 0x66a1e37c9b0eaddca17d3662d6c05f4decf3e110, 18), + ('sovrn-sovrun','ethereum', 'SOVRN', 0x031B8d752d73d7Fe9678ACEf26e818280D0646b4, 18) ) as temp (token_id, blockchain, symbol, contract_address, decimals) where contract_address not in ( -- bad price feeds diff --git a/dbt_subprojects/tokens/models/prices/flare/_schema.yml b/dbt_subprojects/tokens/models/prices/flare/_schema.yml new file mode 100644 index 00000000000..dcd1b19db3a --- /dev/null +++ b/dbt_subprojects/tokens/models/prices/flare/_schema.yml @@ -0,0 +1,29 @@ +version: 2 + +models: + - name: prices_flare_tokens + meta: + blockchain: flare + sector: prices + contributors: hosuke, yakufff + config: + tags: ['prices', 'tokens', 'usd', 'flare'] + description: "Price tokens on Flare Network EVM chain" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - contract_address + columns: + - name: token_id + description: "Id of the token at coinpaprika. This id is required to pull the price feed data. NOTE: Not all tokens are listed at coinpaprika - consider using price data from DEX sources in this case or submit a listing request at coinpaprika." + - name: blockchain + description: "Native blockchain of the token, if any" + data_tests: + - accepted_values: + values: [ "flare" ] + - name: contract_address + description: "Contract address of the token, if any" + - name: symbol + description: "Token symbol" + - name: decimals + description: "Number of decimals for the token contract" diff --git a/dbt_subprojects/tokens/models/prices/flare/prices_flare_tokens.sql b/dbt_subprojects/tokens/models/prices/flare/prices_flare_tokens.sql new file mode 100644 index 00000000000..956f9317452 --- /dev/null +++ b/dbt_subprojects/tokens/models/prices/flare/prices_flare_tokens.sql @@ -0,0 +1,25 @@ +{% set blockchain = 'flare' %} + +{{ config( + schema = 'prices_' + blockchain, + alias = 'tokens', + materialized = 'table', + file_format = 'delta', + tags = ['static'] + ) +}} + +SELECT + token_id + , '{{ blockchain }}' as blockchain + , symbol + , contract_address + , decimals +FROM +( + VALUES + ('flr-flare-network', 'WFLR', 0x1D80c49BbBCd1C0911346656B529DF9E5c2F783d, 18) + , ('joule-kinetic', 'JOULE', 0xE6505f92583103AF7ed9974DEC451A7Af4e3A3bE, 18) + , ('usdc.e-usd-coin.e', 'USDC.e', 0xFbDa5F676cB37624f28265A144A48B0d6e87d3b6, 6) + , ('usdt-tether', 'USDT', 0x0B38e83B86d491735fEaa0a791F65c2B99535396, 6) +) as temp (token_id, symbol, contract_address, decimals) diff --git a/dbt_subprojects/tokens/models/prices/gnosis/prices_gnosis_tokens.sql b/dbt_subprojects/tokens/models/prices/gnosis/prices_gnosis_tokens.sql index 24abc9275ef..396bd2ca4bc 100644 --- a/dbt_subprojects/tokens/models/prices/gnosis/prices_gnosis_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/gnosis/prices_gnosis_tokens.sql @@ -40,5 +40,6 @@ FROM ('safe-safe', 'gnosis', 'SAFE', 0x4d18815d14fe5c3304e87b3fa18318baa5c23820, 18), ('giv-giv', 'gnosis', 'GIV', 0x4f4F9b8D5B4d0Dc10506e5551B0513B61fD59e75, 18), ('usdc-usd-coin', 'gnosis', 'USDC.e', 0x2a22f9c3b484c3629090feed35f17ff8f88f76f0, 6), - ('ageur-ageur', 'gnosis', 'agEUR', 0x4b1e2c2762667331bc91648052f646d1b0d35984, 18) + ('ageur-ageur', 'gnosis', 'agEUR', 0x4b1e2c2762667331bc91648052f646d1b0d35984, 18), + ('brla-brla-digital-brla', 'gnosis', 'BRLA', 0xFECB3F7c54E2CAAE9dC6Ac9060A822D47E053760, 18) ) as temp (token_id, blockchain, symbol, contract_address, decimals) diff --git a/dbt_subprojects/tokens/models/prices/optimism/prices_optimism_tokens_curated.sql b/dbt_subprojects/tokens/models/prices/optimism/prices_optimism_tokens_curated.sql index d0e1460b32d..ba2a0644a73 100644 --- a/dbt_subprojects/tokens/models/prices/optimism/prices_optimism_tokens_curated.sql +++ b/dbt_subprojects/tokens/models/prices/optimism/prices_optimism_tokens_curated.sql @@ -136,5 +136,6 @@ FROM ('pendle-pendle', 'PENDLE',0xbc7b1ff1c6989f006a1185318ed4e7b5796e66e1, 18), ('trb-tellor', 'TRB', 0xaf8ca653fa2772d58f4368b0a71980e9e3ceb888, 18), ('dtoro-dextoro', 'DTORO', 0x1cef2d62af4cd26673c7416957cc4ec619a696a7, 18), - ('osak-osaka-protocol', 'OSAK', 0xbfd5206962267c7b4b4a8b3d76ac2e1b2a5c4d5e, 18) + ('osak-osaka-protocol', 'OSAK', 0xbfd5206962267c7b4b4a8b3d76ac2e1b2a5c4d5e, 18), + ('gyd-gyro-dollar','GYD',0xca5d8f8a8d49439357d3cf46ca2e720702f132b8, 18) ) as temp (token_id, symbol, contract_address, decimals) diff --git a/dbt_subprojects/tokens/models/prices/prices_native_tokens.sql b/dbt_subprojects/tokens/models/prices/prices_native_tokens.sql index f86c6a37a71..e7bc5483e81 100644 --- a/dbt_subprojects/tokens/models/prices/prices_native_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/prices_native_tokens.sql @@ -25,6 +25,7 @@ FROM ('avax-avalanche', null, 'AVAX', null, null), ('bch-bitcoin-cash', null, 'BCH', null, null), ('bnb-binance-coin', null, 'BNB', null, null), + ('boba-boba-network', null, 'BOBA', null, null), ('bsv-bitcoin-sv', null, 'BSV', null, null), ('btc-bitcoin', null, 'BTC', null, null), ('celo-celo', null, 'CELO', null, null), @@ -87,5 +88,6 @@ FROM ('ton-toncoin', null, 'TON', null,null), ('strk-starknet', null, 'STRK', null,null), ('kda-kadena', null, 'KDA', null, null), - ('ron-ronin-token', null, 'RON', null, null) + ('ron-ronin-token', null, 'RON', null, null), + ('hype-hyperliquid', null, 'HYPE', null, null) ) as temp (token_id, blockchain, symbol, contract_address, decimals) diff --git a/dbt_subprojects/tokens/models/prices/prices_tokens.sql b/dbt_subprojects/tokens/models/prices/prices_tokens.sql index 665f2adde64..0f38cb25f82 100644 --- a/dbt_subprojects/tokens/models/prices/prices_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/prices_tokens.sql @@ -11,10 +11,12 @@ , "bitcoin" , "blast" , "bnb" + , "boba" , "cardano" , "celo" , "ethereum" , "fantom" + , "flare" , "gnosis" , "kaia" , "linea" @@ -25,6 +27,7 @@ , "scroll" , "sei" , "solana" + , "viction" , "worldchain" , "zksync" , "zkevm" @@ -45,6 +48,7 @@ ref('prices_native_tokens') ,ref('prices_cardano_tokens') ,ref('prices_ethereum_tokens') ,ref('prices_fantom_tokens') +,ref('prices_flare_tokens') ,ref('prices_gnosis_tokens') ,ref('prices_optimism_tokens') ,ref('prices_polygon_tokens') @@ -64,6 +68,8 @@ ref('prices_native_tokens') ,ref('prices_kaia_tokens') ,ref('prices_tron_tokens') ,ref('prices_ronin_tokens') +,ref('prices_boba_tokens') +,ref('prices_viction_tokens') ] %} diff --git a/dbt_subprojects/tokens/models/prices/prices_trusted_tokens.sql b/dbt_subprojects/tokens/models/prices/prices_trusted_tokens.sql index 37ad50a9faa..cb20a76eda0 100644 --- a/dbt_subprojects/tokens/models/prices/prices_trusted_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/prices_trusted_tokens.sql @@ -47,6 +47,13 @@ WITH trusted_tokens AS ( , ('bnb', 0x2170ed0880ac9a755fd29b2688956bd959f933f8) , ('bnb', 0x7130d2a12b9bcbfae4f2634d864a1ee1ce3ead9c) , ('bnb', 0x1af3f329e8be154074d8769d1ffa4ee058b1dbc3) + , ('boba', 0x5DE1677344D3Cb0D7D465c10b72A8f60699C062d) + , ('boba', 0x66a2A913e447d6b4BF33EFbec43aAeF87890FBbc) + , ('boba', 0xdeaddeaddeaddeaddeaddeaddeaddeaddead0000) + , ('boba', 0xa18bF3994C0Cc6E3b63ac420308E5383f53120D7) + , ('boba', 0xf74195Bb8a5cf652411867c5C2C5b8C2a402be35) + , ('boba', 0x7562F525106F5d54E891e005867Bf489B5988CD9) + , ('boba', 0x68ac1623ACf9eB9F88b65B5F229fE3e2c0d5789E) , ('celo', 0x765de816845861e75a25fca122bb6898b8b1282a) , ('celo', 0x471ece3750da237f93b8e339c536989b8978a438) , ('celo', 0xceba9300f2b948710d2653dd7b07f33a8b32118c) @@ -60,7 +67,9 @@ WITH trusted_tokens AS ( , ('ethereum', 0x6b175474e89094c44da98b954eedeac495271d0f) , ('ethereum', 0x2260fac5e5542a773aa44fbcfedf7c193bc2c599) , ('ethereum', 0xf939e0a03fb07f59a73314e73794be0e57ac1b4e) + , ('ethereum', 0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0) -- wstETH , ('fantom', 0x21be370d5312f44cb42ce377bc9b8a0cef1a4c83) + , ('flare', 0x1D80c49BbBCd1C0911346656B529DF9E5c2F783d) , ('fantom', 0x04068da6c83afcfa0e13ba15a6696662335d5b75) , ('fantom', 0x74b23882a30290451a17c44f4f05243b6b58c76d) , ('fantom', 0x8d11ec38a3eb5e956b052f67da8bdc9bef8abf3e) @@ -144,6 +153,9 @@ WITH trusted_tokens AS ( , ('zkevm', 0x37eaa0ef3549a5bb7d431be78a3d99bd360d19e5) , ('zkevm', 0xa2036f0538221a77a3937f1379699f44945018d0) , ('zkevm', 0xb23c20efce6e24acca0cef9b7b7aa196b84ec942) + , ('viction', 0xC054751BdBD24Ae713BA3Dc9Bd9434aBe2abc1ce) -- WVIC + , ('viction', 0x381B31409e4D220919B2cFF012ED94d70135A59e) -- USDT + , ('viction', 0x20cC4574f263C54eb7aD630c9AC6d4d9068Cf127) -- USDC , ('zksync', 0x3355df6d4c9c3035724fd0e3914de96a5a83aaf4) , ('zksync', 0x2039bb4116b4efc145ec4f0e2ea75012d6c0f181) , ('zksync', 0x5aea5775959fbc2557cc8789bc1bf90a239d9a91) diff --git a/dbt_subprojects/tokens/models/prices/ronin/prices_ronin_tokens.sql b/dbt_subprojects/tokens/models/prices/ronin/prices_ronin_tokens.sql index 00c77acfc2a..5b4b180f5bb 100644 --- a/dbt_subprojects/tokens/models/prices/ronin/prices_ronin_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/ronin/prices_ronin_tokens.sql @@ -25,6 +25,5 @@ FROM , ('slp-smooth-love-potion', 'SLP', 0xa8754b9fa15fc18bb59458815510e40a12cd2014, 0) , ('pixel-pixels', 'PIXEL', 0x7eae20d11ef8c779433eb24503def900b9d28ad7, 18) , ('ygg-yield-guild-games', 'YGG', 0x1c306872bc82525d72bf3562e8f0aa3f8f26e857, 18) - , ('lua-lumi-finance', 'LUA', 0x18d2bdef572c67127e218c425f546fe64430a92c, 18) - + , ('lua-lumi-finance', 'LUA', 0xd61bbbb8369c46c15868ad9263a2710aced156c4, 18) ) as temp (token_id, symbol, contract_address, decimals) diff --git a/dbt_subprojects/tokens/models/prices/solana/prices_solana_tokens.sql b/dbt_subprojects/tokens/models/prices/solana/prices_solana_tokens.sql index 37cc907ebd8..791f3f58b63 100644 --- a/dbt_subprojects/tokens/models/prices/solana/prices_solana_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/solana/prices_solana_tokens.sql @@ -707,5 +707,14 @@ FROM ('moodeng-moo-deng-moodengsolcom', 'solana', 'MOODENG', 'ED5nyyWEzpPPiWimP8vYm7sD7TD3LAt3Q3gRTWHzPJBY', 6), ('scf-smoking-chicken-fish', 'solana', 'SCF', 'GiG7Hr61RVm4CSUxJmgiCoySFQtdiwxtqf64MsRppump', 6), ('luna-luna-by-virtuals', 'solana', 'LUNA', '9se6kma7LeGcQWyRBNcYzyxZPE3r9t9qWZ8SnjnN3jJ7', 8), - ('goat-goatseus-maximus', 'solana', 'GOAT', 'CzLSujWBLFsSjncfkh59rUFqvafWcY5tzedWJSuypump', 6) + ('goat-goatseus-maximus', 'solana', 'GOAT', 'CzLSujWBLFsSjncfkh59rUFqvafWcY5tzedWJSuypump', 6), + ('fwog-fwog', 'solana', 'FWOG', 'A8C3xuqscfmyLrte3VmTqrAq8kgMASius9AFNANwpump', 6), + ('lester-litecoin-mascot', 'solana', 'LESTER', '5z3iCe53hUANTiG8Js8RjHNE2Arjik7L2CXLyr2rpump', 6), + ('happy-happycat', 'solana', 'HAPPY', 'HAPPYwgFcjEJDzRtfWE6tiHE9zGdzpNky2FvjPHsvvGZ', 9), + ('memesai-memes-ai', 'solana', 'MEMESAI', '39qibQxVzemuZTEvjSB7NePhw9WyyHdQCqP8xmBMpump', 6), + ('grift1-orbit', 'solana', 'GRIFT', 'GekTNfm84QfyP2GdAHZ5AgACBRd69aNmgA5FDhZupump', 6), + ('fxn-fxn', 'solana', 'FXN', '92cRC6kV5D7TiHX1j56AbkPbffo9jwcXxSDQZ8Mopump',6), + ('griffain-test-griffaincom', 'solana', 'GRIFFAIN', 'KENJSUYLASHUMfHyy5o4Hp2FdNqZg1AsUPhfH2kYvEP', 6), + ('tank-agenttank', 'solana', 'TANK', 'GAMwtMB6onAvBNBQJCJFuxoaqfPH8uCQ2dewNMVVpump', 6), + ('pengu-pudgy-penguins', 'solana', 'PENGU', '2zMMhcVQEXDtdE6vsFS7S7D5oUodfJHE8vd1gnBouauv', 6) ) as temp (token_id, blockchain, symbol, contract_address, decimals) diff --git a/dbt_subprojects/tokens/models/prices/viction/_schema.yml b/dbt_subprojects/tokens/models/prices/viction/_schema.yml new file mode 100644 index 00000000000..a6d2aed3411 --- /dev/null +++ b/dbt_subprojects/tokens/models/prices/viction/_schema.yml @@ -0,0 +1,29 @@ +version: 2 + +models: + - name: prices_viction_tokens + meta: + blockchain: viction + sector: prices + contributors: hosuke + config: + tags: ['prices', 'tokens', 'usd', 'viction'] + description: "Price tokens on Viction Network EVM chain" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - contract_address + columns: + - name: token_id + description: "Id of the token at coinpaprika. This id is required to pull the price feed data. NOTE: Not all tokens are listed at coinpaprika - consider using price data from DEX sources in this case or submit a listing request at coinpaprika." + - name: blockchain + description: "Native blockchain of the token, if any" + data_tests: + - accepted_values: + values: [ "viction" ] + - name: contract_address + description: "Contract address of the token, if any" + - name: symbol + description: "Token symbol" + - name: decimals + description: "Number of decimals for the token contract" diff --git a/dbt_subprojects/tokens/models/prices/viction/prices_viction_tokens.sql b/dbt_subprojects/tokens/models/prices/viction/prices_viction_tokens.sql new file mode 100644 index 00000000000..0db37fa0789 --- /dev/null +++ b/dbt_subprojects/tokens/models/prices/viction/prices_viction_tokens.sql @@ -0,0 +1,24 @@ +{% set blockchain = 'viction' %} + +{{ config( + schema = 'prices_' + blockchain, + alias = 'tokens', + materialized = 'table', + file_format = 'delta', + tags = ['static'] + ) +}} + +SELECT + token_id + , '{{ blockchain }}' as blockchain + , symbol + , contract_address + , decimals +FROM +( + VALUES + ('tomo-tomochain', 'WVIC', 0xC054751BdBD24Ae713BA3Dc9Bd9434aBe2abc1ce, 18) + , ('usdt-tether', 'USDT', 0x381B31409e4D220919B2cFF012ED94d70135A59e, 6) + , ('usdc-usd-coin', 'USDC', 0x20cC4574f263C54eb7aD630c9AC6d4d9068Cf127, 6) +) as temp (token_id, symbol, contract_address, decimals) diff --git a/dbt_subprojects/tokens/models/tokens/_schema.yml b/dbt_subprojects/tokens/models/tokens/_schema.yml index 5b5784747a1..1969374b9ba 100644 --- a/dbt_subprojects/tokens/models/tokens/_schema.yml +++ b/dbt_subprojects/tokens/models/tokens/_schema.yml @@ -3,11 +3,12 @@ version: 2 models: - name: tokens_erc20 meta: - blockchain: arbitrum, avalanche_c, bnb, ethereum, gnosis, mantle, optimism, fantom, polygon, base, blast, sepolia, sei, nova, worldchain, kaia, ronin + blockchain: arbitrum, avalanche_c, bnb, ethereum, gnosis, mantle, optimism, fantom, polygon, base, blast, sepolia, sei, nova, worldchain, kaia, ronin, boba, flare, viction, sonic sector: tokens - contributors: hildobby, 0xManny, dot2dotseurat, soispoke, mtitus6, wuligy, angus_1, Henrystats, viniabussafi, jeff-dude, rantum, hosuke + contributors: hildobby, 0xManny, dot2dotseurat, soispoke, mtitus6, wuligy, angus_1, Henrystats, viniabussafi, jeff-dude, rantum, hosuke, irishlatte19 config: - tags: ['tokens','erc20', 'arbitrum', 'avalanche_c', 'bnb', 'ethereum', 'gnosis', 'mantle', 'optimism', 'fantom', 'base', 'blast', 'sei', 'nova', 'linea', 'worldchain', 'kaia', 'ronin'] + tags: ['tokens','erc20', 'arbitrum', 'avalanche_c', 'bnb', 'ethereum', 'gnosis', 'mantle', 'optimism', 'fantom', 'base', 'blast', 'sei', 'nova', 'linea', 'worldchain', 'kaia', 'ronin', 'boba', 'flare', 'viction', 'sonic'] + description: > Crosschain ERC20 tokens data_tests: diff --git a/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_erc20.sql b/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_erc20.sql index 286f6aadfcb..7635bf4ce45 100644 --- a/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_erc20.sql +++ b/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_erc20.sql @@ -121,4 +121,9 @@ FROM (VALUES , (0xb59c8912c83157a955f9d715e556257f432c35d7, 'TRUF', 18) , (0xe1d3495717f9534db67a6a8d4940dd17435b6a9e, 'LOCUS', 18) , (0x764bfc309090e7f93edce53e5befa374cdcb7b8e, 'GRIMACE', 18) + , (0xB0BDE111812EAC913b392D80D51966eC977bE3A2, 'jUSDC', 18) + , (0xf3b7994e4dA53E04155057Fd61dc501599d57877, 'farmdWETHV3', 18) + , (0x521598765b0E5a4CD743f2769C06787b84617252, 'TLP', 18) + , (0xf3527ef8dE265eAa3716FB312c12847bFBA66Cef, 'USDX', 18) + , (0x7788A3538C5fc7F9c7C8A74EAC4c898fC8d87d92, 'sUSDX', 18) ) AS temp_table (contract_address, symbol, decimals) diff --git a/dbt_subprojects/tokens/models/tokens/avalanche_c/tokens_avalanche_c_erc20.sql b/dbt_subprojects/tokens/models/tokens/avalanche_c/tokens_avalanche_c_erc20.sql index cfe1b2720cf..3702b206a1b 100644 --- a/dbt_subprojects/tokens/models/tokens/avalanche_c/tokens_avalanche_c_erc20.sql +++ b/dbt_subprojects/tokens/models/tokens/avalanche_c/tokens_avalanche_c_erc20.sql @@ -384,4 +384,7 @@ FROM (VALUES , (0xca5d8f8a8d49439357d3cf46ca2e720702f132b8, 'GYD', 18) , (0xC509aB7bB4eDbF193b82264D499a7Fc526Cd01F4, 'stataAvaUSDC', 6) , (0xc654721fbf1f374fd9ffa3385bba2f4932a6af55, 'JUICY', 18) + , (0xBaCD77aC0c456798e05de15999CB212129d90b70, 'WOOFY', 18) + , (0xfE09E309726FcDb92B05Df5f682185a0B0590dD9, 'RIPPED', 18) + , (0x3db3aa87121d16407cfbbadf3f1c5b519182a399, 'AURA', 18) ) AS temp_table (contract_address, symbol, decimals) diff --git a/dbt_subprojects/tokens/models/tokens/avalanche_c/tokens_avalanche_c_nft_curated.sql b/dbt_subprojects/tokens/models/tokens/avalanche_c/tokens_avalanche_c_nft_curated.sql index 8c42f44a161..46a751ad005 100644 --- a/dbt_subprojects/tokens/models/tokens/avalanche_c/tokens_avalanche_c_nft_curated.sql +++ b/dbt_subprojects/tokens/models/tokens/avalanche_c/tokens_avalanche_c_nft_curated.sql @@ -9,6 +9,16 @@ SELECT contract_address, name, symbol FROM (VALUES + (0x2b9328d83becd4f04de05f129ba56781fa191e67, 'Cattopya', 'CAT'), + (0x34b4da1a0b06cfb09cb0efb46f02e667330e17db, 'Humping Unicorns', 'HUMP'), + (0x47d42b18d54ee0b94b59c3e41dcac3260e995e48, 'Doggerinos Accessories', 'DOGACC'), + (0x824ca4209DebA44Da8d2d71A4c52Bc0E62265FfA, 'Dev and Draw Presale Pass', 'DND PP'), + (0x8d904c8b6bb673d88cdbcd5798cda439f33cb3a4, 'Doggerinos', 'DOGGERINOS'), + (0x9190ba4c3d0a30128509517fa8c0f080fc603f99, 'Fragments of the City', 'CITY'), + (0xb563420b7b8119114968C70093c4966630ad16d3, 'Bruskies', 'Bruskies'), + (0xC93e7eFE0E863a1E4ffC6D2dcF7AfC1d3CCCE0b4, 'Mamboners', 'BONER'), + (0xe6cc79cA731A5e406024015bB2dE5346B52eCA2F, 'Peons V2', 'Peons V2'), + (0xfE09E309726FcDb92B05Df5f682185a0B0590dD9, 'RIPPED DAO', 'RIPPED'), (0x7098b1918eb2aa13945b8a489975bbbf0d5dd79b, 'Long Long Legacy', 'LLL'), (0xc732518034c5df52cdddf17486b9409bc7721e2c, 'Sausagers', 'MEAT'), (0x00bf1594507ccf60b41ad64524d4aba23b059f4b, 'Ferdy Frends', 'FREN'), @@ -12037,5 +12047,6 @@ FROM (VALUES (0xffd2a1cf6dbb896c4db0df992e68e99e329f7a52, 'Angels® Mike Trout 1987 35th Anniversary Chrome T87C-50 Super Rare', 'MLB-22S1-S-1987AC37-M-CHR'), (0xffddfe5194e693c8954ddd9fa9bfb54625bf434c, 'Arne Maier FCA Color Splash Facsimile Signature Team Color TK-67 Legendary', 'BUND-22TK-L-CSTK-67-S-TMC'), (0xffe416277c4a301d3525bacaba00bc4f2000c29e, 'Miami Marlins® Bryan De La Cruz Base Independence Day RWB 22 Rare', 'MLB-22S1-R-B22-M-RWB'), - (0xfff6fa52337d60dbbd222671c0397d5908e5e31d, 'Lil Walter Drip', 'LWD') + (0xfff6fa52337d60dbbd222671c0397d5908e5e31d, 'Lil Walter Drip', 'LWD'), + (0xd1b4367dd9f235f9ee61878019d66e31511e98ee, 'Voidcaller', 'VOIDCALLER') ) AS temp_table (contract_address, name, symbol) diff --git a/dbt_subprojects/tokens/models/tokens/base/tokens_base_erc20.sql b/dbt_subprojects/tokens/models/tokens/base/tokens_base_erc20.sql index 027885e76fa..ca5c1937e5b 100644 --- a/dbt_subprojects/tokens/models/tokens/base/tokens_base_erc20.sql +++ b/dbt_subprojects/tokens/models/tokens/base/tokens_base_erc20.sql @@ -245,58 +245,58 @@ FROM (VALUES , (0x62a52757b580e7fd97203bd0408a7445741b5d5f, 'DT', 18) , (0x6985884c4392d348587b19cb9eaaf157f13271cd, 'ZRO', 18) , (0x64b88c73A5DfA78D1713fE1b4c69a22d7E0faAa7, 'MAV', 18) - , (0x0f1D1b7abAeC1Df25f2C4Db751686FC5233f6D3f, 'IMO', 18) + , (0x0f1D1b7abAeC1Df25f2C4Db751686FC5233f6D3f, 'IMO', 18) , (0x9beec80e62aa257ced8b0edd8692f79ee8783777, 'TIMI', 18) - , (0x013b6451e2b2131052d3473593bd786df5143faf, 'FRENCH', 18) - , (0x31b28012f61fc3600e1c076bafc9fd997fb2da90, 'MRSMIGGLES', 18) - , (0x420b0fa3de2efcf2b2fd04152eb1df36a09717cd, 'KING', 18) + , (0x013b6451e2b2131052d3473593bd786df5143faf, 'FRENCH', 18) + , (0x31b28012f61fc3600e1c076bafc9fd997fb2da90, 'MRSMIGGLES', 18) + , (0x420b0fa3de2efcf2b2fd04152eb1df36a09717cd, 'KING', 18) , (0x190b2aA820495c0e92840E8FA699741976cd6439, 'rETH', 18) , (0x85e90a5430af45776548adb82ee4cd9e33b08077, 'DINO', 18) , (0x7c6b91D9Be155A6Db01f749217d76fF02A7227F2, 'BAL', 18) - , (0xa1e4240C9E9B8db3ba9e7625A9571c3B0FF71988, 'PJ', 18) - , (0x340c070260520ae477b88caa085a33531897145b, '9MM', 18) - , (0x38d513ec43dda20f323f26c7bef74c5cf80b6477, 'CARLO', 18) - , (0x8d3419b9a18651f3926a205ee0b1acea1e7192de, 'LOA', 18) - , (0xed899bfdb28c8ad65307fa40f4acab113ae2e14c, 'ROOST', 18) - , (0x6bd81aad9b25ad1e0b99c47ed01b34eacf4b8be7, 'BODA', 18) - , (0x75570e1189ffc1d63b3417cdf0889f87cd3e9bd1, 'Bunny', 18) - , (0x1c7a460413dd4e964f96d8dfc56e7223ce88cd85, 'SEAM', 18) - , (0x8319767a7b602f88e376368dca1b92d38869b9b4, 'PEACH', 18) - , (0x42069de48741db40aef864f8764432bbccbd0b69, 'BETS', 18) - , (0x1ccb4b14a11e0f2994a7ecbbd4cc69632f4c7c76, 'CCC', 18) - , (0xacd1caef47e4c47bafe8a51b3f4305fc38203b7a, 'LUNE', 18) - , (0xd327d36eb6e1f250d191cd62497d08b4aaa843ce, 'FOMO', 9) - , (0x00e57ec29ef2ba7df07ad10573011647b2366f6d, 'TOSHE', 18) - , (0xf1b4ddf712e108cf43711b1c39f2fddb0d5ce243, 'BASE', 18) - , (0x87c211144b1d9bdaa5a791b8099ea4123dc31d21, 'BCP', 18) - , (0xa5fbc981ebd8f4e791be8bd7a9b7cb144d145bf9, 'MEMEGOD', 18) - , (0x30d19fb77c3ee5cfa97f73d72c6a1e509fa06aef, 'CONDO', 18) - , (0x8b781e0f2967571e96d5d95b3cb61e27785eeaa5, 'BORKIE', 18) - , (0x3159fb5589acd6bf9f82eb0efe8382ed55aed8fd, 'APU', 18) - , (0x029635e83bc26c96006298e05798cdda76a2e7a5, 'SYD', 18) - , (0x314da69de85145fdd5b7580971e9db0388a2cdc4, 'BSW', 18) - , (0x8ad5b9007556749de59e088c88801a3aaa87134b, 'FARTHER', 18) - , (0x64cc19a52f4d631ef5be07947caba14ae00c52eb, 'KIBBLE', 18) - , (0x45096bd2871911ee82a3084d77a01efa3c9c6733, 'BUB', 18) - , (0x44fccd875c8e80b37f38530f434386a6d59141bb, 'DTB', 18) - , (0xfd008f937b4d73eeb00cf74ce90c392be5f07f96, 'MOON', 18) - , (0x160381343365de6d5e7d32172987b3e6bd1cce71, 'Mari', 18) - , (0x546d239032b24eceee0cb05c92fc39090846adc7, 'SEED', 18) - , (0x4c584cbc3a221998dc003349e1c12a4179e97b25, 'BMONEY', 18) - , (0x9721b1ce4ffd8af047bbdfd87e4e20ddc544513a, 'BROS', 18) - , (0xc41ba5737baf6bd0ccd5daf7eee39874e4ad45ff, 'DEGENS', 18) - , (0x10c1b6f768e13c624a4a23337f1a5ba5c9be0e4b, 'WARPIE', 18) - , (0xfd9fa4f785331ce88b5af8994a047ba087c705d8, '$blue', 18) + , (0xa1e4240C9E9B8db3ba9e7625A9571c3B0FF71988, 'PJ', 18) + , (0x340c070260520ae477b88caa085a33531897145b, '9MM', 18) + , (0x38d513ec43dda20f323f26c7bef74c5cf80b6477, 'CARLO', 18) + , (0x8d3419b9a18651f3926a205ee0b1acea1e7192de, 'LOA', 18) + , (0xed899bfdb28c8ad65307fa40f4acab113ae2e14c, 'ROOST', 18) + , (0x6bd81aad9b25ad1e0b99c47ed01b34eacf4b8be7, 'BODA', 18) + , (0x75570e1189ffc1d63b3417cdf0889f87cd3e9bd1, 'Bunny', 18) + , (0x1c7a460413dd4e964f96d8dfc56e7223ce88cd85, 'SEAM', 18) + , (0x8319767a7b602f88e376368dca1b92d38869b9b4, 'PEACH', 18) + , (0x42069de48741db40aef864f8764432bbccbd0b69, 'BETS', 18) + , (0x1ccb4b14a11e0f2994a7ecbbd4cc69632f4c7c76, 'CCC', 18) + , (0xacd1caef47e4c47bafe8a51b3f4305fc38203b7a, 'LUNE', 18) + , (0xd327d36eb6e1f250d191cd62497d08b4aaa843ce, 'FOMO', 9) + , (0x00e57ec29ef2ba7df07ad10573011647b2366f6d, 'TOSHE', 18) + , (0xf1b4ddf712e108cf43711b1c39f2fddb0d5ce243, 'BASE', 18) + , (0x87c211144b1d9bdaa5a791b8099ea4123dc31d21, 'BCP', 18) + , (0xa5fbc981ebd8f4e791be8bd7a9b7cb144d145bf9, 'MEMEGOD', 18) + , (0x30d19fb77c3ee5cfa97f73d72c6a1e509fa06aef, 'CONDO', 18) + , (0x8b781e0f2967571e96d5d95b3cb61e27785eeaa5, 'BORKIE', 18) + , (0x3159fb5589acd6bf9f82eb0efe8382ed55aed8fd, 'APU', 18) + , (0x029635e83bc26c96006298e05798cdda76a2e7a5, 'SYD', 18) + , (0x314da69de85145fdd5b7580971e9db0388a2cdc4, 'BSW', 18) + , (0x8ad5b9007556749de59e088c88801a3aaa87134b, 'FARTHER', 18) + , (0x64cc19a52f4d631ef5be07947caba14ae00c52eb, 'KIBBLE', 18) + , (0x45096bd2871911ee82a3084d77a01efa3c9c6733, 'BUB', 18) + , (0x44fccd875c8e80b37f38530f434386a6d59141bb, 'DTB', 18) + , (0xfd008f937b4d73eeb00cf74ce90c392be5f07f96, 'MOON', 18) + , (0x160381343365de6d5e7d32172987b3e6bd1cce71, 'Mari', 18) + , (0x546d239032b24eceee0cb05c92fc39090846adc7, 'SEED', 18) + , (0x4c584cbc3a221998dc003349e1c12a4179e97b25, 'BMONEY', 18) + , (0x9721b1ce4ffd8af047bbdfd87e4e20ddc544513a, 'BROS', 18) + , (0xc41ba5737baf6bd0ccd5daf7eee39874e4ad45ff, 'DEGENS', 18) + , (0x10c1b6f768e13c624a4a23337f1a5ba5c9be0e4b, 'WARPIE', 18) + , (0xfd9fa4f785331ce88b5af8994a047ba087c705d8, '$blue', 18) , (0x420697291f6ce9fbb34e9feddd61868ca2f81f5c, 'MONEYBEE', 18) - , (0x9a589baa21f0492bd4f35a33915986db56d8eecf, 'CATZ', 18) - , (0x2156006a207a793b4069a2b72be58dc2bd759232, 'COIN', 18) - , (0x17931cfc3217261ce0fa21bb066633c463ed8634, 'BASED', 18) - , (0xb9ea61ed1c9942011e5e44f7fae3efddbf277b1e, 'CHIP', 18) + , (0x9a589baa21f0492bd4f35a33915986db56d8eecf, 'CATZ', 18) + , (0x2156006a207a793b4069a2b72be58dc2bd759232, 'COIN', 18) + , (0x17931cfc3217261ce0fa21bb066633c463ed8634, 'BASED', 18) + , (0xb9ea61ed1c9942011e5e44f7fae3efddbf277b1e, 'CHIP', 18) , (0xea6f7e7e0f46a9e0f4e2048eb129d879f609d632, 'PERCY', 18) - , (0x05ad8adc21778f2a2c6800852f05fb949ef507dc, 'HACHI', 18) - , (0x8fe815417913a93ea99049fc0718ee1647a2a07c, 'XSWAP', 18) - , (0x9260409d4719c235c7c199106219f9616d66bde0, 'ArabWif', 18) - , (0x1c22374032e7e5a1bbde3d943f5deb310db060dd, 'onchain', 18) + , (0x05ad8adc21778f2a2c6800852f05fb949ef507dc, 'HACHI', 18) + , (0x8fe815417913a93ea99049fc0718ee1647a2a07c, 'XSWAP', 18) + , (0x9260409d4719c235c7c199106219f9616d66bde0, 'ArabWif', 18) + , (0x1c22374032e7e5a1bbde3d943f5deb310db060dd, 'onchain', 18) , (0x57d0ffb02f73aa09dd22d7e81d6c0c81054ab5d9, 'DRAGGY', 18) , (0xb59c8912c83157a955f9d715e556257f432c35d7, 'TRUF', 18) , (0x619c4bbbd65f836b78b36cbe781513861d57f39d, 'BWB', 18) @@ -390,12 +390,12 @@ FROM (VALUES , (0xdbcae648ebea8c950b616e10e28da09d1ab4a06d, 'ELIZ', 18) , (0x0a14ef61afb32e5ca672e021784f71705ac14908, 'NULL', 18) , (0x7e72d6410803c40e73806f2a72e3eade5d075cc0, 'MOB', 18) - , (0x24da41bae4d7014ec6faf5403d2db0aa1510358d, 'COPY', 18) + , (0x24da41bae4d7014ec6faf5403d2db0aa1510358d, 'COPY', 18) , (0x02e79d42c3297cd4154a1b52b4a3b27cd75762f1, 'FFTP', 9) , (0xc1bf21674a3d782ee552d835863d065b7a89d619, 'MISHA', 18) - , (0xfc21540d6b89667d167d42086e1feb04da3e9b21, 'INFI', 18) + , (0xfc21540d6b89667d167d42086e1feb04da3e9b21, 'INFI', 18) , (0x9a33406165f562e16c3abd82fd1185482e01b49a, 'TALENT', 18) - , (0xde31526ad9f7e8d271e85677e7ec5882f801a34b, 'First Steps Into Sovereignty', 18) + , (0xde31526ad9f7e8d271e85677e7ec5882f801a34b, 'First Steps Into Sovereignty', 18) , (0xd89cd06d54e5e5af76221c00b60c6b567b17b863, 'TAPPY', 18) , (0x1057cc4ef19cc86a1b034145225f47e354f6f95b, 'FLICKY', 18) , (0x8c3ed1f4d142965d19e0db48ae189dd9448ad95a, 'WOT', 18) @@ -405,5 +405,10 @@ FROM (VALUES , (0x574178357661527601482b79af6bb1ff7cc1306a, '1984', 18) , (0x63e14921ba4546cb15087d574346574eee055812, 'PVP', 18) , (0xd68470491eb513365322810e55e0eba80785dfdd, '243M theft', 18) - , (0xb0505e5a99abd03d94a1169e638b78edfed26ea4, 'uSUI', 18) + , (0xb0505e5a99abd03d94a1169e638b78edfed26ea4, 'uSUI', 18) + , (0x5f7373Fa845692b1dD7bfaE576D6c743482bf26a, 'CLARK', 18) + , (0xBAa5CC21fd487B8Fcc2F632f3F4E8D37262a0842, 'MORPHO', 18) + , (0xCA5d8F8a8d49439357d3CF46Ca2e720702F132b8, 'GYD', 18) + , (0xC0D3700000987C99b3C9009069E4f8413fD22330, 'cdxUSD', 18) + , (0xc694a91e6b071bf030a18bd3053a7fe09b6dae69, 'COW', 18) ) AS temp_table (contract_address, symbol, decimals) diff --git a/dbt_subprojects/tokens/models/tokens/boba/_schema.yml b/dbt_subprojects/tokens/models/tokens/boba/_schema.yml new file mode 100644 index 00000000000..61083aa8444 --- /dev/null +++ b/dbt_subprojects/tokens/models/tokens/boba/_schema.yml @@ -0,0 +1,21 @@ +version: 2 + +models: + - name: tokens_boba_erc20 + meta: + blockchain: boba + sector: tokens + project: erc20 + contributors: hosuke + config: + tags: ['table', 'erc20', 'boba'] + description: "ERC20 Token Addresses, Symbols and Decimals on Boba Network" + columns: + - name: contract_address + description: "ERC20 token contract address" + data_tests: + - unique + - name: symbol + description: "ERC20 token symbol" + - name: decimals + description: "Number of decimals, refers to how divisible an ERC20 token can be" diff --git a/dbt_subprojects/tokens/models/tokens/boba/tokens_boba_erc20.sql b/dbt_subprojects/tokens/models/tokens/boba/tokens_boba_erc20.sql new file mode 100644 index 00000000000..4d812cedd8e --- /dev/null +++ b/dbt_subprojects/tokens/models/tokens/boba/tokens_boba_erc20.sql @@ -0,0 +1,21 @@ +{{ + config( + schema = 'tokens_boba' + ,alias = 'erc20' + ,tags = ['static'] + ,materialized = 'table' + ) +}} + +SELECT + contract_address + , symbol + , decimals +FROM (VALUES + (0xa18bf3994c0cc6e3b63ac420308e5383f53120d7, 'BOBA', 18) + , (0xdeaddeaddeaddeaddeaddeaddeaddeaddead0000, 'ETH', 18) + , (0x66a2a913e447d6b4bf33efbec43aaef87890fbbc, 'USDC', 6) + , (0x5de1677344d3cb0d7d465c10b72a8f60699c062d, 'USDT', 6) + , (0xf74195bb8a5cf652411867c5c2c5b8c2a402be35, 'DAI', 18) + , (0xd203de32170130082896b4111edf825a4774c18e, 'WETH', 18) +) as temp (contract_address, symbol, decimals) diff --git a/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql b/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql index 295b395a1d2..98fe7b101f0 100644 --- a/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql +++ b/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql @@ -4564,12 +4564,12 @@ FROM (VALUES , ( 0x5983B89FA184f14917013B9C3062afD9434C5b03, 'POWER', 0) , ( 0x988567FE094570cCE1FFdA29D1f2d842B70492be, 'ZERO', 6) , ( 0x10dea67478c5f8c5e2d90e5e9b26dbe60c54d800, 'TAIKO', 18) - , ( 0x80ac24aA929eaF5013f6436cdA2a7ba190f5Cc0b, 'syrupUSDC', 6) - , ( 0xa8258deE2a677874a48F5320670A869D74f0cbC1, 'WAR', 18) + , ( 0x80ac24aA929eaF5013f6436cdA2a7ba190f5Cc0b, 'syrupUSDC', 6) + , ( 0xa8258deE2a677874a48F5320670A869D74f0cbC1, 'WAR', 18) , ( 0xbeef69ac7870777598a04b2bd4771c71212e6abc, 'steakLRT', 18) , ( 0x84631c0d0081fde56deb72f6de77abbbf6a9f93a, 'Re7LRT', 18) , ( 0x7a4effd87c2f3c55ca251080b1343b605f327e3a, 'rstETH', 18) - , ( 0x5fd13359ba15a84b76f7f87568309040176167cd, 'amprETH', 18) + , ( 0x5fd13359ba15a84b76f7f87568309040176167cd, 'amprETH', 18) , ( 0xC8E621909D71F555D2A5A90f68DD9EE0C55514De, 'SATORI', 18) , ( 0x61134511187a9a2df38d10dbe07ba2e8e5563967, 's_aWETH', 18) , ( 0xd1c117319b3595fbc39b471ab1fd485629eb05f2, 'vaETH', 18) @@ -4581,41 +4581,41 @@ FROM (VALUES , ( 0xc14900dfb1aa54e7674e1ecf9ce02b3b35157ba5, 'vaFRAX', 18) , ( 0xce4a49d7ed99c7c8746b713ee2f0c9aa631688d8, 's_aDAI', 18) , ( 0xf591d878608e2e5c7d4f1e499330f4ab9bbae37a, 's_aUSDC', 6) - , ( 0x73a15fed60bf67631dc6cd7bc5b6e8da8190acf5, 'USD0', 18) + , ( 0x73a15fed60bf67631dc6cd7bc5b6e8da8190acf5, 'USD0', 18) , ( 0x2E3CFE45E3EE7C017277f22e35d2f29edC99d570, 'wDAG', 8) , ( 0x7448c7456a97769F6cD04F1E83A4a23cCdC46aBD, 'MAV', 18) , ( 0x63a0964A36c34E81959da5894ad888800e17405b, 'ShezETH', 18) , ( 0xDfFb77dB95E16B791178D28CF994b13E84036076, 'BLU', 18) , ( 0x866a2bf4e572cbcf37d5071a7a58503bfb36be1b, 'M', 6) - , ( 0x20157dbabb84e3bbfe68c349d0d44e48ae7b5ad2, 'dlcBTC', 8) - , ( 0xe1B4d34E8754600962Cd944B535180Bd758E6c2e, 'agETH', 18) - , ( 0x5C5b196aBE0d54485975D1Ec29617D42D9198326, 'stdeUSD', 18) - , ( 0x6dc3ce9c57b20131347fdc9089d740daf6eb34c5, 'balETH', 18) - , ( 0x786f4782d1a5c602ea30bc4a95154110b9e231ea, 'shezBTC', 8) - , ( 0x09db87a538bd693e9d08544577d5ccfaa6373a48, 'ynETH', 18) - , ( 0x3b50805453023a91a8bf641e279401a0b23fa6f9, 'REZ', 18) - , ( 0x7777cec341e7434126864195adef9b05dcc3489c, 'ONI', 18) - , ( 0x3ffeea07a27fab7ad1df5297fa75e77a43cb5790, 'PEIPEI', 18) - , ( 0x00f116ac0c304c570daaa68fa6c30a86a04b5c5f, 'INF', 18) - , ( 0x777be1c6075c20184c4fd76344b7b0b7c858fe6b, 'BAR', 18) - , ( 0xaa32f860756f6dcd5a684dc2aadf6c0921257a9a, 'YUNA', 18) - , ( 0xa045fe936e26e1e1e1fb27c1f2ae3643acde0171, 'KAI', 9) - , ( 0x9e566e28c61690f8afe0468f523e137b1ff29f01, 'GNCAT', 9) - , ( 0x7f911119435d8ded9f018194b4b6661331379a3d, 'FWOG', 18) - , ( 0x6985884c4392d348587b19cb9eaaf157f13271cd, 'ZRO', 18) - , ( 0x7b0df1cd724ec34ec9bc4bd19749b01afb490761, 'KOIN', 9) - , ( 0xb60fdf036f2ad584f79525b5da76c5c531283a1b, 'NEMO', 9) - , ( 0x5b342f03d126314d925fa57a45654f92905e6451, 'MNTA', 18) - , ( 0x8149745670881d99700078ede5903a1a7bebe262, 'PEPAY', 18) - , ( 0xb6f4d11d6c274f8f0a55d101b65223a45a3d1128, 'eBAKE', 9) - , ( 0xb35875b40f5ea5483c84ccd6e4ab0afc42a3c355, 'Nerio', 9) + , ( 0x20157dbabb84e3bbfe68c349d0d44e48ae7b5ad2, 'dlcBTC', 8) + , ( 0xe1B4d34E8754600962Cd944B535180Bd758E6c2e, 'agETH', 18) + , ( 0x5C5b196aBE0d54485975D1Ec29617D42D9198326, 'stdeUSD', 18) + , ( 0x6dc3ce9c57b20131347fdc9089d740daf6eb34c5, 'balETH', 18) + , ( 0x786f4782d1a5c602ea30bc4a95154110b9e231ea, 'shezBTC', 8) + , ( 0x09db87a538bd693e9d08544577d5ccfaa6373a48, 'ynETH', 18) + , ( 0x3b50805453023a91a8bf641e279401a0b23fa6f9, 'REZ', 18) + , ( 0x7777cec341e7434126864195adef9b05dcc3489c, 'ONI', 18) + , ( 0x3ffeea07a27fab7ad1df5297fa75e77a43cb5790, 'PEIPEI', 18) + , ( 0x00f116ac0c304c570daaa68fa6c30a86a04b5c5f, 'INF', 18) + , ( 0x777be1c6075c20184c4fd76344b7b0b7c858fe6b, 'BAR', 18) + , ( 0xaa32f860756f6dcd5a684dc2aadf6c0921257a9a, 'YUNA', 18) + , ( 0xa045fe936e26e1e1e1fb27c1f2ae3643acde0171, 'KAI', 9) + , ( 0x9e566e28c61690f8afe0468f523e137b1ff29f01, 'GNCAT', 9) + , ( 0x7f911119435d8ded9f018194b4b6661331379a3d, 'FWOG', 18) + , ( 0x6985884c4392d348587b19cb9eaaf157f13271cd, 'ZRO', 18) + , ( 0x7b0df1cd724ec34ec9bc4bd19749b01afb490761, 'KOIN', 9) + , ( 0xb60fdf036f2ad584f79525b5da76c5c531283a1b, 'NEMO', 9) + , ( 0x5b342f03d126314d925fa57a45654f92905e6451, 'MNTA', 18) + , ( 0x8149745670881d99700078ede5903a1a7bebe262, 'PEPAY', 18) + , ( 0xb6f4d11d6c274f8f0a55d101b65223a45a3d1128, 'eBAKE', 9) + , ( 0xb35875b40f5ea5483c84ccd6e4ab0afc42a3c355, 'Nerio', 9) , ( 0xf7554eac0bf20d702e69d08c425e817abb976aea, 'MAHA', 18) , ( 0x3742f3fcc56b2d46c7b8ca77c23be60cd43ca80a, 'stAVAIL', 18) , ( 0xd8eb27a94e610a7b859758ed1f2d47ad224bfaaa, 'GOPEPE', 18) , ( 0xf7760c2c0677078b1d1b6b8463f1de1c6c91a9f8, 'PP', 18) , ( 0x78128d17a89e5fe51bd0e757cfbc5703c34c7fb6, '$EWT', 18) , ( 0xf1ff59fa458bee12d6526dbd92290090bf670e29, 'fluffy', 18) - , ( 0xffe9ae172dd1fc9929ba6902873e09fadf81afd7, 'GLOW', 18) + , ( 0xffe9ae172dd1fc9929ba6902873e09fadf81afd7, 'GLOW', 18) , ( 0xb146823fb8ea064d14ba1a52e3e55cde09afff2d, 'EYE', 18) , ( 0x88ce174c655b6d11210a069b2c106632dabdb068, 'YAWN', 18) , ( 0xf6b6235f6725f84457f5d6f0b0aa3c962a079977, 'WBKN', 18) @@ -4643,13 +4643,13 @@ FROM (VALUES , ( 0x0ba45a8b5d5575935b8158a88c631e9f9c95a2e5, 'TRB', 18) , ( 0xf0a949b935e367a94cdfe0f2a54892c2bc7b2131, 'ultraETHs', 18) , ( 0x5e362eb2c0706bd1d134689ec75176018385430b, 'DVstETH', 18) - , ( 0xcbc632833687dacdcc7dfac96f6c5989381f4b47, 'ultraETHs', 18) + , ( 0xcbc632833687dacdcc7dfac96f6c5989381f4b47, 'ultraETHs', 18) , ( 0xa684eaf215ad323452e2b2bf6f817d4aa5c116ab, 'lpETH', 18) , ( 0x100db67f41a2df3c32cc7c0955694b98339b7311, 'MONEY', 18) , ( 0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf, 'cbBTC', 8) , ( 0x66b5228cfd34d9f4d9f03188d67816286c7c0b74, 'VOLT', 18) , ( 0x4d1c297d39c5c1277964d0e3f8aa901493664530, 'PUFER', 18) - , ( 0x460372866fe1448de1549cebdb0539f4075a2aa8, 'SHERK', 9) + , ( 0x460372866fe1448de1549cebdb0539f4075a2aa8, 'SHERK', 9) , ( 0x0a6E7Ba5042B38349e437ec6Db6214AEC7B35676, 'SWELL', 18) , ( 0xf9B24C9364457Ea85792179D285855753549eBAa, 'slisBNB', 18) , ( 0x230ea9aed5d08afdb22cd3c06c47cf24ad501301, 'SPX2.0', 18) @@ -4721,4 +4721,26 @@ FROM (VALUES , ( 0xaf270c38ff895ea3f95ed488ceace2386f038249, 'stataEthDAI', 18) , ( 0x00f2a835758b33f3ac53516ebd69f3dc77b0d152, 'stataEthPYUSD', 6) , ( 0x7cc6694cf75c18d488d16fb4bf3c71a3b31cc7fb, 'stataEthETHx', 18) + , ( 0x58D97B57BB95320F9a05dC918Aef65434969c2B2, 'MORPHO', 18) + , ( 0x9994E35Db50125E0DF82e4c2dde62496CE330999, 'legacyMORPHO', 18) + , ( 0xc824a08db624942c5e5f330d56530cd1598859fd, 'hgETH', 18) + , ( 0x6e6B7ADfC7Db9fEeB8896418aC3422966f65D0A5, 'NET', 18) + , ( 0xd4fa2d31b7968e448877f69a96de69f5de8cd23e, 'WaEthUSDC', 6) + , ( 0x7bc3485026ac48b6cf9baf0a377477fff5703af8, 'WaEthUSDT', 6) + , ( 0x0bfc9d54fc184518a81162f8fb99c2eaca081202, 'WaEthWETH', 18) + , ( 0x0fe906e030a44ef24ca8c7dc7b7c53a6c4f00ce9, 'waEthLidoWETH', 18) + , ( 0x775f661b0bd1739349b9a2a3ef60be277c5d2d29, 'waEthLidowstETH', 18) + , ( 0xbEEFC01767ed5086f35deCb6C00e6C12bc7476C1, 'csUSDL', 18) + , ( 0xbeef01735c132ada46aa9aa4c54623caa92a64cb, 'steakUSDC', 18) + , ( 0xbdC7c08592Ee4aa51D06C27Ee23D5087D65aDbcD, 'USDL', 18) + , ( 0x358d94b5b2F147D741088803d932Acb566acB7B6, 'rSWELL', 18) + , ( 0x9Ed15383940CC380fAEF0a75edacE507cC775f22, 'earnETH', 18) + , ( 0x66E47E6957B85Cf62564610B76dD206BB04d831a, 'earnBTC', 8) + , ( 0x9Ba021B0a9b958B5E75cE9f6dff97C7eE52cb3E6, 'apxETH', 18) + , ( 0xa4f6b2cdcb67bf8f48baa459a333d2667aa4b100, 'shezETH', 8) + , ( 0x7F4B66FF703336CfC35b901144614496Ae0b0D27, 'shezUSD', 18) + , ( 0xa7b66dda0d7c7c1e43d3130491216172993d163d, 'EVS', 6) + , ( 0x2371e134e3455e0593363cbf89d3b6cf53740618, 'gtWETH', 18) + , ( 0x5F9D59db355b4A60501544637b00e94082cA575b, 'waEthUSDe', 18) + , ( 0x634Ed807647e07a7C038EF1956a58ADbc6695F88, 'shezUSD', 18) ) AS temp_table (contract_address, symbol, decimals) diff --git a/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_rwa.sql b/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_rwa.sql new file mode 100644 index 00000000000..8eefd5af2ed --- /dev/null +++ b/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_rwa.sql @@ -0,0 +1,36 @@ +{{ config( + schema = 'tokens_ethereum' + , alias = 'rwa' + , tags=['static'] + , post_hook='{{ expose_spells(\'["ethereum"]\', + "sector", + "tokens_ethereum", + \'["synthquest"]\') }}' + , unique_key = ['contract_address'] + ) +}} + +SELECT blockchain, contract_address, backing, symbol, decimals, name +FROM (VALUES + + ('ethereum', 0x68749665FF8D2d112Fa859AA293F07A622782F38, 'Gold-backed', 'XAUT', 6, 'Tether'), + ('ethereum', 0x45804880de22913dafe09f4980848ece6ecbaf78, 'Gold-backed', 'PAXG', 18, 'Paxos'), + ('ethereum', 0x136471a34f6ef19fe571effc1ca711fdb8e49f2b, 'Treasury-backed', 'USYC', 6, 'Hashnote'), + ('ethereum', 0x1b19c19393e2d034d8ff31ff34c81252fcbbee92, 'Treasury-backed', 'OUSG', 18, 'Ondo'), + ('ethereum', 0x7712c34205737192402172409a8F7ccef8aA2AEc, 'Treasury-backed', 'BUIDL', 6, 'Blackrock'), + ('ethereum', 0x96F6eF951840721AdBF46Ac996b59E0235CB985C, 'Treasury-backed', 'USDY', 18, 'Ondo'), + ('ethereum', 0x43415eB6ff9DB7E26A15b704e7A3eDCe97d31C4e, 'Treasury-backed', 'USTB', 6, 'Superstate'), + ('ethereum', 0xdd50C053C096CB04A3e3362E2b622529EC5f2e8a, 'Treasury-backed', 'TBILL', 6, 'Open Eden'), + ('ethereum', 0xe4880249745eAc5F1eD9d8F7DF844792D560e750, 'Treasury-backed', 'USTBL', 5, 'Spiko'), + ('ethereum', 0x8c213ee79581Ff4984583C6a801e5263418C4b86, 'Treasury-backed', 'LTF', 6, 'Centrifuge'), + ('ethereum', 0xa0769f7A8fC65e47dE93797b4e21C073c117Fc80, 'Global-Bond-backed', 'EUTBL', 5, 'Spiko'), + ('ethereum', 0x3f95AA88dDbB7D9D484aa3D482bf0a80009c52c9, 'Global-Bond-backed', 'bERNX', 18, 'Backed'), + ('ethereum', 0x2F123cF3F37CE3328CC9B5b8415f9EC5109b45e7, 'Global-Bond-backed', 'bC3M', 18, 'Backed'), + ('ethereum', 0x3Ee320c9F73a84D1717557af00695A34b26d1F1d, 'Global-Bond-backed', 'XEVT', 6, 'OpenTrade'), + ('ethereum', 0xe4A6f23Fb9e00Fca037Aa0EA0a6954dE0a6C53bF, 'Gold-backed', 'TXAU', 18, 'Aurus'), + ('ethereum', 0x34ABce75D2f8f33940c721dCA0f562617787bfF3, 'Silver-backed', 'TXAG', 18, 'Aurus'), + ('ethereum', 0x6d57B2E05F26C26b549231c866bdd39779e4a488, 'Gold-backed', 'VNXAU', 18, 'VNX'), + ('ethereum', 0x19b22DbADc298c359A1D1b59e35f352A2b40E33c, 'Platinum-backed', 'TXPT', 18, 'Aurus') + + + ) AS temp_table (blockchain, contract_address, backing, symbol, decimals, name) diff --git a/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_schema.yml b/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_schema.yml index bbe1d127dd3..410ddf70608 100644 --- a/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_schema.yml +++ b/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_schema.yml @@ -127,3 +127,26 @@ models: data_tests: - accepted_values: values: ['erc721', 'erc1155' , 'erc20', 'cryptopunks','superrare'] + + - name: tokens_ethereum_rwa + meta: + blockchain: ethereum + sector: rwa + contributors: synthquest + config: + tags: ['tokens', 'ethereum', 'rwa'] + description: > + Selection of RWA token addresses. + columns: + - name: blockchain + description: "Blockchain name" + - name: contract_address + description: "RWA token contract address" + - name: backing + description: "RWA token backing" + - name: symbol + description: "RWA token symbol" + - name: name + description: "RWA token project name" + - name: decimals + description: "Number of decimals" diff --git a/dbt_subprojects/tokens/models/tokens/flare/_schema.yml b/dbt_subprojects/tokens/models/tokens/flare/_schema.yml new file mode 100644 index 00000000000..93ec5d26b80 --- /dev/null +++ b/dbt_subprojects/tokens/models/tokens/flare/_schema.yml @@ -0,0 +1,21 @@ +version: 2 + +models: + - name: tokens_flare_erc20 + meta: + blockchain: flare + sector: tokens + project: erc20 + contributors: hosuke, yakufff + config: + tags: ['table', 'erc20', 'flare'] + description: "ERC20 Token Addresses, Symbols and Decimals on flare Network" + columns: + - name: contract_address + description: "ERC20 token contract address" + data_tests: + - unique + - name: symbol + description: "ERC20 token symbol" + - name: decimals + description: "Number of decimals, refers to how divisible an ERC20 token can be" diff --git a/dbt_subprojects/tokens/models/tokens/flare/tokens_flare_erc20.sql b/dbt_subprojects/tokens/models/tokens/flare/tokens_flare_erc20.sql new file mode 100644 index 00000000000..b12a5c48e61 --- /dev/null +++ b/dbt_subprojects/tokens/models/tokens/flare/tokens_flare_erc20.sql @@ -0,0 +1,32 @@ +{{ + config( + schema = 'tokens_flare' + , alias = 'erc20' + , tags = ['static'] + , materialized = 'table' + ) +}} + +SELECT + contract_address + , symbol + , decimals +FROM (VALUES + (0x1D80c49BbBCd1C0911346656B529DF9E5c2F783d, 'WFLR', 18) + , (0xE6505f92583103AF7ed9974DEC451A7Af4e3A3bE, 'JOULE', 18) + , (0x12e605bc104e93B45e1aD99F9e555f659051c2BB, 'sFLR', 18) + , (0xfF56Eb5b1a7FAa972291117E5E9565dA29bc808d, 'APS', 18) + , (0x4A771Cc1a39FDd8AA08B8EA51F7Fd412e73B3d2B, 'USDX', 6) + , (0x140D8d3649Ec605CF69018C627fB44cCC76eC89f, 'HLN', 18) + , (0xFbDa5F676cB37624f28265A144A48B0d6e87d3b6, 'USDC.e', 6) + , (0x0B38e83B86d491735fEaa0a791F65c2B99535396, 'USDT', 6) + , (0x22757fb83836e3F9F0F353126cACD3B1Dc82a387, 'FLX', 18) + , (0xC18f99CE6DD6278BE2D3f1e738Ed11623444aE33, 'POODLE', 18) + , (0x96B41289D90444B8adD57e6F265DB5aE8651DF29, 'eUSDT', 6) + , (0x932E691aA8c8306C4bB0b19F3f00a284371be8Ba, 'PHIL', 18) + , (0xB5010D5Eb31AA8776b52C7394B76D6d627501C73, 'PFL', 18) + , (0x908BB3E15040801fd29E542221A31Baaa7A4bE19, 'FODO', 18) + , (0xe2bBf70A52Ee84837E9E2e245E5aFc560E259249, 'ZOINK', 18) + , (0x1aa5282692398c078e71Fb3e4A85660d1BF8F586, 'BUNNY', 18) + , (0xc6B19B06A92B337Cbca5f7334d29d45ec4d5E532, 'Moon', 18) +) as temp (contract_address, symbol, decimals) diff --git a/dbt_subprojects/tokens/models/tokens/gnosis/tokens_gnosis_erc20.sql b/dbt_subprojects/tokens/models/tokens/gnosis/tokens_gnosis_erc20.sql index bff97b5ba67..19ca6d3d2d7 100644 --- a/dbt_subprojects/tokens/models/tokens/gnosis/tokens_gnosis_erc20.sql +++ b/dbt_subprojects/tokens/models/tokens/gnosis/tokens_gnosis_erc20.sql @@ -7820,4 +7820,9 @@ FROM (VALUES , ( 0x8418d17640a74f1614ac3e1826f29e78714488a1, 'stataGnoEURe', 18) , ( 0xecfd0638175e291ba3f784a58fb9d38a25418904, 'stataGnowstETH', 18) , ( 0xf0e7ec247b918311afa054e0aedb99d74c31b809, 'stataGnoUSDCe', 6) + , ( 0xFECB3F7c54E2CAAE9dC6Ac9060A822D47E053760, 'BRLA', 18) + , ( 0x7c16f0185a26db0ae7a9377f23bc18ea7ce5d644, 'waGnoGNO', 18) + , ( 0x773cda0cade2a3d86e6d4e30699d40bb95174ff2, 'waGnowstETH', 18) + , ( 0x57f664882f762fa37903fc864e2b633d384b411a, 'waGnoWETH', 18) + , ( 0x51350d88c1bd32Cc6A79368c9Fb70373Fb71F375, 'waGNOUSDCe', 6) ) AS temp_table (contract_address, symbol, decimals) diff --git a/dbt_subprojects/tokens/models/tokens/optimism/tokens_optimism_erc20_curated.sql b/dbt_subprojects/tokens/models/tokens/optimism/tokens_optimism_erc20_curated.sql index fbb3b7e3457..289d88f6963 100644 --- a/dbt_subprojects/tokens/models/tokens/optimism/tokens_optimism_erc20_curated.sql +++ b/dbt_subprojects/tokens/models/tokens/optimism/tokens_optimism_erc20_curated.sql @@ -450,7 +450,8 @@ WITH raw_token_list AS ( ,(0xe62dda84e579e6a37296bcfc74c97349d2c59ce3, 'ysWETH', 18, 'receipt') ,(0xd08C3F25862077056cb1b710937576Af899a4959, 'InstETH', 18, 'underlying') ,(0x57f5e098cad7a3d1eed53991d4d66c45c9af7812, 'wUSDM', 18, 'receipt') - ,(0xbfd5206962267c7b4b4a8b3d76ac2e1b2a5c4d5e, 'OSAK', 18, 'underlying') + ,(0xbfd5206962267c7b4b4a8b3d76ac2e1b2a5c4d5e, 'OSAK', 18, 'underlying') + , (0xCA5d8F8a8d49439357d3CF46Ca2e720702F132b8, 'GYD', 18, 'underlying') ) AS temp_table (contract_address, symbol, decimals, token_type) ) SELECT diff --git a/dbt_subprojects/tokens/models/tokens/ronin/tokens_ronin_erc20.sql b/dbt_subprojects/tokens/models/tokens/ronin/tokens_ronin_erc20.sql index 69567991704..d384a32bd2f 100644 --- a/dbt_subprojects/tokens/models/tokens/ronin/tokens_ronin_erc20.sql +++ b/dbt_subprojects/tokens/models/tokens/ronin/tokens_ronin_erc20.sql @@ -17,4 +17,9 @@ FROM (VALUES , (0x0b7007c13325c48911f73a2dad5fa5dcbf808adc, 'USDC', 6) , (0x97a9107c1793bc407d6f527b77e7fff4d812bece, 'AXS', 18) , (0xa8754b9fa15fc18bb59458815510e40a12cd2014, 'SLP', 0) -) AS temp_table (contract_address, symbol, decimals) \ No newline at end of file + , (0x18d2bdef572c67127e218c425f546fe64430a92c, 'LUAUSD', 18) + , (0x7eae20d11ef8c779433eb24503def900b9d28ad7, 'PIXEL', 18) + , (0xd61bbbb8369c46c15868ad9263a2710aced156c4, 'LUA', 18) + , (0x7894b3088d069e70895effa4e8f7d2c243fd04c1, 'APRS', 18) + , (0xf80132fc0a86add011bffce3aedd60a86e3d704d, 'ANIMA', 18) +) AS temp_table (contract_address, symbol, decimals) diff --git a/dbt_subprojects/tokens/models/tokens/sonic/tokens_sonic_erc20.sql b/dbt_subprojects/tokens/models/tokens/sonic/tokens_sonic_erc20.sql new file mode 100644 index 00000000000..7b2fd6541a5 --- /dev/null +++ b/dbt_subprojects/tokens/models/tokens/sonic/tokens_sonic_erc20.sql @@ -0,0 +1,27 @@ +{{ + config( + schema = 'tokens_sonic' + ,alias = 'erc20' + ,tags = ['static'] + ,materialized = 'table' + ) +}} + +SELECT + contract_address + , symbol + , decimals +FROM (VALUES + (0x309C92261178fA0CF748A855e90Ae73FDb79EBc7, 'WETH', 18) + , (0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38, 'WS', 18) + , (0x29219dd400f2Bf60E5a23d13Be72B486D4038894, 'USDC.e', 6) + , (0xe715cba7b5ccb33790cebff1436809d36cb17e57, 'EURC.e', 6) + , (0xf2f9f482a395b4dd5b5b92173b7d62f3aff92884, 'DOG', 18) + , (0x06341839dac9384bf96c6fc8df6983661a06356a, 'DOGE', 18) + , (0x446649f0727621bdbb76644b1910be2163b62a11, 'SONIC', 18) + , (0x9fdbc3f8abc05fa8f3ad3c17d2f806c1230c4564, 'GOGLZ', 18) + , (0x2030170901a9d87f6bd0ca9b8ad130119c7e1173, 'BABYSONIC', 9) + , (0xe5da20f15420ad15de0fa650600afc998bbe3955, 'stS', 18) + , (0xd4a5c68a1ed1fc2bb06cba2d90d6adeee7503671, 'HOOPS', 18) + +) as temp (contract_address, symbol, decimals) diff --git a/dbt_subprojects/tokens/models/tokens/sonic/tokens_sonic_schema.yml b/dbt_subprojects/tokens/models/tokens/sonic/tokens_sonic_schema.yml new file mode 100644 index 00000000000..6cc0daef3fc --- /dev/null +++ b/dbt_subprojects/tokens/models/tokens/sonic/tokens_sonic_schema.yml @@ -0,0 +1,21 @@ +version: 2 + +models: + - name: tokens_sonic_erc20 + meta: + blockchain: sonic + sector: tokens + project: erc20 + contributors: irishlatte19 + config: + tags: ['table', 'erc20', 'sonic'] + description: "ERC20 Token Addresses, Symbols and Decimals on Sonic" + columns: + - name: contract_address + description: "ERC20 token contract address" + data_tests: + - unique + - name: symbol + description: "ERC20 token symbol" + - name: decimals + description: "Number of decimals, refers to how divisible an ERC20 token can be" \ No newline at end of file diff --git a/dbt_subprojects/tokens/models/tokens/tokens_erc20.sql b/dbt_subprojects/tokens/models/tokens/tokens_erc20.sql index c50255ecaf7..e8854fb8cca 100644 --- a/dbt_subprojects/tokens/models/tokens/tokens_erc20.sql +++ b/dbt_subprojects/tokens/models/tokens/tokens_erc20.sql @@ -10,6 +10,7 @@ ,"base" ,"blast" ,"bnb" + ,"boba" ,"celo" ,"ethereum" ,"fantom" @@ -31,10 +32,11 @@ ,"zksync" ,"zora" ,"bob" + ,"sonic" ]\', "sector", "tokens", - \'["bh2smith","0xManny","hildobby","soispoke","dot2dotseurat","mtitus6","wuligy","lgingerich","0xRob","jeff-dude","viniabussafi","IrishLatte19","angus_1","Henrystats","rantum"]\') }}' + \'["bh2smith","0xManny","hildobby","soispoke","dot2dotseurat","mtitus6","wuligy","lgingerich","0xRob","jeff-dude","viniabussafi","IrishLatte19","angus_1","Henrystats","rantum", "IrishLatte19"]\') }}' ) }} @@ -71,6 +73,10 @@ ,'tokens_tron': {'blockchain': 'tron', 'model': ref('tokens_tron_erc20')} ,'tokens_ronin': {'blockchain': 'ronin', 'model': ref('tokens_ronin_erc20')} ,'tokens_bob': {'blockchain': 'bob', 'model': ref('tokens_bob_erc20')} + ,'tokens_flare': {'blockchain': 'flare', 'model': ref('tokens_flare_erc20')} + ,'tokens_boba': {'blockchain': 'boba', 'model': ref('tokens_boba_erc20')} + ,'tokens_viction': {'blockchain': 'viction', 'model': ref('tokens_viction_erc20')} + ,'tokens_sonic': {'blockchain': 'sonic', 'model': ref('tokens_sonic_erc20')} } %} with automated_source as ( diff --git a/dbt_subprojects/tokens/models/tokens/viction/_schema.yml b/dbt_subprojects/tokens/models/tokens/viction/_schema.yml new file mode 100644 index 00000000000..60e887dff91 --- /dev/null +++ b/dbt_subprojects/tokens/models/tokens/viction/_schema.yml @@ -0,0 +1,23 @@ +version: 2 + +models: + - name: tokens_viction_erc20 + meta: + blockchain: viction + sector: tokens + contributors: hosuke + config: + tags: ['tokens', 'viction', 'erc20'] + description: > + Viction ERC20 tokens + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - contract_address + columns: + - name: contract_address + description: "ERC20 Token's contract address" + - name: symbol + description: "ERC20 Token's symbol" + - name: decimals + description: "ERC20 Token's number of decimals" diff --git a/dbt_subprojects/tokens/models/tokens/viction/tokens_viction_erc20.sql b/dbt_subprojects/tokens/models/tokens/viction/tokens_viction_erc20.sql new file mode 100644 index 00000000000..9bc999f4031 --- /dev/null +++ b/dbt_subprojects/tokens/models/tokens/viction/tokens_viction_erc20.sql @@ -0,0 +1,21 @@ +{{ + config( + schema = 'tokens_viction' + ,alias = 'erc20' + ,tags = ['static'] + ,materialized = 'table' + ) +}} + +SELECT + contract_address + , symbol + , decimals +FROM (VALUES + (0xC054751BdBD24Ae713BA3Dc9Bd9434aBe2abc1ce, 'WVIC', 18) + , (0x381B31409e4D220919B2cFF012ED94d70135A59e, 'USDT', 6) + , (0x20cC4574f263C54eb7aD630c9AC6d4d9068Cf127, 'USDC', 6) + , (0xb786d9c8120d311b948cf1e5aa48d8fbacf477e2, 'SAROS', 18) + , (0x0fd0288aaae91eaf935e2ec14b23486f86516c8c, 'C98', 18) + , (0xCdde1f5D971A369eB952192F9a5C367f33a0A891, 'SVIC', 18) +) AS temp_table (contract_address, symbol, decimals) diff --git a/docs/seeds/seed_overview.md b/docs/seeds/seed_overview.md index 232dce54c1a..c4fb9c71607 100644 --- a/docs/seeds/seed_overview.md +++ b/docs/seeds/seed_overview.md @@ -6,12 +6,12 @@ Seeds will be required in these sector-level spell additions to ensure proper le ## Using `dex.trades` as an Example for Sector-Level Spell Design Approach to Seeds: -1. Add new model seed to [the schema file](/seeds/_sector/dex/_schema.yml), to ensure proper data type assignments. +1. Add new model seed to [the schema file](/dbt_subprojects/dex/seeds/trades/_schema.yml), to ensure proper data type assignments. 2. Build a seed file in CSV format, which contains: - All the unique keys on the model for downstream join conditions in tests. - Fields which we want to test the results of the model execution. - - Example seed file [here](/seeds/_sector/dex/aerodrome_base_base_trades_seed.csv). -3. Within the [model schema file](/models/_sector/dex/trades/arbitrum/_schema.yml#L20-L23), call the [generic seed test](/tests/generic/check_dex_base_trades_seed.sql) with parameters necessary: + - Example seed file [here](/dbt_subprojects/dex/seeds/trades/aerodrome_base_base_trades_seed.csv). +3. Within the [model schema file](/dbt_subprojects/dex/models/trades/arbitrum/_schema.yml#23-25), call the [generic seed test](/dbt_subprojects/dex/tests/generic/check_dex_base_trades_seed.sql) with parameters necessary: - Seed file name. - Filter(s) for project versions, if the spell is split into versions per project. 4. Ultimately, following the above steps, the test query built and executed against seed files lives in the generic seed macro [here](/dbt_macros/generic-tests/check_seed_macro.sql). diff --git a/docs/tests/test_overview.md b/docs/tests/test_overview.md index 82d1d890781..c573ed113ce 100644 --- a/docs/tests/test_overview.md +++ b/docs/tests/test_overview.md @@ -11,7 +11,7 @@ Tests tied to models are highly encouraged & at times required, depending on the These tests would benefit all sector-level spells, first introduced in `nft.trades`: -- Validate column data types, as built [here](https://github.com/duneanalytics/spellbook/blob/d6b5acc1dbd01e67e6cb23d96da6f3fc3ec7d268/tests/generic/check_column_types.sql#L6) and called like [this](/models/_sector/nft/trades/chains/arbitrum/platforms/_schema.yml#L14). +- Validate column data types, as built [here](https://github.com/duneanalytics/spellbook/blob/d6b5acc1dbd01e67e6cb23d96da6f3fc3ec7d268/tests/generic/check_column_types.sql#L6) and called like [this](/dbt_subprojects/nft/models/_sector/trades/chains/arbitrum/platforms/_schema.yml#L14). ## Where to Store Tests? diff --git a/scripts/token_checker.py b/scripts/token_checker.py index 8f0c4f1cfcf..16da52aaacc 100644 --- a/scripts/token_checker.py +++ b/scripts/token_checker.py @@ -32,7 +32,8 @@ def __init__(self): "zkevm": "eth-ethereum", "ronin": "ron-ronin-token", "cardano": "ada-cardano", - "tron": "trx-tron" + "tron": "trx-tron", + "boba": "eth-ethereum" } self.tokens_by_id = self.get_tokens() self.contracts_by_chain = self.get_contracts() diff --git a/sources/_base_sources/evm/boba_base_sources.yml b/sources/_base_sources/evm/boba_base_sources.yml new file mode 100644 index 00000000000..a277253d1c5 --- /dev/null +++ b/sources/_base_sources/evm/boba_base_sources.yml @@ -0,0 +1,444 @@ +version: 2 + +sources: + # Boba Tables + - name: boba + description: "raw tables for the chain" + + tables: + - name: transactions + meta: + docs_slug: /evm/boba/raw/transactions + short_description: The transactions table contains detailed information about transactions on the network. + description: '{{ doc("boba_transactions_doc") }}' + + columns: + - name: block_time + description: "The exact UTC timestamp when the block containing this transaction was added to the chain" + - name: block_number + description: "The sequential number of the block containing this transaction" + - name: value + description: "Amount of ETH sent from sender to recipient (if any), measured in wei (1 ETH = 10^18 wei)" + - name: gas_limit + description: "Maximum number of gas units this transaction can consume" + - name: gas_price + description: "Price per unit of gas for this transaction, denominated in wei (1 gwei = 10^9 wei)" + - name: gas_used + description: "Actual amount of gas units consumed by this transaction's execution" + - name: max_fee_per_gas + description: "Maximum total amount per gas unit the initiator is willing to pay, including boba fee and priority fee" + - name: max_priority_fee_per_gas + description: "Maximum additional fee per gas unit the initiator is willing to pay as a tip to validators" + - name: priority_fee_per_gas + description: "Actual priority fee per gas paid to validators" + - name: nonce + description: "Sequential number representing the count of transactions sent from the sender's address" + - name: index + description: "Position of this transaction within its containing block" + - name: success + description: "Boolean flag indicating whether the transaction executed successfully (true) or failed (false)" + - name: from + description: "Address of the account that initiated and signed this transaction" + - name: to + description: "Address of the recipient account or contract for this transaction" + - name: block_hash + description: "Unique 256-bit identifier (hash) of the block containing this transaction" + - name: data + description: "Input data for the transaction, which may include function calls or contract interaction data" + - name: hash + description: "Unique 256-bit identifier (hash) of this specific transaction" + - name: type + description: "Type of transaction (e.g., legacy, EIP-1559) indicating its structure and fee mechanism" + - name: access_list + description: "List of addresses and storage keys the transaction plans to access, used for gas optimization in EIP-2930 transactions" + - name: chain_id + description: "Chain identifier for the network" + - name: block_date + description: "The UTC date of the block in which this transaction was included" + - name: l1_gas_used + description: "The gas used on Ethereum L1 to publish this L2 transaction" + - name: l1_gas_price + description: "Gas price on the L1 at the time of L2 transaction submission" + - name: l1_fee + description: "L1 Fees that the network pays to submit L2 transactions to Ethereum L1" + - name: l1_fee_scalar + description: "Scalar value used to calculate L1 fee, covering potential changes in L1 gas price and network costs" + - name: l1_block_number + description: "Block number on the L1 where this L2 transaction was batch submitted" + - name: l1_timestamp + description: "The timestamp when the L2 transaction was batched and confirmed on the L1" + - name: l1_tx_origin + description: "L1 transaction origin address for L2 transactions that were initiated on L1" + + - name: traces + meta: + docs_slug: /evm/boba/raw/traces + short_description: The traces table contains information about traces on the network. + description: '{{ doc("boba_traces_doc") }}' + columns: + - name: block_time + description: "The exact UTC timestamp when the block containing this transaction was added to the chain" + - name: block_number + description: "The sequential number of the block containing this transaction" + - name: value + description: "Amount of ETH sent from sender to recipient (if any), measured in wei (1 ETH = 10^18 wei)" + - name: gas + description: "Amount of gas allocated for this trace's execution (including gas used by child traces)" + - name: gas_used + description: "Actual amount of gas consumed by this trace's execution" + - name: block_hash + description: "Unique 256-bit identifier (hash) of the block containing this transaction" + - name: success + description: "Boolean flag indicating whether this specific trace was executed successfully (true) or reverted (false)" + - name: tx_index + description: "Position of the parent transaction within its containing block" + - name: tx_from + description: "Address that initiated the parent transaction" + - name: tx_to + description: "Recipient address of the parent transaction" + - name: sub_traces + description: "Number of child traces spawned by this trace during execution" + - name: error + description: "Error message or code if the trace execution failed" + - name: tx_success + description: "Boolean flag indicating whether the parent transaction of this trace was successful" + - name: tx_hash + description: "Unique 256-bit identifier (hash) of the parent transaction" + - name: from + description: "Address that sent this trace" + - name: to + description: "Address that received this trace" + - name: trace_address + description: "Array indicating the exact position of this trace within the trace tree of the transaction" + - name: type + description: "Type of trace (e.g., call, create, suicide) indicating the nature of the operation" + - name: address + description: "If this trace is a contract creation, this is the address of the deployed contract" + - name: code + description: "If this trace is a contract creation, this is the deployed bytecode of contract" + - name: call_type + description: "Type of call made in this trace (e.g., call, delegatecall, staticcall)" + - name: input + description: "Call data provided to this trace, often containing function signatures and parameters" + - name: output + description: "Data returned by this trace after execution" + - name: refund_address + description: "Address designated to receive any gas refund from this trace" + - name: revert_reason + description: "Reason for reversion if the trace was reverted" + - name: block_date + description: "The UTC date of the block in which this transaction was included" + + - name: traces_decoded + meta: + docs_slug: /evm/boba/decoded/traces_decoded + short_description: The `boba.traces_decoded` table contains decoded traces, including additional information based on submitted smart contracts and their ABIs. + description: '{{ doc("boba_traces_decoded_doc") }}' + columns: + - name: block_date + description: "The UTC date of the block in which this transaction was included" + - name: block_time + description: "The exact UTC timestamp when the block containing this transaction was added to the chain" + - name: block_number + description: "The sequential number of the block containing this transaction" + - name: namespace + description: "Categorical grouping or project name associated with the contract" + - name: contract_name + description: "Human-readable name of the smart contract involved in this trace" + - name: to + description: "Address of the contract or account receiving this trace" + - name: trace_address + description: "Array indicating the exact position of this trace within the trace tree of the transaction" + - name: tx_hash + description: "Unique 256-bit identifier (hash) of the parent transaction" + - name: tx_from + description: "Address that initiated the parent transaction" + - name: tx_to + description: "Recipient address of the parent transaction" + - name: signature + description: "Function signature hash" + - name: function_name + description: "Name of the specific contract function called in this trace" + + - name: logs + meta: + docs_slug: /evm/boba/raw/logs + short_description: The `boba.logs` table contains information about event logs emitted by smart contracts on the boba blockchain. + description: '{{ doc("boba_logs_doc") }}' + columns: + - name: block_date + description: "The UTC date of the block in which this transaction was included" + - name: block_time + description: "The exact UTC timestamp when the block containing this transaction was added to the chain" + - name: block_number + description: "The sequential number of the block containing this transaction" + - name: block_hash + description: "Unique 256-bit identifier (hash) of the block containing this transaction" + - name: tx_index + description: "Position of the parent transaction within its containing block" + - name: tx_hash + description: "Unique 256-bit identifier (hash) of the parent transaction" + - name: contract_address + description: "Address of the smart contract that emitted this log" + - name: topic0 + description: "First 32-byte topic, typically containing the event signature hash" + - name: topic1 + description: "Second 32-byte topic, often containing indexed event parameters" + - name: topic2 + description: "Third 32-byte topic, often containing indexed event parameters" + - name: topic3 + description: "Fourth 32-byte topic, often containing indexed event parameters" + - name: data + description: "ABI-encoded data of the log, containing non-indexed event parameters" + - name: index + description: "Position of this log within the block" + - name: tx_from + description: "Address that initiated the transaction which created this log" + - name: tx_to + description: "Recipient address of the transaction which created this log" + + - name: logs_decoded + meta: + docs_slug: /evm/boba/decoded/logs_decoded + short_description: The `boba.logs_decoded` table contains a subset of all logs for which Dune has the ABI. + description: '{{ doc("boba_logs_decoded_doc") }}' + columns: + - name: block_date + description: "The UTC date of the block in which this transaction was included" + - name: block_time + description: "The exact UTC timestamp when the block containing this transaction was added to the chain" + - name: block_number + description: "The sequential number of the block containing this transaction" + - name: namespace + description: "Categorical grouping or project name associated with the contract" + - name: contract_name + description: "Human-readable name of the smart contract" + - name: contract_address + description: "Address of the smart contract that emitted this log" + - name: tx_hash + description: "Unique 256-bit identifier (hash) of the parent transaction" + - name: tx_from + description: "Address that initiated the transaction which created this log" + - name: tx_to + description: "Recipient address of the transaction which created this log" + - name: index + description: "Position of this log within the block" + - name: signature + description: "Event signature hash" + - name: event_name + description: "Human-readable name of the event" + + - name: contracts + meta: + docs_slug: /evm/boba/raw/contracts + short_description: The `boba.contracts` table tracks decoded contracts on boba, including associated metadata such as namespace, name, address, ABI. It is populated manually by the Dune Community via [contract decoding submissions](https://dune.com/contracts/new). + description: '{{ doc("boba_contracts_doc") }}' + columns: + - name: address + description: "Unique address of the contract on the blockchain" + - name: bytecode + description: "Compiled bytecode of the contract" + - name: name + description: "Human-readable name of the contract" + - name: namespace + description: "Project or protocol name associated with the contract" + - name: abi + description: "JSON representation of the contract's Application Binary Interface" + - name: created_at + description: "Timestamp when this contract entry was created in the table" + + - name: contracts_submitted + meta: + docs_slug: /evm/boba/decoded/contracts_submitted + short_description: The `boba.contracts_submitted` table contains information about contracts submitted for decoding. + description: '{{ doc("boba_contracts_submitted_doc") }}' + columns: + - name: address + description: "Address of the submitted contract" + - name: namespace + description: "Project or protocol name associated with the contract" + - name: name + description: "Name of the submitted contract" + - name: submitted_at + description: "Timestamp when the contract was submitted for decoding" + - name: submitted_by + description: "Address or identifier of the user who submitted the contract" + + - name: creation_traces + meta: + docs_slug: /evm/boba/raw/creation_traces + short_description: The `boba.creation_traces` table contains information about contract creation traces. + description: '{{ doc("boba_creation_traces_doc") }}' + columns: + - name: block_date + description: "The UTC date of the block in which this transaction was included" + - name: block_time + description: "The exact UTC timestamp when the block containing this transaction was added to the chain" + - name: block_number + description: "The sequential number of the block containing this transaction" + - name: tx_hash + description: "Unique 256-bit identifier (hash) of the parent transaction" + - name: address + description: "Address of the created contract" + - name: from + description: "Address that created the contract" + - name: code + description: "Contract bytecode" + - name: success + description: "Whether the contract creation was successful" + - name: block_month + description: "The month of the block date" + + - name: blocks + meta: + docs_slug: /evm/boba/raw/blocks + short_description: The `boba.blocks` table contains information about blocks on the boba blockchain. + description: '{{ doc("boba_blocks_doc") }}' + columns: + - name: block_date + description: "The UTC date of the block in which this transaction was included" + - name: block_time + description: "The exact UTC timestamp when the block containing this transaction was added to the chain" + - name: block_number + description: "The sequential number of the block containing this transaction" + - name: block_hash + description: "Unique 256-bit identifier (hash) of the block containing this transaction" + - name: parent_hash + description: "Hash of the parent block" + - name: nonce + description: "Block nonce value" + - name: difficulty + description: "Block mining difficulty" + - name: gas_limit + description: "Maximum gas allowed in this block" + - name: gas_used + description: "Total gas used by all transactions in this block" + - name: miner + description: "Address of the miner/validator who produced this block" + - name: size + description: "Size of the block in bytes" + - name: total_difficulty + description: "Total chain difficulty up to this block" + - name: base_fee_per_gas + description: "Base fee per gas in this block (EIP-1559)" + - name: state_root + description: "Root hash of the state trie after this block" + - name: transactions_root + description: "Root hash of the transactions trie of this block" + - name: receipts_root + description: "Root hash of the receipts trie of this block" + - name: blob_gas_used + description: "Total blob gas used in this block" + - name: excess_blob_gas + description: "Excess blob gas in this block" + - name: parent_beacon_block_root + description: "Root hash of the parent beacon block" + + - name: erc20_boba + description: "Transfer events for ERC20 tokens on Boba blockchain" + tables: + - name: evt_transfer + meta: + docs_slug: /evm/boba/raw/erc20_transfers + short_description: The evt_transfer table contains all ERC20 token transfer events on the Boba blockchain. + description: '{{ doc("erc20_boba_evt_transfer_doc") }}' + columns: + - name: contract_address + description: "The address of the ERC20 token contract" + - name: from + description: "The address sending the tokens" + - name: to + description: "The address receiving the tokens" + - name: value + description: "The amount of tokens transferred" + - name: evt_tx_hash + description: "The transaction hash of the transfer event" + - name: evt_index + description: "The index of this event within the transaction" + - name: evt_block_time + description: "The timestamp of the block containing this transfer" + - name: evt_block_number + description: "The block number containing this transfer" + + - name: erc721_boba + description: "Transfer events for ERC721 tokens on Boba blockchain" + tables: + - name: evt_transfer + meta: + docs_slug: /evm/boba/raw/erc721_transfers + short_description: The evt_transfer table contains all ERC721 token transfer events on the Boba blockchain. + description: '{{ doc("erc721_boba_evt_transfer_doc") }}' + columns: + - name: contract_address + description: "The address of the ERC721 token contract" + - name: from + description: "The address sending the NFT" + - name: to + description: "The address receiving the NFT" + - name: tokenId + description: "The unique identifier of the NFT being transferred" + - name: evt_tx_hash + description: "The transaction hash of the transfer event" + - name: evt_index + description: "The index of this event within the transaction" + - name: evt_block_time + description: "The timestamp of the block containing this transfer" + - name: evt_block_number + description: "The block number containing this transfer" + + - name: erc1155_boba + description: "Transfer events for ERC1155 tokens on Boba blockchain" + tables: + - name: evt_transfersingle + meta: + docs_slug: /evm/boba/raw/erc1155_transfers_single + short_description: The evt_transfersingle table contains single token transfer events from ERC1155 contracts on the Boba blockchain. + description: '{{ doc("erc1155_boba_evt_transfer_doc") }}' + columns: + - name: contract_address + description: "The address of the ERC1155 token contract" + - name: operator + description: "The address authorized to make the transfer" + - name: from + description: "The address sending the tokens" + - name: to + description: "The address receiving the tokens" + - name: id + description: "The identifier for the token being transferred" + - name: value + description: "The amount of tokens being transferred" + - name: evt_tx_hash + description: "The transaction hash of the transfer event" + - name: evt_index + description: "The index of this event within the transaction" + - name: evt_block_time + description: "The timestamp of the block containing this transfer" + - name: evt_block_number + description: "The block number containing this transfer" + + - name: evt_transferbatch + meta: + docs_slug: /evm/boba/raw/erc1155_transfers_batch + short_description: The evt_transferbatch table contains batch token transfer events from ERC1155 contracts on the Boba blockchain. + description: '{{ doc("erc1155_boba_evt_transfer_doc") }}' + columns: + - name: contract_address + description: "The address of the ERC1155 token contract" + - name: operator + description: "The address authorized to make the transfer" + - name: from + description: "The address sending the tokens" + - name: to + description: "The address receiving the tokens" + - name: ids + description: "The array of token identifiers being transferred" + - name: values + description: "The array of amounts being transferred for each token id" + - name: evt_tx_hash + description: "The transaction hash of the transfer event" + - name: evt_index + description: "The index of this event within the transaction" + - name: evt_block_time + description: "The timestamp of the block containing this transfer" + - name: evt_block_number + description: "The block number containing this transfer" diff --git a/sources/_base_sources/evm/boba_docs_block.md b/sources/_base_sources/evm/boba_docs_block.md new file mode 100644 index 00000000000..bf83ec57bb7 --- /dev/null +++ b/sources/_base_sources/evm/boba_docs_block.md @@ -0,0 +1,220 @@ +{% docs boba_transactions_doc %} + +The `boba.transactions` table contains detailed information about transactions on the Boba blockchain. It includes: + +- Block information: number, timestamp, hash +- Transaction details: hash, from_address, to_address, value +- Gas data: gas_price, gas_limit, gas_used, max_fee_per_gas, priority_fee_per_gas +- L1 data: l1_gas_used, l1_gas_price, l1_fee, l1_block_number, l1_timestamp +- Status: success or failure +- Input data for contract interactions +- Nonce and chain_id +- Transaction type and access list + +This table is used for analyzing transaction patterns, gas usage, value transfers, L1-L2 interactions, and overall network activity on Boba. + +{% enddocs %} + +{% docs boba_traces_doc %} + +The `boba.traces` table contains records of execution steps for transactions on the Boba blockchain. Each trace represents an atomic operation that modifies the state of the Ethereum Virtual Machine (EVM). Key components include: + +- Transaction hash and block information +- From and to addresses +- Value transferred +- Gas metrics (gas, gas_used) +- Input and output data +- Call type (e.g., CALL, DELEGATECALL, CREATE) +- Error information and revert reasons +- Trace address for nested calls +- L1-L2 specific information + +This table is essential for: +- Analyzing internal transactions +- Debugging smart contract interactions +- Tracking value flows through complex transactions +- Understanding contract creation and deployment +- Monitoring L1-L2 message passing + +{% enddocs %} + +{% docs boba_traces_decoded_doc %} + +The `boba.traces_decoded` table contains a subset of decoded traces from the Boba blockchain dependent on submitted smart contracts and their ABIs. It includes: + +- Block information and transaction details +- Contract name and namespace +- Decoded function names and signatures +- Trace address for execution path tracking +- Transaction origin and destination +- Function parameters (when available) + +This table is used for high level analysis of smart contract interactions. For fully decoded function calls and parameters, refer to protocol-specific decoded tables. + +{% enddocs %} + +{% docs boba_logs_doc %} + +The `boba.logs` table contains event logs emitted by smart contracts on the Boba blockchain. It includes: + +- Block information: number, timestamp, hash +- Transaction details: hash, index, from, to +- Contract address (emitting the event) +- Topic0 (event signature) +- Additional topics (indexed parameters) +- Data field (non-indexed parameters) +- Log index and transaction index + +This table is crucial for: +- Tracking on-chain events +- Monitoring contract activity +- Analyzing token transfers +- Following protocol-specific events +- Understanding L1-L2 interactions + +{% enddocs %} + +{% docs boba_logs_decoded_doc %} + +The `boba.logs_decoded` table contains a subset of decoded logs from the Boba blockchain dependent on submitted smart contracts and their ABIs. It includes: + +- Block and transaction information +- Contract details (name, namespace, address) +- Decoded event names and signatures +- Transaction origin and destination +- Event parameters (when available) + +This table is used for high level analysis of smart contract events. For fully decoded events and parameters, refer to protocol-specific decoded tables. + +{% enddocs %} + +{% docs boba_blocks_doc %} + +The `boba.blocks` table contains information about Boba blocks. It provides essential data about each block in the Boba blockchain, including: + +- Block identifiers and timestamps +- Gas metrics and size +- Consensus information (difficulty, nonce) +- State roots and receipts +- L2-specific block data +- Parent block information + +This table is fundamental for analyzing: +- Blockchain structure and growth +- Block production rates +- Network performance +- L1-L2 block relationships +- Chain reorganizations + +{% enddocs %} + +{% docs boba_contracts_doc %} + +The `boba.contracts` table tracks decoded contracts on Boba, including: + +- Contract address and bytecode +- Contract name and namespace +- Complete ABI +- Creation timestamp +- Verification status + +This table is used for: +- Contract verification and analysis +- Protocol research and monitoring +- Development and debugging +- Smart contract security analysis + +{% enddocs %} + +{% docs boba_contracts_submitted_doc %} + +The `boba.contracts_submitted` table tracks contracts submitted for decoding on Boba. It includes: + +- Contract address +- Submission metadata (timestamp, submitter) +- Contract name and namespace +- Verification status + +This table helps track the progress of contract verification and community contributions to the Boba ecosystem. + +{% enddocs %} + +{% docs boba_creation_traces_doc %} + +The `boba.creation_traces` table contains data about contract creation events on the Boba blockchain. It includes: + +- Block information and timestamps +- Transaction details +- Creator's address +- Created contract address +- Deployed contract bytecode +- Creation success status +- Gas consumption + +This table is used for: +- Analyzing contract deployment patterns +- Tracking smart contract origins +- Monitoring protocol deployments +- Understanding contract creation costs + +It's essentially a filtered version of the `boba.traces` table where `type = create`. + +{% enddocs %} + +{% docs erc20_boba_evt_transfer_doc %} + +The `erc20_boba.evt_transfer` table contains Transfer events from ERC20 token contracts on the Boba blockchain. Each record represents a token transfer and includes: + +- Token contract address +- Sender and recipient addresses +- Amount of tokens transferred +- Block and transaction information +- Event log details + +This table is essential for: +- Tracking token transfers and holder activity +- Analyzing token distribution patterns +- Monitoring token holder behavior +- Calculating token balances +- Understanding token velocity and liquidity + +{% enddocs %} + +{% docs erc721_boba_evt_transfer_doc %} + +The `erc721_boba.evt_transfer` table contains Transfer events from ERC721 (NFT) token contracts on the Boba blockchain. Each record represents an NFT transfer and includes: + +- NFT contract address +- Token ID +- Sender and recipient addresses +- Block and transaction information +- Event log details + +This table is used for: +- Tracking NFT ownership changes +- Analyzing NFT trading patterns +- Monitoring NFT collection activity +- Building NFT holder histories +- Understanding NFT market dynamics + +{% enddocs %} + +{% docs erc1155_boba_evt_transfer_doc %} + +The `erc1155_boba.evt_transfersingle` and `erc1155_boba.evt_transferbatch` tables contain Transfer events from ERC1155 token contracts on the Boba blockchain. These tables track both fungible and non-fungible token transfers within the same contract. They include: + +- Token contract address +- Token IDs +- Amounts transferred +- Sender, operator, and recipient addresses +- Block and transaction information +- Event log details + +These tables are essential for: +- Tracking multi-token transfers +- Analyzing gaming asset movements +- Monitoring hybrid token systems +- Understanding complex token ecosystems +- Building token holder analytics + +{% enddocs %} diff --git a/sources/_base_sources/evm/flare_base_sources.yml b/sources/_base_sources/evm/flare_base_sources.yml new file mode 100644 index 00000000000..aced6efea3d --- /dev/null +++ b/sources/_base_sources/evm/flare_base_sources.yml @@ -0,0 +1,593 @@ +version: 2 + +sources: + - name: flare + description: "Raw tables for the Flare blockchain" + tables: + - name: transactions + meta: + docs_slug: "/evm/flare/raw/transactions" + short_description: "The `flare.transactions` table contains all transactions on the Flare blockchain." + description: '{{ doc("flare_transactions_doc") }}' + columns: + - name: block_time + description: "The exact UTC timestamp when this transaction was included" + data_type: timestamp + - name: block_number + description: "The sequential number of the block containing this transaction" + data_type: bigint + - name: value + description: "Amount of native tokens transferred in this transaction" + data_type: uint256 + - name: gas_limit + description: "Maximum amount of gas that can be used by this transaction" + data_type: bigint + - name: gas_price + description: "Price per unit of gas specified by the sender" + data_type: uint256 + - name: gas_used + description: "Amount of gas used by this transaction" + data_type: bigint + - name: max_fee_per_gas + description: "Maximum total fee per unit of gas (EIP-1559)" + data_type: bigint + - name: max_priority_fee_per_gas + description: "Maximum priority fee per unit of gas (EIP-1559)" + data_type: bigint + - name: priority_fee_per_gas + description: "Actual priority fee per unit of gas (EIP-1559)" + data_type: bigint + - name: nonce + description: "Number of transactions sent by the sender prior to this one" + data_type: bigint + - name: index + description: "Index of this transaction within the block" + data_type: bigint + - name: success + description: "Whether the transaction was successful" + data_type: boolean + - name: from + description: "Address that sent the transaction" + data_type: varbinary + - name: to + description: "Address that received the transaction" + data_type: varbinary + - name: block_hash + description: "Hash of the block containing this transaction" + data_type: varbinary + - name: data + description: "Data payload of the transaction" + data_type: varbinary + - name: hash + description: "Unique identifier (hash) of this transaction" + data_type: varbinary + - name: type + description: "Transaction type (0 = legacy, 1 = access list, 2 = EIP-1559)" + data_type: varchar + - name: access_list + description: "List of addresses and storage keys that the transaction plans to access" + data_type: array(row(address varbinary,storageKeys array(varbinary))) + - name: block_date + description: "UTC date of the block containing this transaction" + data_type: date + + - name: traces + meta: + docs_slug: "/evm/flare/raw/traces" + short_description: "The `flare.traces` table contains all transaction traces on the Flare blockchain." + description: '{{ doc("flare_traces_doc") }}' + columns: + - name: block_time + description: "The exact UTC timestamp when this trace was created" + data_type: timestamp + - name: block_number + description: "The sequential number of the block containing this trace" + data_type: bigint + - name: value + description: "Amount of native tokens transferred in this trace" + data_type: uint256 + - name: gas + description: "Gas limit for this trace" + data_type: bigint + - name: gas_used + description: "Amount of gas used by this trace" + data_type: bigint + - name: block_hash + description: "Hash of the block containing this trace" + data_type: varbinary + - name: success + description: "Whether this trace was successful" + data_type: boolean + - name: tx_index + description: "Index of the transaction within the block" + data_type: integer + - name: tx_from + description: "Address that sent the transaction" + data_type: varbinary + - name: tx_to + description: "Address that received the transaction" + data_type: varbinary + - name: sub_traces + description: "Number of sub-traces" + data_type: bigint + - name: error + description: "Error message if the trace failed" + data_type: varchar + - name: tx_success + description: "Whether the parent transaction was successful" + data_type: boolean + - name: tx_hash + description: "Hash of the transaction" + data_type: varbinary + - name: from + description: "Address initiating this trace" + data_type: varbinary + - name: to + description: "Address receiving this trace" + data_type: varbinary + - name: trace_address + description: "Array indicating the position in the call trace tree" + data_type: array(bigint) + - name: type + description: "Type of the trace (call, create, suicide, reward)" + data_type: varchar + - name: address + description: "Address of the contract if this is a create trace" + data_type: varbinary + - name: code + description: "Contract code for create traces" + data_type: varbinary + - name: call_type + description: "Type of call (call, delegatecall, staticcall)" + data_type: varchar + - name: input + description: "Input data for the trace" + data_type: varbinary + - name: output + description: "Output data from the trace" + data_type: varbinary + - name: refund_address + description: "Address receiving refund for self-destruct" + data_type: varbinary + - name: revert_reason + description: "Reason for revert if the trace failed" + data_type: varchar + - name: block_date + description: "UTC date of the block containing this trace" + data_type: date + + - name: traces_decoded + meta: + docs_slug: "/evm/flare/raw/traces_decoded" + short_description: "The `flare.traces_decoded` table contains decoded traces from known contracts on the Flare blockchain." + description: '{{ doc("flare_traces_decoded_doc") }}' + columns: + - name: block_date + description: "UTC date of the block containing this trace" + data_type: date + - name: block_time + description: "The exact UTC timestamp when this trace was created" + data_type: timestamp + - name: block_number + description: "The sequential number of the block containing this trace" + data_type: bigint + - name: namespace + description: "Project namespace for the contract" + data_type: varchar + - name: contract_name + description: "Name of the contract" + data_type: varchar + - name: to + description: "Address receiving this trace" + data_type: varbinary + - name: trace_address + description: "Array indicating the position in the call trace tree" + data_type: array(bigint) + - name: tx_hash + description: "Hash of the transaction" + data_type: varbinary + - name: tx_from + description: "Address that sent the transaction" + data_type: varbinary + - name: tx_to + description: "Address that received the transaction" + data_type: varbinary + - name: signature + description: "Function signature hash" + data_type: varbinary + - name: function_name + description: "Name of the called function" + data_type: varchar + + - name: creation_traces + meta: + docs_slug: "/evm/flare/raw/creation_traces" + short_description: "The `flare.creation_traces` table contains information about contract creation events." + description: '{{ doc("flare_creation_traces_doc") }}' + columns: + - name: block_time + description: "The exact UTC timestamp when the block containing this creation was added to the chain" + data_type: timestamp + - name: block_number + description: "The sequential number of the block containing this creation" + data_type: bigint + - name: tx_hash + description: "Unique 256-bit identifier (hash) of the transaction" + data_type: varbinary + - name: address + description: "Address of the deployed contract" + data_type: varbinary + - name: from + description: "Address of the account that created the contract" + data_type: varbinary + - name: code + description: "Bytecode of the deployed contract" + data_type: varbinary + - name: block_month + description: "The month of the block date" + data_type: date + + - name: logs + meta: + docs_slug: "/evm/flare/raw/logs" + short_description: "The `flare.logs` table contains all event logs emitted by contracts on the Flare blockchain." + description: '{{ doc("flare_logs_doc") }}' + columns: + - name: block_time + description: "The exact UTC timestamp when this log was emitted" + data_type: timestamp + - name: block_number + description: "The sequential number of the block containing this log" + data_type: bigint + - name: block_hash + description: "Hash of the block containing this log" + data_type: varbinary + - name: contract_address + description: "Address of the contract that emitted this log" + data_type: varbinary + - name: topic0 + description: "First topic of the log (typically the event signature)" + data_type: varbinary + - name: topic1 + description: "Second topic of the log" + data_type: varbinary + - name: topic2 + description: "Third topic of the log" + data_type: varbinary + - name: topic3 + description: "Fourth topic of the log" + data_type: varbinary + - name: data + description: "Additional data included in the log" + data_type: varbinary + - name: tx_hash + description: "Hash of the transaction that generated this log" + data_type: varbinary + - name: index + description: "Index of this log within the transaction" + data_type: integer + - name: tx_index + description: "Index of the transaction within the block" + data_type: integer + - name: block_date + description: "UTC date of the block containing this log" + data_type: date + - name: tx_from + description: "Address that sent the transaction" + data_type: varbinary + - name: tx_to + description: "Address that received the transaction" + data_type: varbinary + + - name: logs_decoded + meta: + docs_slug: "/evm/flare/raw/logs_decoded" + short_description: "The `flare.logs_decoded` table contains decoded event logs from known contracts on the Flare blockchain." + description: '{{ doc("flare_logs_decoded_doc") }}' + columns: + - name: block_date + description: "UTC date of the block containing this log" + data_type: date + - name: block_time + description: "The exact UTC timestamp when this log was emitted" + data_type: timestamp + - name: block_number + description: "The sequential number of the block containing this log" + data_type: bigint + - name: namespace + description: "Project namespace for the contract" + data_type: varchar + - name: contract_name + description: "Name of the contract that emitted this event" + data_type: varchar + - name: contract_address + description: "Address of the contract that emitted this event" + data_type: varbinary + - name: tx_hash + description: "Hash of the transaction that generated this event" + data_type: varbinary + - name: tx_from + description: "Address that sent the transaction" + data_type: varbinary + - name: tx_to + description: "Address that received the transaction" + data_type: varbinary + - name: index + description: "Index of this event within the transaction" + data_type: integer + - name: signature + description: "Event signature hash" + data_type: varbinary + - name: event_name + description: "Name of the emitted event" + data_type: varchar + + - name: blocks + meta: + docs_slug: "/evm/flare/raw/blocks" + short_description: "The `flare.blocks` table contains information about blocks on the Flare blockchain." + description: '{{ doc("flare_blocks_doc") }}' + columns: + - name: time + description: "The exact UTC timestamp when this block was added to the chain" + data_type: timestamp + - name: number + description: "The sequential number of this block in the chain" + data_type: bigint + - name: gas_limit + description: "Maximum amount of gas that could be used by all transactions in this block" + data_type: decimal(38,0) + - name: gas_used + description: "Actual amount of gas used by all transactions in this block" + data_type: decimal(38,0) + - name: difficulty + description: "Numerical value indicating the computational effort required to mine this block" + data_type: bigint + - name: total_difficulty + description: "Sum of block difficulties up to this block" + data_type: decimal(38,0) + - name: size + description: "Size of this block in bytes" + data_type: bigint + - name: base_fee_per_gas + description: "Base fee per gas in the block (post-EIP-1559)" + data_type: bigint + - name: hash + description: "Unique 256-bit identifier (hash) of this block" + data_type: varbinary + - name: parent_hash + description: "Hash of the previous block in the chain" + data_type: varbinary + - name: miner + description: "Address of the validator that produced this block" + data_type: varbinary + - name: nonce + description: "Value used to demonstrate proof of work for this block" + data_type: varbinary + - name: state_root + description: "Root hash of the state trie" + data_type: varbinary + - name: transactions_root + description: "Root hash of the transactions trie" + data_type: varbinary + - name: receipts_root + description: "Root hash of the receipts trie" + data_type: varbinary + - name: date + description: "The UTC date when this block was added to the chain" + data_type: date + + - name: erc20_flare + description: "Transfer events for ERC20 tokens on Flare blockchain" + tables: + - name: evt_transfer + meta: + docs_slug: "/evm/flare/decoded/interfaces/erc20/evt_transfer" + short_description: "This table contains individual transfer events for ERC20 tokens on the Flare blockchain. Each row represents a single token transfer event." + description: '{{ doc("erc20_flare_evt_transfer_doc") }}' + columns: + - name: contract_address + description: "Address of the ERC20 token contract that emitted this event" + - name: evt_tx_hash + description: "Hash of the transaction containing this event" + - name: evt_index + description: "Index position of this event within the transaction" + - name: evt_block_time + description: "Timestamp of the block containing this event" + - name: evt_block_number + description: "The block number containing this event" + - name: from + description: "Address that sent the transaction" + data_type: varbinary + - name: to + description: "Address that received the transaction" + data_type: varbinary + - name: value + description: "Amount of ERC20 tokens transferred, in the token's Flare unit" + + - name: evt_approval + meta: + docs_slug: "/evm/flare/decoded/interfaces/erc20/evt_approval" + short_description: "The `flare.evt_approval` table contains approval events for ERC20 tokens on Flare, allowing an address to spend tokens on behalf of the owner." + description: '{{ doc("erc20_flare_evt_approval_doc") }}' + columns: + - name: contract_address + description: "Address of the ERC20 token contract" + - name: evt_tx_hash + description: "Hash of the transaction containing this event" + - name: evt_index + description: "Index position of this event within the transaction" + - name: evt_block_time + description: "Timestamp of the block containing this event" + - name: evt_block_number + description: "The block number containing this event" + - name: owner + description: "Address of the token owner granting approval" + data_type: varbinary + - name: spender + description: "Address being granted permission to spend tokens" + data_type: varbinary + - name: value + description: "Amount of ERC20 tokens approved for spending, in the token's smallest unit" + + - name: erc1155_flare + description: "Events related to ERC1155 tokens on Flare blockchain" + tables: + - name: evt_transfersingle + meta: + docs_slug: "/evm/flare/decoded/interfaces/erc1155/evt_transfersingle" + short_description: "This table contains single transfer events for ERC1155 tokens on the network." + description: '{{ doc("erc1155_flare_evt_transfersingle_doc") }}' + columns: + - name: contract_address + description: "Address of the ERC1155 token contract" + - name: evt_tx_hash + description: "Hash of the transaction containing this event" + - name: evt_index + description: "Index position of this event within the transaction" + - name: evt_block_time + description: "Timestamp of the block containing this event" + - name: evt_block_number + description: "The block number containing this event" + - name: operator + description: "The address that is authorized to execute the transfer on behalf of the owner" + data_type: varbinary + - name: from + description: "Address that sent the transaction" + data_type: varbinary + - name: to + description: "Address that received the transaction" + data_type: varbinary + - name: id + description: "Unique identifier of the ERC1155 token being transferred" + - name: value + description: "Quantity of the ERC1155 token transferred" + + - name: evt_transferbatch + meta: + docs_slug: "/evm/flare/decoded/interfaces/erc1155/evt_transferbatch" + short_description: "This table contains all batch transfer events for ERC1155 tokens on the network." + description: '{{ doc("erc1155_ethereum_evt_transferbatch_doc") }}' + columns: + - name: contract_address + description: "Contract address of the ERC1155 token contract" + - name: evt_tx_hash + description: "Hash of the transaction containing this event" + - name: evt_index + description: "Index position of this event within the transaction" + - name: evt_block_time + description: "Timestamp of the block containing this event" + - name: evt_block_number + description: "The block number containing this event" + - name: operator + description: "Contract address authorized to execute the batch transfer on behalf of the owner" + data_type: varbinary + - name: from + description: "Address that sent the transaction" + data_type: varbinary + - name: to + description: "Address that received the transaction" + data_type: varbinary + - name: ids + description: "Array of unique identifiers of the ERC1155 tokens being transferred" + - name: values + description: "Array of quantities for each ERC1155 token transferred, corresponding to the ids array" + + - name: evt_ApprovalForAll + meta: + docs_slug: "/evm/flare/decoded/interfaces/erc1155/evt_ApprovalForAll" + short_description: "This table contains approval events for all tokens of an ERC1155 contract on this network." + description: '{{ doc("erc1155_ethereum_evt_ApprovalForAll_doc") }}' + columns: + - name: contract_address + description: "Flare address of the ERC1155 token contract" + - name: evt_tx_hash + description: "Hash of the transaction containing this event" + - name: evt_index + description: "Index position of this event within the transaction" + - name: evt_block_time + description: "Timestamp of the block containing this event" + - name: evt_block_number + description: "The block number containing this event" + - name: approved + description: "Boolean indicating whether approval is granted (true) or revoked (false)" + - name: owner + description: "Flare address of the token owner granting or revoking approval" + data_type: varbinary + - name: operator + description: "Flare address being granted or revoked permission to operate all tokens" + data_type: varbinary + + - name: erc721_flare + description: '{{ doc("erc721_flare_evt_transfer_doc") }}' + tables: + - name: evt_transfer + description: "Transfer events for ERC721 tokens on this network" + columns: + - name: contract_address + description: "Contract address of the ERC721 token contract" + - name: evt_tx_hash + description: "Hash of the transaction containing this event" + - name: evt_index + description: "Index position of this event within the transaction" + - name: evt_block_time + description: "Timestamp of the block containing this event" + - name: evt_block_number + description: "The block number containing this event" + - name: from + description: "Address that sent the transaction" + data_type: varbinary + - name: to + description: "Address that received the transaction" + data_type: varbinary + - name: tokenId + description: "Unique identifier of the ERC721 token (NFT) being transferred" + + - name: evt_Approval + meta: + docs_slug: "/evm/flare/decoded/interfaces/erc721/evt_Approval" + short_description: "Approval events for ERC721 tokens on this network" + description: '{{ doc("erc721_ethereum_evt_Approval_doc") }}' + columns: + - name: contract_address + description: "Contract address of the ERC721 token contract" + - name: evt_tx_hash + description: "Hash of the transaction containing this event" + - name: evt_index + description: "Index position of this event within the transaction" + - name: evt_block_time + description: "Timestamp of the block containing this event" + - name: evt_block_number + description: "The block number containing this event" + - name: approved + description: "Boolean indicating whether approval is granted (true) or revoked (false)" + - name: owner + description: "Address of the token owner granting or revoking approval" + data_type: varbinary + - name: tokenId + description: "Unique identifier of the ERC721 token (NFT) for which approval is granted or revoked" + + - name: evt_ApprovalForAll + meta: + docs_slug: "/evm/flare/decoded/interfaces/erc721/evt_ApprovalForAll" + short_description: "The `flare.evt_ApprovalForAll` table contains approval events for all tokens of an ERC721 contract on the Flare blockchain." + description: '{{ doc("erc721_ethereum_evt_ApprovalForAll_doc") }}' + columns: + - name: contract_address + description: "Address of the ERC721 token contract" + - name: evt_tx_hash + description: "Hash of the transaction containing this event" + - name: evt_index + description: "Index position of this event within the transaction" + - name: evt_block_time + description: "Timestamp of the block containing this event" + - name: evt_block_number + description: "The block number containing this event" + - name: approved + description: "Boolean indicating whether approval is granted (true) or revoked (false)" + - name: owner + description: "Address of the token owner granting or revoking approval" + data_type: varbinary + - name: operator + description: "The address being granted or revoked permission to operate all tokens" + data_type: varbinary diff --git a/sources/_base_sources/evm/flare_docs_block.md b/sources/_base_sources/evm/flare_docs_block.md new file mode 100644 index 00000000000..06a96b286c2 --- /dev/null +++ b/sources/_base_sources/evm/flare_docs_block.md @@ -0,0 +1,311 @@ +{% docs flare_transactions_doc %} + +The `flare.transactions` table contains detailed information about transactions on the Flare blockchain. It includes: + +- Block information: number, timestamp, hash +- Transaction details: hash, from_address, to_address, value +- Gas data: gas_price, gas_limit, gas_used, max_fee_per_gas, priority_fee_per_gas +- Status: success or failure +- Input data for contract interactions +- Nonce and chain_id +- Transaction type and access list + +This table is used for analyzing transaction patterns, gas usage, value transfers, and overall network activity on Flare. + +{% enddocs %} + +{% docs flare_traces_doc %} + +The `flare.traces` table contains records of execution steps for transactions on the Flare blockchain. Each trace represents an atomic operation that modifies the state of the Ethereum Virtual Machine (EVM). Key components include: + +- Transaction hash and block information +- From and to addresses +- Value transferred +- Gas metrics (gas, gas_used) +- Input and output data +- Call type (e.g., CALL, DELEGATECALL, CREATE) +- Error information and revert reasons +- Trace address for nested calls + +This table is essential for: +- Analyzing internal transactions +- Debugging smart contract interactions +- Tracking value flows through complex transactions +- Understanding contract creation and deployment +- Monitoring FTSO (Flare Time Series Oracle) interactions +- Analyzing State Connector operations + +{% enddocs %} + +{% docs flare_traces_decoded_doc %} + +The `flare.traces_decoded` table contains a subset of decoded traces from the Flare blockchain dependent on submitted smart contracts and their ABIs. It includes: + +- Block information and transaction details +- Contract name and namespace +- Decoded function names and signatures +- Trace address for execution path tracking +- Transaction origin and destination +- Function parameters (when available) + +This table is used for high level analysis of smart contract interactions, including FTSO and State Connector operations. For fully decoded function calls and parameters, refer to protocol-specific decoded tables. + +{% enddocs %} + +{% docs flare_logs_doc %} + +The `flare.logs` table contains event logs emitted by smart contracts on the Flare blockchain. It includes: + +- Block information: number, timestamp, hash +- Transaction details: hash, index, from, to +- Contract address (emitting the event) +- Topic0 (event signature) +- Additional topics (indexed parameters) +- Data field (non-indexed parameters) +- Log index and transaction index + +This table is crucial for: +- Tracking on-chain events +- Monitoring contract activity +- Analyzing token transfers +- Following protocol-specific events +- Tracking FTSO price submissions and rewards +- Monitoring State Connector attestations + +{% enddocs %} + +{% docs flare_logs_decoded_doc %} + +The `flare.logs_decoded` table contains a subset of decoded logs from the Flare blockchain dependent on submitted smart contracts and their ABIs. It includes: + +- Block and transaction information +- Contract details (name, namespace, address) +- Decoded event names and signatures +- Transaction origin and destination +- Event parameters (when available) + +This table is used for high level analysis of smart contract events, particularly useful for monitoring FTSO and State Connector activities. For fully decoded events and parameters, refer to protocol-specific decoded tables. + +{% enddocs %} + +{% docs flare_blocks_doc %} + +The `flare.blocks` table contains information about Flare blocks. It provides essential data about each block in the Flare blockchain, including: + +- Block identifiers and timestamps +- Gas metrics and size +- Consensus information (difficulty, nonce) +- State roots and receipts +- Parent block information +- Base fee per gas +- Extra data + +This table is used for: +- Block timing analysis +- Network performance monitoring +- Gas price trends +- Chain reorganization studies +- Consensus metrics tracking + +{% enddocs %} + +{% docs flare_contracts_doc %} + +The `flare.contracts` table contains information about verified smart contracts on the Flare blockchain. It includes: + +- Contract address +- Contract name and version +- Verification status and timestamp +- Compiler information +- Source code and ABI +- License type +- Implementation details + +This table is used for: +- Contract verification status +- Smart contract analysis +- Protocol research +- Development and debugging +- FTSO and State Connector contract tracking + +{% enddocs %} + +{% docs flare_creation_traces_doc %} + +The `flare.creation_traces` table contains detailed information about contract creation events on the Flare blockchain. It includes: + +- Block information: time, number, date +- Transaction details: hash, from address +- Contract creation specifics: + * Created contract address + * Contract bytecode + * Creation transaction details + * Success/failure status + +This table is essential for: +- Tracking smart contract deployments +- Analyzing contract creation patterns +- Monitoring new protocol deployments +- Auditing contract creation history +- Understanding contract deployment costs + +{% enddocs %} + +{% docs erc20_flare_evt_transfer_doc %} + +The `flare.erc20_flare.evt_transfer` table contains ERC20 token transfer events on the Flare blockchain. Each row represents a single token transfer and includes: + +- Contract address of the token +- Transaction details (hash, block info) +- Transfer participants (from and to addresses) +- Amount transferred +- Event metadata (index, block time) + +This table is crucial for: +- Tracking token movements +- Analyzing token holder behavior +- Monitoring token activity +- Computing token metrics +- Identifying significant transfers + +{% enddocs %} + +{% docs erc20_flare_evt_approval_doc %} + +The `flare.erc20_flare.evt_approval` table contains ERC20 token approval events on the Flare blockchain. It records when token holders authorize other addresses to spend tokens on their behalf, including: + +- Token contract address +- Transaction information +- Owner address (granting approval) +- Spender address (receiving approval) +- Approved amount +- Event metadata + +This table is used for: +- Monitoring token approvals +- Analyzing DEX interactions +- Tracking delegation patterns +- Security monitoring +- Protocol integration analysis + +{% enddocs %} + +{% docs erc1155_flare_evt_transfersingle_doc %} + +The `flare.erc1155_flare.evt_transfersingle` table contains single transfer events for ERC1155 tokens on the Flare blockchain. Each record includes: + +- Contract address +- Transaction details +- Operator address +- From and to addresses +- Token ID +- Amount transferred +- Event metadata + +This table is essential for: +- Tracking multi-token transfers +- Gaming asset movements +- NFT marketplace analysis +- Collection statistics +- User activity monitoring + +{% enddocs %} + +{% docs erc1155_flare_evt_transferbatch_doc %} + +The `flare.erc1155_flare.evt_transferbatch` table contains batch transfer events for ERC1155 tokens on the Flare blockchain. It records multiple token transfers in a single transaction: + +- Contract address +- Transaction information +- Operator address +- From and to addresses +- Arrays of token IDs and amounts +- Event metadata + +This table is used for: +- Analyzing bulk transfers +- Gaming inventory movements +- Marketplace activity +- Collection migrations +- Protocol efficiency analysis + +{% enddocs %} + +{% docs erc1155_flare_evt_approvalforall_doc %} + +The `flare.erc1155_flare.evt_approvalforall` table contains approval events for ERC1155 tokens on the Flare blockchain. It records when owners grant or revoke approval for all their tokens: + +- Contract address +- Transaction details +- Owner address +- Operator address +- Approval status +- Event metadata + +This table is crucial for: +- Monitoring collection approvals +- Marketplace integrations +- Protocol permissions +- Security analysis +- User behavior studies + +{% enddocs %} + +{% docs erc721_flare_evt_transfer_doc %} + +The `flare.erc721_flare.evt_transfer` table contains transfer events for ERC721 tokens (NFTs) on the Flare blockchain. Each record represents a single NFT transfer: + +- Contract address +- Transaction information +- From and to addresses +- Token ID +- Event metadata + +This table is essential for: +- NFT ownership tracking +- Collection analysis +- Market activity monitoring +- User portfolio tracking +- Transfer pattern analysis + +{% enddocs %} + +{% docs erc721_flare_evt_approval_doc %} + +The `flare.erc721_flare.evt_approval` table contains approval events for ERC721 tokens on the Flare blockchain. It records when NFT owners authorize specific addresses to transfer individual tokens: + +- Contract address +- Transaction details +- Owner address +- Approved address +- Token ID +- Event metadata + +This table is used for: +- NFT approval tracking +- Marketplace integration analysis +- Permission monitoring +- Security auditing +- Protocol interaction study + +{% enddocs %} + +{% docs erc721_flare_evt_approvalforall_doc %} + +The `flare.erc721_flare.evt_approvalforall` table contains collection-wide approval events for ERC721 tokens on the Flare blockchain. It records when owners grant or revoke approval for all their NFTs: + +- Contract address +- Transaction information +- Owner address +- Operator address +- Approval status +- Event metadata + +This table is crucial for: +- Collection permission tracking +- Marketplace authorization +- Protocol integration analysis +- Security monitoring +- User behavior analysis + +{% enddocs %} diff --git a/sources/_base_sources/nova_base_sources.yml b/sources/_base_sources/evm/nova_base_sources.yml similarity index 100% rename from sources/_base_sources/nova_base_sources.yml rename to sources/_base_sources/evm/nova_base_sources.yml diff --git a/sources/_base_sources/evm/viction_base_sources.yml b/sources/_base_sources/evm/viction_base_sources.yml new file mode 100644 index 00000000000..9a4a667cdcc --- /dev/null +++ b/sources/_base_sources/evm/viction_base_sources.yml @@ -0,0 +1,681 @@ +version: 2 + +sources: + - name: viction + description: "Viction blockchain data" + freshness: + warn_after: { count: 12, period: hour } + error_after: { count: 24, period: hour } + tables: + - name: blocks + loaded_at_field: block_time + meta: + docs_slug: "/evm/viction/raw/blocks" + short_description: "The `viction.blocks` table contains block-level data for the Viction blockchain." + description: "Block-level data for the Viction blockchain" + columns: + - name: time + description: "The exact UTC timestamp when this block was added to the chain" + data_type: timestamp + - name: number + description: "The block height or block number" + data_type: bigint + - name: hash + description: "The unique hash of this block" + data_type: varbinary + - name: parent_hash + description: "The hash of the parent block" + data_type: varbinary + - name: gas_limit + description: "The maximum amount of gas that could be used in this block" + data_type: decimal(38,0) + - name: gas_used + description: "The actual amount of gas used in this block" + data_type: decimal(38,0) + - name: miner + description: "The address of the miner who mined this block" + data_type: varbinary + - name: difficulty + description: "The mining difficulty at this block" + data_type: bigint + - name: total_difficulty + description: "The total chain difficulty at this block" + data_type: decimal(38,0) + - name: nonce + description: "A random value used in block creation" + data_type: varbinary + - name: size + description: "The size of this block in bytes" + data_type: bigint + - name: base_fee_per_gas + description: "The base fee per gas in this block (post EIP-1559)" + data_type: bigint + - name: state_root + description: "Hash of the root node of the state trie" + data_type: varbinary + - name: transactions_root + description: "Hash of the root node of the transactions trie" + data_type: varbinary + - name: receipts_root + description: "Hash of the root node of the receipts trie" + data_type: varbinary + - name: date + description: "The UTC date of this block" + data_type: date + - name: transactions + loaded_at_field: block_time + meta: + docs_slug: "/evm/viction/raw/transactions" + short_description: "The `viction.transactions` table contains transaction-level data for the Viction blockchain." + description: "Transaction-level data for the Viction blockchain" + columns: + - name: block_time + description: "The exact UTC timestamp when the block containing this transaction was added to the chain" + data_type: timestamp + - name: block_number + description: "The block height or block number" + data_type: bigint + - name: value + description: "The amount of native currency (VIC) transferred" + data_type: uint256 + - name: gas_limit + description: "The maximum amount of gas that could be used in this transaction" + data_type: bigint + - name: gas_price + description: "The price of gas (in wei) for this transaction" + data_type: uint256 + - name: gas_used + description: "The actual amount of gas used in this transaction" + data_type: bigint + - name: max_fee_per_gas + description: "The maximum fee per gas the sender is willing to pay" + data_type: bigint + - name: max_priority_fee_per_gas + description: "The maximum priority fee per gas the sender is willing to pay" + data_type: bigint + - name: priority_fee_per_gas + description: "The priority fee per gas included in the transaction" + data_type: bigint + - name: nonce + description: "The transaction count from this address" + data_type: bigint + - name: index + description: "The index position of this transaction in the block" + data_type: bigint + - name: success + description: "Whether this transaction was successful" + data_type: boolean + - name: from + description: "The address initiating this transaction" + data_type: varbinary + - name: to + description: "The address receiving this transaction" + data_type: varbinary + - name: block_hash + description: "The hash of the block containing this transaction" + data_type: varbinary + - name: data + description: "The input data of the transaction" + data_type: varbinary + - name: hash + description: "The unique hash of this transaction" + data_type: varbinary + - name: type + description: "The transaction type" + data_type: varchar + - name: access_list + description: "List of addresses and storage keys that the transaction plans to access" + data_type: array(row(address varbinary,storageKeys array(varbinary))) + - name: chain_id + description: "The chain ID specified in the transaction" + data_type: varchar + - name: block_date + description: "The UTC date of the block containing this transaction" + data_type: date + - name: l1_gas_used + description: "The amount of L1 gas used (for L2 chains)" + data_type: bigint + - name: l1_gas_price + description: "The L1 gas price (for L2 chains)" + data_type: bigint + - name: l1_fee + description: "The L1 fee (for L2 chains)" + data_type: bigint + - name: l1_fee_scalar + description: "The L1 fee scalar (for L2 chains)" + data_type: double + - name: l1_block_number + description: "The L1 block number (for L2 chains)" + data_type: bigint + - name: l1_timestamp + description: "The L1 timestamp (for L2 chains)" + data_type: bigint + - name: l1_tx_origin + description: "The L1 transaction origin (for L2 chains)" + data_type: varbinary + - name: l1_batch_number + description: "The L1 batch number (for L2 chains)" + data_type: bigint + - name: l1_batch_tx_index + description: "The L1 batch transaction index (for L2 chains)" + data_type: bigint + - name: traces + loaded_at_field: block_time + meta: + docs_slug: "/evm/viction/raw/traces" + short_description: "The `viction.traces` table contains internal transaction traces for the Viction blockchain." + description: "Internal transaction traces for the Viction blockchain" + columns: + - name: block_time + description: "The exact UTC timestamp when the block containing this trace was added to the chain" + data_type: timestamp + - name: block_number + description: "The block height or block number" + data_type: bigint + - name: value + description: "The amount of native currency (VIC) transferred" + data_type: uint256 + - name: gas + description: "The gas limit for this trace" + data_type: bigint + - name: gas_used + description: "The actual amount of gas used in this trace" + data_type: bigint + - name: block_hash + description: "The hash of the block containing this trace" + data_type: varbinary + - name: success + description: "Whether this trace was successful" + data_type: boolean + - name: tx_index + description: "The index position of the transaction in the block" + data_type: integer + - name: tx_from + description: "The address that sent the transaction" + data_type: varbinary + - name: tx_to + description: "The address that received the transaction" + data_type: varbinary + - name: sub_traces + description: "The number of sub-traces" + data_type: bigint + - name: error + description: "Error message if the trace failed" + data_type: varchar + - name: tx_success + description: "Whether the parent transaction was successful" + data_type: boolean + - name: tx_hash + description: "The hash of the transaction containing this trace" + data_type: varbinary + - name: from + description: "The address initiating this internal transaction" + data_type: varbinary + - name: to + description: "The address receiving this internal transaction" + data_type: varbinary + - name: trace_address + description: "The trace address array indicating the location in the call trace tree" + data_type: array(bigint) + - name: type + description: "The trace type" + data_type: varchar + - name: address + description: "The address of the called contract" + data_type: varbinary + - name: code + description: "The contract code if this trace creates a contract" + data_type: varbinary + - name: call_type + description: "The type of call made to the contract" + data_type: varchar + - name: input + description: "The input data provided to the called contract" + data_type: varbinary + - name: output + description: "The output data from the called contract" + data_type: varbinary + - name: refund_address + description: "The address that receives the refund" + data_type: varbinary + - name: revert_reason + description: "The reason for reversion if the trace was reverted" + data_type: varchar + - name: block_date + description: "The UTC date of the block containing this trace" + data_type: date + - name: traces_decoded + loaded_at_field: block_time + meta: + docs_slug: "/evm/viction/decoded/traces" + short_description: "The `viction.traces_decoded` table contains decoded internal transaction traces for the Viction blockchain." + description: "Decoded internal transaction traces for the Viction blockchain" + columns: + - name: block_date + description: "The UTC date of the block containing this trace" + data_type: date + - name: block_time + description: "The exact UTC timestamp when the block containing this trace was added to the chain" + data_type: timestamp + - name: block_number + description: "The block height or block number" + data_type: bigint + - name: namespace + description: "The namespace of the contract" + data_type: varchar + - name: contract_name + description: "The name of the contract" + data_type: varchar + - name: to + description: "The address receiving this internal transaction" + data_type: varbinary + - name: trace_address + description: "The trace address array indicating the location in the call trace tree" + data_type: array(bigint) + - name: tx_hash + description: "The hash of the transaction containing this trace" + data_type: varbinary + - name: tx_from + description: "The address that sent the transaction" + data_type: varbinary + - name: tx_to + description: "The address that received the transaction" + data_type: varbinary + - name: signature + description: "The function signature" + data_type: varbinary + - name: function_name + description: "The name of the called function" + data_type: varchar + - name: logs + loaded_at_field: block_time + meta: + docs_slug: "/evm/viction/raw/logs" + short_description: "The `viction.logs` table contains event logs emitted by smart contracts on the Viction blockchain." + description: "Event logs emitted by smart contracts on the Viction blockchain" + columns: + - name: block_time + description: "The exact UTC timestamp when the block containing this log was added to the chain" + data_type: timestamp + - name: block_number + description: "The block height or block number" + data_type: bigint + - name: block_hash + description: "The hash of the block containing this log" + data_type: varbinary + - name: contract_address + description: "The address of the contract that generated this log" + data_type: varbinary + - name: topic0 + description: "The first topic (typically the event signature)" + data_type: varbinary + - name: topic1 + description: "The second topic (if any)" + data_type: varbinary + - name: topic2 + description: "The third topic (if any)" + data_type: varbinary + - name: topic3 + description: "The fourth topic (if any)" + data_type: varbinary + - name: data + description: "The data included in this log" + data_type: varbinary + - name: tx_hash + description: "The hash of the transaction that created this log" + data_type: varbinary + - name: index + description: "The index position of this log in the block" + data_type: integer + - name: tx_index + description: "The index position of the transaction in the block" + data_type: integer + - name: block_date + description: "The UTC date of the block containing this log" + data_type: date + - name: tx_from + description: "The address that sent the transaction" + data_type: varbinary + - name: tx_to + description: "The address that received the transaction" + data_type: varbinary + - name: logs_decoded + loaded_at_field: block_time + meta: + docs_slug: "/evm/viction/decoded/logs" + short_description: "The `viction.logs_decoded` table contains decoded event logs from the Viction blockchain." + description: "Decoded event logs from the Viction blockchain" + columns: + - name: block_date + description: "The UTC date of the block containing this log" + data_type: date + - name: block_time + description: "The exact UTC timestamp when the block containing this log was added to the chain" + data_type: timestamp + - name: block_number + description: "The block height or block number" + data_type: bigint + - name: namespace + description: "The namespace of the contract" + data_type: varchar + - name: contract_name + description: "The name of the contract" + data_type: varchar + - name: contract_address + description: "The address of the contract that generated this log" + data_type: varbinary + - name: tx_hash + description: "The hash of the transaction that created this log" + data_type: varbinary + - name: tx_from + description: "The address that sent the transaction" + data_type: varbinary + - name: tx_to + description: "The address that received the transaction" + data_type: varbinary + - name: index + description: "The index position of this log in the block" + data_type: integer + - name: signature + description: "The event signature" + data_type: varbinary + - name: event_name + description: "The name of the event" + data_type: varchar + - name: creation_traces + loaded_at_field: block_time + meta: + docs_slug: "/evm/viction/raw/creation_traces" + short_description: "The `viction.creation_traces` table contains information about contract creation events." + description: "Information about contract creation events on the Viction blockchain" + columns: + - name: block_time + description: "The exact UTC timestamp when the block containing this creation was added to the chain" + data_type: timestamp + - name: block_number + description: "The block height or block number" + data_type: bigint + - name: tx_hash + description: "The hash of the transaction containing this creation trace" + data_type: varbinary + - name: address + description: "The address of the created contract" + data_type: varbinary + - name: from + description: "The address that created the contract" + data_type: varbinary + - name: code + description: "The code of the created contract" + data_type: varbinary + - name: block_month + description: "The month of the block containing this creation trace" + data_type: date + + - name: erc20_viction + description: "Transfer events for ERC20 tokens on Viction blockchain" + tables: + - name: evt_transfer + meta: + docs_slug: "/evm/viction/decoded/interfaces/erc20/evt_transfer" + short_description: "This table contains individual transfer events for ERC20 tokens on the Viction blockchain." + description: "Individual transfer events for ERC20 tokens on the Viction blockchain" + columns: + - name: contract_address + description: "Address of the ERC20 token contract" + data_type: varbinary + - name: from + description: "Address sending the tokens" + data_type: varbinary + - name: to + description: "Address receiving the tokens" + data_type: varbinary + - name: value + description: "Amount of tokens transferred" + data_type: uint256 + - name: evt_tx_hash + description: "Transaction hash of the event" + data_type: varbinary + - name: evt_index + description: "Index of the event in the transaction" + data_type: bigint + - name: evt_block_time + description: "Timestamp of the block containing this event" + data_type: timestamp + - name: evt_block_number + description: "Block number containing this event" + data_type: bigint + + - name: evt_approval + meta: + docs_slug: "/evm/viction/decoded/interfaces/erc20/evt_approval" + short_description: "The `viction.evt_approval` table contains approval events for ERC20 tokens on Viction." + description: "Approval events for ERC20 tokens on Viction" + columns: + - name: contract_address + description: "Address of the ERC20 token contract" + data_type: varbinary + - name: owner + description: "Address of the token owner" + data_type: varbinary + - name: spender + description: "Address being approved to spend tokens" + data_type: varbinary + - name: value + description: "Amount of tokens approved" + data_type: uint256 + - name: evt_tx_hash + description: "Transaction hash of the event" + data_type: varbinary + - name: evt_index + description: "Index of the event in the transaction" + data_type: bigint + - name: evt_block_time + description: "Timestamp of the block containing this event" + data_type: timestamp + - name: evt_block_number + description: "Block number containing this event" + data_type: bigint + + - name: erc1155_viction + description: "Events related to ERC1155 tokens on Viction blockchain" + tables: + - name: evt_transfersingle + meta: + docs_slug: "/evm/viction/decoded/interfaces/erc1155/evt_transfersingle" + short_description: "This table contains single transfer events for ERC1155 tokens on the Viction blockchain." + description: "Single transfer events for ERC1155 tokens on the Viction blockchain" + columns: + - name: contract_address + description: "Address of the ERC1155 token contract" + data_type: varbinary + - name: operator + description: "Address that initiated the transfer" + data_type: varbinary + - name: from + description: "Address sending the tokens" + data_type: varbinary + - name: to + description: "Address receiving the tokens" + data_type: varbinary + - name: id + description: "ID of the token being transferred" + data_type: uint256 + - name: value + description: "Amount of tokens transferred" + data_type: uint256 + - name: evt_tx_hash + description: "Transaction hash of the event" + data_type: varbinary + - name: evt_index + description: "Index of the event in the transaction" + data_type: bigint + - name: evt_block_time + description: "Timestamp of the block containing this event" + data_type: timestamp + - name: evt_block_number + description: "Block number containing this event" + data_type: bigint + + - name: evt_transferbatch + meta: + docs_slug: "/evm/viction/decoded/interfaces/erc1155/evt_transferbatch" + short_description: "This table contains batch transfer events for ERC1155 tokens on the Viction blockchain." + description: "Batch transfer events for ERC1155 tokens on the Viction blockchain" + columns: + - name: contract_address + description: "Contract address of the ERC1155 token contract" + data_type: varbinary + - name: operator + description: "Address that initiated the transfer" + data_type: varbinary + - name: from + description: "Address sending the tokens" + data_type: varbinary + - name: to + description: "Address receiving the tokens" + data_type: varbinary + - name: ids + description: "Array of token IDs being transferred" + data_type: array(uint256) + - name: values + description: "Array of amounts being transferred" + data_type: array(uint256) + - name: evt_tx_hash + description: "Transaction hash of the event" + data_type: varbinary + - name: evt_index + description: "Index of the event in the transaction" + data_type: bigint + - name: evt_block_time + description: "Timestamp of the block containing this event" + data_type: timestamp + - name: evt_block_number + description: "Block number containing this event" + data_type: bigint + + - name: evt_ApprovalForAll + meta: + docs_slug: "/evm/viction/decoded/interfaces/erc1155/evt_approvalforall" + short_description: "This table contains approval events for all tokens of an ERC1155 contract on the Viction blockchain." + description: "Approval events for all tokens of an ERC1155 contract on the Viction blockchain" + columns: + - name: contract_address + description: "Viction address of the ERC1155 token contract" + data_type: varbinary + - name: owner + description: "Address of the token owner" + data_type: varbinary + - name: operator + description: "Address being approved to manage all tokens" + data_type: varbinary + - name: approved + description: "Whether approval is being granted or revoked" + data_type: bool + - name: evt_tx_hash + description: "Transaction hash of the event" + data_type: varbinary + - name: evt_index + description: "Index of the event in the transaction" + data_type: bigint + - name: evt_block_time + description: "Timestamp of the block containing this event" + data_type: timestamp + - name: evt_block_number + description: "Block number containing this event" + data_type: bigint + + - name: erc721_viction + description: "Events related to ERC721 tokens on Viction blockchain" + tables: + - name: evt_transfer + meta: + docs_slug: "/evm/viction/decoded/interfaces/erc721/evt_transfer" + short_description: "This table contains transfer events for ERC721 tokens on the Viction blockchain." + description: "Transfer events for ERC721 tokens on the Viction blockchain" + columns: + - name: contract_address + description: "Contract address of the ERC721 token contract" + data_type: varbinary + - name: from + description: "Address sending the token" + data_type: varbinary + - name: to + description: "Address receiving the token" + data_type: varbinary + - name: tokenId + description: "ID of the token being transferred" + data_type: uint256 + - name: evt_tx_hash + description: "Transaction hash of the event" + data_type: varbinary + - name: evt_index + description: "Index of the event in the transaction" + data_type: bigint + - name: evt_block_time + description: "Timestamp of the block containing this event" + data_type: timestamp + - name: evt_block_number + description: "Block number containing this event" + data_type: bigint + + - name: evt_Approval + meta: + docs_slug: "/evm/viction/decoded/interfaces/erc721/evt_approval" + short_description: "This table contains approval events for ERC721 tokens on the Viction blockchain." + description: "Approval events for ERC721 tokens on the Viction blockchain" + columns: + - name: contract_address + description: "Contract address of the ERC721 token contract" + data_type: varbinary + - name: owner + description: "Address of the token owner" + data_type: varbinary + - name: approved + description: "Address being approved to transfer the token" + data_type: varbinary + - name: tokenId + description: "ID of the token being approved" + data_type: uint256 + - name: evt_tx_hash + description: "Transaction hash of the event" + data_type: varbinary + - name: evt_index + description: "Index of the event in the transaction" + data_type: bigint + - name: evt_block_time + description: "Timestamp of the block containing this event" + data_type: timestamp + - name: evt_block_number + description: "Block number containing this event" + data_type: bigint + + - name: evt_ApprovalForAll + meta: + docs_slug: "/evm/viction/decoded/interfaces/erc721/evt_approvalforall" + short_description: "This table contains approval events for all tokens of an ERC721 contract on the Viction blockchain." + description: "Approval events for all tokens of an ERC721 contract on the Viction blockchain" + columns: + - name: contract_address + description: "Address of the ERC721 token contract" + data_type: varbinary + - name: owner + description: "Address of the token owner" + data_type: varbinary + - name: operator + description: "Address being approved to manage all tokens" + data_type: varbinary + - name: approved + description: "Whether approval is being granted or revoked" + data_type: bool + - name: evt_tx_hash + description: "Transaction hash of the event" + data_type: varbinary + - name: evt_index + description: "Index of the event in the transaction" + data_type: bigint + - name: evt_block_time + description: "Timestamp of the block containing this event" + data_type: timestamp + - name: evt_block_number + description: "Block number containing this event" + data_type: bigint diff --git a/sources/_base_sources/evm/viction_docs_block.md b/sources/_base_sources/evm/viction_docs_block.md new file mode 100644 index 00000000000..27d0935b7dd --- /dev/null +++ b/sources/_base_sources/evm/viction_docs_block.md @@ -0,0 +1,141 @@ +{% docs viction_blocks_doc %} +This table contains block-level data from the Viction blockchain. Each row represents a single block and includes details such as the timestamp, block number, hash, gas metrics, and other block-specific information. + +Key use cases: +- Analyzing block production and network activity over time +- Monitoring gas usage and block size trends +- Tracking miner/validator behavior + +{% enddocs %} + +{% docs viction_transactions_doc %} +This table contains transaction-level data from the Viction blockchain. Each row represents a single transaction and includes details such as the sender, receiver, value transferred, gas usage, and transaction status. + +Key use cases: +- Analyzing transaction patterns and network usage +- Monitoring gas prices and fees +- Tracking specific address activities +- Investigating transaction success/failure rates + +{% enddocs %} + +{% docs viction_traces_doc %} +This table contains internal transaction traces from the Viction blockchain. Each row represents an internal call made during transaction execution, providing detailed information about contract interactions and value transfers. + +Key use cases: +- Analyzing complex contract interactions +- Tracking internal value transfers +- Debugging failed transactions +- Understanding contract execution flows + +{% enddocs %} + +{% docs viction_logs_doc %} +This table contains event logs emitted by smart contracts on the Viction blockchain. Each row represents a single event log and includes the emitting contract address, indexed topics, and event data. + +Key use cases: +- Tracking specific contract events +- Monitoring token transfers and approvals +- Analyzing contract usage patterns +- Building event-based metrics and analytics + +{% enddocs %} + +{% docs viction_creation_traces_doc %} +This table contains information about contract creation events on the Viction blockchain. Each row represents a contract deployment transaction and includes details about the creator, created contract, and deployment parameters. + +Key use cases: +- Tracking new contract deployments +- Analyzing contract creation patterns +- Monitoring smart contract ecosystem growth +- Investigating contract creators and factory patterns + +{% enddocs %} + +{% docs erc20_viction_evt_transfer_doc %} +This table contains Transfer events from ERC20 token contracts on the Viction blockchain. Each row represents a token transfer and includes the sender, receiver, and amount transferred. + +Key use cases: +- Tracking token transfers and holder activity +- Analyzing token circulation and velocity +- Monitoring specific address token flows +- Building token-specific metrics + +{% enddocs %} + +{% docs erc20_viction_evt_approval_doc %} +This table contains Approval events from ERC20 token contracts on the Viction blockchain. Each row represents an approval for token spending and includes the token owner, approved spender, and approved amount. + +Key use cases: +- Tracking token approvals and delegated spending rights +- Monitoring DEX and protocol integrations +- Analyzing user interaction patterns with token contracts +- Identifying potential security risks from large approvals + +{% enddocs %} + +{% docs erc1155_viction_evt_transfersingle_doc %} +This table contains TransferSingle events from ERC1155 token contracts on the Viction blockchain. Each row represents a single token transfer and includes the operator, sender, receiver, token ID, and amount. + +Key use cases: +- Tracking individual token transfers +- Monitoring NFT and multi-token activities +- Analyzing gaming asset movements +- Building token-specific metrics + +{% enddocs %} + +{% docs erc1155_viction_evt_transferbatch_doc %} +This table contains TransferBatch events from ERC1155 token contracts on the Viction blockchain. Each row represents a batch token transfer and includes the operator, sender, receiver, token IDs, and amounts. + +Key use cases: +- Tracking bulk token transfers +- Monitoring large-scale token operations +- Analyzing gaming asset movements +- Building token-specific metrics + +{% enddocs %} + +{% docs erc1155_viction_evt_approvalforall_doc %} +This table contains ApprovalForAll events from ERC1155 token contracts on the Viction blockchain. Each row represents an operator approval for all tokens of a contract. + +Key use cases: +- Tracking operator approvals for token management +- Monitoring marketplace integrations +- Analyzing user interaction patterns +- Identifying potential security risks + +{% enddocs %} + +{% docs erc721_viction_evt_transfer_doc %} +This table contains Transfer events from ERC721 token contracts on the Viction blockchain. Each row represents an NFT transfer and includes the sender, receiver, and token ID. + +Key use cases: +- Tracking NFT ownership changes +- Analyzing NFT trading patterns +- Monitoring specific collection activity +- Building NFT-specific metrics + +{% enddocs %} + +{% docs erc721_viction_evt_approval_doc %} +This table contains Approval events from ERC721 token contracts on the Viction blockchain. Each row represents an approval for a specific NFT and includes the owner, approved address, and token ID. + +Key use cases: +- Tracking NFT approvals and marketplace listings +- Monitoring NFT trading patterns +- Analyzing marketplace integration activity +- Identifying potential security risks + +{% enddocs %} + +{% docs erc721_viction_evt_approvalforall_doc %} +This table contains ApprovalForAll events from ERC721 token contracts on the Viction blockchain. Each row represents an operator approval for all NFTs of a contract. + +Key use cases: +- Tracking operator approvals for NFT management +- Monitoring marketplace integrations +- Analyzing user interaction patterns +- Identifying potential security risks + +{% enddocs %} diff --git a/sources/_base_sources/other/ton_base_sources.yml b/sources/_base_sources/other/ton_base_sources.yml new file mode 100644 index 00000000000..e63917e4c1b --- /dev/null +++ b/sources/_base_sources/other/ton_base_sources.yml @@ -0,0 +1,920 @@ +version: 2 + +sources: + - name: ton + description: "TON blockchain raw data tables" + freshness: + warn_after: { count: 12, period: hour } + error_after: { count: 24, period: hour } + tables: + - name: blocks + loaded_at_field: ingested_at + description: "TON blockchain blocks" + columns: + - name: block_time + description: "Block timestamp" + data_tests: + - not_null + data_type: timestamp + + - name: block_date + description: "Block date" + data_tests: + - not_null + data_type: date + + - name: workchain + description: "Workchain identifier" + data_type: integer + + - name: shard + description: "Shard identifier" + data_type: bigint + + - name: seqno + description: "Block sequence number" + data_type: integer + + - name: root_hash + description: "Root hash of the block" + data_type: varchar + + - name: file_hash + description: "File hash of the block" + data_type: varchar + + - name: mc_block_workchain + description: "Masterchain block workchain" + data_type: integer + + - name: mc_block_shard + description: "Masterchain block shard" + data_type: bigint + + - name: mc_block_seqno + description: "Masterchain block sequence number" + data_type: integer + + - name: global_id + description: "Global identifier" + data_type: integer + + - name: version + description: "Block version" + data_type: integer + + - name: after_merge + description: "Flag indicating if block is after merge" + data_type: boolean + + - name: before_split + description: "Flag indicating if block is before split" + data_type: boolean + + - name: after_split + description: "Flag indicating if block is after split" + data_type: boolean + + - name: want_merge + description: "Flag indicating if block wants to merge" + data_type: boolean + + - name: want_split + description: "Flag indicating if block wants to split" + data_type: boolean + + - name: key_block + description: "Flag indicating if block is a key block" + data_type: boolean + + - name: vert_seqno_incr + description: "Vertical sequence number increment flag" + data_type: boolean + + - name: flags + description: "Block flags" + data_type: integer + + - name: gen_utime + description: "Generation unix time" + data_type: bigint + + - name: start_lt + description: "Start logical time" + data_type: bigint + + - name: end_lt + description: "End logical time" + data_type: bigint + + - name: validator_list_hash_short + description: "Short hash of validator list" + data_type: integer + + - name: gen_catchain_seqno + description: "Generation catchain sequence number" + data_type: integer + + - name: min_ref_mc_seqno + description: "Minimum reference masterchain sequence number" + data_type: integer + + - name: prev_key_block_seqno + description: "Previous key block sequence number" + data_type: integer + + - name: vert_seqno + description: "Vertical sequence number" + data_type: integer + + - name: master_ref_seqno + description: "Master reference sequence number" + data_type: integer + + - name: rand_seed + description: "Random seed" + data_type: varchar + + - name: created_by + description: "Block creator address" + data_type: varchar + + - name: tx_count + description: "Number of transactions in block" + data_type: integer + + - name: updated_at + description: "Last update timestamp" + data_type: timestamp + + - name: ingested_at + description: "Time at which the block was ingested" + data_type: timestamp + + - name: messages + loaded_at_field: ingested_at + description: "TON blockchain messages" + columns: + - name: block_time + description: "Block timestamp" + data_type: timestamp + + - name: block_date + description: "Block date" + data_type: date + + - name: tx_hash + description: "Transaction hash" + data_type: varchar + + - name: tx_lt + description: "Transaction logical time" + data_type: bigint + + - name: tx_now + description: "Transaction timestamp" + data_type: integer + + - name: msg_hash + description: "Message hash" + data_type: varchar + + - name: direction + description: "Message direction" + data_type: varchar + + - name: trace_id + description: "Trace identifier" + data_type: varchar + + - name: source + description: "Source address" + data_type: varchar + + - name: destination + description: "Destination address" + data_type: varchar + + - name: value + description: "Message value" + data_type: bigint + + - name: fwd_fee + description: "Forward fee" + data_type: bigint + + - name: ihr_fee + description: "IHR fee" + data_type: bigint + + - name: created_lt + description: "Creation logical time" + data_type: bigint + + - name: created_at + description: "Creation timestamp" + data_type: bigint + + - name: opcode + description: "Operation code" + data_type: integer + + - name: ihr_disabled + description: "IHR disabled flag" + data_type: boolean + + - name: bounce + description: "Bounce flag" + data_type: boolean + + - name: bounced + description: "Bounced flag" + data_type: boolean + + - name: import_fee + description: "Import fee" + data_type: bigint + + - name: body_hash + description: "Message body hash" + data_type: varchar + + - name: body_boc + description: "Message body BOC" + data_type: varbinary + + - name: comment + description: "Message comment" + data_type: varchar + + - name: init_state_hash + description: "Initial state hash" + data_type: varchar + + - name: init_state_boc + description: "Initial state BOC" + data_type: varbinary + + - name: updated_at + description: "Last update timestamp" + data_type: timestamp + + - name: ingested_at + description: "Time at which the message was ingested" + data_type: timestamp + + - name: transactions + loaded_at_field: ingested_at + description: "TON blockchain transactions" + columns: + - name: block_time + description: "Block timestamp" + data_type: timestamp + + - name: block_date + description: "Block date" + data_type: date + + - name: account + description: "Account address" + data_type: varchar + + - name: hash + description: "Transaction hash" + data_type: varchar + + - name: lt + description: "Logical time" + data_type: bigint + + - name: block_workchain + description: "Block workchain identifier" + data_type: integer + + - name: block_shard + description: "Block shard identifier" + data_type: bigint + + - name: block_seqno + description: "Block sequence number" + data_type: integer + + - name: mc_block_seqno + description: "Masterchain block sequence number" + data_type: integer + + - name: trace_id + description: "Trace identifier" + data_type: varchar + + - name: prev_trans_hash + description: "Previous transaction hash" + data_type: varchar + + - name: prev_trans_lt + description: "Previous transaction logical time" + data_type: bigint + + - name: now + description: "Transaction timestamp" + data_type: integer + + - name: orig_status + description: "Original status" + data_type: varchar + + - name: end_status + description: "End status" + data_type: varchar + + - name: total_fees + description: "Total transaction fees" + data_type: bigint + + - name: account_state_hash_before + description: "Account state hash before transaction" + data_type: varchar + + - name: account_state_hash_after + description: "Account state hash after transaction" + data_type: varchar + + - name: account_state_code_hash_before + description: "Account state code hash before transaction" + data_type: varchar + + - name: account_state_code_hash_after + description: "Account state code hash after transaction" + data_type: varchar + + - name: account_state_balance_before + description: "Account balance before transaction" + data_type: bigint + + - name: account_state_balance_after + description: "Account balance after transaction" + data_type: bigint + + - name: descr + description: "Transaction description" + data_type: varchar + + - name: aborted + description: "Transaction aborted flag" + data_type: boolean + + - name: destroyed + description: "Account destroyed flag" + data_type: boolean + + - name: credit_first + description: "Credit first flag" + data_type: boolean + + - name: is_tock + description: "Is tock transaction flag" + data_type: boolean + + - name: installed + description: "Code installed flag" + data_type: boolean + + - name: storage_fees_collected + description: "Storage fees collected" + data_type: bigint + + - name: storage_fees_due + description: "Storage fees due" + data_type: bigint + + - name: storage_status_change + description: "Storage status change" + data_type: varchar + + - name: credit_due_fees_collected + description: "Credit due fees collected" + data_type: bigint + + - name: credit + description: "Credit amount" + data_type: bigint + + - name: compute_skipped + description: "Compute phase skipped flag" + data_type: boolean + + - name: skipped_reason + description: "Reason for skipping compute phase" + data_type: varchar + + - name: compute_success + description: "Compute phase success flag" + data_type: boolean + + - name: compute_msg_state_used + description: "Message state used in compute phase" + data_type: boolean + + - name: compute_account_activated + description: "Account activated in compute phase" + data_type: boolean + + - name: compute_gas_fees + description: "Gas fees in compute phase" + data_type: bigint + + - name: compute_gas_used + description: "Gas used in compute phase" + data_type: bigint + + - name: compute_gas_limit + description: "Gas limit in compute phase" + data_type: bigint + + - name: compute_gas_credit + description: "Gas credit in compute phase" + data_type: bigint + + - name: compute_mode + description: "Compute phase mode" + data_type: integer + + - name: compute_exit_code + description: "Compute phase exit code" + data_type: integer + + - name: compute_exit_arg + description: "Compute phase exit argument" + data_type: integer + + - name: compute_vm_steps + description: "VM steps in compute phase" + data_type: bigint + + - name: compute_vm_init_state_hash + description: "VM initial state hash" + data_type: varchar + + - name: compute_vm_final_state_hash + description: "VM final state hash" + data_type: varchar + + - name: action_success + description: "Action phase success flag" + data_type: boolean + + - name: action_valid + description: "Action phase validity flag" + data_type: boolean + + - name: action_no_funds + description: "No funds for action phase flag" + data_type: boolean + + - name: action_status_change + description: "Action phase status change" + data_type: varchar + + - name: action_total_fwd_fees + description: "Total forward fees in action phase" + data_type: bigint + + - name: action_total_action_fees + description: "Total action fees" + data_type: bigint + + - name: action_result_code + description: "Action phase result code" + data_type: integer + + - name: action_result_arg + description: "Action phase result argument" + data_type: integer + + - name: action_tot_actions + description: "Total number of actions" + data_type: integer + + - name: action_spec_actions + description: "Number of special actions" + data_type: integer + + - name: action_skipped_actions + description: "Number of skipped actions" + data_type: integer + + - name: action_msgs_created + description: "Number of messages created" + data_type: integer + + - name: action_action_list_hash + description: "Action list hash" + data_type: varchar + + - name: action_tot_msg_size_cells + description: "Total message size in cells" + data_type: bigint + + - name: action_tot_msg_size_bits + description: "Total message size in bits" + data_type: bigint + + - name: bounce + description: "Bounce status" + data_type: varchar + + - name: bounce_msg_size_cells + description: "Bounce message size in cells" + data_type: bigint + + - name: bounce_msg_size_bits + description: "Bounce message size in bits" + data_type: bigint + + - name: bounce_req_fwd_fees + description: "Required forward fees for bounce" + data_type: bigint + + - name: bounce_msg_fees + description: "Bounce message fees" + data_type: bigint + + - name: bounce_fwd_fees + description: "Bounce forward fees" + data_type: bigint + + - name: split_info_cur_shard_pfx_len + description: "Current shard prefix length" + data_type: integer + + - name: split_info_acc_split_depth + description: "Account split depth" + data_type: integer + + - name: split_info_this_addr + description: "This address in split info" + data_type: varchar + + - name: split_info_sibling_addr + description: "Sibling address in split info" + data_type: varchar + + - name: updated_at + description: "Last update timestamp" + data_type: timestamp + + - name: ingested_at + description: "Time at which the transaction was ingested" + data_type: timestamp + + - name: dex_pools + loaded_at_field: ingested_at + description: "TON DEX pools information" + columns: + - name: block_time + description: "Block timestamp" + data_type: timestamp + + - name: block_date + description: "Block date" + data_type: date + + - name: pool + description: "Pool address" + data_type: varchar + + - name: project + description: "DEX project name" + data_type: varchar + + - name: version + description: "DEX version" + data_type: integer + + - name: discovered_at + description: "Pool discovery timestamp" + data_type: integer + + - name: jetton_left + description: "Left token address" + data_type: varchar + + - name: jetton_right + description: "Right token address" + data_type: varchar + + - name: reserves_left + description: "Left token reserves" + data_type: decimal(38,0) + + - name: reserves_right + description: "Right token reserves" + data_type: decimal(38,0) + + - name: total_supply + description: "Total supply of LP tokens" + data_type: decimal(38,0) + + - name: tvl_usd + description: "Total value locked in USD" + data_type: decimal(20,6) + + - name: tvl_ton + description: "Total value locked in TON" + data_type: decimal(20,9) + + - name: last_updated + description: "Last update timestamp" + data_type: integer + + - name: is_liquid + description: "Liquidity status flag" + data_type: boolean + + - name: lp_fee + description: "LP fee percentage" + data_type: decimal(12,10) + + - name: protocol_fee + description: "Protocol fee percentage" + data_type: decimal(12,10) + + - name: referral_fee + description: "Referral fee percentage" + data_type: decimal(12,10) + + - name: updated_at + description: "Last update timestamp" + data_type: timestamp + + - name: ingested_at + description: "Time at which the pool data was ingested" + data_type: timestamp + + - name: dex_trades + loaded_at_field: ingested_at + description: "TON DEX trades information" + columns: + - name: block_time + description: "Block timestamp" + data_type: timestamp + + - name: block_date + description: "Block date" + data_type: date + + - name: tx_hash + description: "Transaction hash" + data_type: varchar + + - name: trace_id + description: "Trace identifier" + data_type: varchar + + - name: project_type + description: "Project type" + data_type: varchar + + - name: project + description: "DEX project name" + data_type: varchar + + - name: version + description: "DEX version" + data_type: integer + + - name: event_time + description: "Event timestamp" + data_type: integer + + - name: event_type + description: "Event type" + data_type: varchar + + - name: trader_address + description: "Trader address" + data_type: varchar + + - name: pool_address + description: "Pool address" + data_type: varchar + + - name: router_address + description: "Router address" + data_type: varchar + + - name: token_sold_address + description: "Sold token address" + data_type: varchar + + - name: token_bought_address + description: "Bought token address" + data_type: varchar + + - name: amount_sold_raw + description: "Raw amount of tokens sold" + data_type: decimal(38,0) + + - name: amount_bought_raw + description: "Raw amount of tokens bought" + data_type: decimal(38,0) + + - name: referral_address + description: "Referral address" + data_type: varchar + + - name: platform_tag + description: "Platform tag" + data_type: varchar + + - name: query_id + description: "Query identifier" + data_type: decimal(20,0) + + - name: volume_usd + description: "Trade volume in USD" + data_type: decimal(20,6) + + - name: volume_ton + description: "Trade volume in TON" + data_type: decimal(20,9) + + - name: updated_at + description: "Last update timestamp" + data_type: timestamp + + - name: ingested_at + description: "Time at which the trade was ingested" + data_type: timestamp + + - name: jetton_events + loaded_at_field: ingested_at + description: "TON jetton events" + columns: + - name: block_time + description: "Block timestamp" + data_type: timestamp + + - name: block_date + description: "Block date" + data_type: date + + - name: type + description: "Event type" + data_type: varchar + + - name: tx_hash + description: "Transaction hash" + data_type: varchar + + - name: tx_lt + description: "Transaction logical time" + data_type: bigint + + - name: utime + description: "Unix timestamp" + data_type: integer + + - name: trace_id + description: "Trace identifier" + data_type: varchar + + - name: tx_aborted + description: "Transaction aborted flag" + data_type: boolean + + - name: query_id + description: "Query identifier" + data_type: decimal(20,0) + + - name: amount + description: "Token amount" + data_type: decimal(38,0) + + - name: source + description: "Source address" + data_type: varchar + + - name: destination + description: "Destination address" + data_type: varchar + + - name: jetton_wallet + description: "Jetton wallet address" + data_type: varchar + + - name: jetton_master + description: "Jetton master contract address" + data_type: varchar + + - name: response_destination + description: "Response destination address" + data_type: varchar + + - name: custom_payload + description: "Custom payload data" + data_type: varbinary + + - name: forward_ton_amount + description: "Forward TON amount" + data_type: decimal(38,0) + + - name: forward_payload + description: "Forward payload data" + data_type: varbinary + + - name: comment + description: "Event comment" + data_type: varchar + + - name: updated_at + description: "Last update timestamp" + data_type: timestamp + + - name: ingested_at + description: "Time at which the event was ingested" + data_type: timestamp + + - name: jetton_metadata + loaded_at_field: ingested_at + description: "TON jetton metadata" + columns: + - name: address + description: "Jetton address" + data_type: varchar + + - name: update_time_onchain + description: "On-chain update timestamp" + data_type: integer + + - name: update_time_metadata + description: "Metadata update timestamp" + data_type: integer + + - name: mintable + description: "Mintable flag" + data_type: boolean + + - name: admin_address + description: "Admin address" + data_type: varchar + + - name: jetton_content_onchain + description: "On-chain jetton content" + data_type: varchar + + - name: jetton_wallet_code_hash + description: "Jetton wallet code hash" + data_type: varchar + + - name: code_hash + description: "Contract code hash" + data_type: varchar + + - name: metadata_status + description: "Metadata status" + data_type: integer + + - name: symbol + description: "Token symbol" + data_type: varchar + + - name: name + description: "Token name" + data_type: varchar + + - name: description + description: "Token description" + data_type: varchar + + - name: image + description: "Token image URL" + data_type: varchar + + - name: image_data + description: "Token image data" + data_type: varchar + + - name: decimals + description: "Token decimals" + data_type: integer + + - name: sources + description: "Original metadata sources" + data_type: row(symbol varchar, name varchar, description varchar, image varchar, image_data varchar, decimals varchar) + + - name: tonapi_image_url + description: "TON API image URL" + data_type: varchar + + - name: adding_date + description: "Token adding timestamp" + data_type: integer + + - name: updated_at + description: "Last update timestamp" + data_type: timestamp + + - name: ingested_at + description: "Time at which the metadata was ingested" + data_type: timestamp diff --git a/sources/_sector/blobs/_sources.yml b/sources/_sector/blobs/_sources.yml index 8a6dfec62f6..a988a85d5e4 100644 --- a/sources/_sector/blobs/_sources.yml +++ b/sources/_sector/blobs/_sources.yml @@ -4,4 +4,5 @@ sources: - name: taikoxyz_ethereum description: "Taiko smart contracts" tables: - - name: TaikoL1_evt_BlockProposed \ No newline at end of file + - name: TaikoL1_evt_BlockProposed + - name: TaikoL1_evt_BlockProposedV2 \ No newline at end of file diff --git a/sources/_sector/dex/trades/base/_sources.yml b/sources/_sector/dex/trades/base/_sources.yml index 3af9b110190..0bb8805bdcc 100644 --- a/sources/_sector/dex/trades/base/_sources.yml +++ b/sources/_sector/dex/trades/base/_sources.yml @@ -172,6 +172,9 @@ sources: tables: - name: PairFactory_evt_PairCreated - name: Pair_evt_Swap + - name: stablebase_base + tables: + - name: SwapFlashLoan_evt_TokenSwap - name: basex_base tables: - name: UniswapV3Pool_evt_Swap @@ -185,4 +188,17 @@ sources: - name: xchange_base tables: - name: XchangePair_evt_Swap - - name: XchangeFactory_evt_PairCreated \ No newline at end of file + - name: XchangeFactory_evt_PairCreated + - name: infusion_base + tables: + - name: Pair_evt_Swap + - name: PairFactory_evt_PairCreated + - name: flashliquidity_base + tables: + - name: FlashLiquidityPair_evt_Swap + - name: FlashLiquidityFactory_evt_PairCreated + - name: akronswap_base + tables: + - name: UniswapV2Pair_evt_Swap + - name: UniswapV2Factory_evt_PairCreated + diff --git a/sources/_sector/dex/trades/ethereum/_sources.yml b/sources/_sector/dex/trades/ethereum/_sources.yml index d95c3bb0c06..5c63d9043bc 100644 --- a/sources/_sector/dex/trades/ethereum/_sources.yml +++ b/sources/_sector/dex/trades/ethereum/_sources.yml @@ -129,3 +129,6 @@ sources: - name: SovereignPool_evt_Swap - name: ProtocolFactory_evt_SovereignPoolDeployed - name: HOT_evt_HotSwap + - name: fluid_ethereum + tables: + - name: FluidDexT1_evt_Swap diff --git a/sources/_sector/dex/trades/gnosis/_sources.yml b/sources/_sector/dex/trades/gnosis/_sources.yml index 6755ea39db5..c040eebe4a1 100644 --- a/sources/_sector/dex/trades/gnosis/_sources.yml +++ b/sources/_sector/dex/trades/gnosis/_sources.yml @@ -16,3 +16,11 @@ sources: tables: - name: UniswapV2Pair_evt_Swap - name: UniswapV2Factory_evt_PairCreated + - name: elk_finance_gnosis + tables: + - name: ElkPair_evt_Swap + - name: ElkFactory_evt_PairCreated + - name: levinswap_gnosis + tables: + - name: UniswapV2Pair_evt_Swap + - name: UniswapV2Factory_evt_PairCreated diff --git a/sources/_sector/dex/trades/optimism/_sources.yml b/sources/_sector/dex/trades/optimism/_sources.yml index e13ce79639f..4d723797c87 100644 --- a/sources/_sector/dex/trades/optimism/_sources.yml +++ b/sources/_sector/dex/trades/optimism/_sources.yml @@ -95,3 +95,9 @@ sources: - name: swaap_v2_optimism tables: - name: Vault_evt_Swap + - name: saddle_finance_optimism + tables: + - name: SwapFlashLoan_evt_TokenSwap + - name: bridgers_optimism + tables: + - name: Bridgers_evt_Swap diff --git a/sources/_sector/dex/trades/polygon/_sources.yml b/sources/_sector/dex/trades/polygon/_sources.yml index 81959c6337b..0f1a0e5624e 100644 --- a/sources/_sector/dex/trades/polygon/_sources.yml +++ b/sources/_sector/dex/trades/polygon/_sources.yml @@ -75,3 +75,11 @@ sources: tables: - name: UniswapV2Pair_evt_Swap - name: UniswapV2Factory_evt_PairCreated + - name: jetswap_polygon + tables: + - name: JetswapPair_evt_Swap + - name: JetswapFactory_evt_PairCreated + - name: gravity_finance_polygon + tables: + - name: UniswapV2Pair_evt_Swap + - name: UniswapV2Factory_evt_PairCreated diff --git a/sources/_sector/dex/trades/ronin/_sources.yml b/sources/_sector/dex/trades/ronin/_sources.yml new file mode 100644 index 00000000000..4e40c27221e --- /dev/null +++ b/sources/_sector/dex/trades/ronin/_sources.yml @@ -0,0 +1,11 @@ +version: 2 + +sources: + - name: katana_dex_ronin + tables: + - name: KatanaPair_evt_Swap + - name: KatanaFactory_evt_PairCreated + - name: katana_dex_ronin + tables: + - name: KatanaV3Pool_evt_Swap + - name: KatanaV3Factory_evt_PoolCreated diff --git a/sources/_sector/dex/trades/zksync/_sources.yml b/sources/_sector/dex/trades/zksync/_sources.yml index 76c083d868d..62602a6b1e8 100644 --- a/sources/_sector/dex/trades/zksync/_sources.yml +++ b/sources/_sector/dex/trades/zksync/_sources.yml @@ -60,6 +60,10 @@ sources: tables: - name: ZFPair_evt_Swap - name: Factory_evt_PairCreated + - name: zkswap_finance_v3_zksync + tables: + - name: ZFV3Pool_evt_Swap + - name: ZFV3Factory_evt_PoolCreated - name: gemswap_zksync tables: - name: ZGemPair_evt_Swap diff --git a/sources/_sector/lending/borrow/zksync/_sources.yml b/sources/_sector/lending/borrow/zksync/_sources.yml index eba64c2b327..a05983f222e 100644 --- a/sources/_sector/lending/borrow/zksync/_sources.yml +++ b/sources/_sector/lending/borrow/zksync/_sources.yml @@ -1,6 +1,12 @@ version: 2 sources: + - name: aave_v3_zksync + tables: + - name: Pool_evt_Borrow + - name: Pool_evt_Repay + - name: Pool_evt_LiquidationCall + - name: zerolend_zksync tables: - name: Pool_evt_Borrow diff --git a/sources/_sector/lending/flashloans/zksync/_sources.yml b/sources/_sector/lending/flashloans/zksync/_sources.yml index 4d3acf5e19e..33180194b58 100644 --- a/sources/_sector/lending/flashloans/zksync/_sources.yml +++ b/sources/_sector/lending/flashloans/zksync/_sources.yml @@ -1,6 +1,10 @@ version: 2 sources: + - name: aave_v3_zksync + tables: + - name: Pool_evt_FlashLoan + - name: zerolend_zksync tables: - name: Pool_evt_FlashLoan diff --git a/sources/_sector/lending/supply/arbitrum/_sources.yml b/sources/_sector/lending/supply/arbitrum/_sources.yml index 2e2ec7b3576..4cd48c2588d 100644 --- a/sources/_sector/lending/supply/arbitrum/_sources.yml +++ b/sources/_sector/lending/supply/arbitrum/_sources.yml @@ -5,6 +5,7 @@ sources: tables: - name: L2Pool_evt_Supply - name: L2Pool_evt_Withdraw + - name: WrappedTokenGatewayV3_call_withdrawETH - name: compound_v3_arbitrum tables: diff --git a/sources/_sector/lending/supply/avalanche_c/_sources.yml b/sources/_sector/lending/supply/avalanche_c/_sources.yml index 6704f977d09..9a600dbfab2 100644 --- a/sources/_sector/lending/supply/avalanche_c/_sources.yml +++ b/sources/_sector/lending/supply/avalanche_c/_sources.yml @@ -6,12 +6,14 @@ sources: - name: LendingPool_evt_Deposit - name: LendingPool_evt_Withdraw - name: LendingPool_evt_RedeemUnderlying + - name: WrappedTokenGatewayV2_call_withdrawETH - name: aave_v3_avalanche_c tables: - name: Pool_evt_Supply - name: Pool_evt_Withdraw - name: Pool_evt_RedeemUnderlying + - name: WrappedTokenGatewayV3_call_withdrawETH - name: benqi_finance_avalanche_c tables: diff --git a/sources/_sector/lending/supply/base/_sources.yml b/sources/_sector/lending/supply/base/_sources.yml index 93a23a0e7cb..0fe93a08384 100644 --- a/sources/_sector/lending/supply/base/_sources.yml +++ b/sources/_sector/lending/supply/base/_sources.yml @@ -6,6 +6,7 @@ sources: - name: L2Pool_evt_Supply - name: L2Pool_evt_Withdraw - name: L2Pool_evt_RedeemUnderlying + - name: WrappedTokenGatewayV3_call_withdrawETH - name: compound_v3_base tables: diff --git a/sources/_sector/lending/supply/bnb/_sources.yml b/sources/_sector/lending/supply/bnb/_sources.yml index 112c7e1b820..0fdc926b6d5 100644 --- a/sources/_sector/lending/supply/bnb/_sources.yml +++ b/sources/_sector/lending/supply/bnb/_sources.yml @@ -10,6 +10,7 @@ sources: tables: - name: Pool_evt_Supply - name: Pool_evt_Withdraw + - name: WrappedTokenGatewayV3_call_withdrawETH - name: the_granary_bnb tables: diff --git a/sources/_sector/lending/supply/ethereum/_sources.yml b/sources/_sector/lending/supply/ethereum/_sources.yml index bc4108ff420..ff1a916f458 100644 --- a/sources/_sector/lending/supply/ethereum/_sources.yml +++ b/sources/_sector/lending/supply/ethereum/_sources.yml @@ -11,21 +11,25 @@ sources: tables: - name: LendingPool_evt_Deposit - name: LendingPool_evt_Withdraw + - name: WrappedTokenGatewayV2_call_withdrawETH - name: aave_v3_ethereum tables: - name: Pool_evt_Supply - name: Pool_evt_Withdraw - name: Pool_evt_ReserveDataUpdated + - name: WrappedTokenGatewayV3_call_withdrawETH - name: LidoPool_evt_Supply - name: LidoPool_evt_Withdraw - name: LidoPool_evt_ReserveDataUpdated + - name: LidoWrappedTokenGatewayV3_call_withdrawETH - name: aave_v3_etherfi_ethereum tables: - name: PoolInstance_evt_Supply - name: PoolInstance_evt_Withdraw - name: PoolInstance_evt_ReserveDataUpdated + - name: WrappedTokenGatewayV3_call_withdrawETH - name: compound_v2_ethereum tables: diff --git a/sources/_sector/lending/supply/fantom/_sources.yml b/sources/_sector/lending/supply/fantom/_sources.yml index 24027641a58..bcd7da0b21e 100644 --- a/sources/_sector/lending/supply/fantom/_sources.yml +++ b/sources/_sector/lending/supply/fantom/_sources.yml @@ -6,6 +6,7 @@ sources: - name: Pool_evt_Supply - name: Pool_evt_Withdraw - name: Pool_evt_RedeemUnderlying + - name: WrappedTokenGatewayV3_call_withdrawETH - name: the_granary_fantom tables: diff --git a/sources/_sector/lending/supply/gnosis/_sources.yml b/sources/_sector/lending/supply/gnosis/_sources.yml index fe0319ee20d..54652218d9d 100644 --- a/sources/_sector/lending/supply/gnosis/_sources.yml +++ b/sources/_sector/lending/supply/gnosis/_sources.yml @@ -10,6 +10,7 @@ sources: tables: - name: Pool_evt_Supply - name: Pool_evt_Withdraw + - name: WrappedTokenGatewayV3_call_withdrawETH - name: real_rmm_v1_gnosis tables: diff --git a/sources/_sector/lending/supply/optimism/_sources.yml b/sources/_sector/lending/supply/optimism/_sources.yml index 4e90f45f3c7..3531ec489cb 100644 --- a/sources/_sector/lending/supply/optimism/_sources.yml +++ b/sources/_sector/lending/supply/optimism/_sources.yml @@ -6,6 +6,7 @@ sources: - name: Pool_evt_Supply - name: Pool_evt_Withdraw - name: Pool_evt_RedeemUnderlying + - name: WrappedTokenGatewayV3_call_withdrawETH - name: sonne_finance_optimism tables: diff --git a/sources/_sector/lending/supply/polygon/_sources.yml b/sources/_sector/lending/supply/polygon/_sources.yml index dc3812322c7..08f15c4112d 100644 --- a/sources/_sector/lending/supply/polygon/_sources.yml +++ b/sources/_sector/lending/supply/polygon/_sources.yml @@ -6,12 +6,14 @@ sources: - name: LendingPool_evt_Deposit - name: LendingPool_evt_Withdraw - name: LendingPool_evt_RedeemUnderlying + - name: WrappedTokenGatewayV2_call_withdrawETH - name: aave_v3_polygon tables: - name: Pool_evt_Supply - name: Pool_evt_Withdraw - name: Pool_evt_RedeemUnderlying + - name: WrappedTokenGatewayV3_call_withdrawETH - name: compound_v3_polygon tables: diff --git a/sources/_sector/lending/supply/scroll/_sources.yml b/sources/_sector/lending/supply/scroll/_sources.yml index 297f65da6b7..967e06b6d80 100644 --- a/sources/_sector/lending/supply/scroll/_sources.yml +++ b/sources/_sector/lending/supply/scroll/_sources.yml @@ -5,6 +5,7 @@ sources: tables: - name: L2Pool_evt_Supply - name: L2Pool_evt_Withdraw + - name: WrappedTokenGatewayV3_call_withdrawETH - name: layer_bank_scroll tables: diff --git a/sources/_sector/lending/supply/zksync/_sources.yml b/sources/_sector/lending/supply/zksync/_sources.yml index 40e2f2be49f..18e8fe9ac4b 100644 --- a/sources/_sector/lending/supply/zksync/_sources.yml +++ b/sources/_sector/lending/supply/zksync/_sources.yml @@ -1,6 +1,12 @@ version: 2 sources: + - name: aave_v3_zksync + tables: + - name: Pool_evt_Supply + - name: Pool_evt_Withdraw + - name: WrappedTokenGatewayV3_call_withdrawETH + - name: zerolend_zksync tables: - name: Pool_evt_Supply diff --git a/sources/_sector/nft/_sources.yml b/sources/_sector/nft/_sources.yml index b0169568859..1e82442e5fc 100644 --- a/sources/_sector/nft/_sources.yml +++ b/sources/_sector/nft/_sources.yml @@ -49,3 +49,6 @@ sources: - name: nft_sei tables: - name: transfers + - name: nft_ronin + tables: + - name: transfers diff --git a/sources/_sector/nft/trades/ronin_sources.yml b/sources/_sector/nft/trades/ronin_sources.yml new file mode 100644 index 00000000000..8624efeec01 --- /dev/null +++ b/sources/_sector/nft/trades/ronin_sources.yml @@ -0,0 +1,7 @@ +version: 2 + +sources: + - name: mavis_marketplace_ronin + tables: + - name: MavisMarketPlace_evt_OrderMatched + diff --git a/sources/_subprojects_outputs/dex/_sources.yml b/sources/_subprojects_outputs/dex/_sources.yml index 763459ee4d0..289b8a02a03 100644 --- a/sources/_subprojects_outputs/dex/_sources.yml +++ b/sources/_subprojects_outputs/dex/_sources.yml @@ -40,6 +40,12 @@ sources: - name: balancer_v2_zkevm tables: - name: trades + - name: balancer_v3_ethereum + tables: + - name: trades + - name: balancer_v3_gnosis + tables: + - name: trades - name: balancer tables: - name: trades @@ -56,7 +62,12 @@ sources: - name: balancer_v2_pools_optimism - name: balancer_v2_pools_polygon - name: balancer_v2_pools_zkevm - - name: balancer_cowswap_amm_pools + - name: balancer_cowswap_amm_pools + - name: balancer_v3_pools_ethereum + - name: balancer_v3_pools_gnosis + - name: balancer_v3_pools_base + - name: balancer_v3_pools_arbitrum + - name: balancer_v3_pools - name: uniswap_v3_optimism tables: - name: ovm1_pool_mapping @@ -69,9 +80,12 @@ sources: - name: cow_protocol_arbitrum tables: - name: trades + - name: cow_protocol_base + tables: + - name: trades - name: jelly_swap tables: - - name: trades + - name: trades - name: beethoven_x tables: - name: trades diff --git a/sources/_subprojects_outputs/hourly_spellbook/_sources.yml b/sources/_subprojects_outputs/hourly_spellbook/_sources.yml index 7fd30baafb7..ecf970cd3af 100644 --- a/sources/_subprojects_outputs/hourly_spellbook/_sources.yml +++ b/sources/_subprojects_outputs/hourly_spellbook/_sources.yml @@ -38,6 +38,27 @@ sources: - name: safe_ethereum tables: - name: safes + - name: safe_arbitrum + tables: + - name: safes + - name: safe_avalanche_c + tables: + - name: safes + - name: safe_base + tables: + - name: safes + - name: safe_linea + tables: + - name: safes + - name: safe_optimism + tables: + - name: safes + - name: safe_polygon + tables: + - name: safes + - name: safe_scroll + tables: + - name: safes - name: perpetual tables: @@ -49,7 +70,7 @@ sources: - name: jelly_swap_sei tables: - - name: pools_metrics_daily + - name: pools_metrics_daily - name: account_abstraction_erc4337 tables: @@ -61,4 +82,4 @@ sources: - name: evms tables: - - name: transaction_metrics \ No newline at end of file + - name: transaction_metrics diff --git a/sources/_subprojects_outputs/spellbook/_sources.yml b/sources/_subprojects_outputs/spellbook/_sources.yml index 6929b1a6430..9aa040b2036 100644 --- a/sources/_subprojects_outputs/spellbook/_sources.yml +++ b/sources/_subprojects_outputs/spellbook/_sources.yml @@ -110,6 +110,15 @@ sources: - name: balancer tables: - name: bpt_prices + - name: balancer_v3_ethereum + tables: + - name: bpt_prices + - name: balancer_v3_gnosis + tables: + - name: bpt_prices + - name: balancer_v3 + tables: + - name: erc4626_token_prices - name: addresses_ethereum tables: diff --git a/sources/_subprojects_outputs/tokens/_sources.yml b/sources/_subprojects_outputs/tokens/_sources.yml index fcaaea8777e..8bc3e6d082d 100644 --- a/sources/_subprojects_outputs/tokens/_sources.yml +++ b/sources/_subprojects_outputs/tokens/_sources.yml @@ -121,6 +121,20 @@ sources: data_type: integer - name: name data_type: varchar + - name: rwa + columns: + - name: blockchain + data_type: varchar + - name: contract_address + data_type: varbinary + - name: backing + data_type: varchar + - name: symbol + data_type: varchar + - name: decimals + data_type: integer + - name: name + data_type: varchar - name: tokens_arbitrum @@ -174,6 +188,7 @@ sources: data_type: integer - name: name data_type: varchar + - name: tokens_base @@ -289,6 +304,20 @@ sources: data_type: integer - name: name data_type: varchar + - name: rwa + columns: + - name: blockchain + data_type: varchar + - name: contract_address + data_type: varbinary + - name: backing + data_type: varchar + - name: symbol + data_type: varchar + - name: decimals + data_type: integer + - name: name + data_type: varchar - name: tokens_fantom diff --git a/sources/aave/ethereum/aave_ethereum_sources.yml b/sources/aave/ethereum/aave_ethereum_sources.yml index 25e06170c4f..77bc29c1866 100644 --- a/sources/aave/ethereum/aave_ethereum_sources.yml +++ b/sources/aave/ethereum/aave_ethereum_sources.yml @@ -117,3 +117,12 @@ sources: - *evt_index - *evt_tx_hash - *id + + - name: StaticATokenLM_evt_Initialized + + - name: StaticATokenFactory_evt_StaticTokenCreated + + - name: aave_v3_ethereum + description: "Decoded contracts for Aave v3 on Ethereum" + tables: + - name: VariableDebtToken_evt_Initialized \ No newline at end of file diff --git a/sources/aave/gnosis/aave_gnosis_sources.yml b/sources/aave/gnosis/aave_gnosis_sources.yml new file mode 100644 index 00000000000..f5e9101db8c --- /dev/null +++ b/sources/aave/gnosis/aave_gnosis_sources.yml @@ -0,0 +1,7 @@ +version: 2 + +sources: + - name: aave_v3_gnosis + description: "Decoded contracts for Aave v3 on Gnosis" + tables: + - name: AToken_evt_Initialized diff --git a/sources/balancer/ethereum/balancer_ethereum_sources.yml b/sources/balancer/ethereum/balancer_ethereum_sources.yml index d110ed98492..6cf62852fc6 100644 --- a/sources/balancer/ethereum/balancer_ethereum_sources.yml +++ b/sources/balancer/ethereum/balancer_ethereum_sources.yml @@ -352,3 +352,37 @@ sources: description: "veBAL holder that voted for the gauge" - name: weight description: "Weight of the user for the gauge" + + - name: balancer_v3_ethereum + description: > + Decoded tables related to Balancer V3, an automated portfolio manager and trading platform, on Ethereum. + tables: + - name: Vault_evt_PoolRegistered + + - name: WeightedPoolFactory_evt_PoolCreated + + - name: WeightedPoolFactory_call_create + + - name: Vault_evt_LiquidityAdded + + - name: Vault_evt_LiquidityRemoved + + - name: StablePoolFactory_evt_PoolCreated + + - name: StablePoolFactory_call_create + + - name: Vault_evt_Swap + + - name: ProtocolFeeController_evt_ProtocolSwapFeeCollected + + - name: ProtocolFeeController_evt_ProtocolYieldFeeCollected + + - name: Vault_evt_Wrap + + - name: Vault_evt_Unwrap + + - name: Vault_evt_LiquidityAddedToBuffer + + - name: Vault_evt_LiquidityRemovedFromBuffer + + - name: Vault_evt_SwapFeePercentageChanged diff --git a/sources/balancer/gnosis/balancer_gnosis_sources.yml b/sources/balancer/gnosis/balancer_gnosis_sources.yml index f640f31cb22..b4afef0be0d 100644 --- a/sources/balancer/gnosis/balancer_gnosis_sources.yml +++ b/sources/balancer/gnosis/balancer_gnosis_sources.yml @@ -245,3 +245,36 @@ sources: - name: assetManager description: 'Address of the contract which managed the asset from the vault' + - name: balancer_v3_gnosis + description: > + Decoded tables related to Balancer V2, an automated portfolio manager and trading platform, on Gnosis. + tables: + - name: Vault_evt_PoolRegistered + + - name: WeightedPoolFactory_evt_PoolCreated + + - name: WeightedPoolFactory_call_create + + - name: Vault_evt_LiquidityAdded + + - name: Vault_evt_LiquidityRemoved + + - name: StablePoolFactory_evt_PoolCreated + + - name: StablePoolFactory_call_create + + - name: Vault_evt_Swap + + - name: ProtocolFeeController_evt_ProtocolSwapFeeCollected + + - name: ProtocolFeeController_evt_ProtocolYieldFeeCollected + + - name: Vault_evt_Wrap + + - name: Vault_evt_Unwrap + + - name: Vault_evt_LiquidityAddedToBuffer + + - name: Vault_evt_LiquidityRemovedFromBuffer + + - name: Vault_evt_SwapFeePercentageChanged diff --git a/sources/balancer_cowswap_amm/base/_sources.yml b/sources/balancer_cowswap_amm/base/_sources.yml new file mode 100644 index 00000000000..a122c59a6ca --- /dev/null +++ b/sources/balancer_cowswap_amm/base/_sources.yml @@ -0,0 +1,9 @@ +version: 2 +sources: + - name: b_cow_amm_base + tables: + - name: BCoWFactory_evt_LOG_NEW_POOL + - name: BCoWFactory_evt_COWAMMPoolCreated + - name: BCoWFactory_call_logBCoWPool + - name: BCoWPool_call_bind + - name: BCoWPool_call_unbind \ No newline at end of file diff --git a/sources/beets/sonic/beets_sonic_sources.yml b/sources/beets/sonic/beets_sonic_sources.yml new file mode 100644 index 00000000000..0e6aa5daddc --- /dev/null +++ b/sources/beets/sonic/beets_sonic_sources.yml @@ -0,0 +1,35 @@ +version: 2 + +sources: + - name: beethoven_x_v2_sonic + description: > + Decoded tables related to Beethoven X, an automated portfolio manager and trading platform, on Sonic. + tables: + - name: Vault_evt_Swap + - name: Vault_evt_PoolRegistered + - name: WeightedPoolFactory_call_create + - name: Vault_evt_PoolBalanceChanged + - name: Vault_evt_PoolBalanceManaged + - name: ComposableStablePoolFactory_call_create + - name: Vault_evt_FlashLoan + - name: Vault_evt_TokensRegistered + + - name: beethoven_x_v3_sonic + description: > + Decoded tables related to Beethoven X, an automated portfolio manager and trading platform, on Sonic. + tables: + - name: Vault_evt_PoolRegistered + - name: WeightedPoolFactory_evt_PoolCreated + - name: WeightedPoolFactory_call_create + - name: Vault_evt_LiquidityAdded + - name: Vault_evt_LiquidityRemoved + - name: StablePoolFactory_evt_PoolCreated + - name: StablePoolFactory_call_create + - name: Vault_evt_Swap + - name: ProtocolFeeController_evt_ProtocolSwapFeeCollected + - name: ProtocolFeeController_evt_ProtocolYieldFeeCollected + - name: Vault_evt_Wrap + - name: Vault_evt_Unwrap + - name: Vault_evt_LiquidityAddedToBuffer + - name: Vault_evt_LiquidityRemovedFromBuffer + - name: Vault_evt_SwapFeePercentageChanged \ No newline at end of file diff --git a/sources/bungee/sources.yml b/sources/bungee/sources.yml new file mode 100644 index 00000000000..c98f528f436 --- /dev/null +++ b/sources/bungee/sources.yml @@ -0,0 +1,116 @@ +version: 2 + +sources: + - name: socket_v2_ethereum + description: "Ethereum Socket Gateway events" + tables: + - name: SocketGateway_evt_SocketBridge + columns: &common_columns + - name: contract_address + description: "Contract address of the Socket Gateway" + - name: evt_tx_hash + description: "Transaction hash of the event" + - name: evt_index + description: "Event index in the transaction" + - name: evt_block_time + description: "Timestamp of the block when the event was emitted" + - name: evt_block_number + description: "Block number when the event was emitted" + - name: amount + description: "Amount of tokens being bridged" + - name: token + description: "Address of the token being bridged" + - name: toChainId + description: "Destination chain ID" + - name: bridgeName + description: "Name of the bridge used" + - name: sender + description: "Address of the sender" + - name: receiver + description: "Address of the receiver" + - name: metadata + description: "Additional bridge metadata" + + - name: socket_v2_arbitrum + description: "Arbitrum Socket Gateway events" + tables: + - name: SocketGateway_evt_SocketBridge + columns: *common_columns + + - name: socket_v2_optimism + description: "Optimism Socket Gateway events" + tables: + - name: SocketGateway_evt_SocketBridge + columns: *common_columns + + - name: socket_v2_avalanche_c + description: "Avalanche C-Chain Socket Gateway events" + tables: + - name: SocketGateway_evt_SocketBridge + columns: *common_columns + + - name: socket_v2_bnb + description: "BNB Chain Socket Gateway events" + tables: + - name: SocketGateway_evt_SocketBridge + columns: *common_columns + + - name: socket_v2_polygon + description: "Polygon Socket Gateway events" + tables: + - name: SocketGateway_evt_SocketBridge + columns: *common_columns + + - name: socket_v2_fantom + description: "Fantom Socket Gateway events" + tables: + - name: SocketGateway_evt_SocketBridge + columns: *common_columns + + - name: socket_v2_gnosis + description: "Gnosis Chain Socket Gateway events" + tables: + - name: SocketGateway_evt_SocketBridge + columns: *common_columns + + - name: socket_v2_zksync + description: "zkSync Socket Gateway events" + tables: + - name: SocketGateway_evt_SocketBridge + columns: *common_columns + + - name: socket_v2_base + description: "Base Socket Gateway events" + tables: + - name: SocketGateway_evt_SocketBridge + columns: *common_columns + + - name: socket_v2_zkevm + description: "zkEVM Socket Gateway events" + tables: + - name: SocketGateway_evt_SocketBridge + columns: *common_columns + + - name: socket_v2_scroll + description: "Scroll Socket Gateway events" + tables: + - name: SocketGateway_evt_SocketBridge + columns: *common_columns + + - name: socket_v2_linea + description: "Linea Socket Gateway events" + tables: + - name: SocketGateway_evt_SocketBridge + columns: *common_columns + + - name: socket_v2_mantle + description: "Mantle Socket Gateway events" + tables: + - name: SocketGateway_evt_SocketBridge + columns: *common_columns + + - name: socket_v2_blast + description: "Blast Socket Gateway events" + tables: + - name: SocketGateway_evt_SocketBridge + columns: *common_columns \ No newline at end of file diff --git a/sources/cow_protocol/arbitrum/cow_protocol_arbitrum_sources.yml b/sources/cow_protocol/arbitrum/cow_protocol_arbitrum_sources.yml index e5ee24ab4da..3aed3e46180 100644 --- a/sources/cow_protocol/arbitrum/cow_protocol_arbitrum_sources.yml +++ b/sources/cow_protocol/arbitrum/cow_protocol_arbitrum_sources.yml @@ -122,3 +122,39 @@ sources: - &value name: value description: ETH amount (in WEI) being passed into contract interaction + - name: cow_protocol_arbitrum + description: "Arbitrum decoded tables related to CoW Protocol contract's" + tables: + - name: CoWSwapEthFlow_evt_OrderPlacement + description: "CoWSwapEthFlow Order Placement Events" + columns: + - *contract_address + - *evt_block_number + - *evt_block_time + - *evt_index + - *evt_tx_hash + - &order + name: order + description: "Contains json encoded data for an EthFlowOrder: https://github.com/cowprotocol/ethflowcontract/blob/main/src/libraries/EthFlowOrder.sol#L19-L45" + - &data + name: data + description: "Hex Encoded data containing quoteId and validTo: https://github.com/cowprotocol/ethflowcontract/blob/9c74c8ba36ff9ff3e255172b02454f831c066865/src/CoWSwapEthFlow.sol#L110-L113" + - &sender + name: sender + description: "User who placed the order" + - &signature + name: signature + description: "Onchain EIP1271 signature" + - name: CoWSwapEthFlow_call_createOrder + description: "CoWSwapEthFlow createOrder function calls with input parameters and return value" + columns: + - *call_block_number + - *call_block_time + - *call_success + - *call_trace_address + - *call_tx_hash + - *contract_address + - *order + - &output_orderHash + name: output_orderHash + description: "ETH Flow Order Hash corresponds directly to a GPv2 Order Uid by concatenation with owner = contract_address and validTo = `ffffffff`" diff --git a/sources/cow_protocol/base/cow_protocol_base_sources.yml b/sources/cow_protocol/base/cow_protocol_base_sources.yml new file mode 100644 index 00000000000..23b8894756e --- /dev/null +++ b/sources/cow_protocol/base/cow_protocol_base_sources.yml @@ -0,0 +1,160 @@ +version: 2 + +sources: + - name: gnosis_protocol_v2_base + description: "Base Chain decoded tables related to CoW Protocol contract" + tables: + - name: GPv2AllowListAuthentication_evt_SolverAdded + description: "GPv2AllowListAuthentication list of events when a Solver was added" + columns: + - &solver + name: solver + description: "Solver wallet address" + - &contract_address + name: contract_address + description: "Base address of contract emitting the event" + - &evt_block_number + name: evt_block_number + description: "Block number which processed the unique transaction hash" + - &evt_block_time + name: evt_block_time + description: "Timestamp for block event time in UTC" + - &evt_index + name: evt_index + description: "Index of the event within transaction" + - &evt_tx_hash + name: evt_tx_hash + description: "Primary key of the transaction" + data_tests: + - not_null + - name: GPv2AllowListAuthentication_evt_SolverRemoved + description: "GPv2AllowListAuthentication list of events when a solver was removed" + columns: + - *solver + - *contract_address + - *evt_block_number + - *evt_block_time + - *evt_index + - *evt_tx_hash + - name: GPv2Settlement_evt_Trade + description: "Trade events emitted by GPv2Settlement" + columns: + - &feeAmount + name: feeAmount + description: "Amount (in sell token) in atoms of the trade fee" + - &buyAmount + name: buyAmount + description: "Amount (in atoms) of the buyToken bought" + - &buyToken + name: buyToken + description: "Contract address of token obtained in trade. 0xeee...ee represents native asset ETH" + - *contract_address + - *evt_block_number + - *evt_block_time + - *evt_index + - *evt_tx_hash + - &orderUid + name: orderUid + description: "Unique identifier of order involved in trade. Note that partially fillable orders can be touched multiple times so this is not a unique ID for trade events." + - &owner + name: owner + description: "Owner of the order being traded (aka trader address)" + - &sellAmount + name: sellAmount + description: "Amount in atoms of the sellToken sold" + - &sellToken + name: sellToken + description: "Contract address of token sold in trade." + - name: GPv2Settlement_call_settle + description: "Contains all calls to the settle method of GPv2Settlement (both successful and failed)" + columns: + - &call_block_number + name: call_block_number + description: "Block number on which the method was called" + - &call_block_time + name: call_block_time + description: "UTC timestamp at which the method was called" + - &call_success + name: call_success + description: "Whether or not the call resulted in a successful transaction" + - &call_trace_address + name: call_trace_address + description: "Trace address of the call" + - &call_tx_hash + name: call_tx_hash + description: "Transaction hash of call (if successful, will result in a real transaction hash)." + - &clearingPrices + name: clearingPrices + description: "An array of relative token prices (matched with `tokens` by index)" + - *contract_address + - &interactions + name: interactions + description: "An array of internal contract interactions" + - &tokens + name: tokens + description: "An array of token addresses (to be matched by index on `clearingPrices`)" + - &trades + name: trades + description: "An array of order data for the trades being executed" + - name: GPv2Settlement_evt_Settlement + description: "Settlement events emitted by GPv2Settlement" + columns: + - *contract_address + - *evt_block_number + - *evt_block_time + - *evt_index + - *evt_tx_hash + - *solver + - name: GPv2Settlement_evt_Interaction + description: "Contract Interaction events emitted by GPv2Settlement" + columns: + - *contract_address + - *evt_block_number + - *evt_block_time + - *evt_index + - *evt_tx_hash + - &selector + name: selector + description: Method ID of the contract being interacted with + - &target + name: target + description: Target contract address of the interaction + - &value + name: value + description: ETH amount (in WEI) being passed into contract interaction + - name: cow_protocol_base + description: "Base decoded tables related to CoW Protocol contract's" + tables: + - name: CoWSwapEthFlow_evt_OrderPlacement + description: "CoWSwapEthFlow Order Placement Events" + columns: + - *contract_address + - *evt_block_number + - *evt_block_time + - *evt_index + - *evt_tx_hash + - &order + name: order + description: "Contains json encoded data for an EthFlowOrder: https://github.com/cowprotocol/ethflowcontract/blob/main/src/libraries/EthFlowOrder.sol#L19-L45" + - &data + name: data + description: "Hex Encoded data containing quoteId and validTo: https://github.com/cowprotocol/ethflowcontract/blob/9c74c8ba36ff9ff3e255172b02454f831c066865/src/CoWSwapEthFlow.sol#L110-L113" + - &sender + name: sender + description: "User who placed the order" + - &signature + name: signature + description: "Onchain EIP1271 signature" + - name: CoWSwapEthFlow_call_createOrder + description: "CoWSwapEthFlow createOrder function calls with input parameters and return value" + columns: + - *call_block_number + - *call_block_time + - *call_success + - *call_trace_address + - *call_tx_hash + - *contract_address + - *order + - &output_orderHash + name: output_orderHash + description: "ETH Flow Order Hash corresponds directly to a GPv2 Order Uid by concatenation with owner = contract_address and validTo = `ffffffff`" diff --git a/sources/cow_protocol/gnosis/cow_protocol_gnosis_sources.yml b/sources/cow_protocol/gnosis/cow_protocol_gnosis_sources.yml index 29eb6a3ba98..76e8db8581d 100644 --- a/sources/cow_protocol/gnosis/cow_protocol_gnosis_sources.yml +++ b/sources/cow_protocol/gnosis/cow_protocol_gnosis_sources.yml @@ -122,3 +122,39 @@ sources: - &value name: value description: ETH amount (in WEI) being passed into contract interaction + - name: cow_protocol_gnosis + description: "Gnosis Chain decoded tables related to CoW Protocol contract's" + tables: + - name: CoWSwapEthFlow_evt_OrderPlacement + description: "CoWSwapEthFlow Order Placement Events" + columns: + - *contract_address + - *evt_block_number + - *evt_block_time + - *evt_index + - *evt_tx_hash + - &order + name: order + description: "Contains json encoded data for an EthFlowOrder: https://github.com/cowprotocol/ethflowcontract/blob/main/src/libraries/EthFlowOrder.sol#L19-L45" + - &data + name: data + description: "Hex Encoded data containing quoteId and validTo: https://github.com/cowprotocol/ethflowcontract/blob/9c74c8ba36ff9ff3e255172b02454f831c066865/src/CoWSwapEthFlow.sol#L110-L113" + - &sender + name: sender + description: "User who placed the order" + - &signature + name: signature + description: "Onchain EIP1271 signature" + - name: CoWSwapEthFlow_call_createOrder + description: "CoWSwapEthFlow createOrder function calls with input parameters and return value" + columns: + - *call_block_number + - *call_block_time + - *call_success + - *call_trace_address + - *call_tx_hash + - *contract_address + - *order + - &output_orderHash + name: output_orderHash + description: "ETH Flow Order Hash corresponds directly to a GPv2 Order Uid by concatenation with owner = contract_address and validTo = `ffffffff`" diff --git a/sources/lifi/sources.yml b/sources/lifi/sources.yml new file mode 100644 index 00000000000..87486c607d9 --- /dev/null +++ b/sources/lifi/sources.yml @@ -0,0 +1,56 @@ +version: 2 + +sources: + - name: lifi_ethereum + description: "Ethereum LiFi events" + tables: + - name: LiFiDiamond_v2_evt_LiFiTransferStarted + columns: &common_columns + - name: contract_address + description: "Contract address of the LiFi Diamond" + - name: evt_tx_hash + description: "Transaction hash of the event" + - name: evt_index + description: "Event index in the transaction" + - name: evt_block_time + description: "Timestamp of the block when the event was emitted" + - name: evt_block_number + description: "Block number when the event was emitted" + - name: bridgeData + description: "JSON data containing bridge transfer information including transactionId, bridge, integrator, referrer, sendingAssetId, receiver, minAmount, and destinationChainId" + + - name: lifi_arbitrum + description: "Arbitrum LiFi events" + tables: + - name: LiFiDiamond_v2_evt_LiFiTransferStarted + columns: *common_columns + + - name: lifi_avalanche_c + description: "Avalanche C-Chain LiFi events" + tables: + - name: LiFiDiamond_v2_evt_LiFiTransferStarted + columns: *common_columns + + - name: lifi_bnb + description: "BNB Chain LiFi events" + tables: + - name: LiFiDiamond_v2_evt_LiFiTransferStarted + columns: *common_columns + + - name: lifi_fantom + description: "Fantom LiFi events" + tables: + - name: LiFiDiamond_v2_evt_LiFiTransferStarted + columns: *common_columns + + - name: lifi_gnosis + description: "Gnosis Chain LiFi events" + tables: + - name: LiFiDiamond_v2_evt_LiFiTransferStarted + columns: *common_columns + + - name: lifi_zksync + description: "zkSync LiFi events" + tables: + - name: LiFiDiamond_v2_evt_LiFiTransferStarted + columns: *common_columns diff --git a/sources/morpho/ethereum/morpho_ethereum_sources.yml b/sources/morpho/ethereum/morpho_ethereum_sources.yml new file mode 100644 index 00000000000..112164e10bb --- /dev/null +++ b/sources/morpho/ethereum/morpho_ethereum_sources.yml @@ -0,0 +1,8 @@ +version: 2 + +sources: + - name: metamorpho_factory_ethereum + description: "Decoded contracts for Morpho on Ethereum" + + tables: + - name: MetaMorphoFactory_evt_CreateMetaMorpho \ No newline at end of file diff --git a/sources/openocean/bnb/openocean_bnb_sources.yml b/sources/openocean/bnb/openocean_bnb_sources.yml new file mode 100644 index 00000000000..0d33a49b1c1 --- /dev/null +++ b/sources/openocean/bnb/openocean_bnb_sources.yml @@ -0,0 +1,6 @@ +version: 2 + +sources: + - name: openocean_v2_bnb + tables: + - name: OpenOceanExchange_evt_Swapped diff --git a/sources/openocean/ethereum/openocean_ethereum_sources.yml b/sources/openocean/ethereum/openocean_ethereum_sources.yml new file mode 100644 index 00000000000..7058039ffd1 --- /dev/null +++ b/sources/openocean/ethereum/openocean_ethereum_sources.yml @@ -0,0 +1,6 @@ +version: 2 + +sources: + - name: openocean_v2_ethereum + tables: + - name: OpenOceanExchangeProxy_evt_Swapped diff --git a/sources/rocketpool/ethereum/rocketpool_ethereum_sources.yml b/sources/rocketpool/ethereum/rocketpool_ethereum_sources.yml new file mode 100644 index 00000000000..0e9a9d500fb --- /dev/null +++ b/sources/rocketpool/ethereum/rocketpool_ethereum_sources.yml @@ -0,0 +1,6 @@ +version: 2 + +sources: + - name: rocketpool_ethereum + tables: + - name: RocketTokenRETH_call_getExchangeRate diff --git a/sources/swell/rsweth/ethereum/swell_rsweth_ethereum_sources.yml b/sources/swell/rsweth/ethereum/swell_rsweth_ethereum_sources.yml new file mode 100644 index 00000000000..d0e05fded47 --- /dev/null +++ b/sources/swell/rsweth/ethereum/swell_rsweth_ethereum_sources.yml @@ -0,0 +1,70 @@ +version: 2 + +sources: + - name: swell_v3_ethereum + description: "swell decoded tables of ethereum contract" + tables: + - name: RswEXIT_evt_WithdrawRequestCreated + description: 'decoded table on `WithdrawRequestCreated` event emitted from RswEXIT contract `0x58749C46Ffe97e4d79508a2C781C440f4756f064`. event emitted when a user initiates a new withdrawal request' + columns: + - &rswexit_contract_address + name: contract_address + description: 'RswExit contract address' + - &evt_tx_hash + name: evt_tx_hash + description: 'transaction hash of event' + - &evt_index + name: evt_index + description: 'index of event within block' + - &evt_block_time + name: evt_block_time + description: 'timestamp of blocktime in UTC' + - &evt_block_number + name: evt_block_number + description: 'block number containing transaction' + - name: lastTokenIdProcessed + description: 'last processed withdrawal' + - &rswexit_owner + name: owner + description: 'owner of rsweth burned' + - &rswexit_tokenid + name: tokenId + description: 'unique id for withdrawal processing' + - name: amount + description: 'amount of rsweth burned' + - name: timestamp + description: 'timestamp of withdrawal request' + - name: rateWhenCreated + description: 'rsweth-eth rate at withdrawal request' + + - name: RswEXIT_evt_WithdrawalsProcessed + description: 'decoded table on `WithdrawalsProcessed` event emitted from RswEXIT contract `0x58749C46Ffe97e4d79508a2C781C440f4756f064`. event emitted when the protocol processes the withdrawal from beaconchain and make it available for user to claim' + columns: + - *rswexit_contract_address + - *evt_tx_hash + - *evt_index + - *evt_block_time + - *evt_block_number + - name: fromTokenId + description: 'first token_id of withdrawals processed in this batch' + - name: toTokenId + description: 'last token_id of withdrawals processed in this batch' + - name: processedRate + description: 'rsweth-eth rate at which withdrawal is processed' + - name: processedExitingETH + description: 'amount of eth exiting in current batch' + - name: processedExitedETH + description: 'amount of eth exited' + + - name: RswEXIT_evt_WithdrawalClaimed + description: 'decoded table on `WithdrawalClaimed` event emitted from RswEXIT contract `0x58749C46Ffe97e4d79508a2C781C440f4756f064`. event emitted when a user claims the ETH withdrawn' + columns: + - *rswexit_contract_address + - *evt_tx_hash + - *evt_index + - *evt_block_time + - *evt_block_number + - *rswexit_owner + - *rswexit_tokenid + - name: exitClaimedETH + description: 'amout of eth claimed' \ No newline at end of file diff --git a/sources/yield_yak/avalanche_c/yield_yak_avalanche_c_sources.yml b/sources/yield_yak/avalanche_c/yield_yak_avalanche_c_sources.yml index 360b00d059a..d11a59bf6d5 100644 --- a/sources/yield_yak/avalanche_c/yield_yak_avalanche_c_sources.yml +++ b/sources/yield_yak/avalanche_c/yield_yak_avalanche_c_sources.yml @@ -414,6 +414,10 @@ sources: - name: SonicStrategyForSA_evt_Withdraw - name: SonicStrategyForSA_evt_Reinvest - name: SonicStrategyForSA_evt_Transfer + - name: StableJackStrategy_evt_Deposit + - name: StableJackStrategy_evt_Withdraw + - name: StableJackStrategy_evt_Reinvest + - name: StableJackStrategy_evt_Transfer - name: StableVaultStrategyForS3D_evt_Deposit - name: StableVaultStrategyForS3D_evt_Withdraw - name: StableVaultStrategyForS3D_evt_Reinvest @@ -446,6 +450,10 @@ sources: - name: SynapseStrategy_evt_Withdraw - name: SynapseStrategy_evt_Reinvest - name: SynapseStrategy_evt_Transfer + - name: TokenMillStrategy_evt_Deposit + - name: TokenMillStrategy_evt_Withdraw + - name: TokenMillStrategy_evt_Reinvest + - name: TokenMillStrategy_evt_Transfer - name: UnipoolStrategyV1_evt_Deposit - name: UnipoolStrategyV1_evt_Withdraw - name: UnipoolStrategyV1_evt_Reinvest