orderbook

package
v1.0.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package orderbook provides primitives to interact with the openapi HTTP API.

Code generated by github.com/deepmap/oapi-codegen version v1.16.2 DO NOT EDIT.

Index

Constants

View Source
const (
	MakerAmountFlag     = 255
	UnwrapWETHFlag      = 254
	SkipOrderPermitFlag = 253
	UsePermit2Flag      = 252
	ArgsHasReceiverFlag = 251
)

Variables

This section is empty.

Functions

func AddressStringToBigInt

func AddressStringToBigInt(addressString string) *big.Int

func GenerateSalt

func GenerateSalt(extension string) string

Types

type BitMask

type BitMask struct {
	Offset *big.Int
	Mask   *big.Int
}

func NewBitMask

func NewBitMask(startBit, endBit *big.Int) *BitMask

NewBitMask creates a new BitMask with the given start and end bit positions.

func (*BitMask) SetBits

func (b *BitMask) SetBits(value, bits *big.Int) *big.Int

func (*BitMask) ToBigInt

func (b *BitMask) ToBigInt() *big.Int

ToBigInt returns the mask value as a big.Int, shifted by the offset.

func (*BitMask) ToString

func (b *BitMask) ToString() string

ToString returns the string representation of the mask shifted by the offset.

type Client

type Client struct {
	Wallet              common.Wallet
	TxBuilder           common.TransactionBuilderFactory
	AggregationRouterV6 *abi.ABI
	SeriesNonceManager  *abi.ABI
	// contains filtered or unexported fields
}

func NewClient

func NewClient(cfg *Configuration) (*Client, error)

func (*Client) CreateOrder

func (api *Client) CreateOrder(ctx context.Context, params CreateOrderParams) (*CreateOrderResponse, error)

CreateOrder creates an order in the Limit Order Protocol

func (*Client) GetActiveOrdersWithPermit

func (api *Client) GetActiveOrdersWithPermit(ctx context.Context, params GetActiveOrdersWithPermitParams) ([]OrderResponse, error)

GetActiveOrdersWithPermit returns all orders in the Limit Order Protocol that are active and have a valid permit

func (*Client) GetAllOrders

func (api *Client) GetAllOrders(ctx context.Context, params GetAllOrdersParams) ([]OrderResponse, error)

GetAllOrders returns all orders in the Limit Order Protocol

func (*Client) GetCount

func (api *Client) GetCount(ctx context.Context, params GetCountParams) (*CountResponse, error)

GetCount returns the number of orders in the Limit Order Protocol

func (*Client) GetEvent

func (api *Client) GetEvent(ctx context.Context, params GetEventParams) (*EventResponse, error)

GetEvent returns an event in the Limit Order Protocol by order hash

func (*Client) GetEvents

func (api *Client) GetEvents(ctx context.Context, params GetEventsParams) ([]EventResponse, error)

GetEvents returns all events in the Limit Order Protocol

func (*Client) GetFillOrderCalldata

func (c *Client) GetFillOrderCalldata(getOrderResponse *GetOrderByHashResponseExtended, takerTraits *TakerTraits) ([]byte, error)

func (*Client) GetOrder

func (api *Client) GetOrder(ctx context.Context, params GetOrderParams) (*GetOrderByHashResponseExtended, error)

GetOrder returns an order from Limit Order Protocol that matches a specific hash

func (*Client) GetOrdersByCreatorAddress

func (api *Client) GetOrdersByCreatorAddress(ctx context.Context, params GetOrdersByCreatorAddressParams) ([]OrderResponse, error)

GetOrdersByCreatorAddress returns all orders created by a given address in the Limit Order Protocol

func (*Client) GetSeriesNonce

func (c *Client) GetSeriesNonce(ctx context.Context, publicAddress gethCommon.Address) (*big.Int, error)

type ClientOnlyAPI

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

func NewClientOnlyAPI

func NewClientOnlyAPI(cfg *ConfigurationAPI) (*ClientOnlyAPI, error)

func (*ClientOnlyAPI) CreateOrder

func (api *ClientOnlyAPI) CreateOrder(ctx context.Context, params CreateOrderParams) (*CreateOrderResponse, error)

CreateOrder creates an order in the Limit Order Protocol

func (*ClientOnlyAPI) GetActiveOrdersWithPermit

func (api *ClientOnlyAPI) GetActiveOrdersWithPermit(ctx context.Context, params GetActiveOrdersWithPermitParams) ([]OrderResponse, error)

GetActiveOrdersWithPermit returns all orders in the Limit Order Protocol that are active and have a valid permit

func (*ClientOnlyAPI) GetAllOrders

func (api *ClientOnlyAPI) GetAllOrders(ctx context.Context, params GetAllOrdersParams) ([]OrderResponse, error)

GetAllOrders returns all orders in the Limit Order Protocol

func (*ClientOnlyAPI) GetCount

func (api *ClientOnlyAPI) GetCount(ctx context.Context, params GetCountParams) (*CountResponse, error)

GetCount returns the number of orders in the Limit Order Protocol

func (*ClientOnlyAPI) GetEvent

func (api *ClientOnlyAPI) GetEvent(ctx context.Context, params GetEventParams) (*EventResponse, error)

GetEvent returns an event in the Limit Order Protocol by order hash

func (*ClientOnlyAPI) GetEvents

func (api *ClientOnlyAPI) GetEvents(ctx context.Context, params GetEventsParams) ([]EventResponse, error)

GetEvents returns all events in the Limit Order Protocol

func (*ClientOnlyAPI) GetOrder

func (api *ClientOnlyAPI) GetOrder(ctx context.Context, params GetOrderParams) (*GetOrderByHashResponseExtended, error)

GetOrder returns an order from Limit Order Protocol that matches a specific hash

func (*ClientOnlyAPI) GetOrdersByCreatorAddress

func (api *ClientOnlyAPI) GetOrdersByCreatorAddress(ctx context.Context, params GetOrdersByCreatorAddressParams) ([]OrderResponse, error)

GetOrdersByCreatorAddress returns all orders created by a given address in the Limit Order Protocol

type CompactSignature

type CompactSignature struct {
	R  []byte
	VS []byte
}

CompactSignature represents a compacted form of an Ethereum signature.

func CompressSignature

func CompressSignature(signature string) (*CompactSignature, error)

CompressSignature converts a standard 65-byte Ethereum signature into the EIP-2098 compact format.

type Configuration

type Configuration struct {
	WalletConfiguration *WalletConfiguration
	APIConfiguration    *ConfigurationAPI
}

func NewConfiguration

func NewConfiguration(params ConfigurationParams) (*Configuration, error)

type ConfigurationAPI

type ConfigurationAPI struct {
	ApiKey string
	ApiURL string

	API api
}

func NewConfigurationAPI

func NewConfigurationAPI(chainId uint64, apiUrl string, apiKey string) (*ConfigurationAPI, error)

type ConfigurationParams

type ConfigurationParams struct {
	NodeUrl    string
	PrivateKey string
	ChainId    uint64
	ApiUrl     string
	ApiKey     string
}

type CountResponse

type CountResponse struct {
	Count int `json:"count"`
}

type CreateOrderParams

type CreateOrderParams struct {
	Wallet                         common.Wallet
	SeriesNonce                    *big.Int
	MakerTraits                    *MakerTraits
	Extension                      Extension
	ExpireAfterUnix                int64
	Maker                          string
	MakerAsset                     string
	TakerAsset                     string
	TakingAmount                   string
	MakingAmount                   string
	Taker                          string
	SkipWarnings                   bool
	EnableOnchainApprovalsIfNeeded bool
}

func (*CreateOrderParams) Validate

func (params *CreateOrderParams) Validate() error

type CreateOrderResponse

type CreateOrderResponse struct {
	Success bool `json:"success"`
}

type EventResponse

type EventResponse struct {
	Id                   int       `json:"id"`
	Network              int       `json:"network"`
	LogId                string    `json:"logId"`
	Version              int       `json:"version"`
	Action               string    `json:"action"`
	OrderHash            string    `json:"orderHash"`
	Taker                string    `json:"taker"`
	RemainingMakerAmount string    `json:"remainingMakerAmount"`
	TransactionHash      string    `json:"transactionHash"`
	BlockNumber          int       `json:"blockNumber"`
	CreateDateTime       time.Time `json:"createDateTime"`
}

type Extension

type Extension struct {
	InteractionsArray []string
}

func NewExtension

func NewExtension(params ExtensionParams) (Extension, error)

func (*Extension) Encode

func (i *Extension) Encode() string

type ExtensionParams

type ExtensionParams struct {
	MakerAsset      string
	MakerAssetData  string
	TakerAssetData  string
	GetMakingAmount string
	GetTakingAmount string
	Predicate       string
	Permit          string
	PreInteraction  string
	PostInteraction string
}

type GetActiveOrdersWithPermitParams

type GetActiveOrdersWithPermitParams struct {
	Wallet string
	Token  string
}

func (*GetActiveOrdersWithPermitParams) Validate

func (params *GetActiveOrdersWithPermitParams) Validate() error

type GetAllOrdersParams

func (*GetAllOrdersParams) Validate

func (params *GetAllOrdersParams) Validate() error

type GetCountParams

func (*GetCountParams) Validate

func (params *GetCountParams) Validate() error

type GetEventParams

type GetEventParams struct {
	OrderHash string
}

func (*GetEventParams) Validate

func (params *GetEventParams) Validate() error

type GetEventsParams

type GetEventsParams struct {
	LimitOrderV3SubscribedApiControllerGetEventsParams
}

func (*GetEventsParams) Validate

func (params *GetEventsParams) Validate() error

type GetOrderByHashResponse

type GetOrderByHashResponse struct {
	ID                   int         `json:"id"`
	OrderHash            string      `json:"orderHash"`
	CreateDateTime       time.Time   `json:"createDateTime"`
	LastChangedDateTime  time.Time   `json:"lastChangedDateTime"`
	TakerAsset           string      `json:"takerAsset"`
	MakerAsset           string      `json:"makerAsset"`
	OrderMaker           string      `json:"orderMaker"`
	OrderStatus          int         `json:"orderStatus"`
	Signature            string      `json:"signature"`
	MakerAmount          string      `json:"makerAmount"`
	RemainingMakerAmount string      `json:"remainingMakerAmount"`
	MakerBalance         string      `json:"makerBalance"`
	MakerAllowance       string      `json:"makerAllowance"`
	TakerAmount          string      `json:"takerAmount"`
	Data                 OrderData   `json:"data"`
	MakerRate            string      `json:"makerRate"`
	TakerRate            string      `json:"takerRate"`
	TakerRateDoubled     float64     `json:"takerRateDoubled"`
	OrderHashSelector    int         `json:"orderHashSelector"`
	OrderInvalidReason   interface{} `json:"orderInvalidReason"`
	IsMakerContract      bool        `json:"isMakerContract"`
}

type GetOrderByHashResponseExtended

type GetOrderByHashResponseExtended struct {
	GetOrderByHashResponse

	LimitOrderDataNormalized NormalizedLimitOrderData
}

type GetOrderParams

type GetOrderParams struct {
	OrderHash string
}

func (*GetOrderParams) Validate

func (params *GetOrderParams) Validate() error

type GetOrdersByCreatorAddressParams

type GetOrdersByCreatorAddressParams struct {
	CreatorAddress string
	LimitOrderV3SubscribedApiControllerGetAllLimitOrdersParams
}

func (*GetOrdersByCreatorAddressParams) Validate

func (params *GetOrdersByCreatorAddressParams) Validate() error

type LimitOrderV3Data

type LimitOrderV3Data struct {
	// AllowedSender An address of the wallet or contract who will be able to fill this order (equals to Zero address on public orders)
	AllowedSender string `json:"allowedSender,omitempty"`

	// Interactions Merged offsets of each field in interactions
	Interactions string `json:"interactions,omitempty"`

	// Maker An address of the maker (wallet or contract address)
	Maker string `json:"maker"`

	// MakerAsset Address of the maker asset
	MakerAsset string `json:"makerAsset"`

	// MakingAmount Order maker's token amount
	MakingAmount string `json:"makingAmount"`

	// Offsets An interaction call data. ABI encoded set of makerAssetData, takerAssetData, getMakingAmount, getTakingAmount, predicate, permit, preInteraction, postInteraction
	Offsets string `json:"offsets,omitempty"`

	// Receiver An address of the wallet or contract who will receive filled amount (equals to Zero address for receiver == makerAddress)
	Receiver string `json:"receiver,omitempty"`

	// Salt Some unique value. It is necessary to be able to create limit orders with the same parameters (so that they have a different hash)
	Salt string `json:"salt"`

	// TakerAsset Address of the taker asset
	TakerAsset string `json:"takerAsset"`

	// TakingAmount Order taker's token amount
	TakingAmount string `json:"takingAmount"`
}

LimitOrderV3Data defines model for LimitOrderV3Data.

type LimitOrderV3Request

type LimitOrderV3Request struct {
	Data LimitOrderV3Data `json:"data"`

	// OrderHash Hash of the limit order typed data
	OrderHash string `json:"orderHash"`

	// Signature Signature of the limit order typed data (using signTypedData_v4)
	Signature string `json:"signature"`
}

LimitOrderV3Request defines model for LimitOrderV3Request.

type LimitOrderV3SubscribedApiControllerCreateLimitOrderJSONRequestBody

type LimitOrderV3SubscribedApiControllerCreateLimitOrderJSONRequestBody = LimitOrderV3Request

LimitOrderV3SubscribedApiControllerCreateLimitOrderJSONRequestBody defines body for LimitOrderV3SubscribedApiControllerCreateLimitOrder for application/json ContentType.

type LimitOrderV3SubscribedApiControllerGetAllLimitOrdersParams

type LimitOrderV3SubscribedApiControllerGetAllLimitOrdersParams struct {
	// Page Pagination step, default: 1 (page = offset / limit)
	Page float32 `url:"page,omitempty" json:"page,omitempty"`

	// Limit Number of limit orders to receive (default: 100, max: 500)
	Limit float32 `url:"limit,omitempty" json:"limit,omitempty"`

	// Statuses JSON an array of statuses by which limit orders will be filtered: 1 - valid limit orders, 2 - temporary invalid limit orders, 3 - invalid limit orders
	Statuses []float32                                                        `url:"statuses,omitempty" json:"statuses,omitempty"`
	SortBy   LimitOrderV3SubscribedApiControllerGetAllLimitOrdersParamsSortBy `url:"sortBy,omitempty" json:"sortBy,omitempty"`

	// TakerAsset Address of the maker asset
	TakerAsset string `url:"takerAsset,omitempty" json:"takerAsset,omitempty"`

	// MakerAsset Address of the maker asset
	MakerAsset string `url:"makerAsset,omitempty" json:"makerAsset,omitempty"`
}

LimitOrderV3SubscribedApiControllerGetAllLimitOrdersParams defines parameters for LimitOrderV3SubscribedApiControllerGetAllLimitOrders.

type LimitOrderV3SubscribedApiControllerGetAllLimitOrdersParamsSortBy

type LimitOrderV3SubscribedApiControllerGetAllLimitOrdersParamsSortBy string

LimitOrderV3SubscribedApiControllerGetAllLimitOrdersParamsSortBy defines parameters for LimitOrderV3SubscribedApiControllerGetAllLimitOrders.

const (
	LimitOrderV3SubscribedApiControllerGetAllLimitOrdersParamsSortByCreateDateTime LimitOrderV3SubscribedApiControllerGetAllLimitOrdersParamsSortBy = "createDateTime"
	LimitOrderV3SubscribedApiControllerGetAllLimitOrdersParamsSortByMakerAmount    LimitOrderV3SubscribedApiControllerGetAllLimitOrdersParamsSortBy = "makerAmount"
	LimitOrderV3SubscribedApiControllerGetAllLimitOrdersParamsSortByMakerRate      LimitOrderV3SubscribedApiControllerGetAllLimitOrdersParamsSortBy = "makerRate"
	LimitOrderV3SubscribedApiControllerGetAllLimitOrdersParamsSortByTakerAmount    LimitOrderV3SubscribedApiControllerGetAllLimitOrdersParamsSortBy = "takerAmount"
	LimitOrderV3SubscribedApiControllerGetAllLimitOrdersParamsSortByTakerRate      LimitOrderV3SubscribedApiControllerGetAllLimitOrdersParamsSortBy = "takerRate"
)

Defines values for LimitOrderV3SubscribedApiControllerGetAllLimitOrdersParamsSortBy.

type LimitOrderV3SubscribedApiControllerGetAllOrdersCountParams

type LimitOrderV3SubscribedApiControllerGetAllOrdersCountParams struct {
	Statuses []string `url:"statuses" json:"statuses"`
}

LimitOrderV3SubscribedApiControllerGetAllOrdersCountParams defines parameters for LimitOrderV3SubscribedApiControllerGetAllOrdersCount.

type LimitOrderV3SubscribedApiControllerGetEventsParams

type LimitOrderV3SubscribedApiControllerGetEventsParams struct {
	Limit float32 `url:"limit" json:"limit"`
}

LimitOrderV3SubscribedApiControllerGetEventsParams defines parameters for LimitOrderV3SubscribedApiControllerGetEvents.

type LimitOrderV3SubscribedApiControllerGetLimitOrderParams

type LimitOrderV3SubscribedApiControllerGetLimitOrderParams struct {
	// Page Pagination step, default: 1 (page = offset / limit)
	Page float32 `url:"page,omitempty" json:"page,omitempty"`

	// Limit Number of limit orders to receive (default: 100, max: 500)
	Limit float32 `url:"limit,omitempty" json:"limit,omitempty"`

	// Statuses JSON an array of statuses by which limit orders will be filtered: 1 - valid limit orders, 2 - temporary invalid limit orders, 3 - invalid limit orders
	Statuses []float32                                                    `url:"statuses,omitempty" json:"statuses,omitempty"`
	SortBy   LimitOrderV3SubscribedApiControllerGetLimitOrderParamsSortBy `url:"sortBy,omitempty" json:"sortBy,omitempty"`

	// TakerAsset Address of the taker asset
	TakerAsset string `url:"takerAsset,omitempty" json:"takerAsset,omitempty"`

	// MakerAsset Address of the maker asset
	MakerAsset string `url:"makerAsset,omitempty" json:"makerAsset,omitempty"`
}

LimitOrderV3SubscribedApiControllerGetLimitOrderParams defines parameters for LimitOrderV3SubscribedApiControllerGetLimitOrder.

type LimitOrderV3SubscribedApiControllerGetLimitOrderParamsSortBy

type LimitOrderV3SubscribedApiControllerGetLimitOrderParamsSortBy string

LimitOrderV3SubscribedApiControllerGetLimitOrderParamsSortBy defines parameters for LimitOrderV3SubscribedApiControllerGetLimitOrder.

const (
	LimitOrderV3SubscribedApiControllerGetLimitOrderParamsSortByCreateDateTime LimitOrderV3SubscribedApiControllerGetLimitOrderParamsSortBy = "createDateTime"
	LimitOrderV3SubscribedApiControllerGetLimitOrderParamsSortByMakerAmount    LimitOrderV3SubscribedApiControllerGetLimitOrderParamsSortBy = "makerAmount"
	LimitOrderV3SubscribedApiControllerGetLimitOrderParamsSortByMakerRate      LimitOrderV3SubscribedApiControllerGetLimitOrderParamsSortBy = "makerRate"
	LimitOrderV3SubscribedApiControllerGetLimitOrderParamsSortByTakerAmount    LimitOrderV3SubscribedApiControllerGetLimitOrderParamsSortBy = "takerAmount"
	LimitOrderV3SubscribedApiControllerGetLimitOrderParamsSortByTakerRate      LimitOrderV3SubscribedApiControllerGetLimitOrderParamsSortBy = "takerRate"
)

Defines values for LimitOrderV3SubscribedApiControllerGetLimitOrderParamsSortBy.

type MakerTraits

type MakerTraits struct {
	AllowedSender string
	Expiry        int64
	Nonce         int64
	Series        int64

	NoPartialFills      bool
	NeedPostinteraction bool
	NeedPreinteraction  bool
	NeedEpochCheck      bool
	HasExtension        bool
	ShouldUsePermit2    bool
	ShouldUnwrapWeth    bool

	AllowPartialFills  bool
	AllowMultipleFills bool
}

func NewMakerTraits

func NewMakerTraits(params MakerTraitsParams) (*MakerTraits, error)

func (*MakerTraits) Encode

func (m *MakerTraits) Encode() string

func (*MakerTraits) IsBitInvalidatorMode

func (m *MakerTraits) IsBitInvalidatorMode() bool

type MakerTraitsParams

type MakerTraitsParams struct {
	AllowedSender      string
	Expiry             int64
	Nonce              int64
	Series             int64
	NoPartialFills     bool
	ShouldCheckEpoch   bool
	UsePermit2         bool
	UnwrapWeth         bool
	HasExtension       bool
	HasPreInteraction  bool
	HasPostInteraction bool
	AllowPartialFills  bool
	AllowMultipleFills bool
}

type NormalizedLimitOrderData

type NormalizedLimitOrderData struct {
	Salt         *big.Int
	MakerAsset   *big.Int
	TakerAsset   *big.Int
	Maker        *big.Int
	Receiver     *big.Int
	MakingAmount *big.Int
	TakingAmount *big.Int
	MakerTraits  *big.Int
}

type Order

type Order struct {
	OrderHash string    `json:"orderHash"`
	Signature string    `json:"signature"`
	Data      OrderData `json:"data"`
}

func CreateLimitOrderMessage

func CreateLimitOrderMessage(orderRequest CreateOrderParams, chainId int) (*Order, error)

type OrderData

type OrderData struct {
	MakerAsset    string `json:"makerAsset"`
	TakerAsset    string `json:"takerAsset"`
	MakingAmount  string `json:"makingAmount"`
	TakingAmount  string `json:"takingAmount"`
	Salt          string `json:"salt"`
	Maker         string `json:"maker"`
	AllowedSender string `json:"allowedSender"`
	Receiver      string `json:"receiver"`
	MakerTraits   string `json:"makerTraits"`
	Extension     string `json:"extension"`
}

type OrderResponse

type OrderResponse struct {
	Signature            string      `json:"signature"`
	OrderHash            string      `json:"orderHash"`
	CreateDateTime       time.Time   `json:"createDateTime"`
	RemainingMakerAmount string      `json:"remainingMakerAmount"`
	MakerBalance         string      `json:"makerBalance"`
	MakerAllowance       string      `json:"makerAllowance"`
	Data                 OrderData   `json:"data"`
	MakerRate            string      `json:"makerRate"`
	TakerRate            string      `json:"takerRate"`
	IsMakerContract      bool        `json:"isMakerContract"`
	OrderInvalidReason   interface{} `json:"orderInvalidReason"`
}

type TakerTraits

type TakerTraits struct {
	Receiver  *common.Address
	Extension string // Assuming extension related functions are defined elsewhere

	MakerAmount     bool
	UnwrapWETH      bool
	SkipOrderPermit bool
	UsePermit2      bool
	ArgsHasReceiver bool
}

func NewTakerTraits

func NewTakerTraits(params TakerTraitsParams) *TakerTraits

func (*TakerTraits) Encode

func (t *TakerTraits) Encode() *TakerTraitsEncoded

type TakerTraitsCalldata

type TakerTraitsCalldata struct {
	Trait *big.Int
	Args  string
}

type TakerTraitsEncoded

type TakerTraitsEncoded struct {
	TraitFlags *big.Int
	Args       []byte
}

type TakerTraitsParams

type TakerTraitsParams struct {
	Receiver        *geth_common.Address
	Extension       string
	MakerAmount     bool
	UnwrapWETH      bool
	SkipOrderPermit bool
	UsePermit2      bool
	ArgsHasReceiver bool
}

type WalletConfiguration

type WalletConfiguration struct {
	PrivateKey string
	NodeURL    string

	Wallet    common.Wallet
	TxBuilder common.TransactionBuilderFactory
}

func NewConfigurationWallet

func NewConfigurationWallet(nodeUrl string, privateKey string, chainId uint64) (*WalletConfiguration, error)

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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