degendb

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2023 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// event types.
	Unknown                 = &GBEventType{name: "Unknown", actionName: "did something", icon: "❓", openseaEventName: ""}
	Transfer                = &GBEventType{name: "Transfer", actionName: "transferred", icon: "📦", openseaEventName: "item_transferred"}
	Sale                    = &GBEventType{name: "Sale", actionName: "sold", icon: "💰", openseaEventName: "item_sold"}
	Purchase                = &GBEventType{name: "Purchase", actionName: "purchased", icon: "🛍️", openseaEventName: "item_sold"}
	Mint                    = &GBEventType{name: "Mint", actionName: "minted", icon: "Ⓜ️", openseaEventName: ""}
	Airdrop                 = &GBEventType{name: "Airdrop", actionName: "got airdropped", icon: "🎁", openseaEventName: ""}
	Burn                    = &GBEventType{name: "Burn", actionName: "burned", icon: "🔥", openseaEventName: ""}
	BurnRedeem              = &GBEventType{name: "BurnRedeem", actionName: "redeemed burned", icon: "🔥", openseaEventName: ""}
	Loan                    = &GBEventType{name: "Loan", actionName: "loaned", icon: "💸", openseaEventName: ""}
	RepayLoan               = &GBEventType{name: "RepayLoan", actionName: "repaid loan", icon: "💸", openseaEventName: ""}
	Listing                 = &GBEventType{name: "Listing", actionName: "listed", icon: "📢", openseaEventName: "item_listed"}
	Bid                     = &GBEventType{name: "Bid", actionName: "(got) bid", icon: "💦", openseaEventName: "item_received_bid"}
	OwnBid                  = &GBEventType{name: "OwnBid", actionName: "bid", icon: "🤑", openseaEventName: ""}
	AcceptedOffer           = &GBEventType{name: "AcceptedOffer", actionName: "accepted offer", icon: "🤝", openseaEventName: ""}
	CollectionOffer         = &GBEventType{name: "CollectionOffer", actionName: "(got) collection-offered", icon: "☂️", openseaEventName: "collection_offer"} // 🧊
	AcceptedCollectionOffer = &GBEventType{name: "AcceptedCollectionOffer", actionName: "accepted collection offer", icon: "🤝", openseaEventName: ""}
	MetadataUpdated         = &GBEventType{name: "MetadataUpdated", actionName: "metadata updated", icon: "♻️", openseaEventName: "item_metadata_updated"}
	Cancelled               = &GBEventType{name: "Cancelled", actionName: "cancelled", icon: "❌", openseaEventName: "item_cancelled"}

	// event type sets.
	SaleTypes = mapset.NewSet[EventType](Sale, Purchase)
)

Functions

func SortMapByValue added in v0.8.0

func SortMapByValue(m map[string]int64, reverse bool) []string

func WriteDataToFile added in v0.8.0

func WriteDataToFile(data interface{}, filePath string)

func ZstdCompress added in v0.8.0

func ZstdCompress(in io.Reader, out io.Writer) error

Types

type AccountType added in v0.11.2

type AccountType string
const (
	ExternallyOwnedAccount AccountType = "EOA"
	Contract               AccountType = "Contract"
)

type Accounts

type Accounts struct {
	// Twitter is the Twitter username for this degen
	Twitter string `bson:"twitter,omitempty" json:"twitter"`

	// Telegram is the Telegram username for this degen
	Telegram string `bson:"telegram,omitempty" json:"telegram"`

	// ChatID is the Telegram chat ID for this degen
	TelegramChatID int64 `bson:"telegram_chat_id,omitempty" json:"telegram_chat_id"`
}

type Address added in v0.11.0

type Address struct {
	// Address is the ethereum address for this wallet/collection
	HexAddress string `bson:"_id" json:"hex_address"`

	// Address is the ethereum Address for this wallet/collection
	Address common.Address `json:"address"`

	// Type is the type of this wallet/collection, e.g. EOA or contract
	Type       string `bson:"type,omitempty"        json:"type,omitempty"`
	IsContract bool   `bson:"is_contract,omitempty" json:"is_contract,omitempty"`

	// Domain is the (main/reverseable) domain (e.g. ENS) for this wallet/collection
	Domain string `bson:"domain,omitempty" json:"domain"`

	// Name is the name of this wallet/collection
	Name string `bson:"name,omitempty" json:"name"`

	// Tags is a list of tags associated with this wallet/collection
	Tags []Tag `bson:"tags,omitempty" json:"tags"`

	// Slugs are the collection slugs of the collection
	Slugs Slugs `bson:"slugs,omitempty" json:"slugs,omitempty"`

	// Description is the description of the collection
	Description string `bson:"description,omitempty" json:"description,omitempty"`

	// TotalSupply is the total supply of the collection
	TotalSupply int `bson:"total_supply,omitempty" json:"total_supply,omitempty"`

	// ImageURL is the URL of the image of the collection
	ImageURL string `bson:"image_url,omitempty" json:"image_url,omitempty"`

	// ExternalURL is the URL of the collection
	ExternalURL string `bson:"external_url,omitempty" json:"external_url,omitempty"`

	// CreatedAt is the time this collection was created in our db
	CreatedAt time.Time `bson:"created_at,omitempty" json:"created_at,omitempty"`
	// UpdatedAt is the time this collection was last updated in our db
	UpdatedAt time.Time `bson:"updated_at,omitempty" json:"updated_at,omitempty"`
}

func (*Address) String added in v0.11.0

func (a *Address) String() string

type CollectionColors added in v0.11.0

type CollectionColors struct {
	Primary   lipgloss.Color
	Secondary lipgloss.Color
}

type Degen

type Degen struct {
	// ID is the unique identifier for this degen
	ID primitive.ObjectID `bson:"_id,omitempty" json:"id"`

	// Name is the name of the degen
	Name string `bson:"name,omitempty" json:"name"`

	// Accounts contains other accounts of this degen
	Accounts Accounts `bson:"accounts,omitempty" json:"accounts"`

	// HexAddresses is the ethereum address for this wallet/collection
	HexAddresses []string `bson:"hex_addresses,omitempty" json:"hex_addresses"`

	// Addresses is a list of wallet addresses associated with this degen
	Addresses []*Address `bson:"addresses,omitempty" json:"addresses"`

	// Tags is a list of tags associated with this degen
	Tags []Tag `bson:"tags,omitempty" json:"tags"`

	// CreatedAt is the time this degen was created
	CreatedAt time.Time `bson:"created_at,omitempty" json:"created_at"`

	// UpdatedAt is the time this degen was last updated
	UpdatedAt time.Time `bson:"updated_at,omitempty" json:"updated_at"`
}

func (*Degen) String added in v0.11.0

func (d *Degen) String() string

type DegenDB

type DegenDB struct {
	// contains filtered or unexported fields
}

func NewDegenDB

func NewDegenDB() *DegenDB

func (*DegenDB) AddCollectionToken

func (ddb *DegenDB) AddCollectionToken(collections interface{}, tokens interface{})

func (*DegenDB) Disconnect added in v0.11.0

func (ddb *DegenDB) Disconnect() error

func (*DegenDB) NewAddress added in v0.11.0

func (ddb *DegenDB) NewAddress(address common.Address) *Address

func (*DegenDB) NewAddresses added in v0.11.0

func (ddb *DegenDB) NewAddresses(addresses []common.Address) []*Address

func (*DegenDB) NewDegen added in v0.11.0

func (ddb *DegenDB) NewDegen(name string, addresses []common.Address, twitter string, telegram string, telegramID int64, tags []Tag) *Degen

type EventColors added in v0.11.0

type EventColors struct {
	Time          lipgloss.Color
	Price         lipgloss.Color
	PriceCurrency lipgloss.Color
	PriceArrow    lipgloss.Color
	From          lipgloss.Color
	To            lipgloss.Color

	Collections map[common.Address]CollectionColors
}

type EventType added in v0.9.0

type EventType interface {
	String() string
	ActionName() string
	Icon() string
	OpenseaEventName() string
}

type GBEventType added in v0.11.0

type GBEventType struct {
	// contains filtered or unexported fields
}

func GetEventType added in v0.11.1

func GetEventType(name string) *GBEventType

func (*GBEventType) ActionName added in v0.11.0

func (et *GBEventType) ActionName() string

func (*GBEventType) Icon added in v0.11.0

func (et *GBEventType) Icon() string

func (*GBEventType) OpenseaEventName added in v0.11.0

func (et *GBEventType) OpenseaEventName() string

func (*GBEventType) String added in v0.11.0

func (et *GBEventType) String() string

type MetadataAttribute added in v0.8.0

type MetadataAttribute struct {
	// Name is the name of the attribute
	Name string `json:"name"`

	// Value is the value of the attribute
	// Value interface{} `json:"value"`
	Value string `json:"value"`

	// Data type of the attribute
	TraitType string `json:"-"`
}

type OpenSeaMetadata added in v0.8.0

type OpenSeaMetadata []struct {
	TokenIdentifier struct {
		ContractAddress string `json:"contract_address"`
		TokenID         int64  `json:"token_id"`
	} `json:"token_identifier"`
	MetadataDict  map[string]interface{} `json:"metadata_dict"`
	TokenStandard string                 `json:"token_standard"`
	Slug          string                 `json:"slug"`
}

type OpenSeaRanks added in v0.8.0

type OpenSeaRanks map[int64]TokenRank

type PreformattedEvent added in v0.11.2

type PreformattedEvent struct {
	TxHash                 common.Hash
	Action                 string
	ReceivedAt             time.Time
	Typemoji               string
	Price                  *price.Price
	TransferredCollections []TransferredCollection
	BlurURL                string
	EtherscanURL           string
	OpenSeaURL             string

	// "attributes"
	IsOwnWallet     bool
	IsOwnCollection bool

	// Purchase or Accepted Offer Indicator
	PAOI string

	// fix this with new chawago watcher
	IsWatchUsersWallet bool

	// temporary until we have a better solution
	From        *Degen
	FromAddress common.Address
	To          *Degen
	ToAddress   common.Address

	Colors EventColors
	Other  map[string]interface{}
}

type Rank

type Rank struct {
	// OpenSea is the OpenSea rank of the token
	OpenSea int64 `bson:"opensea,omitempty" json:"opensea"`

	// Blur is the Blur rank of the token
	Blur int64 `bson:"blur,omitempty" json:"blur"`
}

type RecentEvent added in v0.9.0

type RecentEvent struct {
	Timestamp time.Time `bson:"timestamp,omitempty" json:"timestamp,omitempty"`

	// Event Type
	Type EventType `bson:"type,omitempty" json:"type,omitempty"`

	// Event Volume
	AmountWei    *big.Int `bson:"amount_wei,omitempty"    json:"amount_wei,omitempty"`
	AmountTokens uint64   `bson:"amount_tokens,omitempty" json:"amount_tokens,omitempty"`
}

type SaLiRa added in v0.9.0

type SaLiRa struct {
	ewma.MovingAverage
	Timeframe     time.Duration
	CountSales    int
	CountListings int
	Previous      float64
}

single SaLiRa instance.

func (*SaLiRa) Pretty added in v0.9.0

func (s *SaLiRa) Pretty(faint bool) string

type SaLiRas added in v0.9.0

type SaLiRas []*SaLiRa

SaLiRas is a group of saLiRa instances for different timeframes type SaLiRas map[time.Duration]*saLiRa.

func NewSaLiRas added in v0.9.0

func NewSaLiRas(timeframes []time.Duration) SaLiRas

NewSaLiRas creates a new SaLiRas instance.

type Score added in v0.8.0

type Score struct {
	TokenID       int64   `json:"token_id"`
	Rank          int64   `json:"rank"`
	Score         float64 `json:"score"`
	TokenFeatures struct {
		UniqueAttributeCount int `json:"unique_attribute_count"`
	} `json:"token_features"`
	TokenMetadata map[string]interface{} `json:"token_metadata"`
}

type Slugs

type Slugs struct {
	// OpenSea is the OpenSea slug of the token
	OpenSea string `bson:"opensea,omitempty" json:"opensea"`

	// Blur is the Blur slug of the token
	Blur string `bson:"blur,omitempty" json:"blur"`
}

type Tag

type Tag string

type Token

type Token struct {
	// ID is the unique identifier for this token
	ID primitive.ObjectID `bson:"_id,omitempty" json:"id"`

	// Collection is the collection this token belongs to
	Address Address `bson:"collection,omitempty" json:"collection"`

	// CollectionSlugs are the collection slugs of the collection this token belongs to
	CollectionSlugs Slugs `bson:"collection_slugs,omitempty" json:"collection_slugs"`

	// ContractAddress is the address of the contract this token belongs to
	ContractAddress string `bson:"contract_address,omitempty" json:"contract_address"`

	// Token ID used as in the collection
	TokenID int64 `bson:"token_id,omitempty" json:"token_id"`

	// Name is the name of the token
	Name string `bson:"name,omitempty" json:"name"`

	// Ranks are the ranks of the token
	Rank Rank `bson:"ranks,omitempty" json:"ranks"`

	// Score is the score of the token calculated via the open-rarity algorithm
	Score float64 `bson:"score,omitempty" json:"score"`

	// Metadata is the metadata of the token
	Metadata []MetadataAttribute `bson:"metadata,omitempty" json:"metadata"`

	// CreatedAt is the time this token was created
	CreatedAt time.Time `bson:"created_at,omitempty" json:"created_at"`

	// UpdatedAt is the time this token was last updated
	UpdatedAt time.Time `bson:"updated_at,omitempty" json:"updated_at"`
}

type TokenMetadata added in v0.8.0

type TokenMetadata struct {
	Attributes      []MetadataAttribute `json:"-"`
	Name            string              `json:"name"`
	Description     string              `json:"description"`
	Image           string              `json:"image"`
	TokenID         int64               `json:"token_id"`
	ContractAddress common.Address      `json:"-"`
	Score           Score               `json:"score,omitempty"`
}

type TokenRank added in v0.8.0

type TokenRank struct {
	Rank  int64   `json:"rank"`
	Score float64 `json:"score"`
}

func (TokenRank) GetRankSymbol added in v0.10.0

func (tr TokenRank) GetRankSymbol(totalSupply uint64) string

type Trait added in v0.11.0

type Trait struct {
	Name        string      `json:"trait_type"   mapstructure:"trait_type"`
	Value       interface{} `json:"value"        mapstructure:"value"`
	DisplayType string      `json:"display_type" mapstructure:"display_type"`
	MaxValue    interface{} `json:"max_value"    mapstructure:"max_value"`
	Order       interface{} `json:"order"        mapstructure:"order"`
	TraitCount  float64     `json:"trait_count"  mapstructure:"trait_count"`
}

func (*Trait) String added in v0.11.0

func (t *Trait) String() string

func (*Trait) StringBold added in v0.11.0

func (t *Trait) StringBold() string

type TransferredCollection added in v0.10.0

type TransferredCollection struct {
	CollectionName    string
	TransferredTokens []TransferredToken

	Colors CollectionColors

	// from & to per collection as we print one line per collection...^^
	From string
	To   string
}

type TransferredToken added in v0.10.0

type TransferredToken struct {
	ID         int64
	Rank       int64
	RankSymbol string
	Amount     int64
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL