Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hivemapper model created #5997

Merged
merged 24 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions models/hivemapper/solana/hivemapper_solana_rewards.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{{
config(
schema = 'hivemapper_solana',
alias = 'rewards',
materialized = 'incremental',
file_format = 'delta',
incremental_strategy = 'merge',
unique_key = ['tx_id', 'outer_instruction_index', 'inner_instruction_index', 'block_slot'],
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')],
post_hook = '{{ expose_spells(\'["solana"]\',
"project",
"hivemapper",
\'["ilemi", "alexus98"]\') }}')
}}

with
honey_transfers as (
SELECT
block_time
, block_date
, block_slot
, "action"
, amount
, token_mint_address
, from_owner
, to_owner
, from_token_account
, to_token_account
, tx_signer
, tx_id
, outer_instruction_index
, inner_instruction_index
, outer_executing_account

FROM {{ ref('tokens_solana_transfers') }} WHERE token_mint_address = '4vMsoUT2BWatFweudnQM1xedRLfJgJ7hswhcpz4xgBTy'

{% if is_incremental() %}
and
{{ incremental_predicate('block_time') }}
{% endif %}
)

, memo_join as (
SELECT
case
when contains(tx.log_messages,'Program log: Memo (len 12): "Map Coverage"') then 'map coverage'
when contains(tx.log_messages,'Program log: Memo (len 6): "Bounty"') then 'bounty'
when contains(tx.log_messages,'Program log: Memo (len 4): "Buzz"') then 'buzz'
when contains(tx.log_messages,'Program log: Memo (len 18): "Map Editing and QA"') then 'QA (AI trainer)'
when contains(tx.log_messages,'Program log: Memo (len 15): "Map Consumption"') then 'map consumption'
when contains(tx.log_messages,'Program log: Memo (len 23): "Map Consumption (fleet)"') then 'map consumption (fleet)'
when contains(tx.log_messages,'Program log: Memo (len 17): "Foundation Reward"') then 'FTM'
when contains(tx.log_messages,'Program log: Memo (len 11): "Honey Burst"') then 'burst'
else null
end as reward_type
, hny.*
FROM {{ source('solana', 'transactions') }} tx
JOIN honey_transfers hny ON tx.id = hny.tx_id --assumes only one transfer per tx
WHERE 1=1
and contains(account_keys, 'MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr') --memo program invoked sometimes not by honey though
{% if is_incremental() %}
and
{{ incremental_predicate('tx.block_time') }}
{% endif %}

)

SELECT
*
FROM memo_join
WHERE reward_type is not null

40 changes: 40 additions & 0 deletions models/hivemapper/solana/hivemapper_solana_schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
version: 2

models:
- name: hivemapper_solana_rewards
meta:
blockchain: solana
project: hivemapper
contributors: [ilemi, alexus98]
config:
tags: ['hivemapper', 'solana', 'reward', 'honey']
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- tx_id
- outer_instruction_index
- inner_instruction_index
- block_slot

description: >
List of HONEY rewards distributed for contributors
columns:
- name: reward_type
- name: block_time
- name: block_date
- name: block_slot
- name: action
- name: amount
tests:
- dbt_utils.accepted_range:
max_value: 1000000000000000 # maximum reward of 1 million HONEY * 1e9 (9 decimal places)
min_value: 0
- name: token_mint_address
- name: from_owner
- name: to_owner
- name: from_token_account
- name: to_token_account
- name: tx_signer
- name: tx_id


Loading