dexmodel

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package dexmodel is the wire-shape types shared by every DEX aggregator client in thirdparty/dex/*. Kept separate from the clients themselves so a consumer that only needs the types (e.g. a service composing quotes it received from a dex client) doesn't pull the client packages transitively.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DexApproval

type DexApproval struct {
	Token   string `json:"token"`
	Spender string `json:"spender"`
	Amount  string `json:"amount"`
}

type DexBuildTxIn

type DexBuildTxIn struct {
	Channel string `json:"channel"`
	RouteId string `json:"routeId"`
}

type DexBuildTxOut

type DexBuildTxOut struct {
	UserOp       string       `json:"userOp,omitempty"`
	TxData       *DexTx       `json:"txData"`
	ApprovalData *DexApproval `json:"approvalData,omitempty"`
}

type DexCheckTxIn

type DexCheckTxIn struct {
	Channel   string      `json:"channel"`
	HashType  DexHashType `json:"hashType"`
	Hash      string      `json:"hash"`
	FromChain string      `json:"fromChain"`
	ToChain   string      `json:"toChain"`
	Bridge    string      `json:"bridge,omitempty"`
}

type DexCheckTxOut

type DexCheckTxOut struct {
	Channel string    `json:"channel"`
	Status  DexStatus `json:"status"`
	ToChain string    `json:"toChain"`
	ToHash  string    `json:"toHash"`
	Msg     string    `json:"msg,omitempty"`
}

type DexHashType

type DexHashType string
const (
	DexHashTypeTxHash      DexHashType = "txHash"
	DexHashTypeRequestHash DexHashType = "requestHash"
)

func (DexHashType) IsValid

func (h DexHashType) IsValid() bool

func (DexHashType) String

func (h DexHashType) String() string

type DexQuoteIn

type DexQuoteIn struct {
	FromChain    string `json:"fromChain"`
	ToChain      string `json:"toChain"`
	FromToken    string `json:"fromToken"`
	ToToken      string `json:"toToken"`
	FromAddress  string `json:"fromAddress"`
	ToAddress    string `json:"toAddress"`
	FromAmount   string `json:"fromAmount"`
	Slippage     string `json:"slippage"`
	FeeRate      string `json:"feeRate,omitempty"`
	FeeReceiver  string `json:"feeReceiver,omitempty"`
	FromValueUsd string `json:"fromValueUsd,omitempty"`
	// GasOnDestination is the amount of fromToken (in smallest unit) to
	// be auto-swapped for destination-chain native gas during the
	// bridge. Cross-chain only; empty or "0" disables. Setting it
	// forces the LiFi channel since Bungee's unified API doesn't
	// expose a refuel knob.
	GasOnDestination string `json:"gasOnDestination,omitempty"`
}

type DexQuoteOut

type DexQuoteOut struct {
	Channel string      `json:"channel"`
	Routes  []*DexRoute `json:"routes"`
}

type DexRoute

type DexRoute struct {
	RouteId           string  `json:"routeId"`
	RequestHash       string  `json:"requestHash,omitempty"`
	Name              string  `json:"name"`
	AmountOut         string  `json:"amountOut"`
	AmountOutMin      string  `json:"amountOutMin"`
	Slippage          float64 `json:"slippage,omitempty"`
	SuggestedSlippage float64 `json:"suggestedSlippage"`
	FeeInUsd          string  `json:"feeInUsd"`
	EstimatedTime     int64   `json:"estimatedTime"`
	NeedBuild         bool    `json:"needBuild"`
	// Gasless is true when the route is a Jupiter Ultra RFQ ("jupiterz")
	// quote: the MM has already taken the fee-payer slot, so the
	// frontend only signs the user slot and submits via /trade/execute
	// with the matching RequestId.
	Gasless      bool         `json:"gasless,omitempty"`
	RequestId    string       `json:"requestId,omitempty"`
	TxData       *DexTx       `json:"txData,omitempty"`
	ApprovalData *DexApproval `json:"approvalData,omitempty"`
	// UserOp picks the FE signing path for this route.
	//   "tx"   → FE signs a regular transaction from TxData
	//   "sign" → FE signs the EIP-712 typed-data in SignTypedData and
	//            passes the signature back so the backend can forward
	//            it to the aggregator's intent-solver submit endpoint
	//            (Bungee Permit2 flow for Ondo RWA tokens etc.).
	UserOp string `json:"userOp,omitempty"`
	// SignTypedData is the raw EIP-712 message FE feeds into
	// eth_signTypedData_v4 when UserOp == "sign". Pass-through from
	// the upstream channel.
	SignTypedData json.RawMessage `json:"signTypedData,omitempty"`
	// SubmitRequest is the JSON-serialized "request" object the FE
	// must echo back alongside the signature so the caller can
	// forward both to the aggregator's submit endpoint.
	SubmitRequest json.RawMessage `json:"submitRequest,omitempty"`
	// TrustedSpenders is every EVM contract this route will ask the
	// user to sign for — both approve targets (ApprovalData.Spender,
	// usually Permit2) and permit targets (the spender field inside
	// SignTypedData.message on Bungee intent-mode routes, the
	// aggregator's approvalAddress on LiFi, etc.). Server-vouched:
	// FE must reject any signature whose actual spender isn't in
	// this list. Empty means "no EVM signatures needed" (Solana
	// channels: jupiter*, and any pure-broadcast path).
	TrustedSpenders []string `json:"trustedSpenders,omitempty"`
	// PriceImpactPct is the aggregator-reported price impact for
	// this route as a percent (0.15 = 0.15%, 99.99 = catastrophic).
	// Jupiter passes it through directly; Bungee / LiFi don't emit
	// a comparable field so this stays 0 there — treat 0 as
	// "unknown" not "no impact".
	PriceImpactPct float64 `json:"priceImpactPct,omitempty"`
	// Warnings surface non-fatal concerns the caller should show
	// before the user confirms the trade. Codes are UPPER_SNAKE
	// tokens that FE can key i18n off; the message field is a
	// human-readable fallback.
	Warnings []DexWarning `json:"warnings,omitempty"`
}

type DexStatus

type DexStatus string
const (
	DexStatusPending   DexStatus = "Pending"
	DexStatusSucceeded DexStatus = "Succeeded"
	DexStatusRefunded  DexStatus = "Refunded"
	DexStatusFailed    DexStatus = "Failed"
	// DexStatusNotFound means the upstream (Bungee / LiFi / etc.) has
	// no record of this hash. It is NOT the same as Pending — the
	// aggregator answered a definitive "I've never heard of it",
	// usually because the /execute call 502'd or timed out and the
	// solver never accepted the request. Callers MUST stop polling
	// on NotFound and surface a "not submitted, safe to retry" error;
	// treating it as Pending could deceive a user into re-submitting
	// a real in-flight trade.
	DexStatusNotFound DexStatus = "NotFound"
)

func (DexStatus) String

func (h DexStatus) String() string

type DexTx

type DexTx struct {
	To       string `json:"to,omitempty"`
	Data     string `json:"data,omitempty"`
	Value    string `json:"value,omitempty"`
	GasPrice string `json:"gasPrice,omitempty"`
	GasLimit string `json:"gasLimit,omitempty"`
}

type DexWarning

type DexWarning struct {
	Code    string `json:"code"`    // UPPER_SNAKE — "PRICE_IMPACT_HIGH", "MIN_OUT_ZERO", …
	Message string `json:"message"` // human-readable diagnostic
}

DexWarning is one row surfaced on a route the user might sign.

Jump to

Keyboard shortcuts

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