Skip to content

Commit

Permalink
⬆️ 1.6.10
Browse files Browse the repository at this point in the history
- Checkpoint image now supports custom asset types (SPOT/FUTURE/OPTION)
  • Loading branch information
EvolveArt committed Jul 30, 2023
1 parent 72c3a0f commit 966e4e7
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 6 deletions.
2 changes: 2 additions & 0 deletions empiric-package/empiric/core/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
}
RPC_CLIENT = FullNodeClient(node_url=RPC_URLS[NETWORK])

AssetType = Literal["SPOT", "FUTURE", "OPTION"]


# aggregation mode enum
@unique
Expand Down
11 changes: 11 additions & 0 deletions empiric-package/empiric/publisher/assets.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from typing import Dict, List, Tuple, Union

from empiric.core.utils import key_for_asset
from empiric.core.types import AssetType
from typing_extensions import TypedDict
from empiric.publisher.types import UnsupportedAssetError


class EmpiricSpotAsset(TypedDict):
Expand Down Expand Up @@ -88,6 +90,15 @@ class EmpiricOnchainAsset(TypedDict):
for asset in EMPIRIC_ALL_ASSETS
}

# TODO: Add support for option asset type
def get_asset_spec_for_pair_id_by_type(pair_id: str, asset_type: AssetType) -> EmpiricAsset:
if asset_type == "SPOT":
return get_spot_asset_spec_for_pair_id(pair_id)
elif asset_type == "FUTURE":
return get_future_asset_spec_for_pair_id(pair_id)
else:
raise UnsupportedAssetError("Only SPOT & FUTURE are supported for now.")


def get_spot_asset_spec_for_pair_id(pair_id: str) -> EmpiricSpotAsset:
if pair_id not in _EMPIRIC_ASSET_BY_KEY:
Expand Down
9 changes: 9 additions & 0 deletions empiric-package/empiric/publisher/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,12 @@ def __init__(self, message: str):

def serialize(self):
return self.message

class UnsupportedAssetError:
message: str

def __init__(self, message: str):
self.message = message

def serialize(self):
return self.message
2 changes: 1 addition & 1 deletion empiric-package/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ profile = "black"

[tool.poetry]
name = "empiric-network"
version = "1.6.9"
version = "1.6.10"
authors = ["Pragma <[email protected]>"]
description = "Core package for rollup-native Pragma Oracle"
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pragma"
version = "1.6.9"
version = "1.6.10"
description = "Pragma, the leading Oracle on zkRollups."
authors = ["0xevolve <[email protected]>"]
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion stagecoach/jobs/publishers/checkpoint/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ RUN yum install -y gcc python-devel gmp-devel git

RUN python -m pip install --upgrade pip

RUN pip install empiric-network==1.6.8 typeguard==2.13.3
RUN pip install empiric-network==1.6.10 typeguard==2.13.3

COPY app.py ${LAMBDA_TASK_ROOT}

Expand Down
7 changes: 4 additions & 3 deletions stagecoach/jobs/publishers/checkpoint/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@
import boto3
from empiric.core.logger import get_stream_logger
from empiric.core.utils import currency_pair_to_pair_id
from empiric.publisher.assets import get_spot_asset_spec_for_pair_id
from empiric.publisher.assets import get_asset_spec_for_pair_id_by_type
from empiric.publisher.client import EmpiricPublisherClient

logger = get_stream_logger()

SECRET_NAME = os.environ["SECRET_NAME"]
NETWORK = os.environ["NETWORK"]
ASSETS = os.environ["ASSETS"]
ASSET_TYPE = os.environ.get("ASSET_TYPE", "SPOT")


def handler(event, context):
assets = [get_spot_asset_spec_for_pair_id(asset) for asset in ASSETS.split(",")]
assets = [get_asset_spec_for_pair_id_by_type(asset, ASSET_TYPE) for asset in ASSETS.split(",")]
invocation = asyncio.run(_handler(assets))
return {
"result": invocation,
Expand All @@ -41,7 +42,7 @@ async def _handler(assets):

account_address = int(os.environ.get("ACCOUNT_ADDRESS"))
pairs = [
currency_pair_to_pair_id(*p["pair"]) for p in assets if p["type"] == "SPOT"
currency_pair_to_pair_id(*p["pair"]) for p in assets if p["type"] == ASSET_TYPE
]

publisher_client = EmpiricPublisherClient(
Expand Down

2 comments on commit 966e4e7

@vercel
Copy link

@vercel vercel bot commented on 966e4e7 Jul 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 966e4e7 Jul 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.