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: add quantum to vega asset #557

Merged
merged 5 commits into from
Nov 23, 2023
Merged
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=8bc52316ebe4c278805eb59032cfd33a998cad52
VEGA_SIM_VEGA_TAG=07b6292ceaf5c69182066084f20e26d95c326456
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: '8bc52316ebe4c278805eb59032cfd33a998cad52',
string( name: 'VEGA_VERSION', defaultValue: '07b6292ceaf5c69182066084f20e26d95c326456',
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
18 changes: 9 additions & 9 deletions tests/integration/test_trading.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def test_one_off_transfer(vega_service_with_high_volume_with_market: VegaService
assert len(all_transfers_t1) == 1
assert len(live_transfers_t1) == 0

assert party_a_accounts_t1.general == 499.5
assert party_a_accounts_t1.general == 499.999
assert party_b_accounts_t1.general == 1500

vega.one_off_transfer(
Expand Down Expand Up @@ -189,8 +189,8 @@ def test_one_off_transfer(vega_service_with_high_volume_with_market: VegaService

assert len(all_transfers_t2) == 2
assert len(live_transfers_t2) == 1
assert party_a_accounts_t2.general == 499.5
assert party_b_accounts_t2.general == 999.5
assert party_a_accounts_t2.general == 499.999
assert party_b_accounts_t2.general == 999.999

vega.wait_fn(100)
vega.wait_for_total_catchup()
Expand All @@ -211,8 +211,8 @@ def test_one_off_transfer(vega_service_with_high_volume_with_market: VegaService

assert len(all_transfers_t3) == 2
assert len(live_transfers_t3) == 0
assert party_a_accounts_t3.general == 999.5
assert party_b_accounts_t3.general == 999.5
assert party_a_accounts_t3.general == 999.999
assert party_b_accounts_t3.general == 999.999


@pytest.mark.integration
Expand Down Expand Up @@ -266,7 +266,7 @@ def test_recurring_transfer(vega_service_with_market: VegaServiceNull):
party_a_accounts_t1 = vega.list_accounts(key_name=PARTY_A.name, asset_id=asset_id)
party_b_accounts_t1 = vega.list_accounts(key_name=PARTY_B.name, asset_id=asset_id)

assert party_a_accounts_t1[0].balance == 499.5
assert party_a_accounts_t1[0].balance == 499.999
assert party_b_accounts_t1[0].balance == 1500

# Forward one epoch
Expand All @@ -275,7 +275,7 @@ def test_recurring_transfer(vega_service_with_market: VegaServiceNull):
party_a_accounts_t2 = vega.list_accounts(key_name=PARTY_A.name, asset_id=asset_id)
party_b_accounts_t2 = vega.list_accounts(key_name=PARTY_B.name, asset_id=asset_id)

assert party_a_accounts_t2[0].balance == 249.25
assert party_a_accounts_t2[0].balance == 249.998
assert party_b_accounts_t2[0].balance == 1750


Expand Down Expand Up @@ -333,14 +333,14 @@ def test_funding_reward_pool(vega_service_with_market: VegaServiceNull):

party_a_accounts_t1 = vega.list_accounts(key_name=PARTY_A.name, asset_id=asset_id)

assert party_a_accounts_t1[0].balance == 899.9
assert party_a_accounts_t1[0].balance == 899.999

# Forward one epoch
next_epoch(vega=vega)

party_a_accounts_t2 = vega.list_accounts(key_name=PARTY_A.name, asset_id=asset_id)

assert party_a_accounts_t2[0].balance == 899.9
assert party_a_accounts_t2[0].balance == 899.999


@pytest.mark.integration
Expand Down
12 changes: 11 additions & 1 deletion vega_sim/api/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1992,7 +1992,12 @@ def ping(data_client: vac.VegaTradingDataClientV2):
def list_transfers(
data_client: vac.VegaTradingDataClientV2,
party_id: Optional[str] = None,
direction: data_node_protos_v2.trading_data.TransferDirection = None,
direction: Optional[data_node_protos_v2.trading_data.TransferDirection] = None,
is_reward: Optional[bool] = None,
from_epoch: Optional[int] = None,
to_epoch: Optional[int] = None,
status: Optional[vega_protos.events.v1.events.Transfer.Status] = None,
scope: Optional[data_node_protos_v2.trading_data.ListTransfersRequest.Scope] = None,
) -> List[Transfer]:
"""Returns a list of processed transfers.

Expand All @@ -2013,6 +2018,11 @@ def list_transfers(
data_client=data_client,
party_id=party_id,
direction=direction,
is_reward=is_reward,
from_epoch=from_epoch,
to_epoch=to_epoch,
status=status,
scope=scope,
)

asset_dp = {}
Expand Down
15 changes: 15 additions & 0 deletions vega_sim/api/data_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,11 @@ def list_transfers(
data_client: vac.VegaTradingDataClientV2,
party_id: Optional[str] = None,
direction: Optional[data_node_protos_v2.trading_data.TransferDirection] = None,
is_reward: Optional[bool] = None,
from_epoch: Optional[int] = None,
to_epoch: Optional[int] = None,
status: Optional[vega_protos.events.v1.events.Transfer.Status] = None,
scope: Optional[data_node_protos_v2.trading_data.ListTransfersRequest.Scope] = None,
) -> List[data_node_protos_v2.trading_data.TransferNode]:
"""Returns a list of raw transfers.

Expand Down Expand Up @@ -506,6 +511,16 @@ def list_transfers(
"direction",
data_node_protos_v2.trading_data.TRANSFER_DIRECTION_TRANSFER_TO_OR_FROM,
)
if is_reward is not None:
setattr(base_request, "is_reward", is_reward)
if from_epoch is not None:
setattr(base_request, "from_epoch", from_epoch)
if to_epoch is not None:
setattr(base_request, "to_epoch", to_epoch)
if status is not None:
setattr(base_request, "status", status)
if scope is not None:
setattr(base_request, "scope", scope)

return unroll_v2_pagination(
base_request=base_request,
Expand Down
1,234 changes: 628 additions & 606 deletions vega_sim/proto/data_node/api/v2/trading_data_pb2.py

Large diffs are not rendered by default.

70 changes: 70 additions & 0 deletions vega_sim/proto/data_node/api/v2/trading_data_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1128,19 +1128,34 @@ class ListTransfersRequest(_message.Message):
"is_reward",
"from_epoch",
"to_epoch",
"status",
"scope",
)

class Scope(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
__slots__ = ()
SCOPE_UNSPECIFIED: _ClassVar[ListTransfersRequest.Scope]
SCOPE_INDIVIDUAL: _ClassVar[ListTransfersRequest.Scope]
SCOPE_TEAM: _ClassVar[ListTransfersRequest.Scope]
SCOPE_UNSPECIFIED: ListTransfersRequest.Scope
SCOPE_INDIVIDUAL: ListTransfersRequest.Scope
SCOPE_TEAM: ListTransfersRequest.Scope
PUBKEY_FIELD_NUMBER: _ClassVar[int]
DIRECTION_FIELD_NUMBER: _ClassVar[int]
PAGINATION_FIELD_NUMBER: _ClassVar[int]
IS_REWARD_FIELD_NUMBER: _ClassVar[int]
FROM_EPOCH_FIELD_NUMBER: _ClassVar[int]
TO_EPOCH_FIELD_NUMBER: _ClassVar[int]
STATUS_FIELD_NUMBER: _ClassVar[int]
SCOPE_FIELD_NUMBER: _ClassVar[int]
pubkey: str
direction: TransferDirection
pagination: Pagination
is_reward: bool
from_epoch: int
to_epoch: int
status: _events_pb2.Transfer.Status
scope: ListTransfersRequest.Scope
def __init__(
self,
pubkey: _Optional[str] = ...,
Expand All @@ -1149,6 +1164,8 @@ class ListTransfersRequest(_message.Message):
is_reward: bool = ...,
from_epoch: _Optional[int] = ...,
to_epoch: _Optional[int] = ...,
status: _Optional[_Union[_events_pb2.Transfer.Status, str]] = ...,
scope: _Optional[_Union[ListTransfersRequest.Scope, str]] = ...,
) -> None: ...

class ListTransfersResponse(_message.Message):
Expand Down Expand Up @@ -4960,3 +4977,56 @@ class ObserveTransactionResultsResponse(_message.Message):
_Iterable[_Union[_events_pb2.TransactionResult, _Mapping]]
] = ...,
) -> None: ...

class EstimateTransferFeeRequest(_message.Message):
__slots__ = (
"from_account",
"from_account_type",
"to_account",
"amount",
"asset_id",
)
FROM_ACCOUNT_FIELD_NUMBER: _ClassVar[int]
FROM_ACCOUNT_TYPE_FIELD_NUMBER: _ClassVar[int]
TO_ACCOUNT_FIELD_NUMBER: _ClassVar[int]
AMOUNT_FIELD_NUMBER: _ClassVar[int]
ASSET_ID_FIELD_NUMBER: _ClassVar[int]
from_account: str
from_account_type: _vega_pb2.AccountType
to_account: str
amount: str
asset_id: str
def __init__(
self,
from_account: _Optional[str] = ...,
from_account_type: _Optional[_Union[_vega_pb2.AccountType, str]] = ...,
to_account: _Optional[str] = ...,
amount: _Optional[str] = ...,
asset_id: _Optional[str] = ...,
) -> None: ...

class EstimateTransferFeeResponse(_message.Message):
__slots__ = ("fee", "discount")
FEE_FIELD_NUMBER: _ClassVar[int]
DISCOUNT_FIELD_NUMBER: _ClassVar[int]
fee: str
discount: str
def __init__(
self, fee: _Optional[str] = ..., discount: _Optional[str] = ...
) -> None: ...

class GetTotalTransferFeeDiscountRequest(_message.Message):
__slots__ = ("party_id", "asset_id")
PARTY_ID_FIELD_NUMBER: _ClassVar[int]
ASSET_ID_FIELD_NUMBER: _ClassVar[int]
party_id: str
asset_id: str
def __init__(
self, party_id: _Optional[str] = ..., asset_id: _Optional[str] = ...
) -> None: ...

class GetTotalTransferFeeDiscountResponse(_message.Message):
__slots__ = ("total_discount",)
TOTAL_DISCOUNT_FIELD_NUMBER: _ClassVar[int]
total_discount: str
def __init__(self, total_discount: _Optional[str] = ...) -> None: ...
96 changes: 96 additions & 0 deletions vega_sim/proto/data_node/api/v2/trading_data_pb2_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,16 @@ def __init__(self, channel):
request_serializer=data__node_dot_api_dot_v2_dot_trading__data__pb2.ObserveTransactionResultsRequest.SerializeToString,
response_deserializer=data__node_dot_api_dot_v2_dot_trading__data__pb2.ObserveTransactionResultsResponse.FromString,
)
self.EstimateTransferFee = channel.unary_unary(
"/datanode.api.v2.TradingDataService/EstimateTransferFee",
request_serializer=data__node_dot_api_dot_v2_dot_trading__data__pb2.EstimateTransferFeeRequest.SerializeToString,
response_deserializer=data__node_dot_api_dot_v2_dot_trading__data__pb2.EstimateTransferFeeResponse.FromString,
)
self.GetTotalTransferFeeDiscount = channel.unary_unary(
"/datanode.api.v2.TradingDataService/GetTotalTransferFeeDiscount",
request_serializer=data__node_dot_api_dot_v2_dot_trading__data__pb2.GetTotalTransferFeeDiscountRequest.SerializeToString,
response_deserializer=data__node_dot_api_dot_v2_dot_trading__data__pb2.GetTotalTransferFeeDiscountResponse.FromString,
)
self.ExportNetworkHistory = channel.unary_stream(
"/datanode.api.v2.TradingDataService/ExportNetworkHistory",
request_serializer=data__node_dot_api_dot_v2_dot_trading__data__pb2.ExportNetworkHistoryRequest.SerializeToString,
Expand Down Expand Up @@ -1645,6 +1655,24 @@ def ObserveTransactionResults(self, request, context):
context.set_details("Method not implemented!")
raise NotImplementedError("Method not implemented!")

def EstimateTransferFee(self, request, context):
"""Estimate transfer fee costs

Estimate transfer fee costs with potential discount applied
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details("Method not implemented!")
raise NotImplementedError("Method not implemented!")

def GetTotalTransferFeeDiscount(self, request, context):
"""Available transfer fee discount

Returns available per party per asset transfer discount
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details("Method not implemented!")
raise NotImplementedError("Method not implemented!")

def ExportNetworkHistory(self, request, context):
"""Export network history as CSV

Expand Down Expand Up @@ -2279,6 +2307,16 @@ def add_TradingDataServiceServicer_to_server(servicer, server):
request_deserializer=data__node_dot_api_dot_v2_dot_trading__data__pb2.ObserveTransactionResultsRequest.FromString,
response_serializer=data__node_dot_api_dot_v2_dot_trading__data__pb2.ObserveTransactionResultsResponse.SerializeToString,
),
"EstimateTransferFee": grpc.unary_unary_rpc_method_handler(
servicer.EstimateTransferFee,
request_deserializer=data__node_dot_api_dot_v2_dot_trading__data__pb2.EstimateTransferFeeRequest.FromString,
response_serializer=data__node_dot_api_dot_v2_dot_trading__data__pb2.EstimateTransferFeeResponse.SerializeToString,
),
"GetTotalTransferFeeDiscount": grpc.unary_unary_rpc_method_handler(
servicer.GetTotalTransferFeeDiscount,
request_deserializer=data__node_dot_api_dot_v2_dot_trading__data__pb2.GetTotalTransferFeeDiscountRequest.FromString,
response_serializer=data__node_dot_api_dot_v2_dot_trading__data__pb2.GetTotalTransferFeeDiscountResponse.SerializeToString,
),
"ExportNetworkHistory": grpc.unary_stream_rpc_method_handler(
servicer.ExportNetworkHistory,
request_deserializer=data__node_dot_api_dot_v2_dot_trading__data__pb2.ExportNetworkHistoryRequest.FromString,
Expand Down Expand Up @@ -5519,6 +5557,64 @@ def ObserveTransactionResults(
metadata,
)

@staticmethod
def EstimateTransferFee(
request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None,
):
return grpc.experimental.unary_unary(
request,
target,
"/datanode.api.v2.TradingDataService/EstimateTransferFee",
data__node_dot_api_dot_v2_dot_trading__data__pb2.EstimateTransferFeeRequest.SerializeToString,
data__node_dot_api_dot_v2_dot_trading__data__pb2.EstimateTransferFeeResponse.FromString,
options,
channel_credentials,
insecure,
call_credentials,
compression,
wait_for_ready,
timeout,
metadata,
)

@staticmethod
def GetTotalTransferFeeDiscount(
request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None,
):
return grpc.experimental.unary_unary(
request,
target,
"/datanode.api.v2.TradingDataService/GetTotalTransferFeeDiscount",
data__node_dot_api_dot_v2_dot_trading__data__pb2.GetTotalTransferFeeDiscountRequest.SerializeToString,
data__node_dot_api_dot_v2_dot_trading__data__pb2.GetTotalTransferFeeDiscountResponse.FromString,
options,
channel_credentials,
insecure,
call_credentials,
compression,
wait_for_ready,
timeout,
metadata,
)

@staticmethod
def ExportNetworkHistory(
request,
Expand Down
328 changes: 166 additions & 162 deletions vega_sim/proto/vega/events/v1/events_pb2.py

Large diffs are not rendered by default.

Loading
Loading