go_cowswap

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

README



CowSwap Go SDK

Join our Discord!

Installation

To install the SDK with the go get command, run the following:

go get github.com/itsahedge/go-cowswap

Getting Started

Config

Before you can use the SDK, please set the ENV variables: PRIVATE_KEY & ETH_ADDRESS (refer to .env.example)
Initializing the SDK requires config to be set

Config is of type ConfigOpts

Initializing with default config

To use default config, you only need to specify which network: mainnet, goerli, xdai

// config.go
network := "goerli"
options := ConfigOpts{
    Network:    network,
    Host:       HostConfig[network],
    RpcUrl:     RpcConfig[network],
    EthAddress: os.Getenv("ETH_ADDRESS"),
    PrivateKey: os.Getenv("PRIVATE_KEY"),
}
Initializing with custom config

To use custom config, you need to specify which network: mainnet, goerli, xdai, the host (cow api endpoint), and rpc

// config.go
network := "goerli"
host := "https://api.cow.fi/goerli/api/v1"
customRpc := ""
options := ConfigOpts{
    Network:    network,
    Host:       host,
    RpcUrl:     customRpc,
    EthAddress: os.Getenv("ETH_ADDRESS"),
    PrivateKey: os.Getenv("PRIVATE_KEY"),
}
The following example demonstrates how to initialize the SDK with Read & Write Functions:
package main

import (
	"context"
	"fmt"
	cowswap "github.com/itsahedge/go-cowswap"
	"log"
)

func main() {
	// Initialize the go-cowswap client on Goerli 
	
	network := "goerli"
	rpc := "https://eth-goerli-rpc.gateway.pokt.network"
	host := "https://api.cow.fi/goerli/api/v1"
	privateKey := "YOUR-PRIVATE-KEY"
	address := "YOUR-ETHEREUM-ADDRESS"
	
	options := cowswap.ConfigOpts{
		Network:    network,
		Host:       host,
		RpcUrl:     rpc,
		EthAddress: address,
		PrivateKey: privateKey,
	}
	client, err := cowswap.NewClient(options)
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()

	// Fetch the Chain ID and Block Number from the Client
	chainId, err := client.EthClient.ChainID(ctx)
	if err != nil {
		log.Fatal(err)
	}
	block, err := client.EthClient.BlockNumber(ctx)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("chaind ID: %v, block: %v", chainId, block)
}
Testing

In order to run the tests properly:

  • set your ENV variables for PRIVATE_KEY & ETH_ADDRESS.
  • Set the network config to Goerli
  • have some Goerli ETH/WETH
go test -coverprofile=coverage.out
go tool cover -html=coverage.out

Documentation

Index

Constants

View Source
const (
	MAINNET_API        = "https://api.cow.fi/mainnet/api/v1"
	GOERLI_API         = "https://api.cow.fi/goerli/api/v1"
	GNOSIS_CHAIN_API   = "https://api.cow.fi/xdai/api/v1"
	GPv2Settlement     = "0x9008D19f58AAbD9eD0D60971565AA8510560ab41"
	GPv2_Vault_Relayer = "0xC92E8bdf79f0507f65a392b0ab4667716BFE0110"
)
View Source
const (
	RPC_MAINNET = "https://api.securerpc.com/v1"
	RPC_GOERLI  = "https://eth-goerli-rpc.gateway.pokt.network"
	RPC_XDAI    = "https://xdai-rpc.gateway.pokt.network"
)
View Source
const (
	SUBGRAPH_MAINNET      = "https://api.thegraph.com/subgraphs/name/cowprotocol/cow"
	SUBGRAPH_GOERLI       = "https://api.thegraph.com/subgraphs/name/cowprotocol/cow-goerli"
	SUBGRAPH_GNOSIS_CHAIN = "https://api.thegraph.com/subgraphs/name/cowprotocol/cow-gc"
)

Variables

View Source
var ChainIds = map[string]int{
	"mainnet": 1,
	"goerli":  5,
	"xdai":    100,
}
View Source
var Domain = apitypes.TypedDataDomain{
	Name:              "Gnosis Protocol",
	Version:           "v2",
	ChainId:           math.NewHexOrDecimal256(1),
	VerifyingContract: GPv2Settlement,
}

Default chainId is mainnet

View Source
var ETHEREUM_TOKEN_LIST = map[string]string{
	"WETH": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
	"USDC": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
	"COW":  "0xdef1ca1fb7fbcdc777520aa7f396b4e015f497ab",
	"GNO":  "0x6810e776880c02933d47db1b9fc05908e5386b96",
}
View Source
var Eip712OrderTypes = apitypes.Types{
	"EIP712Domain": {
		{
			Name: "name",
			Type: "string",
		},
		{
			Name: "version",
			Type: "string",
		},
		{
			Name: "chainId",
			Type: "uint256",
		},
		{
			Name: "verifyingContract",
			Type: "address",
		},
	},
	"Order": {
		{
			Name: "sellToken",
			Type: "address",
		},
		{
			Name: "buyToken",
			Type: "address",
		},
		{
			Name: "receiver",
			Type: "address",
		},
		{
			Name: "sellAmount",
			Type: "uint256",
		},
		{
			Name: "buyAmount",
			Type: "uint256",
		},
		{
			Name: "validTo",
			Type: "uint32",
		},
		{
			Name: "appData",
			Type: "bytes32",
		},
		{
			Name: "feeAmount",
			Type: "uint256",
		},
		{
			Name: "kind",
			Type: "string",
		},
		{
			Name: "partiallyFillable",
			Type: "bool",
		},
		{
			Name: "sellTokenBalance",
			Type: "string",
		},
		{
			Name: "buyTokenBalance",
			Type: "string",
		},
	},
	"OrderCancellations": {
		{
			Name: "orderUids",
			Type: "bytes[]",
		},
	},
}
View Source
var GNOSIS_SCAN_TOKEN_LIST = map[string]string{
	"GNO": "",
}
View Source
var GOERLI_TOKEN_LIST = map[string]string{
	"COW":  "0x91056D4A53E1faa1A84306D4deAEc71085394bC8",
	"GNO":  "0x02ABBDbAaa7b1BB64B5c878f7ac17f8DDa169532",
	"BAT":  "0x70cBa46d2e933030E2f274AE58c951C800548AeF",
	"DAI":  "0xdc31Ee1784292379Fbb2964b3B9C4124D8F89C60",
	"POLY": "0x9e32c0EfF886B6Ccae99350Fd5e7002dCED55F15",
	"UNI":  "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984",
	"USDC": "0xD87Ba7A50B2E7E660f678A895E4B72E7CB4CCd9C",
	"WETH": "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6",
	"ZRX":  "0xe4E81Fa6B16327D4B78CFEB83AAdE04bA7075165",
}
View Source
var HostConfig = map[string]string{
	"mainnet": MAINNET_API,
	"goerli":  GOERLI_API,
	"xdai":    GNOSIS_CHAIN_API,
}
View Source
var Options = ConfigOpts{
	Network:    "goerli",
	Host:       HostConfig["goerli"],
	RpcUrl:     RpcConfig["goerli"],
	EthAddress: os.Getenv("ETH_ADDRESS"),
	PrivateKey: os.Getenv("PRIVATE_KEY"),
}
View Source
var RpcConfig = map[string]string{
	"mainnet": RPC_MAINNET,
	"goerli":  RPC_GOERLI,
	"xdai":    RPC_XDAI,
}
View Source
var SubgraphConfig = map[string]string{
	"mainnet": SUBGRAPH_MAINNET,
	"goerli":  SUBGRAPH_GOERLI,
	"xdai":    SUBGRAPH_GNOSIS_CHAIN,
}
View Source
var TOKEN_ADDRESSES = map[string]map[string]string{
	"mainnet": ETHEREUM_TOKEN_LIST,
	"goerli":  GOERLI_TOKEN_LIST,
	"xdai":    GNOSIS_SCAN_TOKEN_LIST,
}
View Source
var TypedData = apitypes.TypedData{
	Types:       Eip712OrderTypes,
	PrimaryType: "Order",
	Domain:      Domain,
	Message:     map[string]interface{}{},
}

Functions

This section is empty.

Types

type ApproveAllowance

type ApproveAllowance struct {
	TokenAddress  string `json:"token_address"`
	WalletAddress string `json:"wallet_address"`
}

type AuctionResponse

type AuctionResponse struct {
	ID                    int `json:"id"`
	Block                 int `json:"block"`
	LatestSettlementBlock int `json:"latestSettlementBlock"`
	Orders                []struct {
		SellToken                    string    `json:"sellToken"`
		BuyToken                     string    `json:"buyToken"`
		Receiver                     string    `json:"receiver"`
		SellAmount                   string    `json:"sellAmount"`
		BuyAmount                    string    `json:"buyAmount"`
		ValidTo                      int       `json:"validTo"`
		AppData                      string    `json:"appData"`
		FeeAmount                    string    `json:"feeAmount"`
		Kind                         string    `json:"kind"`
		PartiallyFillable            bool      `json:"partiallyFillable"`
		SellTokenBalance             string    `json:"sellTokenBalance"`
		BuyTokenBalance              string    `json:"buyTokenBalance"`
		SigningScheme                string    `json:"signingScheme"`
		Signature                    string    `json:"signature"`
		From                         string    `json:"from"`
		QuoteID                      int       `json:"quoteId"`
		CreationTime                 time.Time `json:"creationTime"`
		Owner                        string    `json:"owner"`
		UID                          string    `json:"UID"`
		AvailableBalance             string    `json:"availableBalance"`
		ExecutedSellAmount           string    `json:"executedSellAmount"`
		ExecutedSellAmountBeforeFees string    `json:"executedSellAmountBeforeFees"`
		ExecutedBuyAmount            string    `json:"executedBuyAmount"`
		ExecutedFeeAmount            string    `json:"executedFeeAmount"`
		Invalidated                  bool      `json:"invalidated"`
		Status                       string    `json:"status"`
		FullFeeAmount                string    `json:"fullFeeAmount"`
		IsLiquidityOrder             bool      `json:"isLiquidityOrder"`
		EthflowData                  struct {
			IsRefunded  bool `json:"isRefunded"`
			UserValidTo int  `json:"userValidTo"`
		} `json:"ethflowData"`
		OnchainUser string `json:"onchainUser"`
	} `json:"orders"`
	Prices struct {
		AdditionalProp1 string `json:"additionalProp1"`
		AdditionalProp2 string `json:"additionalProp2"`
		AdditionalProp3 string `json:"additionalProp3"`
	} `json:"prices"`
}

type CancelOrderReq

type CancelOrderReq struct {
	OrderUids     []string `json:"orderUids"`
	Signature     string   `json:"signature"`
	SigningScheme string   `json:"signingScheme"`
}

type Client

type Client struct {
	Options ConfigOpts
	Network string
	Host    string

	Http             *http.Client
	Eip712OrderTypes apitypes.Types
	TypedDataDomain  apitypes.TypedDataDomain

	RpcUrl     string
	EthClient  *ethclient.Client
	ChainId    *big.Int
	ChainIdInt int

	TransactionSigner *TransactionSigner

	Subgraph *subgraph.Client
}

func NewClient

func NewClient(options ConfigOpts) (*Client, error)

NewClient - Client to interact with CowSwap

func (*Client) CancelOrder

func (c *Client) CancelOrder(ctx context.Context, uid string) (*string, int, error)

CancelOrder - Cancel orders

func (*Client) CancelOrders added in v1.0.6

func (c *Client) CancelOrders(ctx context.Context, uids []string) (*string, int, error)

CancelOrders - Cancel multiple orders

func (*Client) CreateOrder

func (c *Client) CreateOrder(ctx context.Context, signedOrder *CounterOrder) (*string, int, error)

func (*Client) GetAllowance

func (c *Client) GetAllowance(ctx context.Context, ownerAddress, tokenAddress string) (*big.Int, error)

GetAllowance - Token allowance for owner

func (*Client) GetAuction

func (c *Client) GetAuction(ctx context.Context) (*AuctionResponse, int, error)

GetAuction - The current batch auction that solvers should be solving right now. Includes the list of solvable orders, the block on which the batch was created, as well as prices for all tokens being traded (used for objective value computation)

func (*Client) GetNativePrice

func (c *Client) GetNativePrice(ctx context.Context, tokenAddress string) (*NativePriceResponse, int, error)

GetNativePrice - Get native price for given token

func (*Client) GetOrdersBySettlementTxHash added in v1.0.8

func (c *Client) GetOrdersBySettlementTxHash(ctx context.Context, txHash string) (*OrdersByTxHashResponse, int, error)

GetOrdersBySettlementTxHash - Get orders by settlement transaction hash

func (*Client) GetOrdersByUid

func (c *Client) GetOrdersByUid(ctx context.Context, uid string) (*OrderByUidResponse, int, error)

GetOrdersByUid - Get existing order from UID

func (*Client) GetOrdersByUser

func (c *Client) GetOrdersByUser(ctx context.Context, userAddress string, opts *OrdersPaginated) (*OrdersByUserResponse, int, error)

GetOrdersByUser - Get orders of a user paginated

func (*Client) GetSolverAuctionById

func (c *Client) GetSolverAuctionById(ctx context.Context, auctionId int) (*SolverAuctionByIdResponse, int, error)

GetSolverAuctionById - The competition information by auction id

func (*Client) GetSolverAuctionByTxHash

func (c *Client) GetSolverAuctionByTxHash(ctx context.Context, txHash string) (*SolverAuctionByTxHashResponse, int, error)

GetSolverAuctionByTxHash - The competition information by transaction hash

func (*Client) GetTrades

func (c *Client) GetTrades(ctx context.Context, opts *GetTrades) (*TradesResponse, int, error)

GetTrades - Get trades for an owner or order_uid

func (*Client) GetVersion added in v1.0.3

func (c *Client) GetVersion(ctx context.Context) (*VersionResponse, int, error)

GetVersion - Information about the current deployed version of the API

func (*Client) Quote

func (c *Client) Quote(ctx context.Context, o *QuoteReq) (*QuoteResponse, int, error)

func (*Client) SetAllowance

func (c *Client) SetAllowance(ctx context.Context, tokenAddress, tokenAmount string) (*types.Transaction, error)

SetAllowance - Set token allowance for owner on CowSwap GPv2 Vault Relayer contract

func (*Client) SignCancelOrder

func (c *Client) SignCancelOrder(uid string) (string, *apitypes.TypedData, error)

SignCancelOrder - Sign a single order for cancellation & generate the order signature

func (*Client) SignCancelOrders added in v1.0.6

func (c *Client) SignCancelOrders(uid []string) (string, *apitypes.TypedData, error)

SignCancelOrders - Sign multiple orders for cancellation & generate the order signature

func (*Client) SignOrder

func (c *Client) SignOrder(o *CounterOrder) (*CounterOrder, error)

type ConfigOpts added in v1.0.3

type ConfigOpts struct {
	Network string
	Host    string
	RpcUrl  string

	EthAddress string
	PrivateKey string
}

type CounterOrder

type CounterOrder struct {
	SellToken         string `json:"sellToken,omitempty"`
	BuyToken          string `json:"buyToken,omitempty"`
	Receiver          string `json:"receiver,omitempty"`
	SellAmount        string `json:"sellAmount"`
	BuyAmount         string `json:"buyAmount"`
	ValidTo           uint32 `json:"validTo,omitempty"`
	AppData           string `json:"appData,omitempty"`
	FeeAmount         string `json:"feeAmount"`
	Kind              string `json:"kind,omitempty"`
	PartiallyFillable bool   `json:"partiallyFillable"`
	Signature         string `json:"signature,omitempty"`
	SigningScheme     string `json:"signingScheme,omitempty"`
	SellTokenBalance  string `json:"sellTokenBalance,omitempty"`
	BuyTokenBalance   string `json:"buyTokenBalance,omitempty"`
	From              string `json:"from,omitempty"`
}

CounterOrder represents a Gnosis CounterOrder.

func SignEip712Order added in v1.0.5

func SignEip712Order(c *Client, o *CounterOrder) (*CounterOrder, error)

SignEip712Order Signs order with EIP712 signing scheme

func SignEthSignOrder added in v1.0.5

func SignEthSignOrder(c *Client, o *CounterOrder) (*CounterOrder, error)

SignEthSignOrder Signs order with eth_sign signing scheme

type ErrorCowResponse

type ErrorCowResponse struct {
	Code        int    `json:"code"`
	ErrorType   string `json:"errorType"`
	Description string `json:"description"`
}

func (*ErrorCowResponse) Error

func (e *ErrorCowResponse) Error() string

type GetTrades

type GetTrades struct {
	Owner    string
	OrderUid string
}

type NativePriceResponse

type NativePriceResponse struct {
	Price float64 `json:"price"`
}

type OrderByUidResponse

type OrderByUidResponse struct {
	SellToken                    string    `json:"sellToken"`
	BuyToken                     string    `json:"buyToken"`
	Receiver                     string    `json:"receiver"`
	SellAmount                   string    `json:"sellAmount"`
	BuyAmount                    string    `json:"buyAmount"`
	ValidTo                      int       `json:"validTo"`
	AppData                      string    `json:"appData"`
	FeeAmount                    string    `json:"feeAmount"`
	Kind                         string    `json:"kind"`
	PartiallyFillable            bool      `json:"partiallyFillable"`
	SellTokenBalance             string    `json:"sellTokenBalance"`
	BuyTokenBalance              string    `json:"buyTokenBalance"`
	SigningScheme                string    `json:"signingScheme"`
	Signature                    string    `json:"signature"`
	From                         string    `json:"from"`
	QuoteID                      int       `json:"quoteId"`
	CreationTime                 time.Time `json:"creationTime"`
	Owner                        string    `json:"owner"`
	UID                          string    `json:"UID"`
	AvailableBalance             string    `json:"availableBalance"`
	ExecutedSellAmount           string    `json:"executedSellAmount"`
	ExecutedSellAmountBeforeFees string    `json:"executedSellAmountBeforeFees"`
	ExecutedBuyAmount            string    `json:"executedBuyAmount"`
	ExecutedFeeAmount            string    `json:"executedFeeAmount"`
	Invalidated                  bool      `json:"invalidated"`
	Status                       string    `json:"status"`
	FullFeeAmount                string    `json:"fullFeeAmount"`
	IsLiquidityOrder             bool      `json:"isLiquidityOrder"`
	EthflowData                  struct {
		IsRefunded  bool `json:"isRefunded"`
		UserValidTo int  `json:"userValidTo"`
	} `json:"ethflowData"`
	OnchainUser string `json:"onchainUser"`
}

type OrdersByTxHashResponse

type OrdersByTxHashResponse []struct {
	CreationDate                 time.Time   `json:"creationDate"`
	Owner                        string      `json:"owner"`
	UID                          string      `json:"uid"`
	AvailableBalance             interface{} `json:"availableBalance"`
	ExecutedBuyAmount            string      `json:"executedBuyAmount"`
	ExecutedSellAmount           string      `json:"executedSellAmount"`
	ExecutedSellAmountBeforeFees string      `json:"executedSellAmountBeforeFees"`
	ExecutedFeeAmount            string      `json:"executedFeeAmount"`
	Invalidated                  bool        `json:"invalidated"`
	Status                       string      `json:"status"`
	Class                        string      `json:"class"`
	SettlementContract           string      `json:"settlementContract"`
	FullFeeAmount                string      `json:"fullFeeAmount"`
	IsLiquidityOrder             bool        `json:"isLiquidityOrder"`
	SellToken                    string      `json:"sellToken"`
	BuyToken                     string      `json:"buyToken"`
	Receiver                     string      `json:"receiver"`
	SellAmount                   string      `json:"sellAmount"`
	BuyAmount                    string      `json:"buyAmount"`
	ValidTo                      int         `json:"validTo"`
	AppData                      string      `json:"appData"`
	FeeAmount                    string      `json:"feeAmount"`
	Kind                         string      `json:"kind"`
	PartiallyFillable            bool        `json:"partiallyFillable"`
	SellTokenBalance             string      `json:"sellTokenBalance"`
	BuyTokenBalance              string      `json:"buyTokenBalance"`
	SigningScheme                string      `json:"signingScheme"`
	Signature                    string      `json:"signature"`
	Interactions                 struct {
		Pre []interface{} `json:"pre"`
	} `json:"interactions"`
}

type OrdersByUserResponse

type OrdersByUserResponse []struct {
	CreationDate                 time.Time   `json:"creationDate"`
	Owner                        string      `json:"owner"`
	UID                          string      `json:"uid"`
	AvailableBalance             interface{} `json:"availableBalance"`
	ExecutedBuyAmount            string      `json:"executedBuyAmount"`
	ExecutedSellAmount           string      `json:"executedSellAmount"`
	ExecutedSellAmountBeforeFees string      `json:"executedSellAmountBeforeFees"`
	ExecutedFeeAmount            string      `json:"executedFeeAmount"`
	Invalidated                  bool        `json:"invalidated"`
	Status                       string      `json:"status"`
	Class                        string      `json:"class"`
	SettlementContract           string      `json:"settlementContract"`
	FullFeeAmount                string      `json:"fullFeeAmount"`
	IsLiquidityOrder             bool        `json:"isLiquidityOrder"`
	SellToken                    string      `json:"sellToken"`
	BuyToken                     string      `json:"buyToken"`
	Receiver                     string      `json:"receiver"`
	SellAmount                   string      `json:"sellAmount"`
	BuyAmount                    string      `json:"buyAmount"`
	ValidTo                      int         `json:"validTo"`
	AppData                      string      `json:"appData"`
	FeeAmount                    string      `json:"feeAmount"`
	Kind                         string      `json:"kind"`
	PartiallyFillable            bool        `json:"partiallyFillable"`
	SellTokenBalance             string      `json:"sellTokenBalance"`
	BuyTokenBalance              string      `json:"buyTokenBalance"`
	SigningScheme                string      `json:"signingScheme"`
	Signature                    string      `json:"signature"`
	Interactions                 struct {
		Pre []interface{} `json:"pre"`
	} `json:"interactions"`
}

type OrdersPaginated

type OrdersPaginated struct {
	Offset string
	Limit  string
}

type QuoteReq

type QuoteReq struct {
	SellToken           string `json:"sellToken"`
	BuyToken            string `json:"buyToken"`
	Receiver            string `json:"receiver"`
	AppData             string `json:"appData"`
	PartiallyFillable   bool   `json:"partiallyFillable"`
	SellTokenBalance    string `json:"sellTokenBalance"`
	BuyTokenBalance     string `json:"buyTokenBalance"`
	PriceQuality        string `json:"priceQuality"`
	SigningScheme       string `json:"signingScheme"`
	OnchainOrder        bool   `json:"onchainOrder"`
	Kind                string `json:"kind"`
	SellAmountBeforeFee string `json:"sellAmountBeforeFee"`
	From                string `json:"from"`
}

type QuoteResponse

type QuoteResponse struct {
	Quote struct {
		SellToken         string `json:"sellToken"`
		BuyToken          string `json:"buyToken"`
		Receiver          string `json:"receiver"`
		SellAmount        string `json:"sellAmount"`
		BuyAmount         string `json:"buyAmount"`
		ValidTo           int    `json:"validTo"`
		AppData           string `json:"appData"`
		FeeAmount         string `json:"feeAmount"`
		Kind              string `json:"kind"`
		PartiallyFillable bool   `json:"partiallyFillable"`
		SellTokenBalance  string `json:"sellTokenBalance"`
		BuyTokenBalance   string `json:"buyTokenBalance"`
		SigningScheme     string `json:"signingScheme"`
	} `json:"quote"`
	From       string    `json:"from"`
	Expiration time.Time `json:"expiration"`
	ID         int       `json:"id"`
}

type SignOrderFunc added in v1.0.5

type SignOrderFunc func(*Client, *CounterOrder) (*CounterOrder, error)

type SolverAuctionByIdResponse

type SolverAuctionByIdResponse struct {
	AuctionId                  int     `json:"auctionId"`
	TransactionHash            string  `json:"transactionHash"`
	GasPrice                   float64 `json:"gasPrice"`
	LiquidityCollectedBlock    int     `json:"liquidityCollectedBlock"`
	CompetitionSimulationBlock int     `json:"competitionSimulationBlock"`
	Solutions                  []struct {
		Solver    string `json:"solver"`
		Objective struct {
			Total   float64 `json:"total"`
			Surplus float64 `json:"surplus"`
			Fees    float64 `json:"fees"`
			Cost    float64 `json:"cost"`
			Gas     int     `json:"gas"`
		} `json:"objective"`
		Prices struct {
			AdditionalProp1 string `json:"additionalProp1"`
			AdditionalProp2 string `json:"additionalProp2"`
			AdditionalProp3 string `json:"additionalProp3"`
		} `json:"prices"`
		Orders []struct {
			Id             string `json:"id"`
			ExecutedAmount string `json:"executedAmount"`
		} `json:"orders"`
		CallData string `json:"callData"`
	} `json:"solutions"`
}

type SolverAuctionByTxHashResponse

type SolverAuctionByTxHashResponse struct {
	AuctionId                  int     `json:"auctionId"`
	TransactionHash            string  `json:"transactionHash"`
	GasPrice                   float64 `json:"gasPrice"`
	LiquidityCollectedBlock    int     `json:"liquidityCollectedBlock"`
	CompetitionSimulationBlock int     `json:"competitionSimulationBlock"`
	Solutions                  []struct {
		Solver    string `json:"solver"`
		Objective struct {
			Total   float64 `json:"total"`
			Surplus float64 `json:"surplus"`
			Fees    float64 `json:"fees"`
			Cost    float64 `json:"cost"`
			Gas     int     `json:"gas"`
		} `json:"objective"`
		Prices struct {
			AdditionalProp1 string `json:"additionalProp1"`
			AdditionalProp2 string `json:"additionalProp2"`
			AdditionalProp3 string `json:"additionalProp3"`
		} `json:"prices"`
		Orders []struct {
			Id             string `json:"id"`
			ExecutedAmount string `json:"executedAmount"`
		} `json:"orders"`
		CallData string `json:"callData"`
	} `json:"solutions"`
}

type TradesResponse

type TradesResponse []struct {
	BlockNumber          int    `json:"blockNumber"`
	LogIndex             int    `json:"logIndex"`
	OrderUID             string `json:"orderUid"`
	BuyAmount            string `json:"buyAmount"`
	SellAmount           string `json:"sellAmount"`
	SellAmountBeforeFees string `json:"sellAmountBeforeFees"`
	Owner                string `json:"owner"`
	BuyToken             string `json:"buyToken"`
	SellToken            string `json:"sellToken"`
	TxHash               string `json:"txHash"`
}

type TransactionSigner

type TransactionSigner struct {
	PrivateKey   *ecdsa.PrivateKey
	SignerPubKey common.Address
	Auth         *bind.TransactOpts
}

func NewSigner

func NewSigner(privateKey string, chainId *big.Int) (*TransactionSigner, error)

NewSigner - Creates a transaction signer with private key

type VersionResponse

type VersionResponse struct {
	Branch  string `json:"branch"`
	Commit  string `json:"commit"`
	Version string `json:"version"`
}

Directories

Path Synopsis
contracts
examples
util

Jump to

Keyboard shortcuts

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