Skip to content

Commit

Permalink
address cmts
Browse files Browse the repository at this point in the history
  • Loading branch information
dydxwill committed Nov 8, 2023
1 parent 6d856b4 commit 25ba7be
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export class DeleveragingHandler extends Handler<DeleveragingEventV1> {
{ txId: this.txId },
).catch((error: Error) => {
logger.error({
at: 'deleveragingHandler#handleViaSqlFunction',
at: 'DeleveragingHandler#handleViaSqlFunction',
message: 'Failed to handle DeleveragingEventV1',
error,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ import { DateTime } from 'luxon';
import {
generateFillSubaccountMessage,
generateOrderSubaccountMessage,
generatePerpetualPositionsContents, isDeleveraging,
generatePerpetualPositionsContents,
isDeleveraging,
isLiquidation,
} from '../../helpers/kafka-helper';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ const scripts: string[] = [
'dydx_event_id_from_parts.sql',
'dydx_event_to_transaction_index.sql',
'dydx_from_jsonlib_long.sql',
'dydx_from_protocol_is_buy.sql',
'dydx_from_protocol_order_side.sql',
'dydx_from_protocol_time_in_force.sql',
'dydx_from_serializable_int.sql',
Expand Down
16 changes: 8 additions & 8 deletions indexer/services/ender/src/scripts/dydx_deleveraging_handler.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
account the block_event (https://github.com/dydxprotocol/indexer/blob/cc70982/services/ender/src/lib/helper.ts#L33)
- transaction_hash: The transaction hash corresponding to this event from the IndexerTendermintBlock 'tx_hashes'.
Returns: JSON object containing fields:
- liquidated_fill: The updated liquidated fill in fill-model format (https://github.com/dydxprotocol/indexer/blob/cc70982/packages/postgres/src/models/fill-model.ts).
- offsetting_fill: The updated liquidated fill in fill-model format (https://github.com/dydxprotocol/indexer/blob/cc70982/packages/postgres/src/models/fill-model.ts).
- liquidated_fill: The created liquidated fill in fill-model format (https://github.com/dydxprotocol/indexer/blob/cc70982/packages/postgres/src/models/fill-model.ts).
- offsetting_fill: The created offsetting fill in fill-model format (https://github.com/dydxprotocol/indexer/blob/cc70982/packages/postgres/src/models/fill-model.ts).
- perpetual_market: The perpetual market for the deleveraging in perpetual-market-model format (https://github.com/dydxprotocol/indexer/blob/cc70982/packages/postgres/src/models/perpetual-market-model.ts).
- liquidated_perpetual_position: The updated liquidated perpetual position in perpetual-position-model format (https://github.com/dydxprotocol/indexer/blob/cc70982/packages/postgres/src/models/perpetual-position-model.ts).
- offsetting_perpetual_position: The updated offsetting perpetual position in perpetual-position-model format (https://github.com/dydxprotocol/indexer/blob/cc70982/packages/postgres/src/models/perpetual-position-model.ts).
Expand Down Expand Up @@ -58,7 +58,7 @@ BEGIN

liquidated_subaccount_uuid = dydx_uuid_from_subaccount_id(event_data->'liquidated');
offsetting_subaccount_uuid = dydx_uuid_from_subaccount_id(event_data->'offsetting');
offsetting_side = dydx_from_protocol_is_buy((event_data->'isBuy')::bool);
offsetting_side = CASE WHEN (event_data->'isBuy')::bool THEN 'BUY' ELSE 'SELL' END;
liquidated_side = CASE WHEN offsetting_side = 'BUY' THEN 'SELL' ELSE 'BUY' END;
clob_pair_id = perpetual_market_record."clobPairId";

Expand Down Expand Up @@ -105,17 +105,17 @@ BEGIN

/* Upsert the perpetual_position records for this deleveraging event. */
liquidated_perpetual_position_record = dydx_update_perpetual_position(
liquidated_subaccount_uuid,
liquidated_subaccount_uuid,
perpetual_id,
liquidated_side,
size,
price);
offsetting_perpetual_position_record = dydx_update_perpetual_position(
offsetting_subaccount_uuid,
perpetual_id,
offsetting_side,
size,
price);
perpetual_id,
offsetting_side,
size,
price);


RETURN jsonb_build_object(
Expand Down
12 changes: 0 additions & 12 deletions indexer/services/ender/src/scripts/dydx_from_protocol_is_buy.sql

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/**
Parameters:
- subaccount_uuid: The subaccount uuid of the updated perpetual position.
- perpetual_id: The perpetual id of the updated perpetual position.
- side: The side of the fill.
- size: The size of the fill.
- price: The price of the fill.
Returns: the updated perpetual position.
*/
CREATE OR REPLACE FUNCTION dydx_update_perpetual_position(
subaccount_uuid uuid,
perpetual_id bigint,
Expand Down Expand Up @@ -53,7 +62,7 @@ BEGIN
"entryPrice" = entry_price,
"sumClose" = sum_close,
"exitPrice" = exit_price
WHERE "id" = perpetual_position_record.id;
WHERE "id" = perpetual_position_record."id";

-- Return the updated perpetual position record
RETURN perpetual_position_record;
Expand Down

0 comments on commit 25ba7be

Please sign in to comment.