Skip to content

Commit

Permalink
do not commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jayy04 committed Jun 12, 2024
1 parent a5f671a commit 402e2a4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
1 change: 1 addition & 0 deletions protocol/daemons/liquidation/client/sub_task_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ func (c *Client) FetchApplicationStateAtBlockHeight(

// Execute all queries at the given block height.
queryCtx := newContextWithQueryBlockHeight(ctx, blockHeight)
c.logger.Info("Fetching application state at block height", "block_height", blockHeight)

// Subaccounts
subaccounts, err = c.GetAllSubaccounts(queryCtx, liqFlags.QueryPageLimit)
Expand Down
8 changes: 4 additions & 4 deletions protocol/testing/genesis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function edit_genesis() {
dasel put -t json -f "$GENESIS" '.app_state.perpetuals.liquidity_tiers.[]' -v "{}"
dasel put -t int -f "$GENESIS" '.app_state.perpetuals.liquidity_tiers.[0].id' -v '0'
dasel put -t string -f "$GENESIS" '.app_state.perpetuals.liquidity_tiers.[0].name' -v 'Large-Cap'
dasel put -t int -f "$GENESIS" '.app_state.perpetuals.liquidity_tiers.[0].initial_margin_ppm' -v '50000' # 5%
dasel put -t int -f "$GENESIS" '.app_state.perpetuals.liquidity_tiers.[0].initial_margin_ppm' -v '500' # 5%
dasel put -t int -f "$GENESIS" '.app_state.perpetuals.liquidity_tiers.[0].maintenance_fraction_ppm' -v '600000' # 60% of IM
dasel put -t int -f "$GENESIS" '.app_state.perpetuals.liquidity_tiers.[0].base_position_notional' -v '1000000000000' # 1_000_000 USDC
dasel put -t int -f "$GENESIS" '.app_state.perpetuals.liquidity_tiers.[0].impact_notional' -v '10000000000' # 10_000 USDC (500 USDC / 5%)
Expand All @@ -143,7 +143,7 @@ function edit_genesis() {
dasel put -t json -f "$GENESIS" '.app_state.perpetuals.liquidity_tiers.[]' -v "{}"
dasel put -t int -f "$GENESIS" '.app_state.perpetuals.liquidity_tiers.[1].id' -v '1'
dasel put -t string -f "$GENESIS" '.app_state.perpetuals.liquidity_tiers.[1].name' -v 'Mid-Cap'
dasel put -t int -f "$GENESIS" '.app_state.perpetuals.liquidity_tiers.[1].initial_margin_ppm' -v '100000' # 10%
dasel put -t int -f "$GENESIS" '.app_state.perpetuals.liquidity_tiers.[1].initial_margin_ppm' -v '1000' # 10%
dasel put -t int -f "$GENESIS" '.app_state.perpetuals.liquidity_tiers.[1].maintenance_fraction_ppm' -v '500000' # 50% of IM
dasel put -t int -f "$GENESIS" '.app_state.perpetuals.liquidity_tiers.[1].base_position_notional' -v '250000000000' # 250_000 USDC
dasel put -t int -f "$GENESIS" '.app_state.perpetuals.liquidity_tiers.[1].impact_notional' -v '5000000000' # 5_000 USDC (500 USDC / 10%)
Expand All @@ -154,7 +154,7 @@ function edit_genesis() {
dasel put -t json -f "$GENESIS" '.app_state.perpetuals.liquidity_tiers.[]' -v "{}"
dasel put -t int -f "$GENESIS" '.app_state.perpetuals.liquidity_tiers.[2].id' -v '2'
dasel put -t string -f "$GENESIS" '.app_state.perpetuals.liquidity_tiers.[2].name' -v 'Long-Tail'
dasel put -t int -f "$GENESIS" '.app_state.perpetuals.liquidity_tiers.[2].initial_margin_ppm' -v '200000' # 20%
dasel put -t int -f "$GENESIS" '.app_state.perpetuals.liquidity_tiers.[2].initial_margin_ppm' -v '2000' # 20%
dasel put -t int -f "$GENESIS" '.app_state.perpetuals.liquidity_tiers.[2].maintenance_fraction_ppm' -v '500000' # 50% of IM
dasel put -t int -f "$GENESIS" '.app_state.perpetuals.liquidity_tiers.[2].base_position_notional' -v '100000000000' # 100_000 USDC
dasel put -t int -f "$GENESIS" '.app_state.perpetuals.liquidity_tiers.[2].impact_notional' -v '2500000000' # 2_500 USDC (500 USDC / 20%)
Expand All @@ -165,7 +165,7 @@ function edit_genesis() {
dasel put -t json -f "$GENESIS" '.app_state.perpetuals.liquidity_tiers.[]' -v "{}"
dasel put -t int -f "$GENESIS" '.app_state.perpetuals.liquidity_tiers.[3].id' -v '3'
dasel put -t string -f "$GENESIS" '.app_state.perpetuals.liquidity_tiers.[3].name' -v 'Safety'
dasel put -t int -f "$GENESIS" '.app_state.perpetuals.liquidity_tiers.[3].initial_margin_ppm' -v '1000000' # 100%
dasel put -t int -f "$GENESIS" '.app_state.perpetuals.liquidity_tiers.[3].initial_margin_ppm' -v '10000' # 100%
dasel put -t int -f "$GENESIS" '.app_state.perpetuals.liquidity_tiers.[3].maintenance_fraction_ppm' -v '200000' # 20% of IM
dasel put -t int -f "$GENESIS" '.app_state.perpetuals.liquidity_tiers.[3].base_position_notional' -v '1000000000' # 1_000 USDC
dasel put -t int -f "$GENESIS" '.app_state.perpetuals.liquidity_tiers.[3].impact_notional' -v '2500000000' # 2_500 USDC (2_500 USDC / 100%)
Expand Down
14 changes: 8 additions & 6 deletions protocol/x/clob/keeper/deleveraging.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ func (k Keeper) NextTickDeleverage(
) {
negativeTncSubaccounts := k.subaccountsKeeper.GetAllNegativeTncSubaccounts(ctx)

k.Logger(ctx).Info(
"Next Tick Deleverage",
"subaccounts", negativeTncSubaccounts,
"nextTickDeleverage", true,
)
if len(negativeTncSubaccounts) > 0 {
k.Logger(ctx).Info(
"Next Tick Deleverage",
"subaccounts", negativeTncSubaccounts,
"nextTickDeleverage", true,
)
}
metrics.SetGauge(metrics.ClobNextTickDeleveragedNegativeTncSubaccounts, float32(len(negativeTncSubaccounts)))
for _, subaccountId := range negativeTncSubaccounts {
k.DeleverageEntireSubaccount(ctx, subaccountId)
Expand All @@ -44,7 +46,7 @@ func (k Keeper) DeleverageEntireSubaccount(
) {
metrics.IncrCounter(metrics.ClobNextTickDeleveragedSubaccount, 1)
k.Logger(ctx).Info(
"Next Tick Deleverage Subaccount",
"Trying to next tick deleverage subaccount",
"subaccountId", subaccountId,
"nextTickDeleverage", true,
)
Expand Down

0 comments on commit 402e2a4

Please sign in to comment.