Documentation ¶
Index ¶
- Constants
- Variables
- func BuildAdd(followID string, oppositeAsset string, slippage decimal.Decimal, ...) string
- func BuildRemove(followID string) string
- func BuildSwap(followID string, fillAsset string, paths route.Paths, ...) string
- func Ceil(d decimal.Decimal, precision int32) decimal.Decimal
- func Decimal(v string) decimal.Decimal
- func DecodeResponse(resp *resty.Response) ([]byte, error)
- func GenerateToken(clientID, sessionID, sessionKey string, exp time.Duration) (string, error)
- func IsErrorCode(err error, code int) bool
- func UnmarshalResponse(resp *resty.Response, v interface{}) error
- type Asset
- type Client
- func (c *Client) ListAssets(ctx context.Context) ([]*Asset, error)
- func (c *Client) ListPairs(ctx context.Context) ([]*Pair, error)
- func (c *Client) PreOrder(ctx context.Context, req *PreOrderReq) (*Order, error)
- func (c *Client) ReadAsset(ctx context.Context, assetID string) (*Asset, error)
- func (c *Client) ReadDeposit(ctx context.Context, depositID string) (*Deposit, error)
- func (c *Client) ReadGroup(ctx context.Context) (*Group, error)
- func (c *Client) ReadOrder(ctx context.Context, id string) (*Order, error)
- func (c *Client) ReadPair(ctx context.Context, base, quote string) (*Pair, error)
- func (c *Client) Resty() *resty.Client
- func (c *Client) UseEndpoint(endpoint string)
- func (c *Client) UseToken(token string)
- type Deposit
- type Error
- type Graph
- type Group
- type Order
- func MergeOrders(orders []*Order) *Order
- func PreOrderWithPairs(pairs []*Pair, req *PreOrderReq) (*Order, error)
- func ReverseRoute(pairs []*Pair, payAssetID, fillAssetID string, fillAmount decimal.Decimal) (*Order, error)
- func Route(pairs []*Pair, payAssetID, fillAssetID string, payAmount decimal.Decimal) (*Order, error)
- type Pair
- type PreOrderReq
- type Result
- type Transfer
Constants ¶
View Source
const ( ActionAdd uint16 = 1 ActionRemove uint16 = 2 ActionSwap uint16 = 3 ProtocolVersion uint8 = 2 )
View Source
const ( DepositStatePending = "Pending" DepositStateCancelled = "Cancelled" DepositStateDone = "Done" )
View Source
const ( OrderStateTrading = "Trading" OrderStateRejected = "Rejected" OrderStateDone = "Done" )
View Source
const (
MaxRouteDepth = 4
)
Variables ¶
View Source
var (
ErrInsufficientLiquiditySwapped = errors.New("insufficient liquidity swapped")
)
Functions ¶
func BuildRemove ¶
func DecodeResponse ¶
func GenerateToken ¶
GenerateToken create a new mixin authorization token store.Scope must be 'FULL'
func IsErrorCode ¶
func UnmarshalResponse ¶
func UnmarshalResponse(resp *resty.Response, v interface{}) error
Types ¶
type Asset ¶
type Asset struct { ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` Symbol string `json:"symbol,omitempty"` DisplaySymbol string `json:"display_symbol,omitempty"` Logo string `json:"logo,omitempty"` ChainID string `json:"chain_id,omitempty"` Price decimal.Decimal `json:"price,omitempty"` Tag string `json:"tag,omitempty"` Chain *Asset `json:"chain,omitempty"` }
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) ListAssets ¶
ListAssets list all assets
func (*Client) PreOrder ¶
PreOrder 预下单
如果要同时对多个交易对预下单,不建议使用这个方法;而是先调用 ListPairs 然后重复拷贝 Pairs 去 Route 或者 ReverseRoute,这样只需要调用一次 /pairs 接口 不会那么容易触发 Rate Limit **注意:** ListPairs 获取到的 Pairs 需要重复拷贝, Route 和 ReverseRoute 会修改Pairs数据
func (*Client) ReadDeposit ¶
func (*Client) UseEndpoint ¶
type Deposit ¶
type Deposit struct { ID string `json:"id,omitempty"` CreatedAt time.Time `json:"created_at,omitempty"` State string `json:"state,omitempty"` UserID string `json:"user_id,omitempty"` FollowID string `json:"follow_id,omitempty"` BaseAssetID string `json:"base_asset_id,omitempty"` QuoteAssetID string `json:"quote_asset_id,omitempty"` BaseAmount decimal.Decimal `json:"base_amount,omitempty"` QuoteAmount decimal.Decimal `json:"quote_amount,omitempty"` Slippage decimal.Decimal `json:"slippage,omitempty"` }
type Order ¶
type Order struct { ID string `json:"id,omitempty"` CreatedAt time.Time `json:"created_at,omitempty"` UserID string `json:"user_id,omitempty"` State string `json:"state,omitempty"` PayAssetID string `json:"pay_asset_id,omitempty"` PayAmount decimal.Decimal `json:"pay_amount,omitempty"` FillAssetID string `json:"fill_asset_id,omitempty"` FillAmount decimal.Decimal `json:"fill_amount,omitempty"` MinAmount decimal.Decimal `json:"min_amount,omitempty"` Paths route.Paths `json:"paths,omitempty"` PriceImpact decimal.Decimal `json:"-"` Transfers []*Transfer `json:"transfers,omitempty"` }
func MergeOrders ¶
func PreOrderWithPairs ¶
func PreOrderWithPairs(pairs []*Pair, req *PreOrderReq) (*Order, error)
func ReverseRoute ¶
type Pair ¶
type Pair struct { BaseAssetID string `json:"base_asset_id,omitempty"` BaseAmount decimal.Decimal `json:"base_amount,omitempty"` QuoteAssetID string `json:"quote_asset_id,omitempty"` QuoteAmount decimal.Decimal `json:"quote_amount,omitempty"` FeePercent decimal.Decimal `json:"fee_percent,omitempty"` ProfitRate decimal.Decimal `json:"profit_rate,omitempty"` RouteID uint16 `json:"route_id,omitempty"` // 池子总的流动性份额 LiquidityAssetID string `json:"liquidity_asset_id,omitempty"` Liquidity decimal.Decimal `json:"liquidity,omitempty"` SwapMethod string `json:"swap_method,omitempty"` Version int64 `json:"version,omitempty"` // volume Volume24h decimal.Decimal `json:"volume_24h,omitempty"` BaseVolume24h decimal.Decimal `json:"base_volume_24h,omitempty"` QuoteVolume24h decimal.Decimal `json:"quote_volume_24h,omitempty"` // value BaseValue decimal.Decimal `json:"base_value,omitempty"` QuoteValue decimal.Decimal `json:"quote_value,omitempty"` // stat Fee24h decimal.Decimal `json:"fee_24h,omitempty"` TransactionCount24h int64 `json:"transaction_count_24h,omitempty"` }
type PreOrderReq ¶
type Result ¶
type Result struct { PayAssetID string PayAmount decimal.Decimal FillAssetID string FillAmount decimal.Decimal FeeAssetID string FeeAmount decimal.Decimal ProfitAmount decimal.Decimal RouteID uint16 }
Result represent Swap Result
func ReverseSwap ¶
ReverseSwap is a Reverse version of Swap
type Transfer ¶ added in v2.0.1
type Transfer struct { ID string `json:"id,omitempty"` CreatedAt time.Time `json:"created_at,omitempty"` AssetID string `json:"asset_id,omitempty"` Amount decimal.Decimal `json:"amount,omitempty"` Memo string `json:"memo,omitempty"` Receiver protocol.MultisigReceiver `json:"receiver,omitempty"` TxHash mixinnet.Hash `json:"tx_hash,omitempty"` }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.