nanswapclient

package
v0.0.0-...-732ec5d Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a client for the Nanswap API

func New

func New(endpoint, apiKey string) *Client

New returns a new initialized Client

func (*Client) CreateOrder

func (c *Client) CreateOrder(ctx context.Context, from, to Ticker, amount decimal.Decimal, toAddress string, maxDuration time.Duration) (CreateOrderResponse, error)

CreateOrder creates a new order and returns order data

func (*Client) GetEstimate

func (c *Client) GetEstimate(ctx context.Context, from, to Ticker, fromAmount decimal.Decimal) (GetEstimateResponse, error)

GetEstimate gets estimated exchange amount

func (*Client) GetEstimateReverse

func (c *Client) GetEstimateReverse(ctx context.Context, from, to Ticker, toAmount decimal.Decimal) (GetEstimateResponse, error)

GetEstimateReverse takes toAmount and returns the fromAmount estimation

func (*Client) GetLimits

func (c *Client) GetLimits(ctx context.Context, from, to Ticker) (GetLimitsResponse, error)

GetLimits returns minimum and maximum from amount for a given pair. Maximum amount depends of current liquidity

func (*Client) GetOrder

func (c *Client) GetOrder(ctx context.Context, id string) (GetOrderResponse, error)

GetOrder returns data of an order

type CreateOrderResponse

type CreateOrderResponse struct {
	ID                 string          `json:"id"`
	From               Ticker          `json:"from"`
	To                 Ticker          `json:"to"`
	ExpectedAmountFrom decimal.Decimal `json:"expectedAmountFrom"`
	ExpectedAmountTo   decimal.Decimal `json:"expectedAmountTo"`
	PayinAddress       string          `json:"payinAddress"`
	PayoutAddress      string          `json:"payoutAddress"`
}

CreateOrderResponse represents the response to a CreateOrder request

type GetEstimateResponse

type GetEstimateResponse struct {
	From       Ticker          `json:"from"`
	To         Ticker          `json:"to"`
	AmountFrom decimal.Decimal `json:"amountFrom"`
	AmountTo   decimal.Decimal `json:"amountTo"`
}

GetEstimateResponse represents the response to a GetEstimate or GetEstimateReverse request

type GetLimitsResponse

type GetLimitsResponse struct {
	From Ticker          `json:"from"`
	To   Ticker          `json:"to"`
	Min  decimal.Decimal `json:"min"`
	Max  decimal.Decimal `json:"max"`
}

GetLimitsResponse represents the response to a GetLimits request

type GetOrderResponse

type GetOrderResponse struct {
	ID                 string          `json:"id"`
	Status             OrderStatus     `json:"status"`
	From               Ticker          `json:"from"`
	To                 Ticker          `json:"to"`
	ExpectedAmountFrom decimal.Decimal `json:"expectedAmountFrom"`
	ExpectedAmountTo   decimal.Decimal `json:"expectedAmountTo"`
	AmountFrom         decimal.Decimal `json:"amountFrom"`
	AmountTo           decimal.Decimal `json:"amountTo"`
	PayinAddress       string          `json:"payinAddress"`
	PayoutAddress      string          `json:"payoutAddress"`
	SenderAddress      string          `json:"senderAddress"`
	PayinHash          string          `json:"payinHash"`
	PayoutHash         string          `json:"payoutHash"`
}

GetOrderResponse represents the response to a GetOrder request

type OrderStatus

type OrderStatus string

OrderStatus represents the status of an order

var (
	OrderStatusWaiting    OrderStatus = "waiting"
	OrderStatusExchanging OrderStatus = "exchanging"
	OrderStatusSending    OrderStatus = "sending"
	OrderStatusCompleted  OrderStatus = "completed"
	OrderStatusError      OrderStatus = "error"
)

type Ticker

type Ticker string

Ticker represents the ticker for a Nanswap-supported currency

var (
	TickerNano   Ticker = "XNO"
	TickerBanano Ticker = "BAN"
)

Jump to

Keyboard shortcuts

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