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

remove vault constants (#1293) #1300

Merged
merged 1 commit into from
Apr 1, 2024
Merged
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
20 changes: 2 additions & 18 deletions protocol/x/vault/keeper/orders.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,6 @@ import (
"github.com/dydxprotocol/v4-chain/protocol/x/vault/types"
)

// TODO (TRA-118): store vault strategy constants in x/vault state.
const (
// Determines how many layers of orders a vault places.
// E.g. if num_levels=2, a vault places 2 asks and 2 bids.
NUM_LAYERS = uint8(2)
// Determines minimum base spread when a vault quotes around reservation price.
MIN_BASE_SPREAD_PPM = uint32(3_000) // 30bps
// Determines the amount to add to min_price_change_ppm to arrive at base spread.
BASE_SPREAD_MIN_PRICE_CHANGE_PREMIUM_PPM = uint32(1_500) // 15bps
// Determines how aggressive a vault skews its orders.
SKEW_FACTOR_PPM = uint32(500_000) // 0.5
// Determines the percentage of vault equity that each order is sized at.
ORDER_SIZE_PCT_PPM = uint32(100_000) // 10%
// Determines how long a vault's orders are valid for.
ORDER_EXPIRATION_SECONDS = uint32(5) // 5 seconds
)

// RefreshAllVaultOrders refreshes all orders for all vaults by
// 1. Cancelling all existing orders.
// 2. Placing new orders.
Expand Down Expand Up @@ -76,11 +59,12 @@ func (k Keeper) RefreshVaultClobOrders(ctx sdk.Context, vaultId types.VaultId) (
log.ErrorLogWithError(ctx, "Failed to get vault clob orders to cancel", err, "vaultId", vaultId)
return err
}
orderExpirationSeconds := k.GetParams(ctx).OrderExpirationSeconds
for _, order := range ordersToCancel {
if _, exists := k.clobKeeper.GetLongTermOrderPlacement(ctx, order.OrderId); exists {
err := k.clobKeeper.HandleMsgCancelOrder(ctx, clobtypes.NewMsgCancelOrderStateful(
order.OrderId,
uint32(ctx.BlockTime().Unix())+ORDER_EXPIRATION_SECONDS,
uint32(ctx.BlockTime().Unix())+orderExpirationSeconds,
))
if err != nil {
log.ErrorLogWithError(ctx, "Failed to cancel order", err, "order", order, "vaultId", vaultId)
Expand Down
Loading