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

Simple Calculator Tool for Accessed Funds Total #250

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

rswanson
Copy link
Member

@rswanson rswanson commented Jan 16, 2023

Motivation

Simple tool to automate calculating the amount of funds that have been accessed by people relative to the amount that has been recovered.

Solution

Quick and simple binary crate to get the current quantity of each token in the NFT accountant, then get the price data for each token to calculate a quick total. This uses all publicly available information, the initial totals are sourced from the nomad-xyz/hack-data repository, the current quantities in the wallet are sourced from the public etherscan api, and the price data is sourced from the coingecko public api.

PR Checklist

  • Added Tests
  • Updated Documentation
  • Updated CHANGELOG.md for the appropriate package
  • Ran PR in local/dev/staging

@rswanson rswanson changed the title Swanny/accessed funds calc [wip] Simple Calculator Tool for Accessed Funds Total Jan 16, 2023
@rswanson
Copy link
Member Author

Also just a note, I'm simply bumping the github actions workflows for now. We're using some egregiously old versions. Thats the only really unrelated change.

@rswanson rswanson marked this pull request as ready for review January 16, 2023 19:16
@rswanson rswanson changed the title [wip] Simple Calculator Tool for Accessed Funds Total Simple Calculator Tool for Accessed Funds Total Jan 16, 2023
@rswanson rswanson assigned rswanson and unassigned rswanson Jan 16, 2023
impl Token {
pub fn get_instance_of(token_name: TokenName) -> Token {
match token_name {
TokenName::Usdc => Token {
Copy link
Member

Choose a reason for hiding this comment

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

if all of these are effectively constants, they should be named statics

you could also re-use assets.rs from the nomad nft server

    pub name: TokenName,
    pub id: &'static str,
    pub decimals: f64,
    pub contract_address: &'static str,
    pub recovered_total: f64,
}

static CQT: Token = oken {
                name: TokenName::Cqt,
                id: "covalent",
                decimals: 18.0,
                contract_address: "0xD417144312DbF50465b1C641d016962017Ef6240",
                recovered_total: 34_082_775.751_599_7,
            };

let mut total_accessed_value: f64 = 0.0;
for token in tokens {
let balance: f64 = get_token_balance(&token, address).await?;
let accessed: f64 = token.recovered_total - balance;
Copy link
Member

Choose a reason for hiding this comment

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

danger math :o

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants