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

Feat/make sla work #485

Closed
wants to merge 9 commits into from
Closed
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
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VEGA_SIM_VEGA_TAG=2de8bbe1e7e44b1d1da434286aa5c9480f882cd9
VEGA_SIM_VEGA_TAG=91462b5cfdaa0917862b4ca76a87c0cef5b1340e
VEGA_SIM_CONSOLE_TAG=develop
VEGA_DEFAULT_KEY_NAME='Key 1'
VEGA_SIM_NETWORKS_INTERNAL_TAG=main
Expand Down
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pipeline {
disableConcurrentBuilds(abortPrevious: true)
}
parameters {
string( name: 'VEGA_VERSION', defaultValue: '2de8bbe1e7e44b1d1da434286aa5c9480f882cd9',
string( name: 'VEGA_VERSION', defaultValue: '91462b5cfdaa0917862b4ca76a87c0cef5b1340e',
description: 'Git branch, tag or hash of the vegaprotocol/vega repository')
string( name: 'VEGACAPSULE_VERSION', defaultValue: 'main',
description: 'Git branch, tag or hash of the vegaprotocol/vegacapsule repository')
Expand Down
29 changes: 27 additions & 2 deletions vega_sim/api/governance.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ def propose_future_market(
vega_protos.markets.PriceMonitoringParameters
] = None,
lp_price_range: float = 1,
commitment_min_time_fraction: float = 0.95,
providers_fee_calculation_time_step: int = 1,
performance_hysteresis_epochs: int = 1,
sla_competition_factor: float = 1,
wallet_name: Optional[str] = None,
parent_market_id: Optional[str] = None,
parent_market_insurance_pool_fraction: float = 1,
Expand Down Expand Up @@ -195,8 +199,21 @@ def propose_future_market(
will drop into a price auction. If not passed defaults to a very
permissive setup
lp_price_range:
float, Range allowed for LP price commitments from mid price
float, Range allowed for LP price commitments from mid price to count for SLA
(e.g. 2 allows mid-price +/- 2 * mid-price )
commitment_min_time_fraction:
float, default 0.95, Specifies the minimum fraction of time LPs must spend
"on the book" providing their committed liquidity.
providers_fee_calculation_time_step:
int, default 1, Specifies how often the quality of liquidity supplied by the
LPs is evaluated and fees arising from that period are earmarked for specific parties.
performance_hysteresis_epochs:
int, default 1, Specifies the number of liquidity epochs over which past performance
will continue to affect rewards.
sla_competition_factor:
float, default 1, Specifies the maximum fraction of their accrued fees an
LP that meets the SLA implied by market.liquidity.commitmentMinTimeFraction
will lose to liquidity providers that achieved a higher SLA performance than them.
key_name:
Optional[str], key name stored in metadata. Defaults to None.
parent_market_id:
Expand Down Expand Up @@ -296,7 +313,6 @@ def propose_future_market(
),
),
),
lp_price_range=str(lp_price_range),
decimal_places=price_decimals,
position_decimal_places=(
0 if position_decimals is None else position_decimals
Expand All @@ -315,6 +331,15 @@ def propose_future_market(
log_normal=risk_model,
linear_slippage_factor="0.001",
quadratic_slippage_factor="0",
liquidity_sla_parameters=vega_protos.markets.LiquiditySLAParameters(
price_range=str(lp_price_range),
commitment_min_time_fraction=str(commitment_min_time_fraction),
providers_fee_calculation_time_step=int(
providers_fee_calculation_time_step
),
performance_hysteresis_epochs=int(performance_hysteresis_epochs),
sla_competition_factor=str(sla_competition_factor),
),
),
)
if parent_market_id is not None:
Expand Down
2 changes: 1 addition & 1 deletion vega_sim/api/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def wait_for_acceptance(
) -> T:
logger.debug("Waiting for proposal acceptance")
submission_accepted = False
for i in range(20):
for i in range(50):
try:
proposal = submission_load_func(submission_ref)
except:
Expand Down
40 changes: 37 additions & 3 deletions vega_sim/api/market.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ class MarketConfig(Config):
"liquidity_monitoring_parameters": "default",
"log_normal": "default",
"instrument": "default",
"lp_price_range": 0.5,
"linear_slippage_factor": 1e-3,
"quadratic_slippage_factor": 0,
"successor": None,
"liquidity_sla_parameters": "default",
}
}

Expand All @@ -121,7 +121,9 @@ def load(self, opt: Optional[str] = None):

self.decimal_places = config["decimal_places"]
self.position_decimal_places = config["position_decimal_places"]
self.lp_price_range = str(config["lp_price_range"])
self.liquidity_sla_parameters = LiquiditySLAParameters(
opt=config["liquidity_sla_parameters"]
)
self.linear_slippage_factor = str(config["linear_slippage_factor"])
self.quadratic_slippage_factor = str(config["quadratic_slippage_factor"])
self.metadata = config["metadata"]
Expand All @@ -146,7 +148,7 @@ def build(self):
changes=vega_protos.governance.NewMarketConfiguration(
decimal_places=self.decimal_places,
position_decimal_places=self.position_decimal_places,
lp_price_range=self.lp_price_range,
liquidity_sla_parameters=self.liquidity_sla_parameters.build(),
metadata=self.metadata,
instrument=self.instrument.build(),
price_monitoring_parameters=self.price_monitoring_parameters.build(),
Expand Down Expand Up @@ -248,6 +250,38 @@ def build(self):
)


class LiquiditySLAParameters(Config):
OPTS = {
"default": {
"price_range": "0.5",
"commitment_min_time_fraction": "1",
"providers_fee_calculation_time_step": 1,
"performance_hysteresis_epochs": 1,
"sla_competition_factor": "1",
}
}

def load(self, opt: Optional[str] = None):
config = super().load(opt=opt)

self.price_range = config["price_range"]
self.commitment_min_time_fraction = config["commitment_min_time_fraction"]
self.providers_fee_calculation_time_step = config[
"providers_fee_calculation_time_step"
]
self.performance_hysteresis_epochs = config["performance_hysteresis_epochs"]
self.sla_competition_factor = config["sla_competition_factor"]

def build(self):
return vega_protos.markets.LiquiditySLAParameters(
price_range=self.price_range,
commitment_min_time_fraction=self.commitment_min_time_fraction,
providers_fee_calculation_time_step=self.providers_fee_calculation_time_step,
performance_hysteresis_epochs=self.performance_hysteresis_epochs,
sla_competition_factor=self.sla_competition_factor,
)


class TargetStakeParameters(Config):
OPTS = {
"default": {
Expand Down
28 changes: 0 additions & 28 deletions vega_sim/api/trading.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,6 @@ def submit_simple_liquidity(
market_id=market_id,
commitment_amount=commitment_amount,
fee=fee,
buy_specs=[(reference_buy, delta_buy, 1)],
sell_specs=[(reference_sell, delta_sell, 1)],
is_amendment=is_amendment,
key_name=key_name,
)
Expand All @@ -332,8 +330,6 @@ def submit_liquidity(
market_id: str,
commitment_amount: int,
fee: float,
buy_specs: List[Tuple[str, int, int]],
sell_specs: List[Tuple[str, int, int]],
is_amendment: bool = False,
key_name: Optional[str] = None,
):
Expand All @@ -352,14 +348,6 @@ def submit_liquidity(
fee:
float, The fee level at which to set the LP fee
(in %, e.g. 0.01 == 1% and 1 == 100%)
buy_specs:
List[Tuple[str, int, int]], List of tuples, each containing a reference
point in their first position, a desired offset in their second and
a proportion in third
sell_specs:
List[Tuple[str, int, int]], List of tuples, each containing a reference
point in their first position, a desired offset in their second and
a proportion in third
key_name:
Optional[str], key name stored in metadata. Defaults to None.
"""
Expand All @@ -375,22 +363,6 @@ def submit_liquidity(
market_id=market_id,
commitment_amount=str(commitment_amount),
fee=str(fee),
buys=[
vega_protos.vega.LiquidityOrder(
reference=spec[0],
offset=str(spec[1]),
proportion=spec[2],
)
for spec in buy_specs
],
sells=[
vega_protos.vega.LiquidityOrder(
reference=spec[0],
offset=str(spec[1]),
proportion=spec[2],
)
for spec in sell_specs
],
)
wallet.submit_transaction(
transaction=submission,
Expand Down
4 changes: 2 additions & 2 deletions vega_sim/proto/blockexplorer/api/v1/blockexplorer_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

462 changes: 254 additions & 208 deletions vega_sim/proto/data_node/api/v2/trading_data_pb2.py

Large diffs are not rendered by default.

Loading
Loading