app

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2025 License: GPL-3.0 Imports: 85 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Error codes.
	RelayErrorInvalidOrder         = "INVALID_ORDER"
	RelayErrorMissingSignature     = "MISSING_SIGNATURE"
	RelayErrorUnsupportedChain     = "UNSUPPORTED_CHAIN"
	RelayErrorBackendError         = "BACKEND_ERROR"
	RelayErrorUnsupportedBackend   = "UNSUPPORTED_BACKEND"
	RelayErrorInvalidOriginSettler = "INVALID_ORIGIN_SETTLER"
	RelayErrorInvalidOrderData     = "INVALID_ORDER_DATA"
	RelayErrorSubmissionFailed     = "SUBMISSION_FAILED"

	// Error messages.
	RelayMsgOrderValidationFailed  = "Order validation failed"
	RelayMsgSignatureRequired      = "Signature is required for gasless orders"
	RelayMsgChainNotSupported      = "Chain not supported for relay"
	RelayMsgBackendFailed          = "Failed to get backend for chain"
	RelayMsgEVMOnly                = "Only EVM chains are supported for relay"
	RelayMsgOriginSettlerMismatch  = "Origin settler mismatch"
	RelayMsgDecodeOrderDataFailed  = "Failed to decode order data"
	RelayMsgConvertOrderDataFailed = "Failed to convert order data"
	RelayMsgOrderRejected          = "Order rejected by solver"
	RelayMsgSubmissionFailed       = "Failed to submit gasless order"

	// Error descriptions.
	RelayDescSignatureEmpty    = "The signature field cannot be empty"
	RelayDescChainNotSupported = "The specified origin chain is not supported"
	RelayDescEVMRequired       = "The specified chain does not have EVM support"
)

Relay error codes and messages.

Variables

View Source
var File_solver_app_solver_proto protoreflect.FileDescriptor

Functions

func IsSupportedToken added in v0.15.0

func IsSupportedToken(token tokens.Token) bool

func Run

func Run(ctx context.Context, cfg Config) error

Run starts the solver service.

func WriteConfigTOML

func WriteConfigTOML(cfg Config, logCfg log.Config, path string) error

WriteConfigTOML writes the toml solver config to disk.

Types

type APIError added in v0.14.0

type APIError struct {
	Err        error
	StatusCode int
}

APIError wraps an error with a non-200 HTTP status code.

func (APIError) Error added in v0.14.0

func (e APIError) Error() string

func (APIError) Format added in v0.16.0

func (e APIError) Format(st fmt.State, verb rune)

func (APIError) Unwrap added in v0.16.0

func (e APIError) Unwrap() error

type Config

type Config struct {
	RPCEndpoints    xchain.RPCEndpoints
	Network         netconf.ID
	MonitoringAddr  string
	APIAddr         string
	SolverPrivKey   string
	DBDir           string
	Tracer          tracer.Config
	CoinGeckoAPIKey string
}

func DefaultConfig

func DefaultConfig() Config

type Cursor

type Cursor struct {
	ChainId     uint64 `protobuf:"varint,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"`
	ConfLevel   uint32 `protobuf:"varint,2,opt,name=conf_level,json=confLevel,proto3" json:"conf_level,omitempty"`
	BlockHeight uint64 `protobuf:"varint,3,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"`
	TxSig       []byte `protobuf:"bytes,4,opt,name=tx_sig,json=txSig,proto3" json:"tx_sig,omitempty"` // Replaces block height when streaming solana
	// contains filtered or unexported fields
}

func (*Cursor) Descriptor deprecated

func (*Cursor) Descriptor() ([]byte, []int)

Deprecated: Use Cursor.ProtoReflect.Descriptor instead.

func (*Cursor) GetBlockHeight

func (x *Cursor) GetBlockHeight() uint64

func (*Cursor) GetChainId

func (x *Cursor) GetChainId() uint64

func (*Cursor) GetConfLevel

func (x *Cursor) GetConfLevel() uint32

func (*Cursor) GetTxSig added in v0.16.0

func (x *Cursor) GetTxSig() []byte

func (*Cursor) ProtoMessage

func (*Cursor) ProtoMessage()

func (*Cursor) ProtoReflect

func (x *Cursor) ProtoReflect() protoreflect.Message

func (*Cursor) Reset

func (x *Cursor) Reset()

func (*Cursor) String

func (x *Cursor) String() string

type CursorChainIdConfLevelIndexKey

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

func (CursorChainIdConfLevelIndexKey) WithChainId

func (CursorChainIdConfLevelIndexKey) WithChainIdConfLevel

func (this CursorChainIdConfLevelIndexKey) WithChainIdConfLevel(chain_id uint64, conf_level uint32) CursorChainIdConfLevelIndexKey

type CursorIndexKey

type CursorIndexKey interface {
	// contains filtered or unexported methods
}

type CursorIterator

type CursorIterator struct {
	ormtable.Iterator
}

func (CursorIterator) Value

func (i CursorIterator) Value() (*Cursor, error)

type CursorPrimaryKey

type CursorPrimaryKey = CursorChainIdConfLevelIndexKey

primary key starting index..

type CursorTable

type CursorTable interface {
	Insert(ctx context.Context, cursor *Cursor) error
	Update(ctx context.Context, cursor *Cursor) error
	Save(ctx context.Context, cursor *Cursor) error
	Delete(ctx context.Context, cursor *Cursor) error
	Has(ctx context.Context, chain_id uint64, conf_level uint32) (found bool, err error)
	// Get returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
	Get(ctx context.Context, chain_id uint64, conf_level uint32) (*Cursor, error)
	List(ctx context.Context, prefixKey CursorIndexKey, opts ...ormlist.Option) (CursorIterator, error)
	ListRange(ctx context.Context, from, to CursorIndexKey, opts ...ormlist.Option) (CursorIterator, error)
	DeleteBy(ctx context.Context, prefixKey CursorIndexKey) error
	DeleteRange(ctx context.Context, from, to CursorIndexKey) error
	// contains filtered or unexported methods
}

func NewCursorTable

func NewCursorTable(db ormtable.Schema) (CursorTable, error)

type Event added in v0.16.0

type Event struct {
	OrderID OrderID
	Status  solvernet.OrderStatus
	Height  uint64
	Tx      string
}

Event represents an order status change event emitted from on-chain tx.

type FillOriginData added in v0.13.0

type FillOriginData = solvernet.FillOriginData

type FilledData added in v0.14.0

type FilledData struct {
	MinReceived []bindings.IERC7683Output
}

FilledData contains order data that is only available for filled orders.

type Handler added in v0.14.0

type Handler struct {
	// Endpoint is the http endpoint path.
	Endpoint string
	// ZeroReq returns a zero struct pointer of the request type used for marshaling incoming requests.
	ZeroReq func() any
	// HandleFunc is the function that handles the request and returns a response.
	// The request will be a pointer (same at type returned by ZeroReq).
	// The response must be a struct and optional error.
	HandleFunc func(context.Context, any) (any, error)

	// SkipInstrument skips the handler instrumentation.
	SkipInstrument bool
}

type Order added in v0.13.0

type Order struct {
	ID            OrderID
	Offset        uint64
	SourceChainID uint64
	Status        solvernet.OrderStatus
	UpdatedBy     common.Address
	// contains filtered or unexported fields
}

func (Order) MinReceived added in v0.13.0

func (o Order) MinReceived() ([]bindings.IERC7683Output, error)

func (Order) PendingData added in v0.14.0

func (o Order) PendingData() (PendingData, error)

type OrderID added in v0.13.0

type OrderID = solvernet.OrderID

type OrderResolved added in v0.13.0

type OrderResolved = solvernet.OrderResolved

type OrderState added in v0.13.0

type OrderState = solvernet.OrderState

type PendingData added in v0.14.0

type PendingData struct {
	MinReceived        []bindings.IERC7683Output
	DestinationSettler common.Address
	DestinationChainID uint64
	FillOriginData     []byte
	MaxSpent           []bindings.IERC7683Output
}

PendingData contains order data that is only available for pending orders.

func (PendingData) ParsedFillOriginData added in v0.14.0

func (d PendingData) ParsedFillOriginData() (FillOriginData, error)

type RejectionError added in v0.13.0

type RejectionError struct {
	Reason types.RejectReason // Succinct human-readable reason for rejection.
	Err    error              // Internal detailed reject condition
}

RejectionError implement error, but represents a logical (expected) rejection, not an unexpected system error. We combine rejections with errors for detailed internal structured errors.

func (*RejectionError) Error added in v0.13.0

func (r *RejectionError) Error() string

Error implements error.

type RelayError added in v0.16.0

type RelayError struct {
	Code        string
	Message     string
	Description string
}

RelayError represents a relay submission error with structured error information.

func (RelayError) Error added in v0.16.0

func (e RelayError) Error() string

type SolverStore

type SolverStore interface {
	CursorTable() CursorTable
	// contains filtered or unexported methods
}

func NewSolverStore

func NewSolverStore(db ormtable.Schema) (SolverStore, error)

type SpendBounds added in v0.15.0

type SpendBounds struct {
	MinSpend *big.Int // minimum spend amount
	MaxSpend *big.Int // maximum spend amount
}

func GetSpendBounds added in v0.15.0

func GetSpendBounds(token tokens.Token) (SpendBounds, bool)

func (SpendBounds) DepositBounds added in v0.15.0

func (b SpendBounds) DepositBounds(price types.Price) SpendBounds

DepositBounds returns the equivalent deposit bounds by dividing the spend bounds (expense) by the given price.

type TokenAmt added in v0.14.0

type TokenAmt struct {
	Token  tokens.Token
	Amount *big.Int
}

TokenAmt represents a token and an amount. It differs from types.AddrAmt in that it contains fully resolved token type, not just the token address.

func (TokenAmt) String added in v0.15.0

func (a TokenAmt) String() string

String returns a string representation of the token amount in primary units with the token symbol appended.

Jump to

Keyboard shortcuts

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