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

Optimism Wallet Summary - WIP #4127

Merged
merged 27 commits into from
Aug 25, 2023
Merged

Conversation

henrystats
Copy link
Contributor

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.

@dune-eng
Copy link

Workflow run id 5912057508 approved.

@dune-eng
Copy link

Workflow run id 5912057553 approved.

@dune-eng
Copy link

Workflow run id 5913926397 approved.

@dune-eng
Copy link

Workflow run id 5913926507 approved.

@dune-eng
Copy link

Workflow run id 5920002394 approved.

@dune-eng
Copy link

Workflow run id 5920002426 approved.

@dune-eng
Copy link

Workflow run id 5920042300 approved.

@dune-eng
Copy link

Workflow run id 5920042310 approved.

@dune-eng
Copy link

Workflow run id 5920099225 approved.

@dune-eng
Copy link

Workflow run id 5920099303 approved.

@dune-eng
Copy link

Workflow run id 5920169361 approved.

@dune-eng
Copy link

Workflow run id 5920169412 approved.

@dune-eng
Copy link

Workflow run id 5920254171 approved.

@dune-eng
Copy link

Workflow run id 5920254185 approved.

@dune-eng
Copy link

Workflow run id 5920304477 approved.

@dune-eng
Copy link

Workflow run id 5920304460 approved.

@henrystats henrystats changed the title Optimism Wallet Summary - WIP Optimism Wallet Summary - Ready for review Aug 21, 2023
@henrystats
Copy link
Contributor Author

henrystats commented Aug 21, 2023

depends on pr 4130

}}

SELECT
1 as dummy
Copy link
Contributor

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

blockchain: varchar
address: varbinary
first_activity_to: varbinary
block_number: bigint
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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"
Copy link
Contributor

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

Comment on lines 46 to 49
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'
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

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
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- 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"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
description: "Table showing summary of an address on Optimism mainet"
description: "Table showing summary of an address on OP mainnet"

@henrystats henrystats changed the title Optimism Wallet Summary - Ready for review Optimism Wallet Summary - WIP Aug 22, 2023
@dune-eng
Copy link

Workflow run id 5953457024 approved.

@dune-eng
Copy link

Workflow run id 5953450960 approved.

@dune-eng
Copy link

Workflow run id 5953560825 approved.

@dune-eng
Copy link

Workflow run id 5953560712 approved.

@henrystats
Copy link
Contributor Author

@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.

@dune-eng
Copy link

Workflow run id 5958481062 approved.

@dune-eng
Copy link

Workflow run id 5958481058 approved.

@chuxinh
Copy link
Contributor

chuxinh commented Aug 24, 2023

Oh I was referring to the function signature since you only use this for the first tx

@henrystats
Copy link
Contributor Author

ohh oke i had updated that @chuxinh

@jeff-dude jeff-dude added the WIP work in progress label Aug 24, 2023
@jeff-dude
Copy link
Member

updated to wip -- feel free to edit title & tag when ready for final review

@henrystats
Copy link
Contributor Author

thank you ser!

Copy link
Contributor

@chuxinh chuxinh left a 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

Comment on lines 28 to 31
- 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"
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- name: recency_age_in_days
- name: recency_in_days

Copy link
Contributor

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"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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"
Copy link
Contributor

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,
Copy link
Contributor

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

Comment on lines 69 to 70
MIN_BY(cm.contract_project, ot.block_number) as first_to_project,
MIN_BY(ot.to, ot.block_number) as first_to_address
Copy link
Contributor

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?

@dune-eng
Copy link

Workflow run id 5970594069 approved.

@dune-eng
Copy link

Workflow run id 5970594186 approved.

@dune-eng
Copy link

Workflow run id 5970595022 approved.

@dune-eng
Copy link

Workflow run id 5970595097 approved.

@henrystats
Copy link
Contributor Author

made the changes @chuxinh

@jeff-dude jeff-dude self-assigned this Aug 25, 2023
@jeff-dude jeff-dude added in review Assignee is currently reviewing the PR and removed WIP work in progress in review Assignee is currently reviewing the PR labels Aug 25, 2023
@jeff-dude jeff-dude merged commit 037638b into duneanalytics:main Aug 25, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Aug 25, 2023
@henrystats henrystats deleted the first-activity branch September 4, 2023 15:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants