bungee

package
v0.16.1 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: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RateLimitPublic = dex.RateLimit{QPS: 5, Burst: 5}

Functions

This section is empty.

Types

type BuildTxOut

type BuildTxOut struct {
	UserOp       string `json:"userOp"`
	ApprovalData struct {
		SpenderAddress string `json:"spenderAddress"`
		Amount         string `json:"amount"`
		TokenAddress   string `json:"tokenAddress"`
		UserAddress    string `json:"userAddress"`
	} `json:"approvalData"`
	TxData struct {
		To    string `json:"to"`
		Data  string `json:"data"`
		Value string `json:"value"`
	} `json:"txData"`
}

type BuildTxResponse

type BuildTxResponse struct {
	Success    bool       `json:"success"`
	StatusCode int        `json:"status_code"`
	Result     BuildTxOut `json:"result"`
}

type Client

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

func NewClient

func NewClient(opts ...ClientOption) *Client

func (*Client) BuildTx

func (*Client) GetSupportedChainIds

func (c *Client) GetSupportedChainIds(ctx context.Context) ([]string, error)

func (*Client) Quote

func (*Client) Status

func (*Client) Submit

func (c *Client) Submit(ctx context.Context, request json.RawMessage, userSignature, requestHash string) (string, error)

Submit posts a signed intent-mode order to Bungee's solver. Used by /trade/execute when the quote returned UserOp="sign" (Permit2-gated assets like Ondo RWA tokens). The submit body is:

{ "request": <signTypedData.message>, "userSignature": "0x..." }

Bungee returns a requestHash that the caller already had from the quote; we round-trip it back as the "tx hash" so /trade/checkTx (which already supports HashType=requestHash for Bungee) can poll settlement status uniformly.

type ClientOption

type ClientOption func(*clientConfig)

func WithRateLimit

func WithRateLimit(r dex.RateLimit) ClientOption

type QuoteOut

type QuoteOut struct {
	OriginChainId      int    `json:"originChainId"`
	DestinationChainId int    `json:"destinationChainId"`
	UserAddress        string `json:"userAddress"`
	ReceiverAddress    string `json:"receiverAddress"`
	Input              struct {
		Token struct {
			ChainId  int    `json:"chainId"`
			Address  string `json:"address"`
			Name     string `json:"name"`
			Symbol   string `json:"symbol"`
			Decimals int    `json:"decimals"`
			LogoURI  string `json:"logoURI"`
			Icon     string `json:"icon"`
		} `json:"token"`
		Amount     string  `json:"amount"`
		PriceInUsd float64 `json:"priceInUsd"`
		ValueInUsd float64 `json:"valueInUsd"`
	} `json:"input"`
	DestinationExec interface{} `json:"destinationExec"`
	AutoRoute       struct {
		UserOp      string `json:"userOp"`
		RequestHash string `json:"requestHash"`
		Output      struct {
			Token struct {
				ChainId  int    `json:"chainId"`
				Address  string `json:"address"`
				Name     string `json:"name"`
				Symbol   string `json:"symbol"`
				Decimals int    `json:"decimals"`
				LogoURI  string `json:"logoURI"`
				Icon     string `json:"icon"`
			} `json:"token"`
			PriceInUsd             float64 `json:"priceInUsd"`
			ValueInUsd             float64 `json:"valueInUsd"`
			MinAmountOut           string  `json:"minAmountOut"`
			Amount                 string  `json:"amount"`
			EffectiveReceivedInUsd float64 `json:"effectiveReceivedInUsd"`
		} `json:"output"`
		RequestType  string `json:"requestType"`
		ApprovalData struct {
			SpenderAddress string `json:"spenderAddress"`
			Amount         string `json:"amount"`
			TokenAddress   string `json:"tokenAddress"`
			UserAddress    string `json:"userAddress"`
		} `json:"approvalData"`
		AffiliateFee  json.RawMessage `json:"affiliateFee"`
		SignTypedData json.RawMessage `json:"signTypedData"`
		GasFee        struct {
			GasToken struct {
				ChainId  int    `json:"chainId"`
				Address  string `json:"address"`
				Name     string `json:"name"`
				Symbol   string `json:"symbol"`
				Decimals int    `json:"decimals"`
				LogoURI  string `json:"logoURI"`
				Icon     string `json:"icon"`
			} `json:"gasToken"`
			GasLimit     string  `json:"gasLimit"`
			GasPrice     string  `json:"gasPrice"`
			EstimatedFee string  `json:"estimatedFee"`
			FeeInUsd     float64 `json:"feeInUsd"`
		} `json:"gasFee"`
		Slippage                float64 `json:"slippage"`
		SuggestedClientSlippage float64 `json:"suggestedClientSlippage"`
		// txData.data is polymorphic: a hex-string for EVM-origin
		// routes (the calldata FE signs as a regular tx) and an
		// object {instructions, lookupTables, signers} for SOL-origin
		// routes (Solana versioned-tx ingredients FE assembles +
		// signs). Hold the raw form here; toStandardQuoteRes decides
		// how to expose it.
		TxData struct {
			To      string          `json:"to"`
			Data    json.RawMessage `json:"data"`
			Value   string          `json:"value"`
			ChainId int             `json:"chainId"`
			Type    string          `json:"type"` // "solana" for SOL-origin, empty for EVM
		} `json:"txData"`
		EstimatedTime int `json:"estimatedTime"`
		RouteDetails  struct {
			Name       string      `json:"name"`
			LogoURI    string      `json:"logoURI"`
			RouteFee   interface{} `json:"routeFee"`
			DexDetails interface{} `json:"dexDetails"`
		} `json:"routeDetails"`
		Refuel      interface{} `json:"refuel"`
		QuoteId     string      `json:"quoteId"`
		QuoteExpiry int         `json:"quoteExpiry"`
	} `json:"autoRoute"`
	ManualRoutes []struct {
		QuoteId     string `json:"quoteId"`
		QuoteExpiry int    `json:"quoteExpiry"`
		Output      struct {
			Token struct {
				ChainId  int    `json:"chainId"`
				Address  string `json:"address"`
				Name     string `json:"name"`
				Symbol   string `json:"symbol"`
				Decimals int    `json:"decimals"`
				LogoURI  string `json:"logoURI"`
				Icon     string `json:"icon"`
			} `json:"token"`
			Amount                 string  `json:"amount"`
			PriceInUsd             float64 `json:"priceInUsd"`
			ValueInUsd             float64 `json:"valueInUsd"`
			MinAmountOut           string  `json:"minAmountOut"`
			EffectiveReceivedInUsd float64 `json:"effectiveReceivedInUsd"`
		} `json:"output"`
		AffiliateFee interface{} `json:"affiliateFee"`
		ApprovalData struct {
			SpenderAddress string `json:"spenderAddress"`
			Amount         string `json:"amount"`
			TokenAddress   string `json:"tokenAddress"`
			UserAddress    string `json:"userAddress"`
		} `json:"approvalData"`
		GasFee struct {
			GasToken struct {
				ChainId         int         `json:"chainId"`
				Address         string      `json:"address"`
				Symbol          string      `json:"symbol"`
				Name            string      `json:"name"`
				Decimals        int         `json:"decimals"`
				Icon            string      `json:"icon"`
				LogoURI         string      `json:"logoURI"`
				ChainAgnosticId interface{} `json:"chainAgnosticId"`
			} `json:"gasToken"`
			GasLimit     string  `json:"gasLimit"`
			GasPrice     string  `json:"gasPrice"`
			EstimatedFee string  `json:"estimatedFee"`
			FeeInUsd     float64 `json:"feeInUsd"`
		} `json:"gasFee"`
		Slippage      float64 `json:"slippage"`
		EstimatedTime int     `json:"estimatedTime"`
		RouteDetails  struct {
			Name     string `json:"name"`
			LogoURI  string `json:"logoURI"`
			RouteFee struct {
				Token struct {
					ChainId         int         `json:"chainId"`
					Address         string      `json:"address"`
					Symbol          string      `json:"symbol"`
					Name            string      `json:"name"`
					Decimals        int         `json:"decimals"`
					Icon            string      `json:"icon"`
					LogoURI         string      `json:"logoURI"`
					ChainAgnosticId interface{} `json:"chainAgnosticId"`
				} `json:"token"`
				Amount     string  `json:"amount"`
				FeeInUsd   float64 `json:"feeInUsd"`
				PriceInUsd float64 `json:"priceInUsd"`
			} `json:"routeFee"`
			DexDetails struct {
				Protocol struct {
					Name        string `json:"name"`
					Icon        string `json:"icon"`
					DisplayName string `json:"displayName"`
				} `json:"protocol"`
				MinAmountOut       string  `json:"minAmountOut"`
				OutputTokenAddress string  `json:"outputTokenAddress"`
				InputTokenAddress  string  `json:"inputTokenAddress"`
				AmountOut          string  `json:"amountOut"`
				Slippage           float64 `json:"slippage"`
			} `json:"dexDetails"`
		} `json:"routeDetails"`
		Refuel interface{} `json:"refuel"`
	} `json:"manualRoutes"`
}

type QuoteRequest

type QuoteRequest struct {
	OriginChainId      string
	DestinationChainId string
	InputToken         string
	OutputToken        string
	UserAddress        string
	ReceiverAddress    string
	FeeTakerAddress    string
	FeeBps             string
	InputAmount        string
	Slippage           string
	EnableManual       bool
	UseInbox           bool
	ExcludeBridges     string
	ExcludeDexes       string
}

type QuoteResponse

type QuoteResponse struct {
	Success    bool     `json:"success"`
	StatusCode int      `json:"status_code"`
	Result     QuoteOut `json:"result"`
}

type RequestStatusOut

type RequestStatusOut struct {
	Hash       string `json:"hash"`
	OriginData struct {
		Input []struct {
			Token struct {
				ChainId  int    `json:"chainId"`
				Address  string `json:"address"`
				Name     string `json:"name"`
				Symbol   string `json:"symbol"`
				Decimals int    `json:"decimals"`
				LogoURI  string `json:"logoURI"`
				Icon     string `json:"icon"`
			} `json:"token"`
			Amount     string  `json:"amount"`
			PriceInUsd float64 `json:"priceInUsd"`
			ValueInUsd float64 `json:"valueInUsd"`
		} `json:"input"`
		OriginChainId int    `json:"originChainId"`
		TxHash        string `json:"txHash"`
		Status        string `json:"status"`
		UserAddress   string `json:"userAddress"`
		Timestamp     int64  `json:"timestamp"`
	} `json:"originData"`
	DestinationData struct {
		Output []struct {
			Token struct {
				ChainId  int    `json:"chainId"`
				Address  string `json:"address"`
				Name     string `json:"name"`
				Symbol   string `json:"symbol"`
				Decimals int    `json:"decimals"`
				LogoURI  string `json:"logoURI"`
				Icon     string `json:"icon"`
			} `json:"token"`
			Amount       string  `json:"amount"`
			MinAmountOut string  `json:"minAmountOut"`
			PriceInUsd   float64 `json:"priceInUsd"`
			ValueInUsd   float64 `json:"valueInUsd"`
		} `json:"output"`
		TxHash             string `json:"txHash"`
		DestinationChainId int    `json:"destinationChainId"`
		ReceiverAddress    string `json:"receiverAddress"`
		Status             string `json:"status"`
		Timestamp          int64  `json:"timestamp"`
	} `json:"destinationData"`
	RouteDetails struct {
		Name    string `json:"name"`
		LogoURI string `json:"logoURI"`
	} `json:"routeDetails"`
	BungeeStatusCode int `json:"bungeeStatusCode"`
	Refund           struct {
		ChainId int    `json:"chainId"`
		TxHash  string `json:"txHash"`
	} `json:"refund"`
}

type RequestStatusResponse

type RequestStatusResponse struct {
	Success    bool               `json:"success"`
	StatusCode int                `json:"status_code"`
	Result     []RequestStatusOut `json:"result"`
}

type SubmitResponse

type SubmitResponse struct {
	Success    bool   `json:"success"`
	StatusCode int    `json:"statusCode"`
	Message    string `json:"message,omitempty"`
	Result     struct {
		RequestHash string `json:"requestHash"`
	} `json:"result"`
}

SubmitResponse is the Bungee /bungee/submit response. The solver echoes back the requestHash on success, plus a status code and error message when rejected.

type SupportedChainsOutItem

type SupportedChainsOutItem struct {
	ChainId  int64  `json:"chainId"`
	Name     string `json:"name"`
	Icon     string `json:"icon"`
	Currency struct {
		Address                 string `json:"address"`
		Icon                    string `json:"icon"`
		Name                    string `json:"name"`
		Symbol                  string `json:"symbol"`
		Decimals                int    `json:"decimals"`
		MinNativeCurrencyForGas string `json:"minNativeCurrencyForGas"`
	} `json:"currency"`
	Explorers        []string `json:"explorers"`
	SendingEnabled   bool     `json:"sendingEnabled"`
	ReceivingEnabled bool     `json:"receivingEnabled"`
	IsAutoEnabled    bool     `json:"isAutoEnabled"`
	IsManualEnabled  bool     `json:"isManualEnabled"`
	Dexes            []string `json:"dexes"`
	Bridges          []string `json:"bridges"`
}

type SupportedChainsResponse

type SupportedChainsResponse struct {
	Success    bool                     `json:"success"`
	StatusCode int                      `json:"status_code"`
	Result     []SupportedChainsOutItem `json:"result"`
}

Jump to

Keyboard shortcuts

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