loader

package
v0.0.0-...-7abe34b Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const MULTICALL_TIMEOUT_MS = 5000
View Source
const SUBGRAPH_RETRY_SECS = 5

Variables

This section is empty.

Functions

func LatestSubgraphBlock

func LatestSubgraphBlock(cfg SyncChannelConfig) (int, error)

Types

type Call3InputType

type Call3InputType struct {
	Target       common.Address
	AllowFailure bool
	CallData     []byte
}

type Call3OutputType

type Call3OutputType struct {
	Success    bool
	ReturnData []uint8
}

type CallJob

type CallJob struct {
	Contract types.EthAddress
	CallData []byte
	Result   chan []byte
}

type ChainConfig

type ChainConfig struct {
	NetworkName         string
	ChainID             int    `json:"chain_id"`
	RPCEndpoint         string `json:"rpc"`
	Subgraph            string `json:"subgraph"`
	QueryContract       string `json:"query_contract"`
	QueryContractABI    string `json:"query_contract_abi"`
	KnockoutTickWidth   int    `json:"knockout_tick_width"`
	MulticallDisabled   bool   `json:"multicall_disabled"`
	MulticallContract   string `json:"multicall_contract"`
	MulticallMaxBatch   int    `json:"multicall_max_batch"`
	MulticallIntervalMs int    `json:"multicall_interval_ms"`
}

func (*ChainConfig) HexChainID

func (c *ChainConfig) HexChainID() types.ChainId

type CombinedData

type CombinedData struct {
	Meta  combinedEntry   `json:"_meta"`
	Swaps json.RawMessage `json:"swaps"`
	Aggs  json.RawMessage `json:"aggEvents"`
	Liqs  json.RawMessage `json:"liquidityChanges"`
	Kos   json.RawMessage `json:"knockoutCrosses"`
	Fees  json.RawMessage `json:"feeChanges"`
	Bals  json.RawMessage `json:"userBalances"`
}

func CombinedQuery

func CombinedQuery(cfg SyncChannelConfig, minBlocks SubgraphStartBlocks, maxBlock int) (metaBlock int, combinedData *CombinedData, err error)

type CombinedGraphReqVars

type CombinedGraphReqVars struct {
	Order             string `json:"orderDir"`
	SwapMinBlock      int    `json:"swapMinBlock"`
	SwapMaxBlock      int    `json:"swapMaxBlock"`
	LiquidityMinBlock int    `json:"liqMinBlock"`
	LiquidityMaxBlock int    `json:"liqMaxBlock"`
	AggMinBlock       int    `json:"aggMinBlock"`
	AggMaxBlock       int    `json:"aggMaxBlock"`
	BalMinBlock       int    `json:"balMinBlock"`
	BalMaxBlock       int    `json:"balMaxBlock"`
	FeeMinBlock       int    `json:"feeMinBlock"`
	FeeMaxBlock       int    `json:"feeMaxBlock"`
	KoMinBlock        int    `json:"koMinBlock"`
	KoMaxBlock        int    `json:"koMaxBlock"`
}

type CrocQuery

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

func NewCrocQuery

func NewCrocQuery(chain *OnChainLoader) *CrocQuery

func (*CrocQuery) QueryAmbientLiq

func (q *CrocQuery) QueryAmbientLiq(pos types.PositionLocation) (*big.Int, error)

func (*CrocQuery) QueryKnockoutLiq

func (q *CrocQuery) QueryKnockoutLiq(pos types.KOClaimLocation) (resp KnockoutLiqResp, err error)

func (*CrocQuery) QueryKnockoutPivot

func (q *CrocQuery) QueryKnockoutPivot(pos types.PositionLocation) (uint32, error)

func (*CrocQuery) QueryLevel

func (q *CrocQuery) QueryLevel(pool types.PoolLocation, tick int) (result LevelResp, err error)

func (*CrocQuery) QueryPoolPrice

func (q *CrocQuery) QueryPoolPrice(pool types.PoolLocation, blockNumber *big.Int) (price float64, err error)

func (*CrocQuery) QueryRangeLiquidity

func (q *CrocQuery) QueryRangeLiquidity(pos types.PositionLocation) (*big.Int, error)

func (*CrocQuery) QueryRangeRewardsLiq

func (q *CrocQuery) QueryRangeRewardsLiq(pos types.PositionLocation) (*big.Int, error)

type GraphReqVars

type GraphReqVars struct {
	Order   string `json:"orderDir"`
	MinTime int    `json:"minTime"`
	MaxTime int    `json:"maxTime"`
}

type GraphRequest

type GraphRequest[V GraphReqVars | CombinedGraphReqVars] struct {
	Query     SubgraphQuery `json:"query"`
	Variables V             `json:"variables"`
}

type ICrocQuery

type ICrocQuery interface {
	QueryAmbientLiq(pos types.PositionLocation) (*big.Int, error)
	QueryRangeLiquidity(pos types.PositionLocation) (*big.Int, error)
	QueryRangeRewardsLiq(pos types.PositionLocation) (*big.Int, error)
	QueryKnockoutLiq(pos types.KOClaimLocation) (KnockoutLiqResp, error)
	QueryKnockoutPivot(pos types.PositionLocation) (uint32, error)
	QueryLevel(pool types.PoolLocation, tick int) (LevelResp, error)
}

type Ingester

type Ingester interface {
	IngestEntries(data []byte, queryStartBlock, queryEndBlock int) (lastObs int, hasMore bool, err error)
}

type KnockoutLiqResp

type KnockoutLiqResp struct {
	Liq        *big.Int
	KnockedOut bool
}

type LevelResp

type LevelResp struct {
	BidLots     *big.Int
	AskLots     *big.Int
	FeeOdometer uint64
}

type NetworkConfig

type NetworkConfig map[types.NetworkName]ChainConfig

func LoadNetworkConfig

func LoadNetworkConfig(path string) NetworkConfig

func (*NetworkConfig) ChainConfig

func (c *NetworkConfig) ChainConfig(chainId types.ChainId) (ChainConfig, bool)

func (*NetworkConfig) ChainIDForNetwork

func (c *NetworkConfig) ChainIDForNetwork(network types.NetworkName) (types.ChainId, bool)

func (*NetworkConfig) NetworkForChainID

func (c *NetworkConfig) NetworkForChainID(chainId types.ChainId) (types.NetworkName, bool)

func (*NetworkConfig) RequireChainID

func (c *NetworkConfig) RequireChainID(network types.NetworkName) types.ChainId

type NonCrocQuery

type NonCrocQuery struct{}

func (*NonCrocQuery) QueryAmbientLiq

func (q *NonCrocQuery) QueryAmbientLiq(pos types.PositionLocation) (*big.Int, error)

func (*NonCrocQuery) QueryKnockoutLiq

func (q *NonCrocQuery) QueryKnockoutLiq(pos types.KOClaimLocation) (KnockoutLiqResp, error)

func (*NonCrocQuery) QueryKnockoutPivot

func (q *NonCrocQuery) QueryKnockoutPivot(pos types.PositionLocation) (uint32, error)

func (*NonCrocQuery) QueryLevel

func (q *NonCrocQuery) QueryLevel(pool types.PoolLocation, tick int) (LevelResp, error)

func (*NonCrocQuery) QueryRangeLiquidity

func (q *NonCrocQuery) QueryRangeLiquidity(pos types.PositionLocation) (*big.Int, error)

func (*NonCrocQuery) QueryRangeRewardsLiq

func (q *NonCrocQuery) QueryRangeRewardsLiq(pos types.PositionLocation) (*big.Int, error)

type OnChainLoader

type OnChainLoader struct {
	Cfg NetworkConfig
	// contains filtered or unexported fields
}

func NewOnChainLoader

func NewOnChainLoader(cfg NetworkConfig) *OnChainLoader

type SubgraphError

type SubgraphError struct {
	Errors []struct {
		Message string `json:"message"`
	} `json:"errors"`
	Data json.RawMessage `json:"data"`
}

type SubgraphQuery

type SubgraphQuery string

type SubgraphStartBlocks

type SubgraphStartBlocks struct {
	Swaps int `json:"swap"`
	Aggs  int `json:"agg"`
	Bal   int `json:"bal"`
	Fee   int `json:"fee"`
	Ko    int `json:"ko"`
	Liq   int `json:"liq"`
}

type SyncChannel

type SyncChannel[R any, S any] struct {
	RowsIngested int
	// contains filtered or unexported fields
}

func NewSyncChannel

func NewSyncChannel[R any, S any](tbl tables.ITable[R, S], config SyncChannelConfig,
	consumeFn func(R)) SyncChannel[R, S]

func (*SyncChannel[R, S]) IngestEntries

func (s *SyncChannel[R, S]) IngestEntries(data []byte, queryStartBlock, queryEndBlock int) (lastObs int, hasMore bool, err error)

func (*SyncChannel[R, S]) SyncTableToSubgraph

func (s *SyncChannel[R, S]) SyncTableToSubgraph(startBlock int, endBlock int) (int, error)

func (*SyncChannel[R, S]) SyncTableToSubgraphWG

func (s *SyncChannel[R, S]) SyncTableToSubgraphWG(startBlock int, endBlock int, wg *sync.WaitGroup) (int, error)

type SyncChannelConfig

type SyncChannelConfig struct {
	Chain   ChainConfig
	Network types.NetworkName
	Query   string
}

Jump to

Keyboard shortcuts

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