Version: v0.0.0-...-571c95a Latest Latest

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

Go to latest
Published: Mar 8, 2021 License: AGPL-3.0 Imports: 7 Imported by: 0




This section is empty.


This section is empty.


This section is empty.


type Database

type Database struct {
	// contains filtered or unexported fields

Database provides a database wrapper for unipan

func New

func New(opts *Opts) (*Database, error)

New returns a new database client

func (*Database) AutoMigrate

func (d *Database) AutoMigrate() error

AutoMigrate is used to automatically migrate datbase tables

func (*Database) Close

func (d *Database) Close() error

Close shuts down the database

func (*Database) GetPair

func (db *Database) GetPair(pair string) (*Pair, error)

GetPair returns a pair searching by its contract information

func (*Database) GetPairByToken

func (db *Database) GetPairByToken(token0, token1 string) (*Pair, error)

GetPairByToken returns the given pair information searching by token addrs

func (*Database) GetPairs

func (db *Database) GetPairs(uniswap bool) ([]*Pair, error)

GetPairs returns all pairs

func (*Database) IsLiquid

func (db *Database) IsLiquid(pair string) error

IsLiquid is used to check if a pair is liquid

func (*Database) NewPair

func (db *Database) NewPair(token0, token1, contract string, uniswap bool) error

NewPair creates a new pair

func (*Database) SetBaseApproved

func (db *Database) SetBaseApproved(pair string) error

SetBaseApproved marks the base token as having been approved

func (*Database) SetLiquid

func (db *Database) SetLiquid(pair string) error

SetLiquid is used to mark a pair as having liquidity deposited

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

func OptsFromConfig(cfg config.Database) *Opts

OptsFromConfig returns database options from a config file

func (*Opts) DSN

func (db *Opts) DSN() string

DSN returns the config string used with gorm

func (*Opts) Open

func (db *Opts) Open() (gorm.Dialector, error)

Open returns the gorm dialector for the corresponding db type

type Pair

type Pair struct {
	Token0 string `gorm:"column:token0"`
	Token1 string `gorm:"column:token1"`
	// address of the pair contract, we should never have duplciates
	Contract string `gorm:"unique"`
	// indicates if the contract is liquid (ie, has had liquidity deposited)
	Liquid bool
	// if true pair is on uniswap
	// if false pair is on pancakeswap
	Uniswap bool
	// BaseApproved indicates that the base token (weth or wbnb) has been approved
	BaseApproved bool `gorm:"column:base_approved"`

Pair tracks a given

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL