mai3

package
v0.0.110 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBlockLengthNotEqualMAI3 = errors.New("length of block graph not equal to mai3 graph")
)

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(logger logging.Logger, url string, btcWhiteList *Whitelist,
	ethWhiteList *Whitelist, satsWhiteList *Whitelist,
	perpIDsUSDBased ...string) *Client

func (*Client) GetMarkPriceWithBlockNumberAddrIndex

func (m *Client) GetMarkPriceWithBlockNumberAddrIndex(
	blockNumber int64, poolAddr string, perpIndex int) (decimal.Decimal, error)

GetMarkPriceWithBlockNumberAddrIndex get mark price based on block number, pool address, perpetual index.

func (*Client) GetMarkPrices

func (m *Client) GetMarkPrices(blockNumber int64) (map[string]decimal.Decimal, error)

GetMarkPrices get mark prices with block number. return map[markPriceID]price

func (*Client) GetPerpIDWithUSDBased

func (m *Client) GetPerpIDWithUSDBased(symbol string) (string, error)

func (*Client) GetUsersBasedOnBlockNumber

func (m *Client) GetUsersBasedOnBlockNumber(blockNumber int64) ([]User, error)

GetUsersBasedOnBlockNumber get users based on blockNumber.

func (*Client) GetUsersBasedOnBlockNumberTrade added in v0.0.82

func (m *Client) GetUsersBasedOnBlockNumberTrade(blockNumber int64, trader string) (User, error)

func (*Client) InBTCInverseContractWhiteList

func (m *Client) InBTCInverseContractWhiteList(perpID string) (bool, string)

func (*Client) InETHInverseContractWhiteList

func (m *Client) InETHInverseContractWhiteList(perpID string) (bool, string)

func (*Client) InSATSInverseContractWhiteList added in v0.0.66

func (m *Client) InSATSInverseContractWhiteList(perpID string) (bool, string)

type Errors added in v0.0.82

type Errors []struct {
	Message string
}

func (Errors) Error added in v0.0.82

func (e Errors) Error() string

type GraphInterface

type GraphInterface interface {
	GetUsersBasedOnBlockNumber(blockNumber int64) ([]User, error)
	GetMarkPrices(blockNumber int64) (map[string]decimal.Decimal, error)
	GetMarkPriceWithBlockNumberAddrIndex(
		blockNumber int64, poolAddr string, perpIndex int) (decimal.Decimal, error)

	// InBTCInverseContractWhiteList return (true, base) if this contract is inverse white list
	InBTCInverseContractWhiteList(perpID string) (bool, string)
	// InETHInverseContractWhiteList return (true, base) if this contract is inverse white list
	InETHInverseContractWhiteList(perpID string) (bool, string)
	// InSATSInverseContractWhiteList return (true, base) if this contract is inverse white list
	InSATSInverseContractWhiteList(perpID string) (bool, string)

	// GetPerpIDWithUSDBased get perpetual id depend on symbol.
	GetPerpIDWithUSDBased(symbol string) (string, error)
}

type MarginAccount

type MarginAccount struct {
	ID                string          `json:"id"`
	Position          decimal.Decimal `json:"position"`
	TotalFee          decimal.Decimal `json:"totalFee"`
	VaultFee          decimal.Decimal `json:"vaultFee"`
	OperatorFee       decimal.Decimal `json:"operatorFee"`
	TotalFeeFactor    decimal.Decimal `json:"totalFeeFactor"`
	VaultFeeFactor    decimal.Decimal `json:"vaultFeeFactor"`
	OperatorFeeFactor decimal.Decimal `json:"operatorFeeFactor"`
}

type MarkPrice

type MarkPrice struct {
	ID    string          `json:"id"`
	Price decimal.Decimal `json:"price"`
}

type MultiClient

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

func NewMultiClient

func NewMultiClient(logger logging.Logger, clients []GraphInterface) *MultiClient

func (*MultiClient) GetMai3GraphInterface

func (c *MultiClient) GetMai3GraphInterface(index int) (GraphInterface, error)

func (*MultiClient) GetMultiMarkPrices

func (c *MultiClient) GetMultiMarkPrices(blockNumbers []int64) (map[string]decimal.Decimal, error)

GetMultiMarkPrices the order of clients need to match blockNumbers

func (*MultiClient) GetMultiUsersBasedOnMultiBlockNumbers

func (c *MultiClient) GetMultiUsersBasedOnMultiBlockNumbers(blockNumbers []int64) ([][]User, error)

GetMultiUsersBasedOnMultiBlockNumbers the order of clients need to match blockNumbers, return 2-D users

type MultiGraphInterface

type MultiGraphInterface interface {
	GetMultiUsersBasedOnMultiBlockNumbers(blockNumbers []int64) ([][]User, error)
	GetMultiMarkPrices(blockNumbers []int64) (map[string]decimal.Decimal, error)
	GetMai3GraphInterface(index int) (GraphInterface, error)
}

type User

type User struct {
	ID             string          `json:"id"`
	StakedMCB      decimal.Decimal `json:"stakedMCB"`
	UnlockMCBTime  int64           `json:"unlockMCBTime"`
	MarginAccounts []*MarginAccount
}

type Whitelist added in v0.0.76

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

func NewWhiteList added in v0.0.76

func NewWhiteList(logger logging.Logger, contractAddr ...string) *Whitelist

NewWhiteList makes sure order of contract address. index = 0 should be USD, index = 1 should be BTC, index = 2 should be ETH.

func (*Whitelist) InInverseContractWhiteList added in v0.0.76

func (w *Whitelist) InInverseContractWhiteList(perpID string) (bool, string)

Jump to

Keyboard shortcuts

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