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

bulk of cosmos #17

Draft
wants to merge 52 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
113233f
cosmos staking/lp
asamere Feb 10, 2023
0941c38
index osmo lp from state export
asamere Feb 11, 2023
7119444
add osmo ui supported assets csv
asamere Feb 13, 2023
bf6643a
delegations from state export
asamere Feb 14, 2023
fc8fc0c
add production tern config
asamere Feb 14, 2023
5c893e8
re-number migration
asamere Feb 14, 2023
e2e587b
arkeodrop cli in airdroputils container
asamere Feb 14, 2023
1d59c70
db pool creating log
asamere Feb 15, 2023
8dd2222
index delegators k8s job
asamere Feb 15, 2023
acc1e9f
only index ETH chains for xfers
asamere Feb 15, 2023
2418902
k8s jobs for indexing delegators, thor-lp, eth
asamere Feb 16, 2023
e04d79b
add min_eligible to chains/tokens
asamere Feb 16, 2023
36f7115
delegate whole chain avg export
asamere Feb 16, 2023
6de87af
expose individual eth indexing components
asamere Feb 16, 2023
b583195
airdrop image build/push
asamere Feb 17, 2023
b79101d
eth staking weighted averages
asamere Feb 17, 2023
1c4c319
export eth farm stake averages
asamere Feb 17, 2023
34b9aef
fix endblock ref for eth xfers
asamere Feb 21, 2023
9935d06
temp
asamere Feb 27, 2024
f236f18
update go module dependencies after hiatus
asamere May 6, 2024
78468d7
Update to get docker working
toshiSat May 27, 2024
a3e14a3
Update snapshot end dates for evm chains
toshiSat May 29, 2024
208a322
Add log
toshiSat Jun 3, 2024
91db7e0
Update block numbers
toshiSat Jun 4, 2024
c107a4c
add logs
toshiSat Jun 6, 2024
fa8aa2c
Parsing REST api for tx's
toshiSat Jun 7, 2024
3dd7543
Added more stakingreward contracts and generated csv
toshiSat Jun 11, 2024
ac5af8f
Rpc call working
toshiSat Jun 14, 2024
7646552
Update cosmos staking to handle new events
toshiSat Jun 20, 2024
9ad1a70
More cosmos staking tweaks
toshiSat Jun 21, 2024
743778d
Remove unused code
toshiSat Jun 21, 2024
33b57fe
Fix importing genesis.json + start indexing GAIA
toshiSat Jun 21, 2024
86e0afe
Remove log
toshiSat Jul 1, 2024
07e1964
Fix exporting to file in export_delegates
toshiSat Jul 3, 2024
fbbe446
Fix OSMO authz txs without delegator
toshiSat Jul 9, 2024
dfd1551
Update cosmos indexer
toshiSat Jul 10, 2024
9a57db0
Updated csv's
toshiSat Aug 12, 2024
55842eb
Index osmo lp alongside delegates
toshiSat Aug 13, 2024
9fd1eba
Update eth csvs to include 2x modifier
toshiSat Aug 15, 2024
073cb5d
Update git ignore
toshiSat Aug 15, 2024
bd5ac45
Rename thor
toshiSat Aug 15, 2024
5ac20fd
Add liquidity state export indexer
toshiSat Aug 16, 2024
711ac5a
Undo comment
toshiSat Oct 9, 2024
20e690d
Add loop to it failing
toshiSat Oct 9, 2024
2b2766d
Use debugf
toshiSat Oct 9, 2024
b6c8f50
Add osmosis csv generation
toshiSat Oct 11, 2024
ca37b63
added OSMO delgate CSV
mperklin Oct 26, 2024
610ad1f
Added OSMO LP list
mperklin Oct 29, 2024
361aff8
Generate airdrop csv files
toshiSat Nov 3, 2024
9e9ccab
Update amounts
toshiSat Nov 3, 2024
5de0aff
Update airdrop scripts
toshiSat Nov 7, 2024
7b57242
Remove quotations and zeros from eth addresses
toshiSat Nov 7, 2024
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
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@
# Dependency directories (remove the comment below to include it)
# vendor/

.env
.env*


.idea/
.vscode/
**.DS_Store
cmd/arkeodrop/__debug_bin
infra/node-data/

infra/node-data/
csv/airdrop_GAIA_delegates.csv
scripts/node_modules/*
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM golang:1.19-buster as builder
ARG GITREF=main

WORKDIR /root
RUN git clone --depth 2 --branch $GITREF https://github.com/arkeonetwork/airdrop.git

WORKDIR /root/airdrop
RUN make install

# final image
FROM ubuntu:noble

WORKDIR /usr/local/bin
COPY --from=builder /go/bin/ .

WORKDIR /root

RUN apt update && apt upgrade -y
RUN apt install -y redis postgresql-client curl wget jq htop vim ssh

COPY ./infra/scripts ./scripts
16 changes: 15 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
GITREF=main
IMGTAG=dev

build:
go build ./...

Expand All @@ -11,4 +14,15 @@ db-migrate:
tern migrate -c db/tern.conf -m db

install:
go install ./cmd/...
go install ./cmd/...

docker-build:
docker build --no-cache --pull --platform=linux/amd64 --build-arg=GITREF=${GITREF} --rm -f Dockerfile -t airdroputils:${IMGTAG} .

docker-tag:
docker tag airdroputils:dev ghcr.io/arkeonetwork/airdroputils:${IMGTAG}

docker-push:
docker push ghcr.io/arkeonetwork/airdroputils:${IMGTAG}

push-image: docker-build docker-tag docker-push
146 changes: 146 additions & 0 deletions cli/cosmos_indexer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
package cli

import (
"fmt"
"strconv"

"github.com/ArkeoNetwork/airdrop/indexer"
"github.com/ArkeoNetwork/common/utils"
"github.com/spf13/cobra"
)

var (
delegationsFromStateExport = &cobra.Command{
Use: "import-delegations [data-directory] [chain] [height]",
Short: "import staked delegations from a cosmos daemond export",
Run: runDelegationsFromStateExport,
Args: cobra.ExactValidArgs(3),
}
liquidityFromStateExport = &cobra.Command{
Use: "import-liquidity [data-directory] [chain] [height]",
Short: "import liquidity from a cosmos daemond export",
Run: runLiquidityFromStateExport,
Args: cobra.ExactValidArgs(3),
}
indexDelegatorsCmd = &cobra.Command{
Use: "delegators [chain]",
Short: "gather cosmos-sdk chain data store in our db",
Run: runDelegatorsIndexer,
Args: cobra.ExactValidArgs(1),
}
indexThorchainLPCmd = &cobra.Command{
Use: "thor-lp [pool]",
Short: "gather cosmos-sdk chain liquidity provider data store in our db",
Run: runThorLPIndexer,
Args: cobra.ExactValidArgs(1),
}
)

func runDelegatorsIndexer(cmd *cobra.Command, args []string) {
flags := cmd.InheritedFlags()
envPath, _ := flags.GetString("env")
c := utils.ReadDBConfig(envPath)
if c == nil {
fmt.Print("error: no config loaded")
return
}

chain := args[0]
params := indexer.CosmosIndexerParams{Chain: chain, DB: *c}
indxr, err := indexer.NewCosmosIndexer(params)
if err != nil {
cmd.PrintErrf("error creating cosmos indexer: %+v", err)
return
}

if err := indxr.IndexCosmosDelegators(); err != nil {
fmt.Printf("error indexing delegators: %+v", err)
cmd.PrintErrf("error indexing delegators: %+v", err)
return
}
}

func runThorSaversIndexer(cmd *cobra.Command, args []string) {
// TODO - this is identical to thor-lp with exception of the endpoint
}

func runThorLPIndexer(cmd *cobra.Command, args []string) {
flags := cmd.InheritedFlags()
envPath, _ := flags.GetString("env")
c := utils.ReadDBConfig(envPath)
if c == nil {
cmd.PrintErrf("no config for path %s", envPath)
return
}

poolName := args[0]
params := indexer.CosmosIndexerParams{Chain: "THOR", DB: *c}
indxr, err := indexer.NewCosmosIndexer(params)
if err != nil {
cmd.PrintErrf("error creating cosmos indexer: %+v", err)
return
}

if err = indxr.IndexThorLP(poolName); err != nil {
cmd.PrintErrf("error indexing LP: %+v", err)
}
}

func runDelegationsFromStateExport(cmd *cobra.Command, args []string) {
flags := cmd.InheritedFlags()
envPath, _ := flags.GetString("env")
c := utils.ReadDBConfig(envPath)
if c == nil {
cmd.PrintErrf("no config for path %s", envPath)
return
}

chain := args[1]
baseDataDir := args[0]
sheight := args[2]
height, err := strconv.ParseInt(sheight, 10, 64)
if err != nil {
cmd.PrintErrf("error parsing height %s: %+v", sheight, err)
return
}

params := indexer.CosmosIndexerParams{Chain: chain, DB: *c}
indxr, err := indexer.NewCosmosIndexer(params)
if err != nil {
cmd.PrintErrf("error creating cosmos indexer: %+v", err)
return
}
if err = indxr.IndexDelegationsFromStateExport(baseDataDir, chain, height); err != nil {
cmd.PrintErrf("error indexing Delegations from state export: %+v", err)
}
}


func runLiquidityFromStateExport(cmd *cobra.Command, args []string) {
flags := cmd.InheritedFlags()
envPath, _ := flags.GetString("env")
c := utils.ReadDBConfig(envPath)
if c == nil {
cmd.PrintErrf("no config for path %s", envPath)
return
}

chain := args[1]
baseDataDir := args[0]
sheight := args[2]
height, err := strconv.ParseInt(sheight, 10, 64)
if err != nil {
cmd.PrintErrf("error parsing height %s: %+v", sheight, err)
return
}

params := indexer.CosmosIndexerParams{Chain: chain, DB: *c}
indxr, err := indexer.NewCosmosIndexer(params)
if err != nil {
cmd.PrintErrf("error creating cosmos indexer: %+v", err)
return
}
if err = indxr.IndexLiquidityFromStateExport(baseDataDir, chain, height); err != nil {
cmd.PrintErrf("error indexing Delegations from state export: %+v", err)
}
}
91 changes: 91 additions & 0 deletions cli/eth_indexer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package cli

import (
"github.com/ArkeoNetwork/airdrop/indexer"
"github.com/ArkeoNetwork/common/logging"
"github.com/ArkeoNetwork/common/utils"
"github.com/spf13/cobra"
)

type Config struct {
DBHost string `mapstructure:"DB_HOST"`
DBPort uint `mapstructure:"DB_PORT"`
DBUser string `mapstructure:"DB_USER"`
DBPass string `mapstructure:"DB_PASS"`
DBName string `mapstructure:"DB_NAME"`
DBSSLMode string `mapstructure:"DB_SSL_MODE"`
DBPoolMaxConns int `mapstructure:"DB_POOL_MAX_CONNS"`
DBPoolMinConns int `mapstructure:"DB_POOL_MIN_CONNS"`
}

var (
log = logging.WithoutFields()
indexEthCmd = &cobra.Command{
Use: "index-eth",
Short: "gather eth chain data store in our db",
Run: runEthIndexer,
}
)

func init() {
indexEthCmd.Flags().BoolP("transfers", "t", false, "index token transfers")
indexEthCmd.Flags().BoolP("rewards", "r", false, "index staking rewards")
indexEthCmd.Flags().Bool("hedgeys", false, "index hedgey events")
}

// index ethereum things
func runEthIndexer(cmd *cobra.Command, args []string) {
log.Info("starting data generation process")
flags := cmd.InheritedFlags()
envPath, _ := flags.GetString("env")
c := utils.ReadDBConfig(envPath)
if c == nil {
cmd.PrintErr("db config undefined")
return
}

indexerApp := indexer.NewIndexer(indexer.IndexerAppParams{
DBConfig: *c,
})
xfers, _ := cmd.Flags().GetBool("transfers")
rewards, _ := cmd.Flags().GetBool("rewards")
hedgeys, _ := cmd.Flags().GetBool("hedgeys")

if !xfers && !rewards && !hedgeys {
log.Infof("no flags set, starting all eth indexers")
indexerApp.Start()
return
}

var err error
if xfers {
if err = indexerApp.IndexTransfers(); err != nil {
cmd.PrintErrf("error indexing transfers: %+v", err)
}
}

if rewards {
if err = indexerApp.IndexStakingRewardsEvents("stakingrewardsv5"); err != nil {
cmd.PrintErrf("error indexing staking rewards v5: %+v", err)
}
if err = indexerApp.IndexStakingRewardsEvents("stakingrewardsv6"); err != nil {
cmd.PrintErrf("error indexing staking rewards v6: %+v", err)
}
if err = indexerApp.IndexStakingRewardsEvents("stakingrewardsv7"); err != nil {
cmd.PrintErrf("error indexing staking rewards v7: %+v", err)
}
if err = indexerApp.IndexStakingRewardsEvents("stakingrewardsv8"); err != nil {
cmd.PrintErrf("error indexing staking rewards v8: %+v", err)
}
if err = indexerApp.IndexStakingRewardsEvents("stakingrewardsv9"); err != nil {
cmd.PrintErrf("error indexing staking rewards v9: %+v", err)
}
}

if hedgeys {
if err = indexerApp.IndexHedgeyEvents(); err != nil {
cmd.PrintErrf("error indexing hedgeys: %+v", err)
}
}
log.Debug("finished data generation process")
}
81 changes: 0 additions & 81 deletions cli/export.go

This file was deleted.

Loading