Completed clean root directory structure: - Root now contains only: .git, .env, docs/, orig/ - Moved all remaining files and directories to orig/: - Config files (.claude, .dockerignore, .drone.yml, etc.) - All .env variants (except active .env) - Git config (.gitconfig, .github, .gitignore, etc.) - Tool configs (.golangci.yml, .revive.toml, etc.) - Documentation (*.md files, @prompts) - Build files (Dockerfiles, Makefile, go.mod, go.sum) - Docker compose files - All source directories (scripts, tests, tools, etc.) - Runtime directories (logs, monitoring, reports) - Dependency files (node_modules, lib, cache) - Special files (--delete) - Removed empty runtime directories (bin/, data/) V2 structure is now clean: - docs/planning/ - V2 planning documents - orig/ - Complete V1 codebase preserved - .env - Active environment config (not in git) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
76 lines
2.3 KiB
Go
76 lines
2.3 KiB
Go
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
|
|
}
|