Skip to content

Commit

Permalink
[IND-461] handle deleveraging events (#730)
Browse files Browse the repository at this point in the history
  • Loading branch information
dydxwill committed Nov 9, 2023
1 parent 8ec07fa commit 8c5c258
Show file tree
Hide file tree
Showing 21 changed files with 754 additions and 62 deletions.
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

0 comments on commit 8c5c258

Please sign in to comment.