persistence

package
v0.0.0-...-84af44b Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2023 License: Apache-2.0 Imports: 30 Imported by: 2

Documentation

Index

Constants

View Source
const (
	OrderStatePending = "PENDING"
	OrderStateDone    = "DONE"
)
View Source
const (
	MakerFeeRate = "0.000"
	TakerFeeRate = "0.001"

	TradeLiquidityTaker = "TAKER"
	TradeLiquidityMaker = "MAKER"
)
View Source
const (
	TransferSourceTradeConfirmed = "TRADE_CONFIRMED"
	TransferSourceOrderCancelled = "ORDER_CANCELLED"
	TransferSourceOrderFilled    = "ORDER_FILLED"
	TransferSourceOrderInvalid   = "ORDER_INVALID"
)

Variables

View Source
var (
	ErrEdDSAVerification = errors.New("crypto/eddsa: verification error")
)

Functions

func AllBrokersWithToken

func AllBrokersWithToken(ctx context.Context, decryptPIN bool) ([]map[string]string, error)

func Authenticate

func Authenticate(ctx context.Context, jwtToken string) (string, error)

func CancelOrder

func CancelOrder(ctx context.Context, order *engine.Order) error

func CancelOrderAction

func CancelOrderAction(ctx context.Context, orderId string, createdAt time.Time, userId string) error

func CountPendingActions

func CountPendingActions(ctx context.Context) (int64, error)

func CountPendingTransfers

func CountPendingTransfers(ctx context.Context) (int64, error)

func CreateOrderAction

func CreateOrderAction(ctx context.Context, o *engine.Order, userId, brokerId string, createdAt time.Time) error

func CreateRefundTransfer

func CreateRefundTransfer(ctx context.Context, brokerId, userId, assetId string, amount, fee number.Decimal, trace string) error

func ExpireTransfers

func ExpireTransfers(ctx context.Context, transfers []*Transfer) error

func ReadProperty

func ReadProperty(ctx context.Context, key string) (string, error)

func ReadPropertyAsTime

func ReadPropertyAsTime(ctx context.Context, key string) (time.Time, error)

func SetupSpanner

func SetupSpanner(ctx context.Context, client *spanner.Client) context.Context

func Spanner

func Spanner(ctx context.Context) *spanner.Client

func Transact

func Transact(ctx context.Context, taker, maker *engine.Order, amount number.Integer) (string, error)

func UpdateUserPublicKey

func UpdateUserPublicKey(ctx context.Context, userId, publicKey string) error

func WriteProperty

func WriteProperty(ctx context.Context, key, value string) error

func WriteTimeProperty

func WriteTimeProperty(ctx context.Context, key string, value time.Time) error

Types

type Action

type Action struct {
	OrderId   string    `spanner:"order_id"`
	Action    string    `spanner:"action"`
	CreatedAt time.Time `spanner:"created_at"`

	Order *Order `spanner:"-"`
}

func ListPendingActions

func ListPendingActions(ctx context.Context, checkpoint time.Time, limit int) ([]*Action, error)

type Broker

type Broker struct {
	BrokerId         string    `spanner:"broker_id"`
	SessionId        string    `spanner:"session_id"`
	SessionKey       string    `spanner:"session_key"`
	PINToken         string    `spanner:"pin_token"`
	EncryptedPIN     string    `spanner:"encrypted_pin"`
	EncryptionHeader []byte    `spanner:"encryption_header"`
	CreatedAt        time.Time `spanner:"created_at"`

	DecryptedPIN string `spanner:"-"`
}

func AddBroker

func AddBroker(ctx context.Context) (*Broker, error)

func AllBrokers

func AllBrokers(ctx context.Context, decryptPIN bool) ([]*Broker, error)

type EdDSASigningMethod

type EdDSASigningMethod struct{}
var Ed25519SigningMethod *EdDSASigningMethod

func (*EdDSASigningMethod) Alg

func (sm *EdDSASigningMethod) Alg() string

func (*EdDSASigningMethod) Sign

func (sm *EdDSASigningMethod) Sign(signingString string, key interface{}) (string, error)

func (*EdDSASigningMethod) Verify

func (sm *EdDSASigningMethod) Verify(signingString, signature string, key interface{}) error

type Order

type Order struct {
	OrderId         string    `spanner:"order_id"`
	OrderType       string    `spanner:"order_type"`
	QuoteAssetId    string    `spanner:"quote_asset_id"`
	BaseAssetId     string    `spanner:"base_asset_id"`
	Side            string    `spanner:"side"`
	Price           string    `spanner:"price"`
	RemainingAmount string    `spanner:"remaining_amount"`
	FilledAmount    string    `spanner:"filled_amount"`
	RemainingFunds  string    `spanner:"remaining_funds"`
	FilledFunds     string    `spanner:"filled_funds"`
	CreatedAt       time.Time `spanner:"created_at"`
	State           string    `spanner:"state"`
	UserId          string    `spanner:"user_id"`
	BrokerId        string    `spanner:"broker_id"`
}

func UserOrder

func UserOrder(ctx context.Context, orderId, userId string) (*Order, error)

func UserOrders

func UserOrders(ctx context.Context, userId string, market, state string, offset time.Time, order string, limit int) ([]*Order, error)

type Property

type Property struct {
	Key       string
	Value     string
	UpdatedAt time.Time
}

type Trade

type Trade struct {
	TradeId      string    `spanner:"trade_id"`
	Liquidity    string    `spanner:"liquidity"`
	AskOrderId   string    `spanner:"ask_order_id"`
	BidOrderId   string    `spanner:"bid_order_id"`
	QuoteAssetId string    `spanner:"quote_asset_id"`
	BaseAssetId  string    `spanner:"base_asset_id"`
	Side         string    `spanner:"side"`
	Price        string    `spanner:"price"`
	Amount       string    `spanner:"amount"`
	CreatedAt    time.Time `spanner:"created_at"`
	UserId       string    `spanner:"user_id"`
	FeeAssetId   string    `spanner:"fee_asset_id"`
	FeeAmount    string    `spanner:"fee_amount"`
}

func LastTrade

func LastTrade(ctx context.Context, market string) (*Trade, error)

func MarketTrades

func MarketTrades(ctx context.Context, market string, offset time.Time, order string, limit int) ([]*Trade, error)

func ReadTransferTrade

func ReadTransferTrade(ctx context.Context, tradeId, assetId string) (*Trade, error)

type Transfer

type Transfer struct {
	TransferId string    `spanner:"transfer_id"`
	Source     string    `spanner:"source"`
	Detail     string    `spanner:"detail"`
	AssetId    string    `spanner:"asset_id"`
	Amount     string    `spanner:"amount"`
	Fee        string    `spanner:"fee"`
	CreatedAt  time.Time `spanner:"created_at"`
	UserId     string    `spanner:"user_id"`
	BrokerId   string    `spanner:"broker_id"`
}

func ListPendingTransfers

func ListPendingTransfers(ctx context.Context, broker string, limit int) ([]*Transfer, error)

type User

type User struct {
	UserId    string
	PublicKey string
}

Jump to

Keyboard shortcuts

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