requests

package
v0.1.0-alpha Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package requests implements methods for sending HTTP requests to Gladius server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetGladiusOrders

func GetGladiusOrders(req *OrdersGET) (*glo.GladiusOrdersJSON, error)

Returns decoded response from the server.

func GetResolvedGladiusOrders

func GetResolvedGladiusOrders(req *OrdersGET, feeOpts *binds.BindOpts) ([]*contracts.ResolvedOrder, error)

Gets gladius orders from the server and resolves them.

Types

type OrderStatus

type OrderStatus string
const (
	OPEN    OrderStatus = "open"
	EXPIRED OrderStatus = "expired"
	FILLED  OrderStatus = "filled"
)

type OrdersGET

type OrdersGET struct {
	// If empty URL from constants will be used.
	GladiusUrl string
	Status     OrderStatus
	Options    *OrdersOpts
}

A representation of a query-string for a GET request to the '/orders' endpoint.

func (*OrdersGET) ToUrl

func (req *OrdersGET) ToUrl() (url string)

Builds a query-string for a GET '/orders' request.

type OrdersOpts

type OrdersOpts struct {
	ChainID int

	SellToken string
	BuyToken  string

	// Querying with both 'swapper' and 'chainId'
	// is not currently supported.
	// Therefore, if 'swapper' is set 'chainID' will be omitted.
	// TODO: throw error in such case.
	Swapper string

	// A maximum number of orders to return.
	Limit int

	// Return orders with sepcific hashes.
	// If one of the hashes in a slice is invalid,
	// then only orders woth valid hashes will be returned.
	OrderHashes []string

	SortKeys *SortKeys

	// *Optional* API key
	GladiusAuthKey string
}

Optional query params that can be used to specify criterias of order's search more accurately. There are server rules that don't allow certain fields to be presented with other specific fields or without other fields: TODO: implement validation of these rules (?)

type RawOrders

type RawOrders []byte

func GetRawOrders

func GetRawOrders(req *OrdersGET) (raw RawOrders, err error)

Returns raw byte response from the server.

func (RawOrders) ToGladiusOrders

func (r RawOrders) ToGladiusOrders() (*glo.GladiusOrdersJSON, error)

type SortKeys

type SortKeys struct {
	// Sort query used with 'createdAt' sort key.
	// *Shouldn't* include 'createdAt' part!
	// https://api.uniswap.org/v2/uniswapx/docs ('/orders&sort')
	Sort string
	// Boolean to sort query results by descending sort key.
	Desc bool
}

Query-params for sorting of orders.

Jump to

Keyboard shortcuts

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