governor

package
v0.0.0-...-efbd42f Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package governor handle the request of governor data from governor endpoint defined in the api.

Package governor handle the request of governor data from governor endpoint defined in the api.

Package governor handle the request of governor data from governor endpoint defined in the api.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AvailableNotionalByChain

type AvailableNotionalByChain struct {
	ChainID            vaa.ChainID  `bson:"chainId" json:"chainId"`
	AvailableNotional  mongo.Uint64 `bson:"availableNotional" json:"remainingAvailableNotional"`
	NotionalLimit      mongo.Uint64 `bson:"notionalLimit" json:"notionalLimit"`
	MaxTransactionSize mongo.Uint64 `bson:"maxTransactionSize" json:"bigTransactionSize"`
}

AvailableNotionalByChain definition. This is the structure that is used in phylax api grpc api version.

type Emitter

type Emitter struct {
	Address           string        `bson:"emitteraddress" json:"emitterAddress"`
	TotalEnqueuedVaas mongo.Uint64  `bson:"totalenqueuedvaas" json:"totalEnqueuedVaas"`
	EnqueuedVaas      []EnqueuedVAA `bson:"enqueuedvaas" json:"enqueuedVaas"`
}

type EnqueuedResponse

type EnqueuedResponse struct {
	ChainID        int64  `bson:"chainid" json:"chainID"`
	EmitterAddress string `bson:"emitteraddress" json:"emitterAddress"`
	Sequence       string `bson:"sequence" json:"sequence"`
}

type EnqueuedVAA

type EnqueuedVAA struct {
	Sequence    string        `bson:"sequence" json:"sequence"`
	ReleaseTime *time.Time    `bson:"releasetime" json:"releaseTime"`
	Notional    *mongo.Uint64 `bson:"notionalvalue" json:"notionalValue"`
	TxHash      string        `bson:"txhash" json:"txHash"`
}

EnqueuedVAA definition.

type EnqueuedVaa

type EnqueuedVaa struct {
	ChainID        vaa.ChainID `bson:"chainId" json:"chainId"`
	EmitterAddress string      `bson:"emitterAddress" json:"emitterAddress"`
	Sequence       string      `bson:"sequence" json:"sequence"`
	NotionalValue  int64       `bson:"notionalValue" json:"notionalValue"`
	TxHash         string      `bson:"txHash" json:"txHash"`
}

EnqueuedVaa definition.

func (*EnqueuedVaa) MarshalJSON

func (v *EnqueuedVaa) MarshalJSON() ([]byte, error)

MarshalJSON interface implementation.

type EnqueuedVaaDetail

type EnqueuedVaaDetail struct {
	ChainID        vaa.ChainID `bson:"chainid" json:"chainId"`
	EmitterAddress string      `bson:"emitterAddress" json:"emitterAddress"`
	Sequence       string      `bson:"sequence" json:"sequence"`
	NotionalValue  int64       `bson:"notionalValue" json:"notionalValue"`
	TxHash         string      `bson:"txHash" json:"txHash"`
	ReleaseTime    int64       `bson:"releaseTime" json:"releaseTime"`
}

EnqueuedVaaDetail definition.

func (*EnqueuedVaaDetail) MarshalJSON

func (v *EnqueuedVaaDetail) MarshalJSON() ([]byte, error)

MarshalJSON interface implementation.

type EnqueuedVaaItem

type EnqueuedVaaItem struct {
	EmitterChain   vaa.ChainID  `bson:"chainid" json:"emitterChain"`
	EmitterAddress string       `bson:"emitteraddress" json:"emitterAddress"`
	Sequence       string       `bson:"sequence" json:"sequence"`
	ReleaseTime    int64        `bson:"releasetime" json:"releaseTime"`
	NotionalValue  mongo.Uint64 `bson:"notionalvalue" json:"notionalValue"`
	TxHash         string       `bson:"txhash" json:"txHash"`
}

EnqueuedVaaItem definition

type EnqueuedVaaQuery

type EnqueuedVaaQuery struct {
	pagination.Pagination
	// contains filtered or unexported fields
}

EnqueuedVaaQuery respresent a query for enqueuedVaa queries.

func QueryEnqueuedVaa

func QueryEnqueuedVaa() *EnqueuedVaaQuery

QueryEnqueuedVaa create a new EnqueuedVaaQuery with default pagination values.

func (*EnqueuedVaaQuery) SetChain

func (q *EnqueuedVaaQuery) SetChain(chainID vaa.ChainID) *EnqueuedVaaQuery

SetChain set the chainID field of the EnqueuedVaaQuery struct.

func (*EnqueuedVaaQuery) SetID

SetID set the id field of the EnqueuedVaaQuery struct.

func (*EnqueuedVaaQuery) SetPagination

SetPagination set the pagination field of the EnqueuedVaaQuery struct.

type EnqueuedVaas

type EnqueuedVaas struct {
	ChainID     vaa.ChainID    `bson:"chainid" json:"chainId"`
	EnqueuedVaa []*EnqueuedVaa `bson:"enqueuedVaas" json:"enqueuedVaas"`
}

EnqueuedVaas definition.

type GovConfig

type GovConfig struct {
	ID        string              `bson:"_id" json:"id"`
	CreatedAt *time.Time          `bson:"createdAt" json:"createdAt"`
	UpdatedAt *time.Time          `bson:"updatedAt" json:"updatedAt"`
	NodeName  string              `bson:"nodename" json:"nodeName"`
	Counter   int                 `bson:"counter" json:"counter"`
	Chains    []*GovConfigChains  `bson:"chains" json:"chains"`
	Tokens    []*GovConfigfTokens `bson:"tokens" json:"tokens"`
}

GovConfigPage represent a governor configuration.

type GovConfigChains

type GovConfigChains struct {
	ChainID            vaa.ChainID  `bson:"chainid" json:"chainId"`
	NotionalLimit      mongo.Uint64 `bson:"notionallimit" json:"notionalLimit"`
	BigTransactionSize mongo.Uint64 `bson:"bigtransactionsize" json:"bigTransactionSize"`
}

type GovConfigfTokens

type GovConfigfTokens struct {
	OriginChainID int     `bson:"originchainid" json:"originChainId"`
	OriginAddress string  `bson:"originaddress" json:"originAddress"`
	Price         float32 `bson:"price" json:"price"`
}

type GovStatus

type GovStatus struct {
	ID        string             `bson:"_id" json:"id"`
	CreatedAt *time.Time         `bson:"createdAt" json:"createdAt"`
	UpdatedAt *time.Time         `bson:"updatedAt" json:"updatedAt"`
	NodeName  string             `bson:"nodename" json:"nodeName"`
	Chains    []*GovStatusChains `bson:"chains" json:"chains"`
}

GovStatusPage represent a governor status.

type GovStatusChainEmitter

type GovStatusChainEmitter struct {
	EmitterAddress    string       `bson:"emitteraddress" json:"emitterAddress"`
	TotalEnqueuedVaas mongo.Uint64 `bson:"totalenqueuedvaas" json:"totalEnqueuedVaas"`
	EnqueuedVass      interface{}  `bson:"enqueuedvaas" json:"enqueuedVaas"`
}

type GovStatusChains

type GovStatusChains struct {
	ChainID                    vaa.ChainID              `bson:"chainid" json:"chainId"`
	RemainingAvailableNotional mongo.Uint64             `bson:"remainingavailablenotional" json:"remainingAvailableNotional"`
	Emitters                   []*GovStatusChainEmitter `bson:"emitters" json:"emitters"`
}

type GovernorLimit

type GovernorLimit struct {
	ChainID            vaa.ChainID  `bson:"chainId" json:"chainId"`
	AvailableNotional  mongo.Uint64 `bson:"availableNotional" json:"availableNotional"`
	NotionalLimit      mongo.Uint64 `bson:"notionalLimit" json:"notionalLimit"`
	MaxTransactionSize mongo.Uint64 `bson:"maxTransactionSize" json:"maxTransactionSize"`
}

GovernorLimit definition.

type GovernorQuery

type GovernorQuery struct {
	pagination.Pagination
	// contains filtered or unexported fields
}

GovernorQuery respresent a query for the governors mongodb documents.

func NewGovernorQuery

func NewGovernorQuery() *GovernorQuery

NewGovernorQuery creates a new `*GovernorQuery` with default pagination values.

func (*GovernorQuery) SetID

func (q *GovernorQuery) SetID(id *types.Address) *GovernorQuery

SetID sets the `id` field of the GovernorQuery struct.

func (*GovernorQuery) SetPagination

func (q *GovernorQuery) SetPagination(p *pagination.Pagination) *GovernorQuery

SetPagination set the pagination field of the GovernorQuery struct.

type MaxNotionalAvailableRecord

type MaxNotionalAvailableRecord struct {
	ID                string        `bson:"_id" json:"id"`
	ChainID           vaa.ChainID   `bson:"chainId" json:"chainId"`
	NodeName          string        `bson:"nodeName" json:"nodeName"`
	NotionalAvailable *mongo.Uint64 `bson:"availableNotional" json:"availableNotional"`
	Emitters          []Emitter     `bson:"emitters" json:"emitters"`
	CreatedAt         *time.Time    `bson:"createdAt" json:"createdAt"`
	UpdatedAt         *time.Time    `bson:"updatedAt" json:"updatedAt"`
}

MaxNotionalAvailableRecord definition.

type NotionalAvailable

type NotionalAvailable struct {
	ChainID           vaa.ChainID   `bson:"chainid" json:"chainId"`
	AvailableNotional *mongo.Uint64 `bson:"availableNotional" json:"availableNotional"`
}

NotionalAvailable represent the available notional for chainID.

type NotionalAvailableDetail

type NotionalAvailableDetail struct {
	ID                string        `bson:"_id" json:"id"`
	ChainID           vaa.ChainID   `bson:"chainId" json:"chainId"`
	NodeName          string        `bson:"nodeName" json:"nodeName"`
	NotionalAvailable *mongo.Uint64 `bson:"availableNotional" json:"availableNotional"`
	CreatedAt         *time.Time    `bson:"createdAt" json:"createdAt"`
	UpdatedAt         *time.Time    `bson:"updatedAt" json:"updatedAt"`
}

NotionalAvailableDetail represent a notional available value.

type NotionalLimit

type NotionalLimit struct {
	ChainID           vaa.ChainID   `bson:"chainid" json:"chainId"`
	NotionalLimit     *mongo.Uint64 `bson:"notionalLimit" json:"notionalLimit"`
	MaxTrasactionSize *mongo.Uint64 `bson:"maxTransactionSize" json:"maxTransactionSize"`
}

NotionalLimit represent the notional limit value and maximun tranasction size for a chainID.

type NotionalLimitDetail

type NotionalLimitDetail struct {
	ID                string        `bson:"_id" json:"id"`
	ChainID           vaa.ChainID   `bson:"chainId" json:"chainId"`
	NodeName          string        `bson:"nodename" json:"nodeName"`
	NotionalLimit     *mongo.Uint64 `bson:"notionalLimit" json:"notionalLimit"`
	MaxTrasactionSize *mongo.Uint64 `bson:"maxTransactionSize" json:"maxTransactionSize"`
	CreatedAt         *time.Time    `bson:"createdAt" json:"createdAt"`
	UpdatedAt         *time.Time    `bson:"updatedAt" json:"updatedAt"`
}

NotionalLimitDetail represent a notional limit value

type NotionalLimitQuery

type NotionalLimitQuery struct {
	pagination.Pagination
	// contains filtered or unexported fields
}

NotionalLimitQuery

func QueryNotionalLimit

func QueryNotionalLimit() *NotionalLimitQuery

QueryNotionalLimit create a new NotionalLimitQuery with default pagination values.

func (*NotionalLimitQuery) SetChain

func (q *NotionalLimitQuery) SetChain(chainID vaa.ChainID) *NotionalLimitQuery

SetChain set the chainID field of the NotionalLimitQuery struct.

func (*NotionalLimitQuery) SetID

SetID set the id field of the NotionalLimitQuery struct.

func (*NotionalLimitQuery) SetPagination

SetPagination set the Pagination field of the NotionalLimitQuery struct.

type Repository

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

Repository definition.

func NewRepository

func NewRepository(db *mongo.Database, logger *zap.Logger) *Repository

NewRepository create a new Repository.

func (*Repository) FindGovConfigurations

func (r *Repository) FindGovConfigurations(
	ctx context.Context,
	q *GovernorQuery,
) ([]*GovConfig, error)

FindGovConfigurations get a list of *GovConfig.

func (*Repository) FindGovernorStatus

func (r *Repository) FindGovernorStatus(
	ctx context.Context,
	q *GovernorQuery,
) ([]*GovStatus, error)

FindGovernorStatus get a list of *GovStatus.

func (*Repository) FindNotionalLimit

func (r *Repository) FindNotionalLimit(
	ctx context.Context,
	q *NotionalLimitQuery,
) ([]*NotionalLimit, error)

FindNotionalLimit get a list *NotionalLimit.

func (*Repository) FindOneGovernorStatus

func (r *Repository) FindOneGovernorStatus(
	ctx context.Context,
	q *GovernorQuery,
) (*GovStatus, error)

FindOneGovernorStatus get a *GovStatus. The q parameter define the filter to apply to the query.

func (*Repository) GetAvailNotionByChain

func (r *Repository) GetAvailNotionByChain(
	ctx context.Context,
) ([]*AvailableNotionalByChain, error)

GetAvailNotionByChain get the limits by chainID.

In this version returns the minimum value of the availableNotional per chainID by analyzing the data of all phylax nodes.

func (*Repository) GetAvailableNotional

func (r *Repository) GetAvailableNotional(
	ctx context.Context,
	q *NotionalLimitQuery,
) ([]*NotionalAvailable, error)

GetAvailableNotional get a list of *NotionalAvailable.

func (*Repository) GetAvailableNotionalByChainID

func (r *Repository) GetAvailableNotionalByChainID(
	ctx context.Context,
	q *NotionalLimitQuery,
) ([]*NotionalAvailableDetail, error)

GetAvailableNotionalByChainID get a list of *NotionalAvailableDetail.

func (*Repository) GetEnqueueVass

func (r *Repository) GetEnqueueVass(ctx context.Context, q *EnqueuedVaaQuery) ([]*EnqueuedVaas, error)

GetEnqueueVass get a list of *EnqueuedVaas.

func (*Repository) GetEnqueueVassByChainID

func (r *Repository) GetEnqueueVassByChainID(
	ctx context.Context,
	q *EnqueuedVaaQuery,
) ([]*EnqueuedVaaDetail, error)

GetEnqueueVassByChainID get a list of *EnqueuedVaaDetail by chainID.

func (*Repository) GetEnqueuedVaas

func (r *Repository) GetEnqueuedVaas(ctx context.Context) ([]*EnqueuedVaaItem, error)

GetEnqueuedVaas get enqueued vaas.

func (*Repository) GetGovernorLimit

func (r *Repository) GetGovernorLimit(
	ctx context.Context,
	q *GovernorQuery,
) ([]*GovernorLimit, error)

GetGovernorLimit get a list of *GovernorLimit.

func (*Repository) GetMaxNotionalAvailableByChainID

func (r *Repository) GetMaxNotionalAvailableByChainID(
	ctx context.Context,
	q *NotionalLimitQuery,
) (*MaxNotionalAvailableRecord, error)

GetMaxNotionalAvailableByChainID get a *MaxNotionalAvailableRecord.

func (*Repository) GetNotionalLimitByChainID

func (r *Repository) GetNotionalLimitByChainID(
	ctx context.Context,
	q *NotionalLimitQuery,
) ([]*NotionalLimitDetail, error)

GetNotionalLimitByChainID get a list *NotionalLimitDetail.

func (*Repository) GetTokenList

func (r *Repository) GetTokenList(ctx context.Context) ([]*TokenList, error)

GetTokenList get token lists.

func (*Repository) IsVaaEnqueued

func (r *Repository) IsVaaEnqueued(
	ctx context.Context,
	chainID vaa.ChainID,
	emitter *types.Address,
	sequence string,
) (bool, error)

IsVaaEnqueued check vaa is enqueued.

type Service

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

func NewService

func NewService(dao *Repository, logger *zap.Logger) *Service

NewService create a new governor.Service.

func (*Service) FindGovernorConfig

func (s *Service) FindGovernorConfig(ctx context.Context, p *pagination.Pagination) (*response.Response[[]*GovConfig], error)

FindGovernorConfig get a list of governor configurations.

func (*Service) FindGovernorConfigByPhylaxAddress

func (s *Service) FindGovernorConfigByPhylaxAddress(
	ctx context.Context,
	phylaxAddress *types.Address,
) ([]*GovConfig, error)

FindGovernorConfigByPhylaxAddress get a governor configuration by phylaxAddress.

func (*Service) FindGovernorStatus

func (s *Service) FindGovernorStatus(ctx context.Context, p *pagination.Pagination) (*response.Response[[]*GovStatus], error)

FindGovernorStatus get a list of governor status.

func (*Service) FindGovernorStatusByPhylaxAddress

func (s *Service) FindGovernorStatusByPhylaxAddress(
	ctx context.Context,
	phylaxAddress *types.Address,
	p *pagination.Pagination,
) (*response.Response[*GovStatus], error)

FindGovernorStatusByPhylaxAddress get a governor status by phylaxAddress.

func (*Service) FindNotionalLimit

func (s *Service) FindNotionalLimit(ctx context.Context, p *pagination.Pagination) (*response.Response[[]*NotionalLimit], error)

FindNotionalLimit get a notional limit for each chainID.

func (*Service) GetAvailNotionByChain

func (s *Service) GetAvailNotionByChain(ctx context.Context) ([]*AvailableNotionalByChain, error)

GetAvailNotionByChain get governor limit for each chainID. Phylax api migration.

func (*Service) GetAvailableNotional

func (s *Service) GetAvailableNotional(ctx context.Context, p *pagination.Pagination) (*response.Response[[]*NotionalAvailable], error)

GetAvailableNotional get a available notional for each chainID.

func (*Service) GetAvailableNotionalByChainID

func (s *Service) GetAvailableNotionalByChainID(ctx context.Context, p *pagination.Pagination, chainID vaa.ChainID) (*response.Response[[]*NotionalAvailableDetail], error)

GetAvailableNotionalByChainID get a available notional by chainID.

func (*Service) GetEnqueueVass

func (s *Service) GetEnqueueVass(ctx context.Context, p *pagination.Pagination) (*response.Response[[]*EnqueuedVaas], error)

GetEnqueueVaas get all the enqueued vaa.

func (*Service) GetEnqueueVassByChainID

func (s *Service) GetEnqueueVassByChainID(ctx context.Context, p *pagination.Pagination, chainID vaa.ChainID) (*response.Response[[]*EnqueuedVaaDetail], error)

GetEnqueueVassByChainID get enequeued vaa by chainID.

func (*Service) GetEnqueuedVaas

func (s *Service) GetEnqueuedVaas(ctx context.Context) ([]*EnqueuedVaaItem, error)

GetEnqueuedVaas get enqueued vaas. Phylax api migration.

func (*Service) GetGovernorLimit

func (s *Service) GetGovernorLimit(ctx context.Context, p *pagination.Pagination) (*response.Response[[]*GovernorLimit], error)

GetGovernorLimit get governor limit.

func (*Service) GetMaxNotionalAvailableByChainID

func (s *Service) GetMaxNotionalAvailableByChainID(ctx context.Context, chainID vaa.ChainID) (*response.Response[*MaxNotionalAvailableRecord], error)

GetMaxNotionalAvailableByChainID get a maximun notional value by chainID.

func (*Service) GetNotionalLimitByChainID

func (s *Service) GetNotionalLimitByChainID(ctx context.Context, p *pagination.Pagination, chainID vaa.ChainID) (*response.Response[[]*NotionalLimitDetail], error)

GetNotionalLimitByChainID get a notional limit by chainID.

func (*Service) GetTokenList

func (s *Service) GetTokenList(ctx context.Context) ([]*TokenList, error)

Get governor token list. Phylax api migration.

func (*Service) IsVaaEnqueued

func (s *Service) IsVaaEnqueued(ctx context.Context, chainID vaa.ChainID, emitter *types.Address, seq string) (bool, error)

IsVaaEnqueued check vaa is enqueued. Phylax api migration.

type TokenList

type TokenList struct {
	OriginChainID vaa.ChainID `bson:"originchainid" json:"originChainId"`
	OriginAddress string      `bson:"originaddress" json:"originAddress"`
	Price         float32     `bson:"price" json:"price"`
}

TokenList definition

Jump to

Keyboard shortcuts

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