Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IND-461] handle deleveraging events #730

Merged
merged 31 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import * as Knex from 'knex';

import { formatAlterTableEnumSql } from '../helpers';

export async function up(knex: Knex): Promise<void> {
return knex.raw(formatAlterTableEnumSql(
'fills',
'type',
['MARKET', 'LIMIT', 'LIQUIDATED', 'LIQUIDATION', 'DELEVERAGED', 'OFFSETTING'],
));
}

export async function down(knex: Knex): Promise<void> {
return knex.raw(formatAlterTableEnumSql(
'fills',
'type',
['MARKET', 'LIMIT', 'LIQUIDATED', 'LIQUIDATION'],
));
}
6 changes: 6 additions & 0 deletions indexer/packages/postgres/src/types/fill-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ export enum FillType {
LIQUIDATED = 'LIQUIDATED',
// LIQUIDATION is for the maker side of the fill, never used for orders
LIQUIDATION = 'LIQUIDATION',
// DELEVERAGED is for the subaccount that was deleveraged in a deleveraging event.
// The fill type will be set to taker.
DELEVERAGED = 'DELEVERAGED',
// OFFSETTING is for the offsetting subaccount in a deleveraging event.
// The fill type will be set to maker.
OFFSETTING = 'OFFSETTING',
}

export interface FillCreateObject {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ export interface TradeContent {
side: string,
createdAt: IsoString,
liquidation: boolean,
deleveraging: boolean,
}

/* ------- MarketMessageContents ------- */
Expand Down
2 changes: 2 additions & 0 deletions indexer/services/comlink/public/api-documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2287,6 +2287,8 @@ This operation does not require authentication
|*anonymous*|LIMIT|
|*anonymous*|LIQUIDATED|
|*anonymous*|LIQUIDATION|
|*anonymous*|DELEVERAGED|
|*anonymous*|OFFSETTING|

## MarketType

Expand Down
4 changes: 3 additions & 1 deletion indexer/services/comlink/public/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,9 @@
"MARKET",
"LIMIT",
"LIQUIDATED",
"LIQUIDATION"
"LIQUIDATION",
"DELEVERAGED",
"OFFSETTING"
],
"type": "string"
},
Expand Down
6 changes: 6 additions & 0 deletions indexer/services/comlink/public/websocket-documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,12 @@ export enum FillType {
LIQUIDATED = 'LIQUIDATED',
// LIQUIDATION is for the maker side of the fill, never used for orders
LIQUIDATION = 'LIQUIDATION',
// DELEVERAGED is for the subaccount that was deleveraged in a deleveraging event.
// The fill type will be set to taker.
DELEVERAGED = 'DELEVERAGED',
// OFFSETTING is for the offsetting subaccount in a deleveraging event.
// The fill type will be set to maker.
OFFSETTING = 'OFFSETTING',
}

export interface TransferSubaccountMessageContents {
Expand Down
Loading
Loading