db

package
v0.0.0-...-f27a35c Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ForeignKeyViolation = "23503"
	UniqueViolation     = "23505"
)

Variables

View Source
var ErrRecordNotFound = pgx.ErrNoRows
View Source
var ErrUniqueViolation = &pgconn.PgError{
	Code: UniqueViolation,
}

Functions

func Close

func Close()

func ErrorCode

func ErrorCode(err error) string

func Init

func Init(ctx context.Context, dbSource string, migrationURL string)

Types

type CancelAllOrdersParams

type CancelAllOrdersParams struct {
	CancelledAt pgtype.Timestamp `json:"cancelledAt"`
	Wallet      string           `json:"wallet"`
}

type CancelOrderParams

type CancelOrderParams struct {
	CancelledAt pgtype.Timestamp `json:"cancelledAt"`
	ID          int64            `json:"id"`
	Wallet      string           `json:"wallet"`
}

type CancelOrderRow

type CancelOrderRow struct {
	ID                       int64            `json:"id"`
	PoolIds                  []string         `json:"poolIds"`
	ParentID                 pgtype.Int8      `json:"parentId"`
	Wallet                   string           `json:"wallet"`
	Status                   OrderStatus      `json:"status"`
	Side                     OrderSide        `json:"side"`
	Type                     OrderType        `json:"type"`
	Price                    pgtype.Numeric   `json:"price"`
	Amount                   pgtype.Numeric   `json:"amount"`
	Slippage                 pgtype.Float8    `json:"slippage"`
	TwapIntervalSeconds      pgtype.Int4      `json:"twapIntervalSeconds"`
	TwapExecutedTimes        pgtype.Int4      `json:"twapExecutedTimes"`
	TwapCurrentExecutedTimes pgtype.Int4      `json:"twapCurrentExecutedTimes"`
	TwapMinPrice             pgtype.Numeric   `json:"twapMinPrice"`
	TwapMaxPrice             pgtype.Numeric   `json:"twapMaxPrice"`
	Deadline                 pgtype.Timestamp `json:"deadline"`
	Nonce                    int64            `json:"nonce"`
	Paths                    string           `json:"paths"`
	TxHash                   pgtype.Text      `json:"txHash"`
	ActualAmount             pgtype.Numeric   `json:"actualAmount"`
	PartialFilledAt          pgtype.Timestamp `json:"partialFilledAt"`
	FilledAt                 pgtype.Timestamp `json:"filledAt"`
	RejectedAt               pgtype.Timestamp `json:"rejectedAt"`
	CancelledAt              pgtype.Timestamp `json:"cancelledAt"`
	CreatedAt                pgtype.Timestamp `json:"createdAt"`
}

type ChatThread

type ChatThread struct {
	ID          int64            `json:"id"`
	ThreadID    string           `json:"threadId"`
	UserAddress string           `json:"userAddress"`
	ThreadName  string           `json:"threadName"`
	CreatedAt   pgtype.Timestamp `json:"createdAt"`
	UpdatedAt   pgtype.Timestamp `json:"updatedAt"`
	IsDeleted   bool             `json:"isDeleted"`
}

type CountOrdersByWalletParams

type CountOrdersByWalletParams struct {
	Wallet    string        `json:"wallet"`
	Status    []OrderStatus `json:"status"`
	NotStatus []OrderStatus `json:"notStatus"`
	Types     []OrderType   `json:"types"`
	Side      NullOrderSide `json:"side"`
	ParentID  pgtype.Int8   `json:"parentId"`
}

type CreateBatchYieldMetricsTxResult

type CreateBatchYieldMetricsTxResult struct {
	RowsAffected int64
}

type CreatePoolParams

type CreatePoolParams struct {
	ID       string `json:"id"`
	Token0ID string `json:"token0Id"`
	Token1ID string `json:"token1Id"`
}

type CreateTokenParams

type CreateTokenParams struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	Symbol   string `json:"symbol"`
	Decimals int32  `json:"decimals"`
	IsStable bool   `json:"isStable"`
}

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type FillOrderParams

type FillOrderParams struct {
	FilledAt     pgtype.Timestamp `json:"filledAt"`
	TxHash       pgtype.Text      `json:"txHash"`
	ActualAmount pgtype.Numeric   `json:"actualAmount"`
	ID           int64            `json:"id"`
}

type FillTwapOrderParams

type FillTwapOrderParams struct {
	Status                   OrderStatus      `json:"status"`
	TwapCurrentExecutedTimes pgtype.Int4      `json:"twapCurrentExecutedTimes"`
	PartialFilledAt          pgtype.Timestamp `json:"partialFilledAt"`
	FilledAt                 pgtype.Timestamp `json:"filledAt"`
	ActualAmount             pgtype.Numeric   `json:"actualAmount"`
	ID                       int64            `json:"id"`
}

type GetChatThreadParams

type GetChatThreadParams struct {
	ThreadID    string `json:"threadId"`
	UserAddress string `json:"userAddress"`
}

type GetChatThreadsParams

type GetChatThreadsParams struct {
	UserAddress string `json:"userAddress"`
	Limit       int32  `json:"limit"`
	Offset      int32  `json:"offset"`
}

type GetOrderByIDParams

type GetOrderByIDParams struct {
	Wallet string `json:"wallet"`
	ID     int64  `json:"id"`
}

type GetOrderByIDRow

type GetOrderByIDRow struct {
	ID                       int64            `json:"id"`
	PoolIds                  []string         `json:"poolIds"`
	ParentID                 pgtype.Int8      `json:"parentId"`
	Wallet                   string           `json:"wallet"`
	Status                   OrderStatus      `json:"status"`
	Side                     OrderSide        `json:"side"`
	Type                     OrderType        `json:"type"`
	Price                    pgtype.Numeric   `json:"price"`
	Amount                   pgtype.Numeric   `json:"amount"`
	Slippage                 pgtype.Float8    `json:"slippage"`
	TwapIntervalSeconds      pgtype.Int4      `json:"twapIntervalSeconds"`
	TwapExecutedTimes        pgtype.Int4      `json:"twapExecutedTimes"`
	TwapCurrentExecutedTimes pgtype.Int4      `json:"twapCurrentExecutedTimes"`
	TwapMinPrice             pgtype.Numeric   `json:"twapMinPrice"`
	TwapMaxPrice             pgtype.Numeric   `json:"twapMaxPrice"`
	TwapStartedAt            pgtype.Timestamp `json:"twapStartedAt"`
	Deadline                 pgtype.Timestamp `json:"deadline"`
	Nonce                    int64            `json:"nonce"`
	Paths                    string           `json:"paths"`
	TxHash                   pgtype.Text      `json:"txHash"`
	ActualAmount             pgtype.Numeric   `json:"actualAmount"`
	PartialFilledAt          pgtype.Timestamp `json:"partialFilledAt"`
	FilledAt                 pgtype.Timestamp `json:"filledAt"`
	RejectedAt               pgtype.Timestamp `json:"rejectedAt"`
	CancelledAt              pgtype.Timestamp `json:"cancelledAt"`
	CreatedAt                pgtype.Timestamp `json:"createdAt"`
}

type GetOrdersByWalletParams

type GetOrdersByWalletParams struct {
	Wallet    string        `json:"wallet"`
	Limit     int32         `json:"limit"`
	Offset    int32         `json:"offset"`
	Status    []OrderStatus `json:"status"`
	NotStatus []OrderStatus `json:"notStatus"`
	Types     []OrderType   `json:"types"`
	Side      NullOrderSide `json:"side"`
	ParentID  pgtype.Int8   `json:"parentId"`
}

type GetOrdersByWalletRow

type GetOrdersByWalletRow struct {
	ID                       int64            `json:"id"`
	PoolIds                  []string         `json:"poolIds"`
	ParentID                 pgtype.Int8      `json:"parentId"`
	Wallet                   string           `json:"wallet"`
	Status                   OrderStatus      `json:"status"`
	Side                     OrderSide        `json:"side"`
	Type                     OrderType        `json:"type"`
	Price                    pgtype.Numeric   `json:"price"`
	Amount                   pgtype.Numeric   `json:"amount"`
	ActualAmount             pgtype.Numeric   `json:"actualAmount"`
	Slippage                 pgtype.Float8    `json:"slippage"`
	TwapIntervalSeconds      pgtype.Int4      `json:"twapIntervalSeconds"`
	TwapExecutedTimes        pgtype.Int4      `json:"twapExecutedTimes"`
	TwapCurrentExecutedTimes pgtype.Int4      `json:"twapCurrentExecutedTimes"`
	TwapMinPrice             pgtype.Numeric   `json:"twapMinPrice"`
	TwapMaxPrice             pgtype.Numeric   `json:"twapMaxPrice"`
	TwapStartedAt            pgtype.Timestamp `json:"twapStartedAt"`
	Deadline                 pgtype.Timestamp `json:"deadline"`
	Nonce                    int64            `json:"nonce"`
	Paths                    string           `json:"paths"`
	TxHash                   pgtype.Text      `json:"txHash"`
	ActualAmount_2           pgtype.Numeric   `json:"actualAmount2"`
	PartialFilledAt          pgtype.Timestamp `json:"partialFilledAt"`
	FilledAt                 pgtype.Timestamp `json:"filledAt"`
	RejectedAt               pgtype.Timestamp `json:"rejectedAt"`
	CancelledAt              pgtype.Timestamp `json:"cancelledAt"`
	CreatedAt                pgtype.Timestamp `json:"createdAt"`
}

type GetPoolByTokenParams

type GetPoolByTokenParams struct {
	Token0ID string `json:"token0Id"`
	Token1ID string `json:"token1Id"`
}

type GetYieldMetricsForChatRow

type GetYieldMetricsForChatRow struct {
	Pool             string         `json:"pool"`
	Chain            string         `json:"chain"`
	Project          string         `json:"project"`
	Symbol           string         `json:"symbol"`
	Apy              pgtype.Numeric `json:"apy"`
	ApyBase          pgtype.Numeric `json:"apyBase"`
	ApyReward        pgtype.Numeric `json:"apyReward"`
	RewardTokens     []string       `json:"rewardTokens"`
	UnderlyingTokens []string       `json:"underlyingTokens"`
}

type GetYieldMetricsParams

type GetYieldMetricsParams struct {
	Pool   string `json:"pool"`
	Limit  int32  `json:"limit"`
	Offset int32  `json:"offset"`
}

type InsertOrderParams

type InsertOrderParams struct {
	PoolIds                  []string         `json:"poolIds"`
	ParentID                 pgtype.Int8      `json:"parentId"`
	Wallet                   string           `json:"wallet"`
	Status                   OrderStatus      `json:"status"`
	Side                     OrderSide        `json:"side"`
	Type                     OrderType        `json:"type"`
	Price                    pgtype.Numeric   `json:"price"`
	Amount                   pgtype.Numeric   `json:"amount"`
	Slippage                 pgtype.Float8    `json:"slippage"`
	TwapIntervalSeconds      pgtype.Int4      `json:"twapIntervalSeconds"`
	TwapExecutedTimes        pgtype.Int4      `json:"twapExecutedTimes"`
	TwapCurrentExecutedTimes pgtype.Int4      `json:"twapCurrentExecutedTimes"`
	TwapMinPrice             pgtype.Numeric   `json:"twapMinPrice"`
	TwapMaxPrice             pgtype.Numeric   `json:"twapMaxPrice"`
	TwapStartedAt            pgtype.Timestamp `json:"twapStartedAt"`
	Deadline                 pgtype.Timestamp `json:"deadline"`
	Signature                string           `json:"signature"`
	Paths                    string           `json:"paths"`
	Nonce                    int64            `json:"nonce"`
	TxHash                   pgtype.Text      `json:"txHash"`
	ActualAmount             pgtype.Numeric   `json:"actualAmount"`
	PartialFilledAt          pgtype.Timestamp `json:"partialFilledAt"`
	FilledAt                 pgtype.Timestamp `json:"filledAt"`
	RejectedAt               pgtype.Timestamp `json:"rejectedAt"`
	CancelledAt              pgtype.Timestamp `json:"cancelledAt"`
	CreatedAt                pgtype.Timestamp `json:"createdAt"`
}

type InsertOrderRow

type InsertOrderRow struct {
	ID                       int64            `json:"id"`
	PoolIds                  []string         `json:"poolIds"`
	ParentID                 pgtype.Int8      `json:"parentId"`
	Wallet                   string           `json:"wallet"`
	Status                   OrderStatus      `json:"status"`
	Side                     OrderSide        `json:"side"`
	Type                     OrderType        `json:"type"`
	Price                    pgtype.Numeric   `json:"price"`
	Amount                   pgtype.Numeric   `json:"amount"`
	Slippage                 pgtype.Float8    `json:"slippage"`
	TwapIntervalSeconds      pgtype.Int4      `json:"twapIntervalSeconds"`
	TwapExecutedTimes        pgtype.Int4      `json:"twapExecutedTimes"`
	TwapCurrentExecutedTimes pgtype.Int4      `json:"twapCurrentExecutedTimes"`
	TwapMinPrice             pgtype.Numeric   `json:"twapMinPrice"`
	TwapMaxPrice             pgtype.Numeric   `json:"twapMaxPrice"`
	TwapStartedAt            pgtype.Timestamp `json:"twapStartedAt"`
	Deadline                 pgtype.Timestamp `json:"deadline"`
	Nonce                    int64            `json:"nonce"`
	Paths                    string           `json:"paths"`
	TxHash                   pgtype.Text      `json:"txHash"`
	ActualAmount             pgtype.Numeric   `json:"actualAmount"`
	PartialFilledAt          pgtype.Timestamp `json:"partialFilledAt"`
	FilledAt                 pgtype.Timestamp `json:"filledAt"`
	RejectedAt               pgtype.Timestamp `json:"rejectedAt"`
	CancelledAt              pgtype.Timestamp `json:"cancelledAt"`
	CreatedAt                pgtype.Timestamp `json:"createdAt"`
}

type ListOrdersByWalletResult

type ListOrdersByWalletResult struct {
	Orders []GetOrdersByWalletRow
	Count  int64
}

type ListThreadsByWalletResult

type ListThreadsByWalletResult struct {
	Threads []ChatThread
	Count   int64
}

type NullOrderSide

type NullOrderSide struct {
	OrderSide OrderSide `json:"orderSide"`
	Valid     bool      `json:"valid"` // Valid is true if OrderSide is not NULL
}

func (*NullOrderSide) Scan

func (ns *NullOrderSide) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullOrderSide) Value

func (ns NullOrderSide) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullOrderStatus

type NullOrderStatus struct {
	OrderStatus OrderStatus `json:"orderStatus"`
	Valid       bool        `json:"valid"` // Valid is true if OrderStatus is not NULL
}

func (*NullOrderStatus) Scan

func (ns *NullOrderStatus) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullOrderStatus) Value

func (ns NullOrderStatus) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullOrderType

type NullOrderType struct {
	OrderType OrderType `json:"orderType"`
	Valid     bool      `json:"valid"` // Valid is true if OrderType is not NULL
}

func (*NullOrderType) Scan

func (ns *NullOrderType) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullOrderType) Value

func (ns NullOrderType) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Order

type Order struct {
	ID                       int64            `json:"id"`
	PoolIds                  []string         `json:"poolIds"`
	Paths                    string           `json:"paths"`
	Wallet                   string           `json:"wallet"`
	Status                   OrderStatus      `json:"status"`
	Side                     OrderSide        `json:"side"`
	Type                     OrderType        `json:"type"`
	Price                    pgtype.Numeric   `json:"price"`
	ActualAmount             pgtype.Numeric   `json:"actualAmount"`
	Amount                   pgtype.Numeric   `json:"amount"`
	Slippage                 pgtype.Float8    `json:"slippage"`
	Nonce                    int64            `json:"nonce"`
	Signature                string           `json:"signature"`
	TxHash                   pgtype.Text      `json:"txHash"`
	ParentID                 pgtype.Int8      `json:"parentId"`
	TwapIntervalSeconds      pgtype.Int4      `json:"twapIntervalSeconds"`
	TwapExecutedTimes        pgtype.Int4      `json:"twapExecutedTimes"`
	TwapCurrentExecutedTimes pgtype.Int4      `json:"twapCurrentExecutedTimes"`
	TwapMinPrice             pgtype.Numeric   `json:"twapMinPrice"`
	TwapMaxPrice             pgtype.Numeric   `json:"twapMaxPrice"`
	TwapStartedAt            pgtype.Timestamp `json:"twapStartedAt"`
	Deadline                 pgtype.Timestamp `json:"deadline"`
	PartialFilledAt          pgtype.Timestamp `json:"partialFilledAt"`
	FilledAt                 pgtype.Timestamp `json:"filledAt"`
	RejectedAt               pgtype.Timestamp `json:"rejectedAt"`
	CancelledAt              pgtype.Timestamp `json:"cancelledAt"`
	CreatedAt                pgtype.Timestamp `json:"createdAt"`
}

type OrderSide

type OrderSide string
const (
	OrderSideBUY  OrderSide = "BUY"
	OrderSideSELL OrderSide = "SELL"
)

func (*OrderSide) Scan

func (e *OrderSide) Scan(src interface{}) error

type OrderStatus

type OrderStatus string
const (
	OrderStatusPENDING       OrderStatus = "PENDING"
	OrderStatusPARTIALFILLED OrderStatus = "PARTIAL_FILLED"
	OrderStatusFILLED        OrderStatus = "FILLED"
	OrderStatusREJECTED      OrderStatus = "REJECTED"
	OrderStatusCANCELLED     OrderStatus = "CANCELLED"
)

func (*OrderStatus) Scan

func (e *OrderStatus) Scan(src interface{}) error

type OrderType

type OrderType string
const (
	OrderTypeMARKET OrderType = "MARKET"
	OrderTypeLIMIT  OrderType = "LIMIT"
	OrderTypeSTOP   OrderType = "STOP"
	OrderTypeTWAP   OrderType = "TWAP"
)

func (*OrderType) Scan

func (e *OrderType) Scan(src interface{}) error

type Pool

type Pool struct {
	ID        string             `json:"id"`
	Token0ID  string             `json:"token0Id"`
	Token1ID  string             `json:"token1Id"`
	CreatedAt pgtype.Timestamptz `json:"createdAt"`
}

type PoolDetailsRow

type PoolDetailsRow struct {
	ID             string `json:"id"`
	Token0ID       string `json:"token0Id"`
	Token1ID       string `json:"token1Id"`
	Token0Name     string `json:"token0Name"`
	Token0Symbol   string `json:"token0Symbol"`
	Token0Decimals int32  `json:"token0Decimals"`
	Token0IsStable bool   `json:"token0IsStable"`
	Token1Name     string `json:"token1Name"`
	Token1Symbol   string `json:"token1Symbol"`
	Token1Decimals int32  `json:"token1Decimals"`
	Token1IsStable bool   `json:"token1IsStable"`
}

type Price

type Price struct {
	ID             int64            `json:"id"`
	PoolID         string           `json:"poolId"`
	BlockNumber    int64            `json:"blockNumber"`
	BlockTimestamp int64            `json:"blockTimestamp"`
	Sender         string           `json:"sender"`
	Recipient      string           `json:"recipient"`
	Amount0        int64            `json:"amount0"`
	Amount1        int64            `json:"amount1"`
	SqrtPriceX96   int64            `json:"sqrtPriceX96"`
	Liquidity      int64            `json:"liquidity"`
	Tick           int32            `json:"tick"`
	PriceUsd       pgtype.Numeric   `json:"priceUsd"`
	TimestampUtc   pgtype.Timestamp `json:"timestampUtc"`
	CreatedAt      pgtype.Timestamp `json:"createdAt"`
}

type Querier

type Querier interface {
	CancelAllOrders(ctx context.Context, arg CancelAllOrdersParams) error
	CancelOrder(ctx context.Context, arg CancelOrderParams) (CancelOrderRow, error)
	CountChatThreads(ctx context.Context, userAddress string) (int64, error)
	CountOrdersByWallet(ctx context.Context, arg CountOrdersByWalletParams) (int64, error)
	CreatePool(ctx context.Context, arg CreatePoolParams) (Pool, error)
	CreateToken(ctx context.Context, arg CreateTokenParams) (Token, error)
	FillOrder(ctx context.Context, arg FillOrderParams) (Order, error)
	FillTwapOrder(ctx context.Context, arg FillTwapOrderParams) (Order, error)
	GetChatThread(ctx context.Context, arg GetChatThreadParams) (ChatThread, error)
	GetChatThreads(ctx context.Context, arg GetChatThreadsParams) ([]ChatThread, error)
	GetLatestYieldMetric(ctx context.Context) (YieldMetric, error)
	GetMatchedOrder(ctx context.Context, price pgtype.Numeric) (Order, error)
	GetMatchedTwapOrder(ctx context.Context) ([]Order, error)
	GetOrderByID(ctx context.Context, arg GetOrderByIDParams) (GetOrderByIDRow, error)
	GetOrdersByWallet(ctx context.Context, arg GetOrdersByWalletParams) ([]GetOrdersByWalletRow, error)
	GetPool(ctx context.Context, id string) (Pool, error)
	GetPoolByToken(ctx context.Context, arg GetPoolByTokenParams) (Pool, error)
	GetPools(ctx context.Context) ([]Pool, error)
	GetPoolsByIDs(ctx context.Context, ids []string) ([]Pool, error)
	GetYieldMetrics(ctx context.Context, arg GetYieldMetricsParams) ([]YieldMetric, error)
	GetYieldMetricsForChat(ctx context.Context, dollar_1 []string) ([]GetYieldMetricsForChatRow, error)
	InsertOrder(ctx context.Context, arg InsertOrderParams) (InsertOrderRow, error)
	PoolDetails(ctx context.Context, id string) (PoolDetailsRow, error)
	RejectOrder(ctx context.Context, arg RejectOrderParams) (Order, error)
	UpsertChatThread(ctx context.Context, arg UpsertChatThreadParams) (ChatThread, error)
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) CancelAllOrders

func (q *Queries) CancelAllOrders(ctx context.Context, arg CancelAllOrdersParams) error

func (*Queries) CancelOrder

func (q *Queries) CancelOrder(ctx context.Context, arg CancelOrderParams) (CancelOrderRow, error)

func (*Queries) CountChatThreads

func (q *Queries) CountChatThreads(ctx context.Context, userAddress string) (int64, error)

func (*Queries) CountOrdersByWallet

func (q *Queries) CountOrdersByWallet(ctx context.Context, arg CountOrdersByWalletParams) (int64, error)

func (*Queries) CreatePool

func (q *Queries) CreatePool(ctx context.Context, arg CreatePoolParams) (Pool, error)

func (*Queries) CreateToken

func (q *Queries) CreateToken(ctx context.Context, arg CreateTokenParams) (Token, error)

func (*Queries) FillOrder

func (q *Queries) FillOrder(ctx context.Context, arg FillOrderParams) (Order, error)

func (*Queries) FillTwapOrder

func (q *Queries) FillTwapOrder(ctx context.Context, arg FillTwapOrderParams) (Order, error)

func (*Queries) GetChatThread

func (q *Queries) GetChatThread(ctx context.Context, arg GetChatThreadParams) (ChatThread, error)

func (*Queries) GetChatThreads

func (q *Queries) GetChatThreads(ctx context.Context, arg GetChatThreadsParams) ([]ChatThread, error)

func (*Queries) GetLatestYieldMetric

func (q *Queries) GetLatestYieldMetric(ctx context.Context) (YieldMetric, error)

func (*Queries) GetMatchedOrder

func (q *Queries) GetMatchedOrder(ctx context.Context, price pgtype.Numeric) (Order, error)

func (*Queries) GetMatchedTwapOrder

func (q *Queries) GetMatchedTwapOrder(ctx context.Context) ([]Order, error)

func (*Queries) GetOrderByID

func (q *Queries) GetOrderByID(ctx context.Context, arg GetOrderByIDParams) (GetOrderByIDRow, error)

func (*Queries) GetOrdersByWallet

func (q *Queries) GetOrdersByWallet(ctx context.Context, arg GetOrdersByWalletParams) ([]GetOrdersByWalletRow, error)

func (*Queries) GetPool

func (q *Queries) GetPool(ctx context.Context, id string) (Pool, error)

func (*Queries) GetPoolByToken

func (q *Queries) GetPoolByToken(ctx context.Context, arg GetPoolByTokenParams) (Pool, error)

func (*Queries) GetPools

func (q *Queries) GetPools(ctx context.Context) ([]Pool, error)

func (*Queries) GetPoolsByIDs

func (q *Queries) GetPoolsByIDs(ctx context.Context, ids []string) ([]Pool, error)

func (*Queries) GetYieldMetrics

func (q *Queries) GetYieldMetrics(ctx context.Context, arg GetYieldMetricsParams) ([]YieldMetric, error)

func (*Queries) GetYieldMetricsForChat

func (q *Queries) GetYieldMetricsForChat(ctx context.Context, dollar_1 []string) ([]GetYieldMetricsForChatRow, error)

func (*Queries) InsertOrder

func (q *Queries) InsertOrder(ctx context.Context, arg InsertOrderParams) (InsertOrderRow, error)

func (*Queries) PoolDetails

func (q *Queries) PoolDetails(ctx context.Context, id string) (PoolDetailsRow, error)

func (*Queries) RejectOrder

func (q *Queries) RejectOrder(ctx context.Context, arg RejectOrderParams) (Order, error)

func (*Queries) UpsertChatThread

func (q *Queries) UpsertChatThread(ctx context.Context, arg UpsertChatThreadParams) (ChatThread, error)

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type RejectOrderParams

type RejectOrderParams struct {
	RejectedAt pgtype.Timestamp `json:"rejectedAt"`
	ID         int64            `json:"id"`
}

type SqlStore

type SqlStore struct {
	*Queries
	// contains filtered or unexported fields
}
var DB *SqlStore

func NewStore

func NewStore(connPool *pgxpool.Pool) *SqlStore

NewStore creates a new store

func (*SqlStore) CreateBatchYieldMetricsTx

func (store *SqlStore) CreateBatchYieldMetricsTx(ctx context.Context, yieldMetrics []*YieldMetricData) (CreateBatchYieldMetricsTxResult, error)

func (*SqlStore) ListOrdersByWalletTx

func (store *SqlStore) ListOrdersByWalletTx(ctx context.Context, params GetOrdersByWalletParams) (*ListOrdersByWalletResult, error)

func (*SqlStore) ListThreadsTx

func (store *SqlStore) ListThreadsTx(ctx context.Context, params GetChatThreadsParams) (*ListThreadsByWalletResult, error)

type Token

type Token struct {
	ID        string             `json:"id"`
	Name      string             `json:"name"`
	Symbol    string             `json:"symbol"`
	Decimals  int32              `json:"decimals"`
	IsStable  bool               `json:"isStable"`
	CreatedAt pgtype.Timestamptz `json:"createdAt"`
}

type UpsertChatThreadParams

type UpsertChatThreadParams struct {
	ThreadID    string `json:"threadId"`
	UserAddress string `json:"userAddress"`
	ThreadName  string `json:"threadName"`
}

type YieldMetric

type YieldMetric struct {
	ID               int64              `json:"id"`
	Pool             string             `json:"pool"`
	Chain            string             `json:"chain"`
	Project          string             `json:"project"`
	Symbol           string             `json:"symbol"`
	TvlUsd           pgtype.Numeric     `json:"tvlUsd"`
	ApyBase          pgtype.Numeric     `json:"apyBase"`
	ApyReward        pgtype.Numeric     `json:"apyReward"`
	Apy              pgtype.Numeric     `json:"apy"`
	RewardTokens     []string           `json:"rewardTokens"`
	ApyPct1d         pgtype.Numeric     `json:"apyPct1d"`
	ApyPct7d         pgtype.Numeric     `json:"apyPct7d"`
	ApyPct30d        pgtype.Numeric     `json:"apyPct30d"`
	Stablecoin       pgtype.Bool        `json:"stablecoin"`
	IlRisk           pgtype.Text        `json:"ilRisk"`
	Exposure         pgtype.Text        `json:"exposure"`
	Predictions      []byte             `json:"predictions"`
	PoolMeta         pgtype.Text        `json:"poolMeta"`
	Mu               pgtype.Numeric     `json:"mu"`
	Sigma            pgtype.Numeric     `json:"sigma"`
	Count            pgtype.Int4        `json:"count"`
	Outlier          pgtype.Bool        `json:"outlier"`
	UnderlyingTokens []string           `json:"underlyingTokens"`
	Il7d             pgtype.Numeric     `json:"il7d"`
	ApyBase7d        pgtype.Numeric     `json:"apyBase7d"`
	ApyMean30d       pgtype.Numeric     `json:"apyMean30d"`
	VolumeUsd1d      pgtype.Numeric     `json:"volumeUsd1d"`
	VolumeUsd7d      pgtype.Numeric     `json:"volumeUsd7d"`
	ApyBaseInception pgtype.Numeric     `json:"apyBaseInception"`
	CreatedAt        pgtype.Timestamptz `json:"createdAt"`
	UpdatedAt        pgtype.Timestamptz `json:"updatedAt"`
}

type YieldMetricData

type YieldMetricData struct {
	Pool             string          `json:"pool"`
	Chain            string          `json:"chain"`
	Project          string          `json:"project"`
	Symbol           string          `json:"symbol"`
	TvlUsd           float64         `json:"tvlUsd"`
	ApyBase          float64         `json:"apyBase"`
	ApyReward        float64         `json:"apyReward"`
	Apy              float64         `json:"apy"`
	RewardTokens     []string        `json:"rewardTokens"`
	ApyPct1d         float64         `json:"apyPct1D"`
	ApyPct7d         float64         `json:"apyPct7D"`
	ApyPct30d        float64         `json:"apyPct30D"`
	Stablecoin       bool            `json:"stablecoin"`
	IlRisk           string          `json:"ilRisk"`
	Exposure         string          `json:"exposure"`
	Predictions      json.RawMessage `json:"predictions"`
	PoolMeta         string          `json:"poolMeta"`
	UnderlyingTokens []string        `json:"underlyingTokens"`
	Il7d             float64         `json:"il7d"`
	ApyBase7d        float64         `json:"apyBase7d"`
	ApyMean30d       float64         `json:"apyMean30d"`
	VolumeUsd1d      float64         `json:"volumeUsd1d"`
	VolumeUsd7d      float64         `json:"volumeUsd7d"`
	ApyBaseInception float64         `json:"apyBaseInception"`
}

Jump to

Keyboard shortcuts

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