package models import "fmt" // DecimalValue represents a quantity with explicit decimals. type DecimalValue struct { Value string `json:"value"` Decimals uint8 `json:"decimals"` Symbol string `json:"symbol"` } func (d DecimalValue) Validate() error { if d.Value == "" { return fmt.Errorf("decimal value missing raw value") } return nil } // Token describes basic token metadata used by the pricing engine. type Token struct { Address string `json:"address,omitempty"` Symbol string `json:"symbol"` Decimals uint8 `json:"decimals"` } // Pool encapsulates the static parameters needed to price a pool. type Pool struct { Address string `json:"address"` Exchange string `json:"exchange"` Token0 Token `json:"token0"` Token1 Token `json:"token1"` Reserve0 DecimalValue `json:"reserve0"` Reserve1 DecimalValue `json:"reserve1"` Fee *DecimalValue `json:"fee,omitempty"` SqrtPriceX96 string `json:"sqrt_price_x96,omitempty"` Tick string `json:"tick,omitempty"` Liquidity string `json:"liquidity,omitempty"` Amplification string `json:"amplification,omitempty"` Weights []DecimalValue `json:"weights,omitempty"` } // TestCase defines an assertion to run against a pool. type TestCase struct { Name string `json:"name"` Type string `json:"type"` InputToken string `json:"input_token,omitempty"` OutputToken string `json:"output_token,omitempty"` AmountIn *DecimalValue `json:"amount_in,omitempty"` AmountOut *DecimalValue `json:"amount_out,omitempty"` Expected DecimalValue `json:"expected"` ToleranceBPS float64 `json:"tolerance_bps"` } // Vector bundles a pool with the checks that should hold true. type Vector struct { Name string `json:"name"` Description string `json:"description"` Pool Pool `json:"pool"` Tests []TestCase `json:"tests"` } func (v Vector) Validate() error { if v.Name == "" { return fmt.Errorf("vector missing name") } if v.Pool.Exchange == "" { return fmt.Errorf("vector %s missing exchange type", v.Name) } for _, t := range v.Tests { if t.Expected.Value == "" { return fmt.Errorf("vector %s test %s missing expected value", v.Name, t.Name) } } return nil }