entities

package
v0.0.0-...-f6bc33c Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2023 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AccountFieldUnspecified = iota
	AccountFieldID
	AccountFieldPartyID
	AccountFieldAssetID
	AccountFieldMarketID
	AccountFieldType
)
View Source
const (
	OneOffStr    = "OneOff"
	RecurringStr = "Recurring"
	UnknownStr   = "Unknown"
)
View Source
const (
	AssetStatusUnspecified    = AssetStatus(zeta.Asset_STATUS_UNSPECIFIED)
	AssetStatusProposed       = AssetStatus(zeta.Asset_STATUS_PROPOSED)
	AssetStatusRejected       = AssetStatus(zeta.Asset_STATUS_REJECTED)
	AssetStatusPendingListing = AssetStatus(zeta.Asset_STATUS_PENDING_LISTING)
	AssetStatusEnabled        = AssetStatus(zeta.Asset_STATUS_ENABLED)
)
View Source
const (
	MarketTradingModeUnspecified       = MarketTradingMode(zeta.Market_TRADING_MODE_UNSPECIFIED)
	MarketTradingModeContinuous        = MarketTradingMode(zeta.Market_TRADING_MODE_CONTINUOUS)
	MarketTradingModeBatchAuction      = MarketTradingMode(zeta.Market_TRADING_MODE_BATCH_AUCTION)
	MarketTradingModeOpeningAuction    = MarketTradingMode(zeta.Market_TRADING_MODE_OPENING_AUCTION)
	MarketTradingModeMonitoringAuction = MarketTradingMode(zeta.Market_TRADING_MODE_MONITORING_AUCTION)
	MarketTradingModeNoTrading         = MarketTradingMode(zeta.Market_TRADING_MODE_NO_TRADING)
)
View Source
const (
	MarketStateUnspecified       = MarketState(zeta.Market_STATE_UNSPECIFIED)
	MarketStateProposed          = MarketState(zeta.Market_STATE_PROPOSED)
	MarketStateRejected          = MarketState(zeta.Market_STATE_REJECTED)
	MarketStatePending           = MarketState(zeta.Market_STATE_PENDING)
	MarketStateCancelled         = MarketState(zeta.Market_STATE_CANCELLED)
	MarketStateActive            = MarketState(zeta.Market_STATE_ACTIVE)
	MarketStateSuspended         = MarketState(zeta.Market_STATE_SUSPENDED)
	MarketStateClosed            = MarketState(zeta.Market_STATE_CLOSED)
	MarketStateTradingTerminated = MarketState(zeta.Market_STATE_TRADING_TERMINATED)
	MarketStateSettled           = MarketState(zeta.Market_STATE_SETTLED)
)
View Source
const (
	DepositStatusUnspecified = DepositStatus(zeta.Deposit_STATUS_UNSPECIFIED)
	DepositStatusOpen        = DepositStatus(zeta.Deposit_STATUS_OPEN)
	DepositStatusCancelled   = DepositStatus(zeta.Deposit_STATUS_CANCELLED)
	DepositStatusFinalized   = DepositStatus(zeta.Deposit_STATUS_FINALIZED)
)
View Source
const (
	WithdrawalStatusUnspecified = WithdrawalStatus(zeta.Withdrawal_STATUS_UNSPECIFIED)
	WithdrawalStatusOpen        = WithdrawalStatus(zeta.Withdrawal_STATUS_OPEN)
	WithdrawalStatusRejected    = WithdrawalStatus(zeta.Withdrawal_STATUS_REJECTED)
	WithdrawalStatusFinalized   = WithdrawalStatus(zeta.Withdrawal_STATUS_FINALIZED)
)
View Source
const (
	ProposalStateUnspecified        = ProposalState(zeta.Proposal_STATE_UNSPECIFIED)
	ProposalStateFailed             = ProposalState(zeta.Proposal_STATE_FAILED)
	ProposalStateOpen               = ProposalState(zeta.Proposal_STATE_OPEN)
	ProposalStatePassed             = ProposalState(zeta.Proposal_STATE_PASSED)
	ProposalStateRejected           = ProposalState(zeta.Proposal_STATE_REJECTED)
	ProposalStateDeclined           = ProposalState(zeta.Proposal_STATE_DECLINED)
	ProposalStateEnacted            = ProposalState(zeta.Proposal_STATE_ENACTED)
	ProposalStateWaitingForNodeVote = ProposalState(zeta.Proposal_STATE_WAITING_FOR_NODE_VOTE)
)
View Source
const (
	ProposalErrorUnspecified                      = ProposalError(zeta.ProposalError_PROPOSAL_ERROR_UNSPECIFIED)
	ProposalErrorCloseTimeTooSoon                 = ProposalError(zeta.ProposalError_PROPOSAL_ERROR_CLOSE_TIME_TOO_SOON)
	ProposalErrorCloseTimeTooLate                 = ProposalError(zeta.ProposalError_PROPOSAL_ERROR_CLOSE_TIME_TOO_LATE)
	ProposalErrorEnactTimeTooSoon                 = ProposalError(zeta.ProposalError_PROPOSAL_ERROR_ENACT_TIME_TOO_SOON)
	ProposalErrorEnactTimeTooLate                 = ProposalError(zeta.ProposalError_PROPOSAL_ERROR_ENACT_TIME_TOO_LATE)
	ProposalErrorInsufficientTokens               = ProposalError(zeta.ProposalError_PROPOSAL_ERROR_INSUFFICIENT_TOKENS)
	ProposalErrorInvalidInstrumentSecurity        = ProposalError(zeta.ProposalError_PROPOSAL_ERROR_INVALID_INSTRUMENT_SECURITY)
	ProposalErrorNoProduct                        = ProposalError(zeta.ProposalError_PROPOSAL_ERROR_NO_PRODUCT)
	ProposalErrorUnsupportedProduct               = ProposalError(zeta.ProposalError_PROPOSAL_ERROR_UNSUPPORTED_PRODUCT)
	ProposalErrorNoTradingMode                    = ProposalError(zeta.ProposalError_PROPOSAL_ERROR_NO_TRADING_MODE)
	ProposalErrorUnsupportedTradingMode           = ProposalError(zeta.ProposalError_PROPOSAL_ERROR_UNSUPPORTED_TRADING_MODE)
	ProposalErrorNodeValidationFailed             = ProposalError(zeta.ProposalError_PROPOSAL_ERROR_NODE_VALIDATION_FAILED)
	ProposalErrorMissingBuiltinAssetField         = ProposalError(zeta.ProposalError_PROPOSAL_ERROR_MISSING_BUILTIN_ASSET_FIELD)
	ProposalErrorMissingErc20ContractAddress      = ProposalError(zeta.ProposalError_PROPOSAL_ERROR_MISSING_ERC20_CONTRACT_ADDRESS)
	ProposalErrorInvalidAsset                     = ProposalError(zeta.ProposalError_PROPOSAL_ERROR_INVALID_ASSET)
	ProposalErrorIncompatibleTimestamps           = ProposalError(zeta.ProposalError_PROPOSAL_ERROR_INCOMPATIBLE_TIMESTAMPS)
	ProposalErrorNoRiskParameters                 = ProposalError(zeta.ProposalError_PROPOSAL_ERROR_NO_RISK_PARAMETERS)
	ProposalErrorNetworkParameterInvalidKey       = ProposalError(zeta.ProposalError_PROPOSAL_ERROR_NETWORK_PARAMETER_INVALID_KEY)
	ProposalErrorNetworkParameterInvalidValue     = ProposalError(zeta.ProposalError_PROPOSAL_ERROR_NETWORK_PARAMETER_INVALID_VALUE)
	ProposalErrorNetworkParameterValidationFailed = ProposalError(zeta.ProposalError_PROPOSAL_ERROR_NETWORK_PARAMETER_VALIDATION_FAILED)
	ProposalErrorOpeningAuctionDurationTooSmall   = ProposalError(zeta.ProposalError_PROPOSAL_ERROR_OPENING_AUCTION_DURATION_TOO_SMALL)
	ProposalErrorOpeningAuctionDurationTooLarge   = ProposalError(zeta.ProposalError_PROPOSAL_ERROR_OPENING_AUCTION_DURATION_TOO_LARGE)
	ProposalErrorCouldNotInstantiateMarket        = ProposalError(zeta.ProposalError_PROPOSAL_ERROR_COULD_NOT_INSTANTIATE_MARKET)
	ProposalErrorInvalidFutureProduct             = ProposalError(zeta.ProposalError_PROPOSAL_ERROR_INVALID_FUTURE_PRODUCT)
	ProposalErrorInvalidRiskParameter             = ProposalError(zeta.ProposalError_PROPOSAL_ERROR_INVALID_RISK_PARAMETER)
	ProposalErrorMajorityThresholdNotReached      = ProposalError(zeta.ProposalError_PROPOSAL_ERROR_MAJORITY_THRESHOLD_NOT_REACHED)
	ProposalErrorParticipationThresholdNotReached = ProposalError(zeta.ProposalError_PROPOSAL_ERROR_PARTICIPATION_THRESHOLD_NOT_REACHED)
	ProposalErrorInvalidAssetDetails              = ProposalError(zeta.ProposalError_PROPOSAL_ERROR_INVALID_ASSET_DETAILS)
	ProposalErrorUnknownType                      = ProposalError(zeta.ProposalError_PROPOSAL_ERROR_UNKNOWN_TYPE)
	ProposalErrorUnknownRiskParameterType         = ProposalError(zeta.ProposalError_PROPOSAL_ERROR_UNKNOWN_RISK_PARAMETER_TYPE)
	ProposalErrorInvalidFreeform                  = ProposalError(zeta.ProposalError_PROPOSAL_ERROR_INVALID_FREEFORM)
	ProposalErrorInsufficientEquityLikeShare      = ProposalError(zeta.ProposalError_PROPOSAL_ERROR_INSUFFICIENT_EQUITY_LIKE_SHARE)
	ProposalErrorInvalidMarket                    = ProposalError(zeta.ProposalError_PROPOSAL_ERROR_INVALID_MARKET)
	ProposalErrorTooManyMarketDecimalPlaces       = ProposalError(zeta.ProposalError_PROPOSAL_ERROR_TOO_MANY_MARKET_DECIMAL_PLACES)
	ProposalErrorTooManyPriceMonitoringTriggers   = ProposalError(zeta.ProposalError_PROPOSAL_ERROR_TOO_MANY_PRICE_MONITORING_TRIGGERS)
	ProposalErrorERC20AddressAlreadyInUse         = ProposalError(zeta.ProposalError_PROPOSAL_ERROR_ERC20_ADDRESS_ALREADY_IN_USE)
)
View Source
const (
	VoteValueUnspecified = VoteValue(zeta.Vote_VALUE_UNSPECIFIED)
	VoteValueNo          = VoteValue(zeta.Vote_VALUE_NO)
	VoteValueYes         = VoteValue(zeta.Vote_VALUE_YES)
)
View Source
const (
	// Default value, always invalid.
	LedgerMovementTypeUnspecified = LedgerMovementType(zeta.TransferType_TRANSFER_TYPE_UNSPECIFIED)
	// Loss.
	LedgerMovementTypeLoss = LedgerMovementType(zeta.TransferType_TRANSFER_TYPE_LOSS)
	// Win.
	LedgerMovementTypeWin = LedgerMovementType(zeta.TransferType_TRANSFER_TYPE_WIN)
	// Mark to market loss.
	LedgerMovementTypeMTMLoss = LedgerMovementType(zeta.TransferType_TRANSFER_TYPE_MTM_LOSS)
	// Mark to market win.
	LedgerMovementTypeMTMWin = LedgerMovementType(zeta.TransferType_TRANSFER_TYPE_MTM_WIN)
	// Margin too low.
	LedgerMovementTypeMarginLow = LedgerMovementType(zeta.TransferType_TRANSFER_TYPE_MARGIN_LOW)
	// Margin too high.
	LedgerMovementTypeMarginHigh = LedgerMovementType(zeta.TransferType_TRANSFER_TYPE_MARGIN_HIGH)
	// Margin was confiscated.
	LedgerMovementTypeMarginConfiscated = LedgerMovementType(zeta.TransferType_TRANSFER_TYPE_MARGIN_CONFISCATED)
	// Pay maker fee.
	LedgerMovementTypeMakerFeePay = LedgerMovementType(zeta.TransferType_TRANSFER_TYPE_MAKER_FEE_PAY)
	// Receive maker fee.
	LedgerMovementTypeMakerFeeReceive = LedgerMovementType(zeta.TransferType_TRANSFER_TYPE_MAKER_FEE_RECEIVE)
	// Pay infrastructure fee.
	LedgerMovementTypeInfrastructureFeePay = LedgerMovementType(zeta.TransferType_TRANSFER_TYPE_INFRASTRUCTURE_FEE_PAY)
	// Receive infrastructure fee.
	LedgerMovementTypeInfrastructureFeeDistribute = LedgerMovementType(zeta.TransferType_TRANSFER_TYPE_INFRASTRUCTURE_FEE_DISTRIBUTE)
	// Pay liquidity fee.
	LedgerMovementTypeLiquidityFeePay = LedgerMovementType(zeta.TransferType_TRANSFER_TYPE_LIQUIDITY_FEE_PAY)
	// Receive liquidity fee.
	LedgerMovementTypeLiquidityFeeDistribute = LedgerMovementType(zeta.TransferType_TRANSFER_TYPE_LIQUIDITY_FEE_DISTRIBUTE)
	// Bond too low.
	LedgerMovementTypeBondLow = LedgerMovementType(zeta.TransferType_TRANSFER_TYPE_BOND_LOW)
	// Bond too high.
	LedgerMovementTypeBondHigh = LedgerMovementType(zeta.TransferType_TRANSFER_TYPE_BOND_HIGH)
	// Actual withdraw from system.
	LedgerMovementTypeWithdraw = LedgerMovementType(zeta.TransferType_TRANSFER_TYPE_WITHDRAW)
	// Deposit funds.
	LedgerMovementTypeDeposit = LedgerMovementType(zeta.TransferType_TRANSFER_TYPE_DEPOSIT)
	// Bond slashing.
	LedgerMovementTypeBondSlashing = LedgerMovementType(zeta.TransferType_TRANSFER_TYPE_BOND_SLASHING)
	// Reward payout.
	LedgerMovementTypeRewardPayout            = LedgerMovementType(zeta.TransferType_TRANSFER_TYPE_REWARD_PAYOUT)
	LedgerMovementTypeTransferFundsSend       = LedgerMovementType(zeta.TransferType_TRANSFER_TYPE_TRANSFER_FUNDS_SEND)
	LedgerMovementTypeTransferFundsDistribute = LedgerMovementType(zeta.TransferType_TRANSFER_TYPE_TRANSFER_FUNDS_DISTRIBUTE)
	LedgerMovementTypeClearAccount            = LedgerMovementType(zeta.TransferType_TRANSFER_TYPE_CLEAR_ACCOUNT)
)
View Source
const (
	LedgerEntryFieldUnspecified = iota
	LedgerEntryFieldTransferType
)

Variables

View Source
var (
	ErrInvalidID = errors.New("not a valid hex id (or well known exception)")
	ErrNotFound  = errors.New("no resource corresponding to this id")
)
View Source
var BalanceColumns = []string{"account_id", "tx_hash", "zeta_time", "balance"}
View Source
var ErrChainAlreadySet = errors.New("chain already set")
View Source
var ErrMarketDataIntegerOverflow = errors.New("integer overflow encountered when converting market data for persistence")
View Source
var LedgerEntryColumns = []string{
	"ledger_entry_time",
	"account_from_id", "account_to_id", "quantity",
	"tx_hash", "zeta_time", "transfer_time", "type",
	"account_from_balance",
	"account_to_balance",
}
View Source
var LiquidityProvisionColumns = []string{
	"id", "party_id", "created_at", "updated_at", "market_id",
	"commitment_amount", "fee", "sells", "buys", "version",
	"status", "reference", "tx_hash", "zeta_time",
}
View Source
var MarginLevelsColumns = []string{
	"account_id", "timestamp", "maintenance_margin",
	"search_level", "initial_margin", "collateral_release_level", "tx_hash", "zeta_time",
}
View Source
var OrderColumns = []string{
	"id", "market_id", "party_id", "side", "price",
	"size", "remaining", "time_in_force", "type", "status",
	"reference", "reason", "version", "pegged_offset", "batch_id",
	"pegged_reference", "lp_id", "created_at", "updated_at", "expires_at",
	"tx_hash", "zeta_time", "seq_num", "post_only", "reduce_only",
}
View Source
var PositionColumns = []string{
	"market_id", "party_id", "open_volume", "realised_pnl", "unrealised_pnl",
	"average_entry_price", "average_entry_market_price", "loss", "adjustment", "tx_hash", "zeta_time", "pending_open_volume",
	"pending_realised_pnl", "pending_unrealised_pnl", "pending_average_entry_price", "pending_average_entry_market_price",
	"loss_socialisation_amount", "distressed_status",
}

ValidatorStatusRanking so we know which direction was a promotion and which was a demotion.

Functions

func CalculateOpenClosedVolume

func CalculateOpenClosedVolume(currentOpenVolume, tradedVolume int64) (int64, int64)

func CreateLedgerEntryTime

func CreateLedgerEntryTime(zetaTime time.Time, seqNum int) time.Time

func DeserializeSigners

func DeserializeSigners(data Signers) []*types.Signer

func NanosToPostgresTimestamp

func NanosToPostgresTimestamp(nanos int64) time.Time

NanosToPostgresTimestamp postgres stores timestamps in microsecond resolution.

func NodeFromValidatorUpdateEvent

func NodeFromValidatorUpdateEvent(evt eventspb.ValidatorUpdate, txHash TxHash, zetaTime time.Time) (Node, ValidatorUpdateAux, error)

func PackNodeSignatures

func PackNodeSignatures(signatures []NodeSignature) string

packNodeSignatures packs a list signatures into the form form: 0x + sig1 + sig2 + ... + sigN in hex encoded form If the list is empty, return an empty string instead.

func RankingScoreFromRankingEvent

func RankingScoreFromRankingEvent(evt eventspb.ValidatorRankingEvent, txHash TxHash, zetaTime time.Time) (RankingScore, RankingScoreAux, error)

func ReverseSlice

func ReverseSlice[T any](input []T) (reversed []T)

func RewardScoreFromScoreEvent

func RewardScoreFromScoreEvent(evt eventspb.ValidatorScoreEvent, txHash TxHash, zetaTime time.Time) (RewardScore, RewardScoreAux, error)

Types

type Account

type Account struct {
	ID       AccountID
	PartyID  PartyID
	AssetID  AssetID
	MarketID MarketID
	Type     zeta.AccountType
	TxHash   TxHash
	ZetaTime time.Time
}

func AccountFromProto

func AccountFromProto(va *zeta.Account, txHash TxHash) (Account, error)

func AccountProtoFromDetails

func AccountProtoFromDetails(ad *zeta.AccountDetails, txHash TxHash) (Account, error)

func GetAccountFromMarginLevel

func GetAccountFromMarginLevel(ctx context.Context, margin *zeta.MarginLevels, accountSource AccountSource, txHash TxHash, zetaTime time.Time) (Account, error)

func (Account) String

func (a Account) String() string

func (Account) ToAccountDetailsProto

func (a Account) ToAccountDetailsProto() *zeta.AccountDetails

func (Account) ToProto

func (a Account) ToProto() *zeta.Account

type AccountBalance

type AccountBalance struct {
	*Account
	Balance  decimal.Decimal
	TxHash   TxHash
	ZetaTime time.Time
}

func (AccountBalance) Cursor

func (ab AccountBalance) Cursor() *Cursor

func (AccountBalance) Equal

func (ab AccountBalance) Equal(other AccountBalance) bool

func (AccountBalance) Key

func (AccountBalance) ToProto

func (ab AccountBalance) ToProto() *v2.AccountBalance

func (AccountBalance) ToProtoEdge

func (ab AccountBalance) ToProtoEdge(_ ...any) (*v2.AccountEdge, error)

func (AccountBalance) ToRow

func (ab AccountBalance) ToRow() []interface{}

type AccountBalanceKey

type AccountBalanceKey struct {
	AccountID AccountID
	ZetaTime  time.Time
}

type AccountCursor

type AccountCursor struct {
	AccountID AccountID `json:"account_id"`
}

func (*AccountCursor) Parse

func (ac *AccountCursor) Parse(cursorString string) error

func (AccountCursor) String

func (ac AccountCursor) String() string

type AccountField

type AccountField int64

AccountField is an enumeration of the properties of an account which can be used for grouping and sorting.

func AccountFieldFromProto

func AccountFieldFromProto(field v2.AccountField) (AccountField, error)

func (AccountField) String

func (s AccountField) String() string

type AccountFilter

type AccountFilter struct {
	AssetID      AssetID
	PartyIDs     []PartyID
	AccountTypes []types.AccountType
	MarketIDs    []MarketID
}

func AccountFilterFromProto

func AccountFilterFromProto(pbFilter *v2.AccountFilter) (AccountFilter, error)

type AccountID

type AccountID = ID[_Account]

type AccountSource

type AccountSource interface {
	Obtain(ctx context.Context, a *Account) error
	GetByID(ctx context.Context, id AccountID) (Account, error)
}

type AggregatedBalance

type AggregatedBalance struct {
	ZetaTime  time.Time
	Balance   decimal.Decimal
	AccountID *AccountID
	PartyID   *PartyID
	AssetID   *AssetID
	MarketID  *MarketID
	Type      *types.AccountType
}

AggregatedBalance represents the the summed balance of a bunch of accounts at a given time. ZetaTime and Balance will always be set. The others will be nil unless when querying, you requested grouping by one of the corresponding fields.

func AggregatedBalanceScan

func AggregatedBalanceScan(fields []AccountField, rows interface {
	Next() bool
	Values() ([]any, error)
},
) ([]AggregatedBalance, error)

NewAggregatedBalanceFromValues returns a new AggregatedBalance from a list of values as returned from pgx.rows.values(). - zetaTime is assumed to be first - then any extra fields listed in 'fields' in order (usually as as result of grouping) - then finally the balance itself.

func (AggregatedBalance) Cursor

func (balance AggregatedBalance) Cursor() *Cursor

func (*AggregatedBalance) ToProto

func (balance *AggregatedBalance) ToProto() *v2.AggregatedBalance

func (AggregatedBalance) ToProtoEdge

func (balance AggregatedBalance) ToProtoEdge(_ ...any) (*v2.AggregatedBalanceEdge, error)

type AggregatedBalanceCursor

type AggregatedBalanceCursor struct {
	ZetaTime  time.Time `json:"zeta_time"`
	AccountID *AccountID
	PartyID   *PartyID
	AssetID   *AssetID
	MarketID  *MarketID
	Type      *types.AccountType
}

func (*AggregatedBalanceCursor) Parse

func (c *AggregatedBalanceCursor) Parse(cursorString string) error

func (AggregatedBalanceCursor) String

func (c AggregatedBalanceCursor) String() string

type AggregatedLedgerEntriesCursor

type AggregatedLedgerEntriesCursor struct {
	ZetaTime time.Time `json:"zeta_time"`
}

func (*AggregatedLedgerEntriesCursor) Parse

func (c *AggregatedLedgerEntriesCursor) Parse(cursorString string) error

func (AggregatedLedgerEntriesCursor) String

type AggregatedLedgerEntry

type AggregatedLedgerEntry struct {
	ZetaTime     time.Time
	Quantity     decimal.Decimal
	TransferType *LedgerMovementType
	AssetID      *AssetID

	FromAccountPartyID  *PartyID
	ToAccountPartyID    *PartyID
	FromAccountMarketID *MarketID
	ToAccountMarketID   *MarketID
	FromAccountType     *types.AccountType
	ToAccountType       *types.AccountType
	FromAccountBalance  decimal.Decimal
	ToAccountBalance    decimal.Decimal
}

AggregatedLedgerEntry represents the the summed amount of ledger entries for a set of accounts within a given time range. ZetaTime and Quantity will always be set. The others will be nil unless when querying grouping by one of the corresponding fields is requested.

func (AggregatedLedgerEntry) Cursor

func (ledgerEntries AggregatedLedgerEntry) Cursor() *Cursor

func (*AggregatedLedgerEntry) ToProto

func (ledgerEntries *AggregatedLedgerEntry) ToProto() *v2.AggregatedLedgerEntry

func (AggregatedLedgerEntry) ToProtoEdge

func (ledgerEntries AggregatedLedgerEntry) ToProtoEdge(_ ...any) (*v2.AggregatedLedgerEntriesEdge, error)

type Asset

type Asset struct {
	ID                AssetID
	Name              string
	Symbol            string
	Decimals          int
	Quantum           decimal.Decimal
	Source            string
	ERC20Contract     string
	TxHash            TxHash
	ZetaTime          time.Time
	LifetimeLimit     decimal.Decimal
	WithdrawThreshold decimal.Decimal
	Status            AssetStatus
}

func (Asset) Cursor

func (a Asset) Cursor() *Cursor

func (Asset) ToProto

func (a Asset) ToProto() *pb.Asset

func (Asset) ToProtoEdge

func (a Asset) ToProtoEdge(_ ...any) (*v2.AssetEdge, error)

type AssetCursor

type AssetCursor struct {
	ID AssetID `json:"id"`
}

func (*AssetCursor) Parse

func (ac *AssetCursor) Parse(cursorString string) error

func (AssetCursor) String

func (ac AssetCursor) String() string

type AssetID

type AssetID = ID[_Asset]

type AssetStatus

type AssetStatus zeta.Asset_Status

func (*AssetStatus) DecodeText

func (m *AssetStatus) DecodeText(_ *pgtype.ConnInfo, src []byte) error

func (AssetStatus) EncodeText

func (m AssetStatus) EncodeText(_ *pgtype.ConnInfo, buf []byte) ([]byte, error)

type AuctionDuration

type AuctionDuration struct {
	Duration int64  `json:"duration,omitempty"`
	Volume   uint64 `json:"volume,omitempty"`
}

type Balance

type Balance struct {
	AccountID AccountID
	TxHash    TxHash
	ZetaTime  time.Time
	Balance   decimal.Decimal
}

func (Balance) Key

func (b Balance) Key() BalanceKey

func (Balance) ToRow

func (b Balance) ToRow() []interface{}

type BalanceKey

type BalanceKey struct {
	AccountID AccountID
	ZetaTime  time.Time
}

type BeginBlockEvent

type BeginBlockEvent interface {
	events.Event
	BeginBlock() eventspb.BeginBlock
}

type Block

type Block struct {
	ZetaTime time.Time
	Height   int64
	Hash     []byte
}

func BlockFromBeginBlock

func BlockFromBeginBlock(b BeginBlockEvent) (*Block, error)

type Candle

type Candle struct {
	PeriodStart        time.Time
	LastUpdateInPeriod time.Time
	Open               decimal.Decimal
	Close              decimal.Decimal
	High               decimal.Decimal
	Low                decimal.Decimal
	Volume             uint64
}

func (Candle) Cursor

func (c Candle) Cursor() *Cursor

func (Candle) ToProtoEdge

func (c Candle) ToProtoEdge(_ ...any) (*v2.CandleEdge, error)

func (*Candle) ToV1CandleProto

func (c *Candle) ToV1CandleProto(interval zeta.Interval) (*zeta.Candle, error)

func (*Candle) ToV2CandleProto

func (c *Candle) ToV2CandleProto() *v2.Candle

type CandleCursor

type CandleCursor struct {
	PeriodStart time.Time `json:"periodStart"`
}

func (*CandleCursor) Parse

func (c *CandleCursor) Parse(cursorString string) error

func (CandleCursor) String

func (c CandleCursor) String() string

type Chain

type Chain struct {
	ID string
}

type Checkpoint

type Checkpoint struct {
	Hash        string
	BlockHash   string
	BlockHeight int64
	TxHash      TxHash
	ZetaTime    time.Time
	SeqNum      uint64
}

func CheckpointFromProto

func CheckpointFromProto(cpe *eventspb.CheckpointEvent, txHash TxHash) (Checkpoint, error)

func (Checkpoint) Cursor

func (cp Checkpoint) Cursor() *Cursor

func (*Checkpoint) ToProto

func (cp *Checkpoint) ToProto() *v2.Checkpoint

func (Checkpoint) ToProtoEdge

func (cp Checkpoint) ToProtoEdge(_ ...any) (*v2.CheckpointEdge, error)

type CheckpointCursor

type CheckpointCursor struct {
	BlockHeight int64 `json:"blockHeight"`
}

func (*CheckpointCursor) Parse

func (cp *CheckpointCursor) Parse(cursorString string) error

func (CheckpointCursor) String

func (cp CheckpointCursor) String() string

type CloseOnLimitOperation

type CloseOnLimitOperation bool

CloseOnLimitOperation is the type that is used for opening and closing the set of output items under some operation. Intended for generic use.

type Condition

type Condition struct {
	Operator v1.Condition_Operator
	Value    string
}

type CoreSnapshotData

type CoreSnapshotData struct {
	BlockHeight     uint64
	BlockHash       string
	ZetaCoreVersion string
	TxHash          TxHash
	ZetaTime        time.Time
}

func CoreSnapshotDataFromProto

func CoreSnapshotDataFromProto(s *eventspb.CoreSnapshotData, txHash TxHash, zetaTime time.Time) CoreSnapshotData

func (CoreSnapshotData) Cursor

func (s CoreSnapshotData) Cursor() *Cursor

func (*CoreSnapshotData) ToProto

func (CoreSnapshotData) ToProtoEdge

func (s CoreSnapshotData) ToProtoEdge(_ ...any) (*v2.CoreSnapshotEdge, error)

type CoreSnapshotDataCursor

type CoreSnapshotDataCursor struct {
	ZetaTime        time.Time
	BlockHeight     uint64
	BlockHash       string
	ZetaCoreVersion string
}

func (*CoreSnapshotDataCursor) Parse

func (sc *CoreSnapshotDataCursor) Parse(cursorString string) error

func (CoreSnapshotDataCursor) String

func (sc CoreSnapshotDataCursor) String() string

type Cursor

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

func NewCursor

func NewCursor(cursor string) *Cursor

func (*Cursor) Decode

func (c *Cursor) Decode(value string) error

func (*Cursor) Encode

func (c *Cursor) Encode() string

func (*Cursor) IsSet

func (c *Cursor) IsSet() bool

func (*Cursor) Value

func (c *Cursor) Value() string

type CursorPagination

type CursorPagination struct {
	Pagination
	Forward     *offset
	Backward    *offset
	NewestFirst bool
}

func CursorPaginationFromProto

func CursorPaginationFromProto(cp *v2.Pagination) (CursorPagination, error)

func DefaultCursorPagination

func DefaultCursorPagination(newestFirst bool) CursorPagination

func NewCursorPagination

func NewCursorPagination(first *int32, after *string, last *int32, before *string, newestFirst bool) (CursorPagination, error)

func (CursorPagination) HasBackward

func (p CursorPagination) HasBackward() bool

func (CursorPagination) HasForward

func (p CursorPagination) HasForward() bool

type Data

type Data struct {
	Signers        Signers
	Data           []Property
	MatchedSpecIds [][]byte // pgx automatically handles [][]byte to Postgres ByteaArray mappings
	BroadcastAt    time.Time
	TxHash         TxHash
	ZetaTime       time.Time
	SeqNum         uint64
}

type DataSourceDefinition

type DataSourceDefinition struct {
	Type     int
	External *DataSourceDefinitionExternal
	Internal *DataSourceDefinitionInternal
}

func (*DataSourceDefinition) GetFilters

func (s *DataSourceDefinition) GetFilters() []*v1.Filter

func (*DataSourceDefinition) GetSigners

func (s *DataSourceDefinition) GetSigners() []*v1.Signer

type DataSourceDefinitionExternal

type DataSourceDefinitionExternal struct {
	Signers Signers
	Filters []Filter
}

type DataSourceDefinitionInternal

type DataSourceDefinitionInternal struct {
	Time time.Time
}

type DataSourceSpec

type DataSourceSpec struct {
	ID        SpecID
	CreatedAt time.Time
	UpdatedAt time.Time
	Data      *DataSourceDefinition
	Status    DataSourceSpecStatus
	TxHash    TxHash
	ZetaTime  time.Time
}

func DataSourceSpecFromProto

func DataSourceSpecFromProto(spec *zetapb.DataSourceSpec, txHash TxHash, zetaTime time.Time) (*DataSourceSpec, error)

func (DataSourceSpec) Cursor

func (ds DataSourceSpec) Cursor() *Cursor

func (*DataSourceSpec) ToOracleProto

func (ds *DataSourceSpec) ToOracleProto() *zetapb.OracleSpec

func (DataSourceSpec) ToOracleProtoEdge

func (ds DataSourceSpec) ToOracleProtoEdge(_ ...any) (*v2.OracleSpecEdge, error)

func (*DataSourceSpec) ToProto

func (ds *DataSourceSpec) ToProto() *zetapb.DataSourceSpec

type DataSourceSpecConfiguration

type DataSourceSpecConfiguration struct {
	Signers Signers
	Filters []Filter
}

type DataSourceSpecCursor

type DataSourceSpecCursor struct {
	ZetaTime time.Time `json:"zetaTime"`
	ID       SpecID    `json:"id"`
}

func (*DataSourceSpecCursor) Parse

func (ds *DataSourceSpecCursor) Parse(cursorString string) error

func (DataSourceSpecCursor) String

func (ds DataSourceSpecCursor) String() string

type DataSourceSpecRaw

type DataSourceSpecRaw struct {
	ID        SpecID
	CreatedAt time.Time
	UpdatedAt time.Time
	Signers   Signers
	Filters   []Filter
	Status    DataSourceSpecStatus
	TxHash    TxHash
	ZetaTime  time.Time
}

type DataSourceSpecStatus

type DataSourceSpecStatus zetapb.DataSourceSpec_Status

func (*DataSourceSpecStatus) DecodeText

func (s *DataSourceSpecStatus) DecodeText(_ *pgtype.ConnInfo, src []byte) error

func (DataSourceSpecStatus) EncodeText

func (s DataSourceSpecStatus) EncodeText(_ *pgtype.ConnInfo, buf []byte) ([]byte, error)

type DateRange

type DateRange struct {
	Start *time.Time
	End   *time.Time
}

func DateRangeFromProto

func DateRangeFromProto(dateRangeInput *v2.DateRange) (dateRange DateRange)

type Delegation

type Delegation struct {
	PartyID  PartyID         `json:"party_id"`
	NodeID   NodeID          `json:"node_id"`
	EpochID  int64           `json:"epoch_id"`
	Amount   decimal.Decimal `json:"amount"`
	TxHash   TxHash
	ZetaTime time.Time
	SeqNum   uint64
}

func DelegationFromEventProto

func DelegationFromEventProto(pd *eventspb.DelegationBalanceEvent, txHash TxHash) (Delegation, error)

func DelegationFromProto

func DelegationFromProto(pd *zeta.Delegation, txHash TxHash) (Delegation, error)

func (Delegation) Cursor

func (d Delegation) Cursor() *Cursor

func (Delegation) String

func (d Delegation) String() string

func (Delegation) ToProto

func (d Delegation) ToProto() *zeta.Delegation

func (Delegation) ToProtoEdge

func (d Delegation) ToProtoEdge(_ ...any) (*v2.DelegationEdge, error)

type DelegationCursor

type DelegationCursor struct {
	ZetaTime time.Time `json:"zetaTime"`
	PartyID  PartyID   `json:"partyId"`
	NodeID   NodeID    `json:"nodeId"`
	EpochID  int64     `json:"epochId"`
}

func (*DelegationCursor) Parse

func (c *DelegationCursor) Parse(cursorString string) error

func (DelegationCursor) String

func (c DelegationCursor) String() string

type Deposit

type Deposit struct {
	ID                DepositID
	Status            DepositStatus
	PartyID           PartyID
	Asset             AssetID
	Amount            decimal.Decimal
	ForeignTxHash     string
	CreditedTimestamp time.Time
	CreatedTimestamp  time.Time
	TxHash            TxHash
	ZetaTime          time.Time
}

func DepositFromProto

func DepositFromProto(deposit *zeta.Deposit, txHash TxHash, zetaTime time.Time) (*Deposit, error)

func (Deposit) Cursor

func (d Deposit) Cursor() *Cursor

func (Deposit) ToProto

func (d Deposit) ToProto() *zeta.Deposit

func (Deposit) ToProtoEdge

func (d Deposit) ToProtoEdge(_ ...any) (*v2.DepositEdge, error)

type DepositCursor

type DepositCursor struct {
	ZetaTime time.Time `json:"zetaTime"`
	ID       DepositID `json:"id"`
}

func (*DepositCursor) Parse

func (dc *DepositCursor) Parse(cursorString string) error

func (DepositCursor) String

func (dc DepositCursor) String() string

type DepositID

type DepositID = ID[_Deposit]

type DepositStatus

type DepositStatus zeta.Deposit_Status

func (*DepositStatus) DecodeText

func (s *DepositStatus) DecodeText(_ *pgtype.ConnInfo, src []byte) error

func (DepositStatus) EncodeText

func (s DepositStatus) EncodeText(_ *pgtype.ConnInfo, buf []byte) ([]byte, error)

type ERC20MultiSigSignerAddedEvent

type ERC20MultiSigSignerAddedEvent struct {
	ERC20MultiSigSignerEvent
}

func (ERC20MultiSigSignerAddedEvent) Cursor

func (ERC20MultiSigSignerAddedEvent) ToDataNodeApiV2Proto

func (e ERC20MultiSigSignerAddedEvent) ToDataNodeApiV2Proto(ctx context.Context, notaryService NotaryService) (*v2.ERC20MultiSigSignerAddedBundle, error)

func (ERC20MultiSigSignerAddedEvent) ToProto

func (ERC20MultiSigSignerAddedEvent) ToProtoEdge

type ERC20MultiSigSignerEvent

type ERC20MultiSigSignerEvent struct {
	ID           ERC20MultiSigSignerEventID
	ValidatorID  NodeID
	SignerChange EthereumAddress
	Submitter    EthereumAddress
	Nonce        string
	TxHash       TxHash
	ZetaTime     time.Time
	EpochID      int64
	Event        ERC20MultiSigSignerEventType
}

func ERC20MultiSigSignerEventFromAddedProto

func ERC20MultiSigSignerEventFromAddedProto(e *eventspb.ERC20MultiSigSignerAdded, txHash TxHash) (*ERC20MultiSigSignerEvent, error)

func ERC20MultiSigSignerEventFromRemovedProto

func ERC20MultiSigSignerEventFromRemovedProto(e *eventspb.ERC20MultiSigSignerRemoved, txHash TxHash) ([]*ERC20MultiSigSignerEvent, error)

func (ERC20MultiSigSignerEvent) Cursor

func (e ERC20MultiSigSignerEvent) Cursor() *Cursor

type ERC20MultiSigSignerEventCursor

type ERC20MultiSigSignerEventCursor struct {
	ZetaTime time.Time                  `json:"zeta_time"`
	ID       ERC20MultiSigSignerEventID `json:"id"`
}

func (*ERC20MultiSigSignerEventCursor) Parse

func (c *ERC20MultiSigSignerEventCursor) Parse(cursorString string) error

func (ERC20MultiSigSignerEventCursor) String

type ERC20MultiSigSignerEventID

type ERC20MultiSigSignerEventID = ID[_ERC20MultiSigSignerEvent]

type ERC20MultiSigSignerEventType

type ERC20MultiSigSignerEventType string
const (
	ERC20MultiSigSignerEventTypeAdded   ERC20MultiSigSignerEventType = "SIGNER_ADDED"
	ERC20MultiSigSignerEventTypeRemoved ERC20MultiSigSignerEventType = "SIGNER_REMOVED"
)

type ERC20MultiSigSignerRemovedEvent

type ERC20MultiSigSignerRemovedEvent struct {
	ERC20MultiSigSignerEvent
}

func (ERC20MultiSigSignerRemovedEvent) Cursor

func (ERC20MultiSigSignerRemovedEvent) ToDataNodeApiV2Proto

func (ERC20MultiSigSignerRemovedEvent) ToProto

func (ERC20MultiSigSignerRemovedEvent) ToProtoEdge

type Epoch

type Epoch struct {
	ID         int64
	StartTime  time.Time
	ExpireTime time.Time
	EndTime    *time.Time
	TxHash     TxHash
	ZetaTime   time.Time
	FirstBlock *int64
	LastBlock  *int64
}

func EpochFromProto

func EpochFromProto(ee eventspb.EpochEvent, txHash TxHash) Epoch

func (*Epoch) ToProto

func (e *Epoch) ToProto() *zeta.Epoch

type EpochData

type EpochData struct {
	*zeta.EpochData
}

func (EpochData) MarshalJSON

func (ed EpochData) MarshalJSON() ([]byte, error)

func (*EpochData) UnmarshalJSON

func (ed *EpochData) UnmarshalJSON(b []byte) error

type EpochRewardSummary

type EpochRewardSummary struct {
	AssetID    AssetID
	MarketID   MarketID
	RewardType string
	EpochID    uint64
	Amount     num.Decimal
}

func (EpochRewardSummary) Cursor

func (r EpochRewardSummary) Cursor() *Cursor

func (*EpochRewardSummary) ToProto

func (EpochRewardSummary) ToProtoEdge

func (r EpochRewardSummary) ToProtoEdge(_ ...any) (*v2.EpochRewardSummaryEdge, error)

type EpochRewardSummaryCursor

type EpochRewardSummaryCursor struct {
	EpochID    uint64 `json:"epoch_id"`
	AssetID    string `json:"asset_id"`
	MarketID   string `json:"market_id"`
	RewardType string `json:"reward_type"`
	Amount     string `json:"amount"`
}

func (*EpochRewardSummaryCursor) Parse

func (rc *EpochRewardSummaryCursor) Parse(cursorString string) error

func (EpochRewardSummaryCursor) String

func (rc EpochRewardSummaryCursor) String() string

type EthereumAddress

type EthereumAddress string

func (*EthereumAddress) Bytes

func (addr *EthereumAddress) Bytes() ([]byte, error)

func (*EthereumAddress) DecodeBinary

func (addr *EthereumAddress) DecodeBinary(ci *pgtype.ConnInfo, src []byte) error

func (EthereumAddress) EncodeBinary

func (addr EthereumAddress) EncodeBinary(ci *pgtype.ConnInfo, buf []byte) ([]byte, error)

func (*EthereumAddress) Error

func (addr *EthereumAddress) Error() error

func (*EthereumAddress) String

func (addr *EthereumAddress) String() string

type EthereumKeyRotation

type EthereumKeyRotation struct {
	NodeID      NodeID
	OldAddress  EthereumAddress
	NewAddress  EthereumAddress
	BlockHeight uint64
	TxHash      TxHash
	ZetaTime    time.Time
	SeqNum      uint64
}

func EthereumKeyRotationFromProto

func EthereumKeyRotationFromProto(kr *eventspb.EthereumKeyRotation, txHash TxHash, zetaTime time.Time,
	seqNum uint64,
) (EthereumKeyRotation, error)

func (EthereumKeyRotation) Cursor

func (kr EthereumKeyRotation) Cursor() *Cursor

func (EthereumKeyRotation) ToProto

func (EthereumKeyRotation) ToProtoEdge

func (kr EthereumKeyRotation) ToProtoEdge(_ ...any) (*v2.EthereumKeyRotationEdge, error)

type EthereumKeyRotationCursor

type EthereumKeyRotationCursor struct {
	ZetaTime   time.Time       `json:"zetaTime"`
	NodeID     NodeID          `json:"nodeID"`
	OldAddress EthereumAddress `json:"oldAddress"`
	NewAddress EthereumAddress `json:"newAddress"`
}

func (*EthereumKeyRotationCursor) Parse

func (ec *EthereumKeyRotationCursor) Parse(cursorString string) error

func (EthereumKeyRotationCursor) String

func (ec EthereumKeyRotationCursor) String() string

type ExternalData

type ExternalData struct {
	Data *Data
}

func ExternalDataFromProto

func ExternalDataFromProto(data *datapb.ExternalData, txHash TxHash, zetaTime time.Time, seqNum uint64) (*ExternalData, error)

func (ExternalData) Cursor

func (od ExternalData) Cursor() *Cursor

func (ExternalData) ToOracleProto

func (od ExternalData) ToOracleProto() *zetapb.OracleData

func (ExternalData) ToOracleProtoEdge

func (od ExternalData) ToOracleProtoEdge(_ ...any) (*v2.OracleDataEdge, error)

func (*ExternalData) ToProto

func (od *ExternalData) ToProto() *datapb.ExternalData

type ExternalDataCursor

type ExternalDataCursor struct {
	ZetaTime time.Time `json:"zetaTime"`
	Signers  Signers   `json:"signers"`
}

func (*ExternalDataCursor) Parse

func (c *ExternalDataCursor) Parse(cursorString string) error

func (ExternalDataCursor) String

func (c ExternalDataCursor) String() string

type ExternalDataSourceSpec

type ExternalDataSourceSpec struct {
	Spec *DataSourceSpec
}

func ExternalDataSourceSpecFromProto

func ExternalDataSourceSpecFromProto(spec *zetapb.ExternalDataSourceSpec, txHash TxHash, zetaTime time.Time) (*ExternalDataSourceSpec, error)

func (*ExternalDataSourceSpec) ToProto

type FeeFactors

type FeeFactors struct {
	MakerFee          string `json:"makerFee,omitempty"`
	InfrastructureFee string `json:"infrastructureFee,omitempty"`
	LiquidityFee      string `json:"liquidityFee,omitempty"`
}

type Fees

type Fees struct {
	Factors *FeeFactors `json:"factors,omitempty"`
}

func (Fees) ToProto

func (f Fees) ToProto() *zeta.Fees

type Filter

type Filter struct {
	Key        PropertyKey `json:"key"`
	Conditions []Condition `json:"conditions"`
}

func FiltersFromProto

func FiltersFromProto(filters []*v1.Filter) []Filter

type ID

type ID[T any] string

func (*ID[T]) Bytes

func (id *ID[T]) Bytes() ([]byte, error)

func (*ID[T]) DecodeBinary

func (id *ID[T]) DecodeBinary(ci *pgtype.ConnInfo, src []byte) error

func (ID[T]) EncodeBinary

func (id ID[T]) EncodeBinary(ci *pgtype.ConnInfo, buf []byte) ([]byte, error)

func (*ID[T]) Error

func (id *ID[T]) Error() error

func (*ID[T]) SetBytes

func (id *ID[T]) SetBytes(src []byte) error

func (*ID[T]) String

func (id *ID[T]) String() string

type KeyRotation

type KeyRotation struct {
	NodeID      NodeID
	OldPubKey   ZetaPublicKey
	NewPubKey   ZetaPublicKey
	BlockHeight uint64
	TxHash      TxHash
	ZetaTime    time.Time
}

func KeyRotationFromProto

func KeyRotationFromProto(kr *eventspb.KeyRotation, txHash TxHash, zetaTime time.Time) (*KeyRotation, error)

func (KeyRotation) Cursor

func (kr KeyRotation) Cursor() *Cursor

func (KeyRotation) ToProto

func (kr KeyRotation) ToProto() *eventspb.KeyRotation

func (KeyRotation) ToProtoEdge

func (kr KeyRotation) ToProtoEdge(_ ...any) (*v2.KeyRotationEdge, error)

type KeyRotationCursor

type KeyRotationCursor struct {
	ZetaTime  time.Time     `json:"zeta_time"`
	NodeID    NodeID        `json:"node_id"`
	OldPubKey ZetaPublicKey `json:"old_pub_key"`
	NewPubKey ZetaPublicKey `json:"new_pub_key"`
}

func (*KeyRotationCursor) Parse

func (c *KeyRotationCursor) Parse(cursorString string) error

func (KeyRotationCursor) String

func (c KeyRotationCursor) String() string

type LedgerEntry

type LedgerEntry struct {
	LedgerEntryTime    time.Time
	FromAccountID      AccountID `db:"account_from_id"`
	ToAccountID        AccountID `db:"account_to_id"`
	Quantity           decimal.Decimal
	TxHash             TxHash
	ZetaTime           time.Time
	TransferTime       time.Time
	Type               LedgerMovementType
	FromAccountBalance decimal.Decimal `db:"account_from_balance"`
	ToAccountBalance   decimal.Decimal `db:"account_to_balance"`
}

func (LedgerEntry) ToProto

func (le LedgerEntry) ToProto(ctx context.Context, accountSource AccountSource) (*zeta.LedgerEntry, error)

func (LedgerEntry) ToRow

func (le LedgerEntry) ToRow() []any

type LedgerEntryField

type LedgerEntryField int64

LedgerEntryField is an enumeration of the properties of a ledger entry which can be used for grouping and sorting.

func LedgerEntryFieldFromProto

func LedgerEntryFieldFromProto(field v2.LedgerEntryField) (LedgerEntryField, error)

func (LedgerEntryField) String

func (s LedgerEntryField) String() string

type LedgerEntryFilter

type LedgerEntryFilter struct {
	// CloseOnAccountFilters is used to open/close the output set of entries under the FromAccount/ToAccount values.
	// If true -> the output set will contain entries which sending and receiving accounts
	// all match the criteria given in the `AccountFilter` type.
	// Otherwise will contain entries that have a match the settings in both accounts (sending or receiving) or in one of them.
	CloseOnAccountFilters CloseOnLimitOperation
	// FromAccountFilter is a filter which is used to request properties for FromAccount field.
	FromAccountFilter AccountFilter
	// ToAccountFilter is a filter which is used to request properties for ToAccount field.
	ToAccountFilter AccountFilter

	// Filter on LedgerMovementType
	TransferTypes []LedgerMovementType
}

Settings for receiving closed/open sets on different parts of the outputs of LedgerEntries. Any kind of relation between the data types on logical and practical level in the set is the `limit operation`. We close or not the set of output items on the limit operation via the `CloseOnOperation` set values.

func LedgerEntryFilterFromProto

func LedgerEntryFilterFromProto(pbFilter *v2.LedgerEntryFilter) (*LedgerEntryFilter, error)

type LedgerMovementType

type LedgerMovementType zeta.TransferType

func (*LedgerMovementType) DecodeText

func (l *LedgerMovementType) DecodeText(_ *pgtype.ConnInfo, src []byte) error

func (LedgerMovementType) EncodeText

func (l LedgerMovementType) EncodeText(_ *pgtype.ConnInfo, buf []byte) ([]byte, error)

type LiquidityMonitoringParameters

type LiquidityMonitoringParameters struct {
	TargetStakeParameters *TargetStakeParameters `json:"targetStakeParameters,omitempty"`
	TriggeringRatio       string                 `json:"triggeringRatio,omitempty"`
	AuctionExtension      int64                  `json:"auctionExtension,omitempty"`
}

func (LiquidityMonitoringParameters) ToProto

type LiquidityOrderReference

type LiquidityOrderReference struct {
	*zeta.LiquidityOrderReference
}

func (*LiquidityOrderReference) DecodeBinary

func (l *LiquidityOrderReference) DecodeBinary(_ *pgtype.ConnInfo, src []byte) error

func (LiquidityOrderReference) EncodeBinary

func (l LiquidityOrderReference) EncodeBinary(_ *pgtype.ConnInfo, buf []byte) ([]byte, error)

type LiquidityProvision

type LiquidityProvision struct {
	ID               LiquidityProvisionID
	PartyID          PartyID
	CreatedAt        time.Time
	UpdatedAt        time.Time
	MarketID         MarketID
	CommitmentAmount decimal.Decimal
	Fee              decimal.Decimal
	Sells            []LiquidityOrderReference
	Buys             []LiquidityOrderReference
	Version          int64
	Status           LiquidityProvisionStatus
	Reference        string
	TxHash           TxHash
	ZetaTime         time.Time
}

func LiquidityProvisionFromProto

func LiquidityProvisionFromProto(lpProto *zeta.LiquidityProvision, txHash TxHash, zetaTime time.Time) (LiquidityProvision, error)

func (LiquidityProvision) Cursor

func (lp LiquidityProvision) Cursor() *Cursor

func (LiquidityProvision) Key

func (LiquidityProvision) ToProto

func (LiquidityProvision) ToProtoEdge

func (lp LiquidityProvision) ToProtoEdge(_ ...any) (*v2.LiquidityProvisionsEdge, error)

func (LiquidityProvision) ToRow

func (lp LiquidityProvision) ToRow() []interface{}

type LiquidityProvisionCursor

type LiquidityProvisionCursor struct {
	ZetaTime time.Time            `json:"zetaTime"`
	ID       LiquidityProvisionID `json:"id"`
}

func (*LiquidityProvisionCursor) Parse

func (lc *LiquidityProvisionCursor) Parse(cursorString string) error

func (LiquidityProvisionCursor) String

func (lc LiquidityProvisionCursor) String() string

type LiquidityProvisionID

type LiquidityProvisionID = ID[_LiquidityProvision]

type LiquidityProvisionKey

type LiquidityProvisionKey struct {
	ID       LiquidityProvisionID
	ZetaTime time.Time
}

type LiquidityProvisionStatus

type LiquidityProvisionStatus zeta.LiquidityProvision_Status

func (*LiquidityProvisionStatus) DecodeText

func (s *LiquidityProvisionStatus) DecodeText(_ *pgtype.ConnInfo, src []byte) error

func (LiquidityProvisionStatus) EncodeText

func (s LiquidityProvisionStatus) EncodeText(_ *pgtype.ConnInfo, buf []byte) ([]byte, error)

type MarginCursor

type MarginCursor struct {
	ZetaTime  time.Time
	AccountID AccountID
}

func (*MarginCursor) Parse

func (mc *MarginCursor) Parse(cursorString string) error

func (MarginCursor) String

func (mc MarginCursor) String() string

type MarginLevels

type MarginLevels struct {
	AccountID              AccountID
	MaintenanceMargin      decimal.Decimal
	SearchLevel            decimal.Decimal
	InitialMargin          decimal.Decimal
	CollateralReleaseLevel decimal.Decimal
	Timestamp              time.Time
	TxHash                 TxHash
	ZetaTime               time.Time
}

func MarginLevelsFromProto

func MarginLevelsFromProto(ctx context.Context, margin *zeta.MarginLevels, accountSource AccountSource, txHash TxHash, zetaTime time.Time) (MarginLevels, error)

func (MarginLevels) Cursor

func (ml MarginLevels) Cursor() *Cursor

func (MarginLevels) Key

func (ml MarginLevels) Key() MarginLevelsKey

func (*MarginLevels) ToProto

func (ml *MarginLevels) ToProto(ctx context.Context, accountSource AccountSource) (*zeta.MarginLevels, error)

func (MarginLevels) ToProtoEdge

func (ml MarginLevels) ToProtoEdge(input ...any) (*v2.MarginEdge, error)

func (MarginLevels) ToRow

func (ml MarginLevels) ToRow() []interface{}

type MarginLevelsKey

type MarginLevelsKey struct {
	AccountID AccountID
	ZetaTime  time.Time
}

type Market

type Market struct {
	ID                            MarketID
	TxHash                        TxHash
	ZetaTime                      time.Time
	InstrumentID                  string
	TradableInstrument            TradableInstrument
	DecimalPlaces                 int
	Fees                          Fees
	OpeningAuction                AuctionDuration
	PriceMonitoringSettings       PriceMonitoringSettings
	LiquidityMonitoringParameters LiquidityMonitoringParameters
	TradingMode                   MarketTradingMode
	State                         MarketState
	MarketTimestamps              MarketTimestamps
	PositionDecimalPlaces         int
	LpPriceRange                  string
	LinearSlippageFactor          *decimal.Decimal
	QuadraticSlippageFactor       *decimal.Decimal
}

func NewMarketFromProto

func NewMarketFromProto(market *zeta.Market, txHash TxHash, zetaTime time.Time) (*Market, error)

func (Market) Cursor

func (m Market) Cursor() *Cursor

func (Market) ToProto

func (m Market) ToProto() *zeta.Market

func (Market) ToProtoEdge

func (m Market) ToProtoEdge(_ ...any) (*v2.MarketEdge, error)

type MarketCursor

type MarketCursor struct {
	ZetaTime time.Time `json:"zetaTime"`
	ID       MarketID  `json:"id"`
}

func (*MarketCursor) Parse

func (mc *MarketCursor) Parse(cursorString string) error

func (MarketCursor) String

func (mc MarketCursor) String() string

type MarketData

type MarketData struct {
	// Mark price, as an integer, for example `123456` is a correctly
	// formatted price of `1.23456` assuming market configured to 5 decimal places
	MarkPrice decimal.Decimal
	// Highest price level on an order book for buy orders, as an integer, for example `123456` is a correctly
	// formatted price of `1.23456` assuming market configured to 5 decimal places
	BestBidPrice decimal.Decimal
	// Aggregated volume being bid at the best bid price
	BestBidVolume uint64
	// Aggregated volume being bid at the best bid price
	BestOfferPrice decimal.Decimal
	// Aggregated volume being offered at the best offer price, as an integer, for example `123456` is a correctly
	// formatted price of `1.23456` assuming market configured to 5 decimal places
	BestOfferVolume uint64
	// Highest price on the order book for buy orders not including pegged orders
	BestStaticBidPrice decimal.Decimal
	// Total volume at the best static bid price excluding pegged orders
	BestStaticBidVolume uint64
	// Lowest price on the order book for sell orders not including pegged orders
	BestStaticOfferPrice decimal.Decimal
	// Total volume at the best static offer price excluding pegged orders
	BestStaticOfferVolume uint64
	// Arithmetic average of the best bid price and best offer price, as an integer, for example `123456` is a correctly
	// formatted price of `1.23456` assuming market configured to 5 decimal places
	MidPrice decimal.Decimal
	// Arithmetic average of the best static bid price and best static offer price
	StaticMidPrice decimal.Decimal
	// Market identifier for the data
	Market MarketID
	// The sum of the size of all positions greater than 0 on the market
	OpenInterest uint64
	// Time in seconds until the end of the auction (0 if currently not in auction period)
	AuctionEnd int64
	// Time until next auction (used in FBA's) - currently always 0
	AuctionStart int64
	// Indicative price (zero if not in auction)
	IndicativePrice decimal.Decimal
	// Indicative volume (zero if not in auction)
	IndicativeVolume uint64
	// The current trading mode for the market
	MarketTradingMode string
	// The current trading mode for the market
	MarketState string
	// When a market is in an auction trading mode, this field indicates what triggered the auction
	AuctionTrigger string
	// When a market auction is extended, this field indicates what caused the extension
	ExtensionTrigger string
	// Targeted stake for the given market
	TargetStake decimal.Decimal
	// Available stake for the given market
	SuppliedStake decimal.Decimal
	// One or more price monitoring bounds for the current timestamp
	PriceMonitoringBounds []*types.PriceMonitoringBounds
	// the market value proxy
	MarketValueProxy string
	// the equity like share of liquidity fee for each liquidity provider
	LiquidityProviderFeeShares []*types.LiquidityProviderFeeShare
	// A synthetic time created which is the sum of zeta_time + (seq num * Microsecond)
	SyntheticTime time.Time
	// Transaction which caused this update
	TxHash TxHash
	// Zeta Block time at which the data was received from Zeta Node
	ZetaTime time.Time
	// SeqNum is the order in which the market data was received in the block
	SeqNum uint64
	// NextMarkToMarket is the next timestamp when the market wil be marked to market
	NextMarkToMarket time.Time
}

MarketData represents a market data record that is stored in the SQL database.

func MarketDataFromProto

func MarketDataFromProto(data *types.MarketData, txHash TxHash) (*MarketData, error)

func (MarketData) Cursor

func (md MarketData) Cursor() *Cursor

func (MarketData) Equal

func (md MarketData) Equal(other MarketData) bool

func (MarketData) ToProto

func (md MarketData) ToProto() *types.MarketData

func (MarketData) ToProtoEdge

func (md MarketData) ToProtoEdge(_ ...any) (*v2.MarketDataEdge, error)

type MarketDataCursor

type MarketDataCursor struct {
	SyntheticTime time.Time `json:"synthetic_time"`
}

func (*MarketDataCursor) Parse

func (c *MarketDataCursor) Parse(cursorString string) error

func (MarketDataCursor) String

func (c MarketDataCursor) String() string

type MarketDepth

type MarketDepth struct {
	// Which market is this for
	MarketID string
	// All of the orders in the order book
	LiveOrders map[string]*types.Order
	// Just the buy side of the book
	BuySide []*PriceLevel
	// Just the sell side of the book
	SellSide []*PriceLevel
	// All price levels that have changed in the last update
	Changes []*PriceLevel
	// Sequence number is an increment-only value to identify a state
	// of the market depth in time. Used when trying to match updates
	// to a snapshot dump
	SequenceNumber uint64
	// PreviousSequenceNumber is the sequence number of the last published update. 'Changes' include
	// updates from all events with a sequence number > PreviousSequenceNumber and <= SequenceNumber
	PreviousSequenceNumber uint64
}

func (*MarketDepth) AddOrderUpdate

func (md *MarketDepth) AddOrderUpdate(order *types.Order)

func (*MarketDepth) GetPriceLevel

func (md *MarketDepth) GetPriceLevel(side types.Side, price *num.Uint) *PriceLevel

func (*MarketDepth) ToProto

func (md *MarketDepth) ToProto(limit uint64) *zeta.MarketDepth

type MarketID

type MarketID = ID[_Market]

type MarketState

type MarketState zeta.Market_State

func (*MarketState) DecodeText

func (s *MarketState) DecodeText(_ *pgtype.ConnInfo, src []byte) error

func (MarketState) EncodeText

func (s MarketState) EncodeText(_ *pgtype.ConnInfo, buf []byte) ([]byte, error)

type MarketTimestamps

type MarketTimestamps struct {
	Proposed int64 `json:"proposed,omitempty"`
	Pending  int64 `json:"pending,omitempty"`
	Open     int64 `json:"open,omitempty"`
	Close    int64 `json:"close,omitempty"`
}

func (MarketTimestamps) ToProto

func (mt MarketTimestamps) ToProto() *zeta.MarketTimestamps

type MarketTradingMode

type MarketTradingMode zeta.Market_TradingMode

func (*MarketTradingMode) DecodeText

func (m *MarketTradingMode) DecodeText(_ *pgtype.ConnInfo, src []byte) error

func (MarketTradingMode) EncodeText

func (m MarketTradingMode) EncodeText(_ *pgtype.ConnInfo, buf []byte) ([]byte, error)

type NetworkLimits

type NetworkLimits struct {
	TxHash                   TxHash
	ZetaTime                 time.Time
	CanProposeMarket         bool
	CanProposeAsset          bool
	ProposeMarketEnabled     bool
	ProposeAssetEnabled      bool
	GenesisLoaded            bool
	ProposeMarketEnabledFrom time.Time
	ProposeAssetEnabledFrom  time.Time
}

func NetworkLimitsFromProto

func NetworkLimitsFromProto(vn *zeta.NetworkLimits, txHash TxHash) NetworkLimits

func (*NetworkLimits) ToProto

func (nl *NetworkLimits) ToProto() *zeta.NetworkLimits

type NetworkParameter

type NetworkParameter struct {
	Key      string
	Value    string
	TxHash   TxHash
	ZetaTime time.Time
}

func NetworkParameterFromProto

func NetworkParameterFromProto(pnp *zeta.NetworkParameter, txHash TxHash) (NetworkParameter, error)

func (NetworkParameter) Cursor

func (np NetworkParameter) Cursor() *Cursor

func (NetworkParameter) ToProto

func (np NetworkParameter) ToProto() *zeta.NetworkParameter

func (NetworkParameter) ToProtoEdge

func (np NetworkParameter) ToProtoEdge(_ ...any) (*v2.NetworkParameterEdge, error)

type NetworkParameterCursor

type NetworkParameterCursor struct {
	Key string
}

func (*NetworkParameterCursor) Parse

func (c *NetworkParameterCursor) Parse(cursorString string) error

type Node

type Node struct {
	ID                NodeID
	PubKey            ZetaPublicKey       `db:"zeta_pub_key"`
	TmPubKey          TendermintPublicKey `db:"tendermint_pub_key"`
	EthereumAddress   EthereumAddress
	InfoURL           string
	Location          string
	Status            NodeStatus
	Name              string
	AvatarURL         string
	TxHash            TxHash
	ZetaTime          time.Time
	StakedByOperator  decimal.Decimal
	StakedByDelegates decimal.Decimal
	StakedTotal       decimal.Decimal
	MaxIntendedStake  decimal.Decimal
	PendingStake      decimal.Decimal
	EpochData         EpochData
	Delegations       []Delegation  `json:""`
	RewardScore       *RewardScore  `json:""`
	RankingScore      *RankingScore `json:""`
}

func NodeFromProto

func NodeFromProto(node *zeta.Node, txHash TxHash, zetaTime time.Time) (Node, error)

func (Node) Cursor

func (node Node) Cursor() *Cursor

func (*Node) ToProto

func (node *Node) ToProto() *zeta.Node

func (Node) ToProtoEdge

func (node Node) ToProtoEdge(_ ...any) (*v2.NodeEdge, error)

type NodeBasic

type NodeBasic struct {
	ID              NodeID
	PubKey          ZetaPublicKey       `db:"zeta_pub_key"`
	TmPubKey        TendermintPublicKey `db:"tendermint_pub_key"`
	EthereumAddress EthereumAddress
	InfoURL         string
	Location        string
	Status          NodeStatus
	Name            string
	AvatarURL       string
	TxHash          TxHash
	ZetaTime        time.Time
}

func (NodeBasic) ToProto

func (n NodeBasic) ToProto() *v2.NodeBasic

type NodeCursor

type NodeCursor struct {
	ID NodeID `json:"id"`
}

func (*NodeCursor) Parse

func (nc *NodeCursor) Parse(cursorString string) error

func (NodeCursor) String

func (nc NodeCursor) String() string

type NodeData

type NodeData struct {
	StakedTotal     decimal.Decimal
	TotalNodes      uint32
	InactiveNodes   uint32
	TendermintNodes NodeSet
	ErsatzNodes     NodeSet
	PendingNodes    NodeSet
	Uptime          float64
	ZetaTime        time.Time
}

func (*NodeData) ToProto

func (n *NodeData) ToProto() *zeta.NodeData

type NodeID

type NodeID = ID[_Node]

type NodeSet

type NodeSet struct {
	Total    uint32
	Inactive uint32
	Promoted []string
	Demoted  []string
	Maximum  uint32
}

func (*NodeSet) ToProto

func (n *NodeSet) ToProto() *zeta.NodeSet

type NodeSignature

type NodeSignature struct {
	ResourceID NodeSignatureID
	Sig        []byte
	Kind       NodeSignatureKind
	TxHash     TxHash
	ZetaTime   time.Time
}

func NodeSignatureFromProto

func NodeSignatureFromProto(ns *commandspb.NodeSignature, txHash TxHash, zetaTime time.Time) (*NodeSignature, error)

func (NodeSignature) Cursor

func (w NodeSignature) Cursor() *Cursor

func (NodeSignature) ToProto

func (w NodeSignature) ToProto() *commandspb.NodeSignature

func (NodeSignature) ToProtoEdge

func (w NodeSignature) ToProtoEdge(_ ...any) (*v2.NodeSignatureEdge, error)

type NodeSignatureCursor

type NodeSignatureCursor struct {
	ResourceID NodeSignatureID `json:"resource_id"`
	Sig        []byte          `json:"sig"`
}

func (*NodeSignatureCursor) Parse

func (c *NodeSignatureCursor) Parse(cursorString string) error

func (NodeSignatureCursor) String

func (c NodeSignatureCursor) String() string

type NodeSignatureID

type NodeSignatureID = ID[_NodeSignature]

type NodeSignatureKind

type NodeSignatureKind commandspb.NodeSignatureKind

func (*NodeSignatureKind) DecodeText

func (s *NodeSignatureKind) DecodeText(_ *pgtype.ConnInfo, src []byte) error

func (NodeSignatureKind) EncodeText

func (s NodeSignatureKind) EncodeText(_ *pgtype.ConnInfo, buf []byte) ([]byte, error)

type NodeStatus

type NodeStatus zeta.NodeStatus

func (*NodeStatus) DecodeText

func (ns *NodeStatus) DecodeText(_ *pgtype.ConnInfo, src []byte) error

func (NodeStatus) EncodeText

func (ns NodeStatus) EncodeText(_ *pgtype.ConnInfo, buf []byte) ([]byte, error)

type NotaryService

type NotaryService interface {
	GetByResourceID(ctx context.Context, id string, pagination CursorPagination) ([]NodeSignature, PageInfo, error)
}

type OracleData

type OracleData struct {
	ExternalData *ExternalData
}

func OracleDataFromProto

func OracleDataFromProto(data *zetapb.OracleData, txHash TxHash, zetaTime time.Time, seqNum uint64) (*OracleData, error)

func (OracleData) Cursor

func (od OracleData) Cursor() *Cursor

func (OracleData) ToProto

func (od OracleData) ToProto() *zetapb.OracleData

func (OracleData) ToProtoEdge

func (od OracleData) ToProtoEdge(_ ...any) (*v2.OracleDataEdge, error)

type OracleDataCursor

type OracleDataCursor = ExternalDataCursor

type OracleSpec

type OracleSpec struct {
	ExternalDataSourceSpec *ExternalDataSourceSpec
}

func OracleSpecFromProto

func OracleSpecFromProto(spec *zetapb.OracleSpec, txHash TxHash, zetaTime time.Time) (*OracleSpec, error)

func (OracleSpec) Cursor

func (os OracleSpec) Cursor() *Cursor

func (OracleSpec) ToProto

func (os OracleSpec) ToProto() *zetapb.OracleSpec

func (OracleSpec) ToProtoEdge

func (os OracleSpec) ToProtoEdge(_ ...any) (*v2.OracleSpecEdge, error)

type OracleSpecStatus

type OracleSpecStatus = DataSourceSpecStatus

type Order

type Order struct {
	ID              OrderID
	MarketID        MarketID
	PartyID         PartyID
	Side            Side
	Price           decimal.Decimal
	Size            int64
	Remaining       int64
	TimeInForce     OrderTimeInForce
	Type            OrderType
	Status          OrderStatus
	Reference       string
	Reason          OrderError
	Version         int32
	PeggedOffset    decimal.Decimal
	BatchID         int32
	PeggedReference PeggedReference
	LpID            []byte
	CreatedAt       time.Time
	UpdatedAt       time.Time
	ExpiresAt       time.Time
	TxHash          TxHash
	ZetaTime        time.Time
	SeqNum          uint64
	PostOnly        bool
	ReduceOnly      bool
}

func OrderFromProto

func OrderFromProto(po *zeta.Order, seqNum uint64, txHash TxHash) (Order, error)

func (Order) Cursor

func (o Order) Cursor() *Cursor

func (Order) Key

func (o Order) Key() OrderKey

func (Order) ToProto

func (o Order) ToProto() *zeta.Order

func (Order) ToProtoEdge

func (o Order) ToProtoEdge(_ ...any) (*v2.OrderEdge, error)

func (Order) ToRow

func (o Order) ToRow() []interface{}

type OrderCursor

type OrderCursor struct {
	CreatedAt time.Time `json:"createdAt"`
	ID        OrderID   `json:"id"`
	ZetaTime  time.Time `json:"zetaTime"`
}

func (*OrderCursor) Parse

func (oc *OrderCursor) Parse(cursorString string) error

func (OrderCursor) String

func (oc OrderCursor) String() string

type OrderError

type OrderError = zeta.OrderError
const (
	// Default value, no error reported.
	OrderErrorUnspecified OrderError = zeta.OrderError_ORDER_ERROR_UNSPECIFIED
	// Order was submitted for a market that does not exist.
	OrderErrorInvalidMarketID OrderError = zeta.OrderError_ORDER_ERROR_INVALID_MARKET_ID
	// Order was submitted with an invalid identifier.
	OrderErrorInvalidOrderID OrderError = zeta.OrderError_ORDER_ERROR_INVALID_ORDER_ID
	// Order was amended with a sequence number that was not previous version + 1.
	OrderErrorOutOfSequence OrderError = zeta.OrderError_ORDER_ERROR_OUT_OF_SEQUENCE
	// Order was amended with an invalid remaining size (e.g. remaining greater than total size).
	OrderErrorInvalidRemainingSize OrderError = zeta.OrderError_ORDER_ERROR_INVALID_REMAINING_SIZE
	// Node was unable to get Zeta (blockchain) time.
	OrderErrorTimeFailure OrderError = zeta.OrderError_ORDER_ERROR_TIME_FAILURE
	// Failed to remove an order from the book.
	OrderErrorRemovalFailure OrderError = zeta.OrderError_ORDER_ERROR_REMOVAL_FAILURE
	// An order with `TimeInForce.TIME_IN_FORCE_GTT` was submitted or amended
	// with an expiration that was badly formatted or otherwise invalid.
	OrderErrorInvalidExpirationDatetime OrderError = zeta.OrderError_ORDER_ERROR_INVALID_EXPIRATION_DATETIME
	// Order was submitted or amended with an invalid reference field.
	OrderErrorInvalidOrderReference OrderError = zeta.OrderError_ORDER_ERROR_INVALID_ORDER_REFERENCE
	// Order amend was submitted for an order field that cannot not be amended (e.g. order identifier).
	OrderErrorEditNotAllowed OrderError = zeta.OrderError_ORDER_ERROR_EDIT_NOT_ALLOWED
	// Amend failure because amend details do not match original order.
	OrderErrorAmendFailure OrderError = zeta.OrderError_ORDER_ERROR_AMEND_FAILURE
	// Order not found in an order book or store.
	OrderErrorNotFound OrderError = zeta.OrderError_ORDER_ERROR_NOT_FOUND
	// Order was submitted with an invalid or missing party identifier.
	OrderErrorInvalidParty OrderError = zeta.OrderError_ORDER_ERROR_INVALID_PARTY_ID
	// Order was submitted for a market that has closed.
	OrderErrorMarketClosed OrderError = zeta.OrderError_ORDER_ERROR_MARKET_CLOSED
	// Order was submitted, but the party did not have enough collateral to cover the order.
	OrderErrorMarginCheckFailed OrderError = zeta.OrderError_ORDER_ERROR_MARGIN_CHECK_FAILED
	// Order was submitted, but the party did not have an account for this asset.
	OrderErrorMissingGeneralAccount OrderError = zeta.OrderError_ORDER_ERROR_MISSING_GENERAL_ACCOUNT
	// Unspecified internal error.
	OrderErrorInternalError OrderError = zeta.OrderError_ORDER_ERROR_INTERNAL_ERROR
	// Order was submitted with an invalid or missing size (e.g. 0).
	OrderErrorInvalidSize OrderError = zeta.OrderError_ORDER_ERROR_INVALID_SIZE
	// Order was submitted with an invalid persistence for its type.
	OrderErrorInvalidPersistance OrderError = zeta.OrderError_ORDER_ERROR_INVALID_PERSISTENCE
	// Order was submitted with an invalid type field.
	OrderErrorInvalidType OrderError = zeta.OrderError_ORDER_ERROR_INVALID_TYPE
	// Order was stopped as it would have traded with another order submitted from the same party.
	OrderErrorSelfTrading OrderError = zeta.OrderError_ORDER_ERROR_SELF_TRADING
	// Order was submitted, but the party did not have enough collateral to cover the fees for the order.
	OrderErrorInsufficientFundsToPayFees OrderError = zeta.OrderError_ORDER_ERROR_INSUFFICIENT_FUNDS_TO_PAY_FEES
	// Order was submitted with an incorrect or invalid market type.
	OrderErrorIncorrectMarketType OrderError = zeta.OrderError_ORDER_ERROR_INCORRECT_MARKET_TYPE
	// Order was submitted with invalid time in force.
	OrderErrorInvalidTimeInForce OrderError = zeta.OrderError_ORDER_ERROR_INVALID_TIME_IN_FORCE
	// A GFN order has got to the market when it is in auction mode.
	OrderErrorCannotSendGFNOrderDuringAnAuction OrderError = zeta.OrderError_ORDER_ERROR_CANNOT_SEND_GFN_ORDER_DURING_AN_AUCTION
	// A GFA order has got to the market when it is in continuous trading mode.
	OrderErrorCannotSendGFAOrderDuringContinuousTrading OrderError = zeta.OrderError_ORDER_ERROR_CANNOT_SEND_GFA_ORDER_DURING_CONTINUOUS_TRADING
	// Attempt to amend order to GTT without ExpiryAt.
	OrderErrorCannotAmendToGTTWithoutExpiryAt OrderError = zeta.OrderError_ORDER_ERROR_CANNOT_AMEND_TO_GTT_WITHOUT_EXPIRYAT
	// Attempt to amend ExpiryAt to a value before CreatedAt.
	OrderErrorExpiryAtBeforeCreatedAt OrderError = zeta.OrderError_ORDER_ERROR_EXPIRYAT_BEFORE_CREATEDAT
	// Attempt to amend to GTC without an ExpiryAt value.
	OrderErrorCannotHaveGTCAndExpiryAt OrderError = zeta.OrderError_ORDER_ERROR_CANNOT_HAVE_GTC_AND_EXPIRYAT
	// Amending to FOK or IOC is invalid.
	OrderErrorCannotAmendToFOKOrIOC OrderError = zeta.OrderError_ORDER_ERROR_CANNOT_AMEND_TO_FOK_OR_IOC
	// Amending to GFA or GFN is invalid.
	OrderErrorCannotAmendToGFAOrGFN OrderError = zeta.OrderError_ORDER_ERROR_CANNOT_AMEND_TO_GFA_OR_GFN
	// Amending from GFA or GFN is invalid.
	OrderErrorCannotAmendFromGFAOrGFN OrderError = zeta.OrderError_ORDER_ERROR_CANNOT_AMEND_FROM_GFA_OR_GFN
	// IOC orders are not allowed during auction.
	OrderErrorCannotSendIOCOrderDuringAuction OrderError = zeta.OrderError_ORDER_ERROR_CANNOT_SEND_IOC_ORDER_DURING_AUCTION
	// FOK orders are not allowed during auction.
	OrderErrorCannotSendFOKOrderDurinAuction OrderError = zeta.OrderError_ORDER_ERROR_CANNOT_SEND_FOK_ORDER_DURING_AUCTION
	// Pegged orders must be LIMIT orders.
	OrderErrorMustBeLimitOrder OrderError = zeta.OrderError_ORDER_ERROR_MUST_BE_LIMIT_ORDER
	// Pegged orders can only have TIF GTC or GTT.
	OrderErrorMustBeGTTOrGTC OrderError = zeta.OrderError_ORDER_ERROR_MUST_BE_GTT_OR_GTC
	// Pegged order must have a reference price.
	OrderErrorWithoutReferencePrice OrderError = zeta.OrderError_ORDER_ERROR_WITHOUT_REFERENCE_PRICE
	// Buy pegged order cannot reference best ask price.
	OrderErrorBuyCannotReferenceBestAskPrice OrderError = zeta.OrderError_ORDER_ERROR_BUY_CANNOT_REFERENCE_BEST_ASK_PRICE
	// Pegged order offset must be >= 0.
	OrderErrorOffsetMustBeGreaterOrEqualToZero OrderError = zeta.OrderError_ORDER_ERROR_OFFSET_MUST_BE_GREATER_OR_EQUAL_TO_ZERO
	// Sell pegged order cannot reference best bid price.
	OrderErrorSellCannotReferenceBestBidPrice OrderError = zeta.OrderError_ORDER_ERROR_SELL_CANNOT_REFERENCE_BEST_BID_PRICE
	// Pegged order offset must be > zero.
	OrderErrorOffsetMustBeGreaterThanZero OrderError = zeta.OrderError_ORDER_ERROR_OFFSET_MUST_BE_GREATER_THAN_ZERO
	// The party has an insufficient balance, or does not have
	// a general account to submit the order (no deposits made
	// for the required asset).
	OrderErrorInsufficientAssetBalance OrderError = zeta.OrderError_ORDER_ERROR_INSUFFICIENT_ASSET_BALANCE
	// Cannot amend a non pegged orders details.
	OrderErrorCannotAmendPeggedOrderDetailsOnNonPeggedOrder OrderError = zeta.OrderError_ORDER_ERROR_CANNOT_AMEND_PEGGED_ORDER_DETAILS_ON_NON_PEGGED_ORDER
	// We are unable to re-price a pegged order because a market price is unavailable.
	OrderErrorUnableToRepricePeggedOrder OrderError = zeta.OrderError_ORDER_ERROR_UNABLE_TO_REPRICE_PEGGED_ORDER
	// It is not possible to amend the price of an existing pegged order.
	OrderErrorUnableToAmendPriceOnPeggedOrder OrderError = zeta.OrderError_ORDER_ERROR_UNABLE_TO_AMEND_PRICE_ON_PEGGED_ORDER
	// An FOK, IOC, or GFN order was rejected because it resulted in trades outside the price bounds.
	OrderErrorNonPersistentOrderOutOfPriceBounds OrderError = zeta.OrderError_ORDER_ERROR_NON_PERSISTENT_ORDER_OUT_OF_PRICE_BOUNDS
)

type OrderFilter

type OrderFilter struct {
	Statuses         []zeta.Order_Status
	Types            []zeta.Order_Type
	TimeInForces     []zeta.Order_TimeInForce
	Reference        *string
	DateRange        *DateRange
	ExcludeLiquidity bool
	LiveOnly         bool
	PartyIDs         []string
	MarketIDs        []string
}

type OrderID

type OrderID = ID[_Order]

type OrderKey

type OrderKey struct {
	ID       OrderID
	Version  int32
	ZetaTime time.Time
}

type OrderStatus

type OrderStatus = zeta.Order_Status
const (
	// Default value, always invalid.
	OrderStatusUnspecified OrderStatus = zeta.Order_STATUS_UNSPECIFIED
	// Used for active unfilled or partially filled orders.
	OrderStatusActive OrderStatus = zeta.Order_STATUS_ACTIVE
	// Used for expired GTT orders.
	OrderStatusExpired OrderStatus = zeta.Order_STATUS_EXPIRED
	// Used for orders cancelled by the party that created the order.
	OrderStatusCancelled OrderStatus = zeta.Order_STATUS_CANCELLED
	// Used for unfilled FOK or IOC orders, and for orders that were stopped by the network.
	OrderStatusStopped OrderStatus = zeta.Order_STATUS_STOPPED
	// Used for closed fully filled orders.
	OrderStatusFilled OrderStatus = zeta.Order_STATUS_FILLED
	// Used for orders when not enough collateral was available to fill the margin requirements.
	OrderStatusRejected OrderStatus = zeta.Order_STATUS_REJECTED
	// Used for closed partially filled IOC orders.
	OrderStatusPartiallyFilled OrderStatus = zeta.Order_STATUS_PARTIALLY_FILLED
	// Order has been removed from the order book and has been parked, this applies to pegged orders only.
	OrderStatusParked OrderStatus = zeta.Order_STATUS_PARKED
)

type OrderTimeInForce

type OrderTimeInForce = zeta.Order_TimeInForce
const (
	// Default value for TimeInForce, can be valid for an amend.
	OrderTimeInForceUnspecified OrderTimeInForce = zeta.Order_TIME_IN_FORCE_UNSPECIFIED
	// Good until cancelled.
	OrderTimeInForceGTC OrderTimeInForce = zeta.Order_TIME_IN_FORCE_GTC
	// Good until specified time.
	OrderTimeInForceGTT OrderTimeInForce = zeta.Order_TIME_IN_FORCE_GTT
	// Immediate or cancel.
	OrderTimeInForceIOC OrderTimeInForce = zeta.Order_TIME_IN_FORCE_IOC
	// Fill or kill.
	OrderTimeInForceFOK OrderTimeInForce = zeta.Order_TIME_IN_FORCE_FOK
	// Good for auction.
	OrderTimeInForceGFA OrderTimeInForce = zeta.Order_TIME_IN_FORCE_GFA
	// Good for normal.
	OrderTimeInForceGFN OrderTimeInForce = zeta.Order_TIME_IN_FORCE_GFN
)

type OrderType

type OrderType = zeta.Order_Type
const (
	// Default value, always invalid.
	OrderTypeUnspecified OrderType = zeta.Order_TYPE_UNSPECIFIED
	// Used for Limit orders.
	OrderTypeLimit OrderType = zeta.Order_TYPE_LIMIT
	// Used for Market orders.
	OrderTypeMarket OrderType = zeta.Order_TYPE_MARKET
	// Used for orders where the initiating party is the network (with distressed traders).
	OrderTypeNetwork OrderType = zeta.Order_TYPE_NETWORK
)

type PageInfo

type PageInfo struct {
	HasNextPage     bool
	HasPreviousPage bool
	StartCursor     string
	EndCursor       string
}

func PageEntities

func PageEntities[T proto.Message, U PagedEntity[T]](items []U, pagination CursorPagination) ([]U, PageInfo)

func (PageInfo) ToProto

func (p PageInfo) ToProto() *v2.PageInfo

type PagedEntity

type PagedEntity[T proto.Message] interface {
	Entities | Transfer | MarginLevels

	// ToProtoEdge may need some optional arguments in order to generate the proto, for example margin levels
	// requires an account source. This is not ideal, but we can come back to this later if a better solution can be found.
	ToProtoEdge(...any) (T, error)
	Cursor() *Cursor
}

type Pagination

type Pagination interface{}

type Party

type Party struct {
	ID       PartyID
	TxHash   TxHash
	ZetaTime *time.Time // Can be NULL for built-in party 'network'
}

func PartyFromProto

func PartyFromProto(pp *types.Party, txHash TxHash) Party

func (Party) Cursor

func (p Party) Cursor() *Cursor

func (*Party) Parse

func (p *Party) Parse(cursorString string) error

func (Party) String

func (p Party) String() string

func (Party) ToProto

func (p Party) ToProto() *types.Party

func (Party) ToProtoEdge

func (p Party) ToProtoEdge(_ ...any) (*v2.PartyEdge, error)

type PartyID

type PartyID = ID[_Party]

type PeggedReference

type PeggedReference = zeta.PeggedReference
const (
	// Default value for PeggedReference, no reference given.
	PeggedReferenceUnspecified PeggedReference = zeta.PeggedReference_PEGGED_REFERENCE_UNSPECIFIED
	// Mid price reference.
	PeggedReferenceMid PeggedReference = zeta.PeggedReference_PEGGED_REFERENCE_MID
	// Best bid price reference.
	PeggedReferenceBestBid PeggedReference = zeta.PeggedReference_PEGGED_REFERENCE_BEST_BID
	// Best ask price reference.
	PeggedReferenceBestAsk PeggedReference = zeta.PeggedReference_PEGGED_REFERENCE_BEST_ASK
)

type Position

type Position struct {
	MarketID                MarketID
	PartyID                 PartyID
	OpenVolume              int64
	RealisedPnl             decimal.Decimal
	UnrealisedPnl           decimal.Decimal
	AverageEntryPrice       decimal.Decimal
	AverageEntryMarketPrice decimal.Decimal
	Loss                    decimal.Decimal // what the party lost because of loss socialization
	Adjustment              decimal.Decimal // what a party was missing which triggered loss socialization
	TxHash                  TxHash
	ZetaTime                time.Time
	// keep track of trades that haven't been settled as separate fields
	// these will be zeroed out once we process settlement events
	PendingOpenVolume              int64
	PendingRealisedPnl             decimal.Decimal
	PendingUnrealisedPnl           decimal.Decimal
	PendingAverageEntryPrice       decimal.Decimal
	PendingAverageEntryMarketPrice decimal.Decimal
	LossSocialisationAmount        decimal.Decimal
	DistressedStatus               PositionStatus
}

func NewEmptyPosition

func NewEmptyPosition(marketID MarketID, partyID PartyID) Position

func (*Position) AverageEntryPriceUint

func (p *Position) AverageEntryPriceUint() *num.Uint

func (Position) Cursor

func (p Position) Cursor() *Cursor

func (Position) Equal

func (p Position) Equal(q Position) bool

func (Position) Key

func (p Position) Key() PositionKey

func (Position) ToProto

func (p Position) ToProto() *zeta.Position

func (Position) ToProtoEdge

func (p Position) ToProtoEdge(_ ...any) (*v2.PositionEdge, error)

func (Position) ToRow

func (p Position) ToRow() []interface{}

func (*Position) ToggleDistressedStatus

func (p *Position) ToggleDistressedStatus()

func (*Position) UpdateOrdersClosed

func (p *Position) UpdateOrdersClosed()

func (*Position) UpdateWithLossSocialization

func (p *Position) UpdateWithLossSocialization(e lossSocialization)

func (*Position) UpdateWithPositionSettlement

func (p *Position) UpdateWithPositionSettlement(e positionSettlement)

func (*Position) UpdateWithSettleDistressed

func (p *Position) UpdateWithSettleDistressed(e settleDistressed)

func (*Position) UpdateWithSettleMarket

func (p *Position) UpdateWithSettleMarket(e settleMarket)

func (*Position) UpdateWithTrade

func (p *Position) UpdateWithTrade(trade zeta.Trade, seller bool, sf num.Decimal)

type PositionCursor

type PositionCursor struct {
	ZetaTime time.Time `json:"zeta_time"`
	PartyID  PartyID   `json:"party_id"`
	MarketID MarketID  `json:"market_id"`
}

func (*PositionCursor) Parse

func (rc *PositionCursor) Parse(cursorString string) error

func (PositionCursor) String

func (rc PositionCursor) String() string

type PositionKey

type PositionKey struct {
	MarketID MarketID
	PartyID  PartyID
	ZetaTime time.Time
}

type PositionStatus

type PositionStatus int32

func (*PositionStatus) DecodeText

func (p *PositionStatus) DecodeText(_ *pgtype.ConnInfo, src []byte) error

func (PositionStatus) EncodeText

func (p PositionStatus) EncodeText(_ *pgtype.ConnInfo, buf []byte) ([]byte, error)

type PriceLevel

type PriceLevel struct {
	// Price of the price level
	Price *num.Uint
	// How many orders are at this level
	TotalOrders uint64
	// How much volume is at this level
	TotalVolume uint64
	// What side of the book is this level
	Side types.Side
}

type PriceMonitoringParameters

type PriceMonitoringParameters struct {
	Triggers []*PriceMonitoringTrigger `json:"triggers,omitempty"`
}

type PriceMonitoringSettings

type PriceMonitoringSettings struct {
	Parameters *PriceMonitoringParameters `json:"priceMonitoringParameters,omitempty"`
}

func (PriceMonitoringSettings) ToProto

type PriceMonitoringTrigger

type PriceMonitoringTrigger struct {
	Horizon          uint64          `json:"horizon"`
	Probability      decimal.Decimal `json:"probability"`
	AuctionExtension uint64          `json:"auctionExtension"`
}

func (PriceMonitoringTrigger) Equals

func (trigger PriceMonitoringTrigger) Equals(other PriceMonitoringTrigger) bool

func (PriceMonitoringTrigger) ToProto

type Property

type Property struct {
	Name  string
	Value string
}

type PropertyKey

type PropertyKey struct {
	Name          string `json:"name"`
	Type          v1.PropertyKey_Type
	DecimalPlaces *uint64 `json:"number_decimal_places,omitempty"`
}

type Proposal

type Proposal struct {
	ID                      ProposalID
	Reference               string
	PartyID                 PartyID
	State                   ProposalState
	Rationale               ProposalRationale
	Terms                   ProposalTerms
	Reason                  ProposalError
	ErrorDetails            string
	ProposalTime            time.Time
	ZetaTime                time.Time
	RequiredMajority        num.Decimal
	RequiredParticipation   num.Decimal
	RequiredLPMajority      *num.Decimal
	RequiredLPParticipation *num.Decimal
	TxHash                  TxHash
}

func ProposalFromProto

func ProposalFromProto(pp *zeta.Proposal, txHash TxHash) (Proposal, error)

func (Proposal) Cursor

func (p Proposal) Cursor() *Cursor

func (Proposal) ToProto

func (p Proposal) ToProto() *zeta.Proposal

func (Proposal) ToProtoEdge

func (p Proposal) ToProtoEdge(_ ...any) (*v2.GovernanceDataEdge, error)

type ProposalCursor

type ProposalCursor struct {
	State    ProposalState `json:"state"`
	ZetaTime time.Time     `json:"zeta_time"`
	ID       ProposalID    `json:"id"`
}

func (*ProposalCursor) Parse

func (pc *ProposalCursor) Parse(cursorString string) error

func (ProposalCursor) String

func (pc ProposalCursor) String() string

type ProposalError

type ProposalError zeta.ProposalError

func (*ProposalError) DecodeText

func (s *ProposalError) DecodeText(_ *pgtype.ConnInfo, src []byte) error

func (ProposalError) EncodeText

func (s ProposalError) EncodeText(_ *pgtype.ConnInfo, buf []byte) ([]byte, error)

type ProposalID

type ProposalID = ID[_Proposal]

type ProposalRationale

type ProposalRationale struct {
	*zeta.ProposalRationale
}

func (ProposalRationale) MarshalJSON

func (pt ProposalRationale) MarshalJSON() ([]byte, error)

func (*ProposalRationale) UnmarshalJSON

func (pt *ProposalRationale) UnmarshalJSON(b []byte) error

type ProposalState

type ProposalState zeta.Proposal_State

func (*ProposalState) DecodeText

func (s *ProposalState) DecodeText(_ *pgtype.ConnInfo, src []byte) error

func (ProposalState) EncodeText

func (s ProposalState) EncodeText(_ *pgtype.ConnInfo, buf []byte) ([]byte, error)

type ProposalTerms

type ProposalTerms struct {
	*zeta.ProposalTerms
}

func (ProposalTerms) MarshalJSON

func (pt ProposalTerms) MarshalJSON() ([]byte, error)

func (*ProposalTerms) UnmarshalJSON

func (pt *ProposalTerms) UnmarshalJSON(b []byte) error

type ProposalType

func (*ProposalType) String

func (p *ProposalType) String() string

type ProtoEntity

type ProtoEntity[T proto.Message] interface {
	Entities | Account | NodeBasic
	ToProto() T
}

type ProtocolUpgradeProposal

type ProtocolUpgradeProposal struct {
	UpgradeBlockHeight uint64
	ZetaReleaseTag     string
	Approvers          []string
	Status             ProtocolUpgradeProposalStatus
	TxHash             TxHash
	ZetaTime           time.Time
}

func ProtocolUpgradeProposalFromProto

func ProtocolUpgradeProposalFromProto(p *eventspb.ProtocolUpgradeEvent, txHash TxHash, zetaTime time.Time) ProtocolUpgradeProposal

func (ProtocolUpgradeProposal) Cursor

func (p ProtocolUpgradeProposal) Cursor() *Cursor

func (ProtocolUpgradeProposal) ToProto

func (ProtocolUpgradeProposal) ToProtoEdge

type ProtocolUpgradeProposalCursor

type ProtocolUpgradeProposalCursor struct {
	ZetaTime           time.Time
	UpgradeBlockHeight uint64
	ZetaReleaseTag     string
}

func (*ProtocolUpgradeProposalCursor) Parse

func (pc *ProtocolUpgradeProposalCursor) Parse(cursorString string) error

func (ProtocolUpgradeProposalCursor) String

type ProtocolUpgradeProposalStatus

type ProtocolUpgradeProposalStatus eventspb.ProtocolUpgradeProposalStatus

func (*ProtocolUpgradeProposalStatus) DecodeText

func (ps *ProtocolUpgradeProposalStatus) DecodeText(_ *pgtype.ConnInfo, src []byte) error

func (ProtocolUpgradeProposalStatus) EncodeText

func (ps ProtocolUpgradeProposalStatus) EncodeText(_ *pgtype.ConnInfo, buf []byte) ([]byte, error)

type RankingScore

type RankingScore struct {
	StakeScore       decimal.Decimal     `json:"stake_score"`
	PerformanceScore decimal.Decimal     `json:"performance_score"`
	PreviousStatus   ValidatorNodeStatus `json:"previous_status,string"`
	Status           ValidatorNodeStatus `json:",string"`
	VotingPower      uint32              `json:"voting_power"`
	RankingScore     decimal.Decimal     `json:"ranking_score"`
	TxHash           TxHash              `json:"tx_hash"`
	ZetaTime         time.Time           `json:"zeta_time"`
	EpochSeq         uint64
}

func (*RankingScore) ToProto

func (rs *RankingScore) ToProto() *zeta.RankingScore

type RankingScoreAux

type RankingScoreAux struct {
	NodeID   NodeID
	EpochSeq uint64
}

type Reward

type Reward struct {
	PartyID        PartyID
	AssetID        AssetID
	MarketID       MarketID
	EpochID        int64
	Amount         decimal.Decimal
	PercentOfTotal float64
	RewardType     string
	Timestamp      time.Time
	TxHash         TxHash
	ZetaTime       time.Time
	SeqNum         uint64
}

func RewardFromProto

func RewardFromProto(pr eventspb.RewardPayoutEvent, txHash TxHash, zetaTime time.Time, seqNum uint64) (Reward, error)

func (Reward) Cursor

func (r Reward) Cursor() *Cursor

func (Reward) String

func (r Reward) String() string

func (Reward) ToProto

func (r Reward) ToProto() *zeta.Reward

func (Reward) ToProtoEdge

func (r Reward) ToProtoEdge(_ ...any) (*v2.RewardEdge, error)

type RewardCursor

type RewardCursor struct {
	PartyID string `json:"party_id"`
	AssetID string `json:"asset_id"`
	EpochID int64  `json:"epoch_id"`
}

func (*RewardCursor) Parse

func (rc *RewardCursor) Parse(cursorString string) error

func (RewardCursor) String

func (rc RewardCursor) String() string

type RewardScore

type RewardScore struct {
	RawValidatorScore   decimal.Decimal     `json:"raw_validator_score"`
	PerformanceScore    decimal.Decimal     `json:"performance_score"`
	MultisigScore       decimal.Decimal     `json:"multisig_score"`
	ValidatorScore      decimal.Decimal     `json:"validator_score"`
	NormalisedScore     decimal.Decimal     `json:"normalised_score"`
	ValidatorNodeStatus ValidatorNodeStatus `json:"validator_node_status,string"`
	TxHash              TxHash              `json:"tx_hash"`
	ZetaTime            time.Time           `json:"zeta_time"`
	EpochSeq            uint64
}

func (*RewardScore) ToProto

func (rs *RewardScore) ToProto() *zeta.RewardScore

type RewardScoreAux

type RewardScoreAux struct {
	NodeID   NodeID
	EpochSeq uint64
}

type RewardSummary

type RewardSummary struct {
	PartyID PartyID
	AssetID AssetID
	Amount  decimal.Decimal
}

func (*RewardSummary) ToProto

func (r *RewardSummary) ToProto() *zeta.RewardSummary

type RewardSummaryFilter

type RewardSummaryFilter struct {
	AssetIDs  []AssetID
	MarketIDs []MarketID
	FromEpoch *uint64
	ToEpoch   *uint64
}

RewardSummaryFilter is the filter for the reward summary.

func RewardSummaryFilterFromProto

func RewardSummaryFilterFromProto(pb *v2.RewardSummaryFilter) (filter RewardSummaryFilter)

RewardSummaryFilterFromProto converts a protobuf v2.RewardSummaryFilter to an entities.RewardSummaryFilter.

type RiskFactor

type RiskFactor struct {
	MarketID MarketID
	Short    decimal.Decimal
	Long     decimal.Decimal
	TxHash   TxHash
	ZetaTime time.Time
}

func RiskFactorFromProto

func RiskFactorFromProto(factor *zeta.RiskFactor, txHash TxHash, zetaTime time.Time) (*RiskFactor, error)

func (*RiskFactor) ToProto

func (rf *RiskFactor) ToProto() *zeta.RiskFactor

type Side

type Side = zeta.Side
const (
	// Default value, always invalid.
	SideUnspecified Side = zeta.Side_SIDE_UNSPECIFIED
	// Buy order.
	SideBuy Side = zeta.Side_SIDE_BUY
	// Sell order.
	SideSell Side = zeta.Side_SIDE_SELL
)

type Signer

type Signer []byte

type Signers

type Signers = []Signer

func SerializeSigners

func SerializeSigners(signers []*types.Signer) (Signers, error)

type SpecID

type SpecID = ID[_Spec]

type StakeLinking

type StakeLinking struct {
	ID                 StakeLinkingID
	StakeLinkingType   StakeLinkingType
	EthereumTimestamp  time.Time
	PartyID            PartyID
	Amount             decimal.Decimal
	StakeLinkingStatus StakeLinkingStatus
	FinalizedAt        time.Time
	ForeignTxHash      string
	ForeignBlockHeight int64
	ForeignBlockTime   int64
	LogIndex           int64
	EthereumAddress    string
	TxHash             TxHash
	ZetaTime           time.Time
}

func StakeLinkingFromProto

func StakeLinkingFromProto(stake *eventspb.StakeLinking, txHash TxHash, zetaTime time.Time) (*StakeLinking, error)

func (StakeLinking) Cursor

func (s StakeLinking) Cursor() *Cursor

func (*StakeLinking) ToProto

func (s *StakeLinking) ToProto() *eventspb.StakeLinking

func (StakeLinking) ToProtoEdge

func (s StakeLinking) ToProtoEdge(_ ...any) (*v2.StakeLinkingEdge, error)

type StakeLinkingCursor

type StakeLinkingCursor struct {
	ZetaTime time.Time      `json:"zetaTime"`
	ID       StakeLinkingID `json:"id"`
}

func (*StakeLinkingCursor) Parse

func (s *StakeLinkingCursor) Parse(cursorString string) error

func (StakeLinkingCursor) String

func (s StakeLinkingCursor) String() string

type StakeLinkingID

type StakeLinkingID = ID[_StakeLinking]

type StakeLinkingStatus

type StakeLinkingStatus eventspb.StakeLinking_Status

func (*StakeLinkingStatus) DecodeText

func (s *StakeLinkingStatus) DecodeText(_ *pgtype.ConnInfo, src []byte) error

func (StakeLinkingStatus) EncodeText

func (s StakeLinkingStatus) EncodeText(_ *pgtype.ConnInfo, buf []byte) ([]byte, error)

type StakeLinkingType

type StakeLinkingType eventspb.StakeLinking_Type

func (*StakeLinkingType) DecodeText

func (s *StakeLinkingType) DecodeText(_ *pgtype.ConnInfo, src []byte) error

func (StakeLinkingType) EncodeText

func (s StakeLinkingType) EncodeText(_ *pgtype.ConnInfo, buf []byte) ([]byte, error)

type TargetStakeParameters

type TargetStakeParameters struct {
	TimeWindow     int64   `json:"timeWindow,omitempty"`
	ScalingFactors float64 `json:"scalingFactor,omitempty"`
}

func (TargetStakeParameters) ToProto

type TendermintPublicKey

type TendermintPublicKey string

func (*TendermintPublicKey) Bytes

func (pk *TendermintPublicKey) Bytes() ([]byte, error)

func (*TendermintPublicKey) DecodeBinary

func (pk *TendermintPublicKey) DecodeBinary(ci *pgtype.ConnInfo, src []byte) error

func (TendermintPublicKey) EncodeBinary

func (pk TendermintPublicKey) EncodeBinary(ci *pgtype.ConnInfo, buf []byte) ([]byte, error)

func (*TendermintPublicKey) Error

func (pk *TendermintPublicKey) Error() error

func (*TendermintPublicKey) String

func (pk *TendermintPublicKey) String() string

type TimeUpdateEvent

type TimeUpdateEvent interface {
	events.Event
	Time() time.Time
}

type TradableInstrument

type TradableInstrument struct {
	*zeta.TradableInstrument
}

func (TradableInstrument) MarshalJSON

func (ti TradableInstrument) MarshalJSON() ([]byte, error)

func (TradableInstrument) ToProto

func (*TradableInstrument) UnmarshalJSON

func (ti *TradableInstrument) UnmarshalJSON(data []byte) error

type Trade

type Trade struct {
	SyntheticTime           time.Time
	TxHash                  TxHash
	ZetaTime                time.Time
	SeqNum                  uint64
	ID                      TradeID
	MarketID                MarketID
	Price                   decimal.Decimal
	Size                    uint64
	Buyer                   PartyID
	Seller                  PartyID
	Aggressor               Side
	BuyOrder                OrderID
	SellOrder               OrderID
	Type                    TradeType
	BuyerMakerFee           decimal.Decimal
	BuyerInfrastructureFee  decimal.Decimal
	BuyerLiquidityFee       decimal.Decimal
	SellerMakerFee          decimal.Decimal
	SellerInfrastructureFee decimal.Decimal
	SellerLiquidityFee      decimal.Decimal
	BuyerAuctionBatch       uint64
	SellerAuctionBatch      uint64
}

func TradeFromProto

func TradeFromProto(t *zeta.Trade, txHash TxHash, zetaTime time.Time, sequenceNumber uint64) (*Trade, error)

func (Trade) Cursor

func (t Trade) Cursor() *Cursor

func (Trade) ToProto

func (t Trade) ToProto() *zeta.Trade

func (Trade) ToProtoEdge

func (t Trade) ToProtoEdge(_ ...any) (*v2.TradeEdge, error)

type TradeCursor

type TradeCursor struct {
	SyntheticTime time.Time `json:"synthetic_time"`
}

func (*TradeCursor) Parse

func (c *TradeCursor) Parse(cursorString string) error

func (TradeCursor) String

func (c TradeCursor) String() string

type TradeID

type TradeID = ID[_Trade]

type TradeType

type TradeType = zeta.Trade_Type
const (
	// Default value, always invalid.
	TradeTypeUnspecified TradeType = zeta.Trade_TYPE_UNSPECIFIED
	// Normal trading between two parties.
	TradeTypeDefault TradeType = zeta.Trade_TYPE_DEFAULT
	// Trading initiated by the network with another party on the book,
	// which helps to zero-out the positions of one or more distressed parties.
	TradeTypeNetworkCloseOutGood TradeType = zeta.Trade_TYPE_NETWORK_CLOSE_OUT_GOOD
	// Trading initiated by the network with another party off the book,
	// with a distressed party in order to zero-out the position of the party.
	TradeTypeNetworkCloseOutBad TradeType = zeta.Trade_TYPE_NETWORK_CLOSE_OUT_BAD
)

type Transfer

type Transfer struct {
	ID                  TransferID
	TxHash              TxHash
	ZetaTime            time.Time
	FromAccountID       AccountID
	ToAccountID         AccountID
	AssetID             AssetID
	Amount              decimal.Decimal
	Reference           string
	Status              TransferStatus
	TransferType        TransferType
	DeliverOn           *time.Time
	StartEpoch          *uint64
	EndEpoch            *uint64
	Factor              *decimal.Decimal
	DispatchMetric      *zeta.DispatchMetric
	DispatchMetricAsset *string
	DispatchMarkets     []string
	Reason              *string
}

func TransferFromProto

func TransferFromProto(ctx context.Context, t *eventspb.Transfer, txHash TxHash, zetaTime time.Time, accountSource AccountSource) (*Transfer, error)

func (Transfer) Cursor

func (t Transfer) Cursor() *Cursor

func (*Transfer) ToProto

func (t *Transfer) ToProto(ctx context.Context, accountSource AccountSource) (*eventspb.Transfer, error)

func (Transfer) ToProtoEdge

func (t Transfer) ToProtoEdge(input ...any) (*v2.TransferEdge, error)

type TransferCursor

type TransferCursor struct {
	ZetaTime time.Time  `json:"zetaTime"`
	ID       TransferID `json:"id"`
}

func (*TransferCursor) Parse

func (tc *TransferCursor) Parse(cursorString string) error

func (TransferCursor) String

func (tc TransferCursor) String() string

type TransferID

type TransferID = ID[_Transfer]

type TransferStatus

type TransferStatus eventspb.Transfer_Status

func (*TransferStatus) DecodeText

func (m *TransferStatus) DecodeText(_ *pgtype.ConnInfo, src []byte) error

func (TransferStatus) EncodeText

func (m TransferStatus) EncodeText(_ *pgtype.ConnInfo, buf []byte) ([]byte, error)

type TransferType

type TransferType int
const (
	Unknown TransferType = iota
	OneOff
	Recurring
)

func (*TransferType) DecodeText

func (m *TransferType) DecodeText(_ *pgtype.ConnInfo, src []byte) error

func (TransferType) EncodeText

func (m TransferType) EncodeText(_ *pgtype.ConnInfo, buf []byte) ([]byte, error)

type TxHash

type TxHash string

func (*TxHash) Bytes

func (h *TxHash) Bytes() ([]byte, error)

func (*TxHash) DecodeBinary

func (h *TxHash) DecodeBinary(ci *pgtype.ConnInfo, src []byte) error

func (TxHash) EncodeBinary

func (h TxHash) EncodeBinary(ci *pgtype.ConnInfo, buf []byte) ([]byte, error)

func (*TxHash) Error

func (h *TxHash) Error() error

func (*TxHash) String

func (h *TxHash) String() string

type ValidatorNodeStatus

type ValidatorNodeStatus zeta.ValidatorNodeStatus

func ValidatorNodeStatusFromString

func ValidatorNodeStatusFromString(status string) ValidatorNodeStatus

func (*ValidatorNodeStatus) DecodeText

func (ns *ValidatorNodeStatus) DecodeText(_ *pgtype.ConnInfo, src []byte) error

func (ValidatorNodeStatus) EncodeText

func (ns ValidatorNodeStatus) EncodeText(_ *pgtype.ConnInfo, buf []byte) ([]byte, error)

func (*ValidatorNodeStatus) UnmarshalJSON

func (ns *ValidatorNodeStatus) UnmarshalJSON(src []byte) error

type ValidatorUpdateAux

type ValidatorUpdateAux struct {
	Added           bool
	EpochSeq        uint64
	ZetaPubKeyIndex uint32
	TxHash          TxHash
}

type Vote

type Vote struct {
	PartyID                     PartyID
	ProposalID                  ProposalID
	Value                       VoteValue
	TotalGovernanceTokenBalance decimal.Decimal
	TotalGovernanceTokenWeight  decimal.Decimal
	TotalEquityLikeShareWeight  decimal.Decimal
	InitialTime                 time.Time // First vote for this party/proposal
	TxHash                      TxHash
	ZetaTime                    time.Time // Time of last vote update
}

func VoteFromProto

func VoteFromProto(pv *zeta.Vote, txHash TxHash) (Vote, error)

func (Vote) Cursor

func (v Vote) Cursor() *Cursor

func (Vote) ToProto

func (v Vote) ToProto() *zeta.Vote

func (Vote) ToProtoEdge

func (v Vote) ToProtoEdge(_ ...any) (*v2.VoteEdge, error)

type VoteCursor

type VoteCursor struct {
	PartyID  PartyID   `json:"party_id"`
	ZetaTime time.Time `json:"zeta_time"`
}

func (*VoteCursor) Parse

func (vc *VoteCursor) Parse(cursorString string) error

func (VoteCursor) String

func (vc VoteCursor) String() string

type VoteValue

type VoteValue zeta.Vote_Value

func (*VoteValue) DecodeText

func (s *VoteValue) DecodeText(_ *pgtype.ConnInfo, src []byte) error

func (VoteValue) EncodeText

func (s VoteValue) EncodeText(_ *pgtype.ConnInfo, buf []byte) ([]byte, error)

type WithdrawExt

type WithdrawExt struct {
	*zeta.WithdrawExt
}

func (WithdrawExt) MarshalJSON

func (we WithdrawExt) MarshalJSON() ([]byte, error)

func (*WithdrawExt) UnmarshalJSON

func (we *WithdrawExt) UnmarshalJSON(b []byte) error

type Withdrawal

type Withdrawal struct {
	ID                 WithdrawalID
	PartyID            PartyID
	Amount             decimal.Decimal
	Asset              AssetID
	Status             WithdrawalStatus
	Ref                string
	ForeignTxHash      string
	CreatedTimestamp   time.Time
	WithdrawnTimestamp time.Time
	Ext                WithdrawExt
	TxHash             TxHash
	ZetaTime           time.Time
}

func WithdrawalFromProto

func WithdrawalFromProto(withdrawal *zeta.Withdrawal, txHash TxHash, zetaTime time.Time) (*Withdrawal, error)

func (Withdrawal) Cursor

func (w Withdrawal) Cursor() *Cursor

func (Withdrawal) ToProto

func (w Withdrawal) ToProto() *zeta.Withdrawal

func (Withdrawal) ToProtoEdge

func (w Withdrawal) ToProtoEdge(_ ...any) (*v2.WithdrawalEdge, error)

type WithdrawalCursor

type WithdrawalCursor struct {
	ZetaTime time.Time    `json:"zetaTime"`
	ID       WithdrawalID `json:"id"`
}

func (*WithdrawalCursor) Parse

func (wc *WithdrawalCursor) Parse(cursorString string) error

func (WithdrawalCursor) String

func (wc WithdrawalCursor) String() string

type WithdrawalID

type WithdrawalID = ID[_Withdrawal]

type WithdrawalStatus

type WithdrawalStatus zeta.Withdrawal_Status

func (*WithdrawalStatus) DecodeText

func (s *WithdrawalStatus) DecodeText(_ *pgtype.ConnInfo, src []byte) error

func (WithdrawalStatus) EncodeText

func (s WithdrawalStatus) EncodeText(_ *pgtype.ConnInfo, buf []byte) ([]byte, error)

type ZetaPublicKey

type ZetaPublicKey string

func (*ZetaPublicKey) Bytes

func (pk *ZetaPublicKey) Bytes() ([]byte, error)

func (*ZetaPublicKey) DecodeBinary

func (pk *ZetaPublicKey) DecodeBinary(ci *pgtype.ConnInfo, src []byte) error

func (ZetaPublicKey) EncodeBinary

func (pk ZetaPublicKey) EncodeBinary(ci *pgtype.ConnInfo, buf []byte) ([]byte, error)

func (*ZetaPublicKey) Error

func (pk *ZetaPublicKey) Error() error

func (*ZetaPublicKey) String

func (pk *ZetaPublicKey) String() string

Jump to

Keyboard shortcuts

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