Skip to content

Commit

Permalink
fixed python typing
Browse files Browse the repository at this point in the history
  • Loading branch information
dzmitry-lahoda committed Apr 16, 2024
1 parent 4d43666 commit 86efc4a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 21 deletions.
6 changes: 4 additions & 2 deletions mantis/blackbox/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,21 @@ def simulator_router(input: Input[str, str] = Depends()) -> list[SingleInputAsse
"""_summary_
Given input, find and return route.
"""

raw_data = get_remote_data()
cvm_data = ExtendedCvmRegistry.from_raw(
raw_data.cvm_registry,
raw_data.networks,
raw_data.cosmos_chains.chains,
raw_data.osmosis_pools,
)

input : Input[str, int] = Input[str, int](**input.model_dump())
routes = solve(input, cvm_data)
routes: list[SingleInputAssetCvmRoute[str, str]] = [SingleInputAssetCvmRoute[str, str](**route.model_dump()) for route in routes]
return routes


def solve(original_input: Input, cvm_data: ExtendedCvmRegistry) -> list[SingleInputAssetCvmRoute]:
def solve(original_input: Input, cvm_data: ExtendedCvmRegistry) -> list[SingleInputAssetCvmRoute[str, int]]:
ctx = Ctx()
ctx.max_depth_of_route = 6
original_data = for_simulation(cvm_data, {})
Expand Down
22 changes: 5 additions & 17 deletions mantis/simulation/routers/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,27 +162,13 @@ class AssetTransfers(
Fixed costs $q_i$ >= 0s
"""

in_asset_amount: TAmount = Field(
# strict=True,
json_schema_extra={
'title': 'Password',
'description': 'Password of the user',
'examples': ['123456'],
}
)
in_asset_amount: TAmount
"""
Tendered amount of token on chain were it is.
Must be like escrowed amount.
"""

out_asset_amount: TAmount = Field(
# strict=True,
json_schema_extra={
'title': 'Password',
'description': 'Password of the user',
'examples': ['123456'],
}
)
out_asset_amount: TAmount
"""
Expected received amount LAMBDA.
Must be like liquid amount of this token minted.
Expand Down Expand Up @@ -344,6 +330,8 @@ class Input(


class Trade(Generic[TId, TAmount]):
model_config = ConfigDict(coerce_numbers_to_str=True)

out_asset_amount: TAmount
"""
Amount to be used out of trade.
Expand All @@ -367,7 +355,6 @@ class Spawn(BaseModel, Trade[TId, TAmount], Generic[TId, TAmount]):
"""
cross chain transfer assets
"""

in_asset_id: TId | None = None

in_asset_amount: TAmount | None = None
Expand Down Expand Up @@ -395,6 +382,7 @@ class SingleInputAssetCvmRoute(BaseModel, Trade[TId, TAmount], Generic[TId, TAmo
"""
always starts with Input asset_id
"""
model_config = ConfigDict(coerce_numbers_to_str=True)

next: list[Union[Exchange[TId, TAmount], Spawn[TId, TAmount]]]

Expand Down
3 changes: 1 addition & 2 deletions mantis/simulation/routers/oracles/bforacle.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,11 @@ class BFSolution:
deltas: list[float]
routes: list[SingleInputAssetCvmRoute]


def route(
input: Input,
all_data: AllData,
ctx: Ctx = Ctx(),
):
) -> list[SingleInputAssetCvmRoute[str, int]]:
"""
Bellman Ford inspired solution.
The function divides the transaction if several paths (`splits``) and for each path
Expand Down

0 comments on commit 86efc4a

Please sign in to comment.