Documentation
¶
Overview ¶
Package gas provides LiquidLane route gas prediction and Chainlink-backed gas conversion facts.
It is intentionally limited to LiquidLane adapter swap accounting: callers provide expected swap demands plus a compact adapter liquidity snapshot, and the package returns route labels and route gas units. Solver-specific settlement and payload overhead, auction/executor gas limits, price updates, bids, and economics stay outside.
Index ¶
- func RouteUnits(routes []Route) uint64
- func RoutesString(routes []Route) string
- func UnitsForRouteAt(route Route, first bool) uint64
- type AdapterDemand
- type AdapterState
- type Demand
- type OracleConfig
- type OracleReader
- type Prediction
- type PriceSnapshot
- type RawConfig
- type RawTokenFeed
- type Route
- type Snapshot
- type State
- type Token
- type USDFeed
- type VaultState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RouteUnits ¶
func RoutesString ¶
func UnitsForRouteAt ¶
Types ¶
type AdapterDemand ¶
AdapterDemand is one expected swap output scoped to its LiquidLane adapter and shared vault.
type AdapterState ¶
type AdapterState struct {
Vault common.Address `json:"vault"`
Acquire map[common.Address]*big.Int `json:"acquire"`
}
AdapterState contains liquidity owned by one adapter.
type OracleConfig ¶
func ParseConfig ¶
func ParseConfig(raw RawConfig) (OracleConfig, error)
ParseConfig validates the shared gas YAML without changing its gas.* field paths.
type OracleReader ¶
type OracleReader struct {
// contains filtered or unexported fields
}
func NewOracleReader ¶
func NewOracleReader(c multicaller, cfg OracleConfig) (*OracleReader, error)
func (*OracleReader) Read ¶
func (r *OracleReader) Read(ctx context.Context, tokens []Token) (*PriceSnapshot, error)
Read validates prices against the block timestamp returned in the same latest-state batch.
func (*OracleReader) Validate ¶
func (r *OracleReader) Validate(ctx context.Context, tokens []Token) error
Validate checks configured tokens and the timed Multicall3 surface before quoting starts.
func (*OracleReader) ValidateTokens ¶
func (r *OracleReader) ValidateTokens(tokens []Token) error
type Prediction ¶
func Predict ¶
func Predict(demands []Demand, st *State) Prediction
Predict returns LiquidLane adapter route gas for the demands in order.
func PredictAdapters ¶
func PredictAdapters(demands []AdapterDemand, snapshot *Snapshot) Prediction
PredictAdapters predicts swap routes for a multi-adapter transaction. Acquire balances are consumed per adapter while free and withdrawable liquidity is consumed once across adapters sharing a vault.
type PriceSnapshot ¶
type PriceSnapshot struct {
// BlockTime is the timestamp returned alongside prices in the same latest-state batch.
BlockTime time.Time
// contains filtered or unexported fields
}
func NewPriceSnapshot ¶
func NewPriceSnapshot(rates map[common.Address]*big.Int) *PriceSnapshot
func (*PriceSnapshot) MarshalJSON ¶
func (s *PriceSnapshot) MarshalJSON() ([]byte, error)
func (*PriceSnapshot) TokenOutPerNative ¶
func (s *PriceSnapshot) TokenOutPerNative(token common.Address) *big.Int
type RawConfig ¶
type RawConfig struct {
NativeUSDFeed string `yaml:"nativeUsdFeed"`
NativeMaxAge string `yaml:"nativeMaxAge"`
TokenUSDFeeds []RawTokenFeed `yaml:"tokenUsdFeeds"`
}
RawConfig is the shared YAML representation of LiquidLane gas oracle configuration.
type RawTokenFeed ¶
type Route ¶
type Route uint8
Route describes the LiquidLane adapter path a swap is expected to take.
func PredictRoutes ¶
PredictRoutes estimates the adapter route for each demand in order.
type Snapshot ¶
type Snapshot struct {
Adapters map[common.Address]*AdapterState `json:"adapters"`
Vaults map[common.Address]*VaultState `json:"vaults"`
}
Snapshot separates adapter-local acquire balances from shared vault liquidity.
func WithReserveBps ¶
WithReserveBps returns a conservative copy of snapshot with every mutable liquidity budget reduced.