-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Optimism Wallet Summary - WIP #4127
Conversation
Workflow run id 5912057508 approved. |
Workflow run id 5912057553 approved. |
Workflow run id 5913926397 approved. |
Workflow run id 5913926507 approved. |
Workflow run id 5920002394 approved. |
Workflow run id 5920002426 approved. |
Workflow run id 5920042300 approved. |
Workflow run id 5920042310 approved. |
Workflow run id 5920099225 approved. |
Workflow run id 5920099303 approved. |
Workflow run id 5920169361 approved. |
Workflow run id 5920169412 approved. |
Workflow run id 5920254171 approved. |
Workflow run id 5920254185 approved. |
Workflow run id 5920304477 approved. |
Workflow run id 5920304460 approved. |
depends on pr 4130 |
}} | ||
|
||
SELECT | ||
1 as dummy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a new line below
seeds/addresses_events/_schema.yml
Outdated
blockchain: varchar | ||
address: varbinary | ||
first_activity_to: varbinary | ||
block_number: bigint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a new line below
@@ -0,0 +1,3 @@ | |||
blockchain,address,first_activity_to,block_number,tx_hash | |||
optimism,0x77BA75A9a95b5aB756749fF5519aC40Ed4AAb486,0x5485798748221719181499103911646299086586,30689881,0x429f0e772d36451ad1e5c9b39a369eb7c1471cd16084209e33eb3d7abf28b56c | |||
optimism,0x1ddb27df0c0c20effb80d65ce7f870b2b083819c,0x8700daec35af8ff88c16bdf0418774cb3d7599b4,104546448,0x5c913779a545da143e0cff539d2197590b834614692b4c2ba7601a480a17d836 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a new line below
}} | ||
|
||
SELECT | ||
1 as dummmy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a new line below
- name: gas_spent | ||
description: "total gas spent by adddress on OP mainet" | ||
- name: unique_dapps | ||
description: "unique dapps address interacted with OP mainet" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a new line below
WHEN (COUNT(ot.hash)/(date_diff('day', min(ot.block_time), max(ot.block_time)) + 1)) >= 1 THEN 'Daily User' | ||
WHEN (COUNT(ot.hash)/(date_diff('day', min(ot.block_time), max(ot.block_time)) + 1)) >= 0.142857142857 THEN 'Weekly User' | ||
WHEN (COUNT(ot.hash)/(date_diff('day', min(ot.block_time), max(ot.block_time)) + 1)) >= 0.0333333333333 THEN 'Monthly User' | ||
WHEN (COUNT(ot.hash)/(date_diff('day', min(ot.block_time), max(ot.block_time)) + 1)) >= 0.0027397260274 THEN 'Yearly User' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you explain how these numbers are derived?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
number of transactions / number of days active (age)
soo for a daily user they need to make at least one transaction per day
for a weekly user they need to make at least one transaction per week which 1/7 = 0.142857.. same for monthly and yearly as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added + 1 because date_diff returns zero (causes an error since we're dividing by 0) if an address as only been active on one day... this is causing the label to be inaccurate when an address is only active one day so will fix that shortly.
END as usage_frequency, | ||
COUNT(ot.hash) as number_of_transactions, | ||
COUNT(DISTINCT(cm.contract_project)) as unique_dapps | ||
FROM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if i've missed something here but is the logic saying that if it's incremental, then only the weekly active addresses are showing up in this table?
or is the logic here self updating the original table if an address is included in weekly active here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep the latter.. the table only updates data for an address that's included in the weekly active.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few other things could be helpful to add:
- First contract interacted, or even like a path of contracts interacted for the first few transactions? You can you contract_mapping table for that
- First function call
- address recency
- amount of op delegation (first delegated at block_number, block_time, amount etc). I previously created a table in Dune trying to do the address summary. Feel free to borrow some ideas from there: https://dune.com/queries/2794862
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okee.. thank you... I'll resolve your comments and also add the other things later this evening.
version: 2 | ||
|
||
models: | ||
- name: addresses_summary_optimism_mainet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- name: addresses_summary_optimism_mainet | |
- name: addresses_summary_op_mainnet |
contributors: Henrystats | ||
config: | ||
tags: ['table', 'wallet summary', 'mainet', 'addresses_summary', 'optimism'] | ||
description: "Table showing summary of an address on Optimism mainet" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
description: "Table showing summary of an address on Optimism mainet" | |
description: "Table showing summary of an address on OP mainnet" |
Workflow run id 5953457024 approved. |
Workflow run id 5953450960 approved. |
Workflow run id 5953560825 approved. |
Workflow run id 5953560712 approved. |
@chuxinh I've made the changes as requested... for the first_contract_project did you mean I should add that in first_activity as well? Will do that in a bit if that's the case, originally left it out since I assumed you suggested that so we'd not need to do a left join with the contract mapping table but we need to because of the unique dapps column.. ci is failing now cause a couple of heavy pr's recently got merged. |
Workflow run id 5958481062 approved. |
Workflow run id 5958481058 approved. |
Oh I was referring to the function signature since you only use this for the first tx |
ohh oke i had updated that @chuxinh |
updated to |
thank you ser! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logic looks good to me! Just a few more comments and thanks so much for this!! @henrystats
- name: address_age | ||
description: "Time period the address has been active for labelled" | ||
- name: address_age | ||
description: "Time period since the address was last active for labelled" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicate
description: "Time period since the address was last active for labelled" | ||
- name: address_age_in_days | ||
description: "Time period in days the address has been active for" | ||
- name: recency_age_in_days |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- name: recency_age_in_days | |
- name: recency_in_days |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe change to the name above. also remember to update that in sql
- name: usage_frequency | ||
description: "How often address is active" | ||
- name: gas_spent | ||
description: "Total gas spent by an address on OP Mainnet" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
description: "Total gas spent by an address on OP Mainnet" | |
description: "Total gas spent in ETH by an address on OP Mainnet" |
tests: | ||
- unique | ||
- name: first_activity_to | ||
description: "Which Optimism address received the first activity of the address with ETH" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First transaction activity to address
case when gas_price = cast(0 as uint256) then 0 | ||
else cast(gas_used as double) * cast(gas_price as double)/1e18 + cast(l1_fee as double) /1e18 | ||
end as gas_spent, | ||
data, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove data column if it's not used
MIN_BY(cm.contract_project, ot.block_number) as first_to_project, | ||
MIN_BY(ot.to, ot.block_number) as first_to_address |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe can also at the last to address and project?
Workflow run id 5970594069 approved. |
Workflow run id 5970594186 approved. |
Workflow run id 5970595022 approved. |
Workflow run id 5970595097 approved. |
made the changes @chuxinh |
Thank you for contributing to Spellbook!
Please refer to the top of the
readme
in the root of Spellbook to learn how to contribute to Spellbook on DuneSQL.