Documentation ¶
Index ¶
- func StartDeleveragingDaemonTaskLoop(client *Client, ctx context.Context, s SubTaskRunner, flags flags.DaemonFlags, ...)
- type Client
- func (c *Client) FetchSubaccountsAtBlockHeight(ctx context.Context, blockHeight uint32, ...) (subaccounts []satypes.Subaccount, err error)
- func (c *Client) GetAllSubaccounts(ctx context.Context, pageLimit uint64) (subaccounts []satypes.Subaccount, err error)
- func (c *Client) GetPreviousBlockInfo(ctx context.Context) (blockHeight uint32, err error)
- func (c *Client) GetSubaccountOpenPositionInfo(subaccounts []satypes.Subaccount) (subaccountOpenPositionInfo map[uint32]*clobtypes.SubaccountOpenPositionInfo)
- func (c *Client) SendDeleveragingSubaccountIds(ctx context.Context, ...) error
- func (c *Client) Start(ctx context.Context, flags flags.DaemonFlags, appFlags appflags.Flags, ...) error
- type SubTaskRunner
- type SubTaskRunnerImpl
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StartDeleveragingDaemonTaskLoop ¶
func StartDeleveragingDaemonTaskLoop( client *Client, ctx context.Context, s SubTaskRunner, flags flags.DaemonFlags, ticker *time.Ticker, stop <-chan bool, )
StartDeleveragingDaemonTaskLoop contains the logic to periodically run the deleveraging daemon task.
Types ¶
type Client ¶
type Client struct { // Query clients BlocktimeQueryClient blocktimetypes.QueryClient SubaccountQueryClient satypes.QueryClient DeleveragingServiceClient api.DeleveragingServiceClient // include HealthCheckable to track the health of the daemon. daemontypes.HealthCheckable // contains filtered or unexported fields }
Client implements a daemon service client that periodically gets a list of all subaccounts with open positions on perpetuals
func (*Client) FetchSubaccountsAtBlockHeight ¶
func (c *Client) FetchSubaccountsAtBlockHeight( ctx context.Context, blockHeight uint32, deleveragingFlags flags.DeleveragingFlags, ) ( subaccounts []satypes.Subaccount, err error, )
func (*Client) GetAllSubaccounts ¶
func (c *Client) GetAllSubaccounts( ctx context.Context, pageLimit uint64, ) ( subaccounts []satypes.Subaccount, err error, )
GetAllSubaccounts queries a gRPC server and returns a list of subaccounts and their balances and open positions.
func (*Client) GetPreviousBlockInfo ¶
GetPreviousBlockInfo queries a gRPC server using `QueryPreviousBlockInfoRequest` and returns the previous block height.
func (*Client) GetSubaccountOpenPositionInfo ¶
func (c *Client) GetSubaccountOpenPositionInfo( subaccounts []satypes.Subaccount, ) ( subaccountOpenPositionInfo map[uint32]*clobtypes.SubaccountOpenPositionInfo, )
GetSubaccountOpenPositionInfo iterates over the given subaccounts and returns a map of perpetual id to open position info.
func (*Client) SendDeleveragingSubaccountIds ¶
func (c *Client) SendDeleveragingSubaccountIds( ctx context.Context, openPositionInfoMap map[uint32]*clobtypes.SubaccountOpenPositionInfo, ) error
SendDeleveragingSubaccountIds sends a list of subaccounts with open positions for each perp to a gRPC server via `UpdateSubaccountsListForDeleveragingDaemon`.
func (*Client) Start ¶
func (c *Client) Start( ctx context.Context, flags flags.DaemonFlags, appFlags appflags.Flags, grpcClient daemontypes.GrpcClient, ) error
Start begins a job that periodically: 1) Queries a gRPC server for all subaccounts including their open positions. 2) Sends a list of subaccount ids with open positions for each perpetual.
type SubTaskRunner ¶
type SubTaskRunner interface { RunDeleveragingDaemonTaskLoop( ctx context.Context, client *Client, deleveragingFlags flags.DeleveragingFlags, ) error }
SubTaskRunner provides an interface that encapsulates the deleveraging daemon logic to gather subaccounts with open positions for each perp. This interface is used to mock the daemon logic in tests.
type SubTaskRunnerImpl ¶
type SubTaskRunnerImpl struct{}
func (*SubTaskRunnerImpl) RunDeleveragingDaemonTaskLoop ¶
func (s *SubTaskRunnerImpl) RunDeleveragingDaemonTaskLoop( ctx context.Context, daemonClient *Client, deleveragingFlags flags.DeleveragingFlags, ) error
RunDeleveragingDaemonTaskLoop contains the logic to communicate with various gRPC services to generate the list of subaccounts with open positions for each perpetual.