Documentation ¶
Index ¶
- type Database
- func (d *Database) AutoMigrate() error
- func (d *Database) Close() error
- func (db *Database) GetInfo(name string, block uint64) (PoolInfo, error)
- func (db *Database) GetNumInfos(poolName string) (int, error)
- func (db *Database) GetPool(name string) (*Pool, error)
- func (db *Database) GetTokenDecimals(poolName, tokenName string) (uint8, error)
- func (db *Database) NewPool(name string, contractAddress string, block uint64, ...) error
- func (db *Database) PurgeOldInfos(poolName string, purgeCount int) error
- func (db *Database) RecordInfo(name string, block uint64, ...) error
- type Opts
- type Pool
- type PoolInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database wraps gorm.DB with convenience functions
func (*Database) AutoMigrate ¶
AutoMigrate is used to automatically migrate datbase tables
func (*Database) GetNumInfos ¶
GetNumInfos returns the number of infos recorded for a pool
func (*Database) GetTokenDecimals ¶
GetTokenDecimals returns the decimal count associated with various tokens
func (*Database) NewPool ¶
func (db *Database) NewPool( name string, contractAddress string, block uint64, balances, denormWeights, tokenTotalSupplies, decimals map[string]interface{}, ) error
NewPool creates a new entry in the database for an index pool
func (*Database) PurgeOldInfos ¶
PurgeOldInfos is used to purge old information from the database
type Opts ¶
type Opts struct { Type string Host string Port string User string Password string DBName string DBPath string SSLModeDisable bool }
Opts is used to configure database connections
func OptsFromConfig ¶
OptsFromConfig returns database options from a config file
type Pool ¶
type Pool struct { gorm.Model Name string `gorm:"unique"` ContractAddress string // denotes the last block that we did an update at // this is to make sure we dont needlessly update the information LastUpdateAt uint64 // maps block num -> info Infos datatypes.JSONMap // TokenDecimals tracks the decimal values for a given token // at the moment we expect this to be fixed and not updated that often // decimal value is of type uint8 TokenDecimals datatypes.JSONMap }
Pool is a single IndexPool
type PoolInfo ¶
type PoolInfo struct { // tokenName -> balance (big.Int) Balances datatypes.JSONMap `json:"balances"` // tokenName -> weight (big.Int) DenormalizedWeights datatypes.JSONMap `json:"denormalized_weights"` // TokenTotalSupplies tracks the total supply for all tokens held by the indice // this is not to be confused with the IndexPool tokens themselves. For example // DEFI5 holds UNI, SNX, AAVE, CMP and CRV so this will track the supply fo rthose // supply value is of type string TokenTotalSupplies datatypes.JSONMap `json:"token_total_supplies"` }
PoolInfo records pool information for a given block
Click to show internal directories.
Click to hide internal directories.