queries

package
v0.0.0-...-7608417 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPairNotFound = common.NewError("pair_not_found", "pair not found")
View Source
var ErrPlanNotFound = common.NewError("plan_not_found", "plan not found")

Functions

This section is empty.

Types

type Pair

type Pair struct {
	Id                    string                             `json:"id"`
	Status                domain.PairStatus                  `json:"status"`
	Assets                []domain.Asset                     `json:"assets"`
	ParticipantAddresses  []domain.Address                   `json:"participant_addresses"`
	ShareValue            int                                `json:"share_value"`
	InvestingPeriod       int                                `json:"investing_period"`
	WalletSecurity        domain.MultiSigWalletSecurity      `json:"wallet_security"`
	ProfitSharingStrategy domain.ProfitSharingStrategy       `json:"profit_sharing_strategy"`
	LossProtection        float64                            `json:"loss_protection"`
	Wallet                *domain.MultisigWallet             `json:"wallet"`
	Assurances            map[domain.Asset][]domain.SignedTx `json:"assurances"`
	Deposits              map[domain.Asset]domain.TxHash     `json:"deposits"`
	WithdrawTx            *domain.SignedTx                   `json:"withdraw_tx"`
	LP                    map[domain.Asset]domain.TxHash     `json:"lp"`
	Deadline              *time.Time                         `json:"deadline"`
	WithdrawnTx           *domain.TxHash                     `json:"withdrawn_tx"`
	CreatedAt             time.Time                          `json:"created_at"`
	UpdatedAt             time.Time                          `json:"updated_at"`
}

Pair represents a pair

type PairsQuery

type PairsQuery struct {
	*common.BaseProjection
}

PairsQuery is a query that keeps track of all pairs

func NewPairsQuery

func NewPairsQuery(db *sql.DB, store common.Store) (*PairsQuery, error)

NewPairsQuery creates a new PairsQuery

func (*PairsQuery) Callback

func (pq *PairsQuery) Callback(event eventsourcing.Event) error

Callback implements the common.Projection.Callback

func (*PairsQuery) Find

func (pq *PairsQuery) Find(
	ctx context.Context,
	status *domain.PairStatus,
	assets []domain.Asset,
	assetsOrder bool,
	participantAddresses []domain.Address,
	shareValue *int,
	investingPeriod *int,
	walletSecurity *domain.MultiSigWalletSecurity,
	profitSharingStrategy *domain.ProfitSharingStrategy,
	lossProtection *float64,
) ([]Pair, error)

Find finds pairs by given conditions TODO: Add pagination and order by

func (*PairsQuery) Get

func (pq *PairsQuery) Get(ctx context.Context, id string) (*Pair, error)

Get gets a pair by id

type Plan

type Plan struct {
	Id              string                        `json:"id"`
	Assets          []domain.Asset                `json:"assets"`
	Security        domain.MultiSigWalletSecurity `json:"security"`
	Strategy        domain.ProfitSharingStrategy  `json:"strategy"`
	Quantum         int                           `json:"quantum"`
	LossProtection  float64                       `json:"loss_protection"`
	InvestingPeriod int                           `json:"investing_period"`
}

type PlansQuery

type PlansQuery struct {
	*common.BaseProjection
}

PlansQuery is a query that keeps track of all plans

func NewPlansQuery

func NewPlansQuery(db *sql.DB, store common.Store) (*PlansQuery, error)

NewPlansQuery creates a new PlansQuery

func (*PlansQuery) All

func (pq *PlansQuery) All(ctx context.Context) ([]Plan, error)

All returns all plans

func (*PlansQuery) Callback

func (pq *PlansQuery) Callback(event eventsourcing.Event) error

Callback implements the common.Projection.Callback

func (*PlansQuery) Get

func (pq *PlansQuery) Get(ctx context.Context, id string) (*Plan, error)

Get returns a plan by id

Jump to

Keyboard shortcuts

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