From 5ebf7389bb1c4bda50d81f63cb83a674f9799374 Mon Sep 17 00:00:00 2001 From: dzmitry-lahoda Date: Tue, 16 Apr 2024 18:07:54 +0100 Subject: [PATCH] fixing model conversion --- mantis/simulation/routers/data.py | 30 +++++++------------------- mantis/simulation/routers/test_data.py | 9 +++++++- 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/mantis/simulation/routers/data.py b/mantis/simulation/routers/data.py index 9a10e374..73318027 100644 --- a/mantis/simulation/routers/data.py +++ b/mantis/simulation/routers/data.py @@ -20,7 +20,7 @@ # This is global unique ID for token(asset) or exchange(pool) TId = TypeVar("TId", int, str) TNetworkId = TypeVar("TNetworkId", int, str) -TAmount = TypeVar("TAmount", int, float, dec) +TAmount = TypeVar("TAmount", int, float, dec, str) MINIMAL_FEE_PER_MILLION_DEFAULT = 100 """ @@ -329,30 +329,16 @@ class Input( in_asset_id: TId = Field(example="158456325028528675187087900673") out_asset_id: TId = Field(example="158456325028528675187087900674") # tendered amount DELTA - in_asset_amount: TAmount = Field( - example="1000000000000", - title='Password', - type = 'string', - json_schema_extra={ - 'title': 'Password', - 'description': 'Password of the user', - 'examples': ['123456'] - } - ) - # expected received amount LAMBDA - out_asset_amount: TAmount = Field( - example="10", - type='string', - json_schema_extra={ - 'title': 'Password', - 'description': 'Password of the user', - 'examples': ['123456'], - } - ) + in_asset_amount: TAmount = Field(example="10000000") + out_asset_amount: TAmount = Field(example="100") + """ + expected received amount LAMBDA + """ + # if max is True, user wants to spent all in to get at least out # if max is False, user wants to get exact out, but spent as small as possible in # please fail if bool is False for now - max: bool = Field(example=True) + max: bool = Field(example=True, default=True) class Trade(Generic[TId, TAmount]): diff --git a/mantis/simulation/routers/test_data.py b/mantis/simulation/routers/test_data.py index be8939a9..60650bb1 100644 --- a/mantis/simulation/routers/test_data.py +++ b/mantis/simulation/routers/test_data.py @@ -2,6 +2,7 @@ from pathlib import Path from simulation.routers.data import ( + Input, new_data, new_pair, new_transfer, @@ -15,7 +16,13 @@ def _test_all_data_from_csv(): assert read_dummy_data(TEST_DATA_DIR) -def _test_token_price_in_usd(): +def test_big_numbers_api(): + """_summary_ + Ensures that amounts are strings on the wire but big integers in memory + """ + input : Input[str, str] = Input(in_asset_id="1", out_asset_id="2", in_asset_amount="100", out_asset_amount="100") + +def test_token_price_in_usd(): pica_usd = new_pair( 1, 1,