Skip to content

Commit

Permalink
dev: Updated hash method to Poseidon (#225)
Browse files Browse the repository at this point in the history
* dev(poseidon): Updated hash method to Poseidon

* Update config.example.yaml

* fix: use better types for signer

* bump: 2.3.2 → 2.4.0

---------

Co-authored-by: 0xevolve <[email protected]>
  • Loading branch information
akhercha and EvolveArt authored Nov 14, 2024
1 parent 75842e5 commit 99524a3
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 99 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
## v2.4.0 (2024-11-15)

### Fix

- use better types for signer
- starkex all assets + broken fetchers (#224)
- bybit future api (#221)

## v2.3.2 (2024-11-02)

### Feat

- lambda function (#216)

### Fix

- Ekubo fetcher for quote_address == 0 (#218)

## v2.3.0 (2024-10-29)

### Feat
Expand Down
2 changes: 1 addition & 1 deletion pragma-sdk/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.2
2.4.0
36 changes: 18 additions & 18 deletions pragma-sdk/pragma_sdk/common/fetchers/future_fetchers/binance.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import time

from datetime import datetime, timezone
from typing import Any, List, Optional, Tuple
from typing import Any, List

from aiohttp import ClientSession

Expand All @@ -22,9 +22,7 @@ class BinanceFutureFetcher(FetcherInterfaceT):
async def fetch_pair( # type: ignore[override]
self, pair: Pair, session: ClientSession
) -> List[FutureEntry] | PublisherFetchError:
filtered_data = []
url = self.format_url(pair)
selection = str(pair)
async with session.get(url) as resp:
if resp.status == 404:
return PublisherFetchError(f"No data found for {pair} from Binance")
Expand All @@ -46,14 +44,14 @@ async def fetch(
) -> List[Entry | PublisherFetchError | BaseException]:
entries: List[Entry | PublisherFetchError | BaseException] = []
for pair in self.pairs:
future_entries = await self.fetch_pair(pair, session)
if isinstance(future_entries, list):
entries.extend(future_entries)
entries_or_error = await self.fetch_pair(pair, session)
if isinstance(entries_or_error, PublisherFetchError):
entries.append(entries_or_error)
else:
entries.append(future_entries)
entries.extend(entries_or_error)
return entries

def format_url(self, pair: Optional[Pair] = None) -> str:
def format_url(self, pair: Pair) -> str:
return (
self.BASE_URL + "?symbol=" + pair.base_currency.id + pair.quote_currency.id
)
Expand All @@ -62,7 +60,7 @@ def _construct(
self,
pair: Pair,
data: Any,
) -> List[FutureEntry]:
) -> list[FutureEntry] | PublisherFetchError:
decimals = pair.decimals()
price = float(data["markPrice"])
price_int = int(price * (10**decimals))
Expand All @@ -81,12 +79,14 @@ def _construct(
else:
expiry_timestamp = int(0)

return FutureEntry(
pair_id=pair.id,
price=price_int,
volume=int(volume),
timestamp=int(time.time()),
source=self.SOURCE,
publisher=self.publisher,
expiry_timestamp=expiry_timestamp * 1000,
)
return [
FutureEntry(
pair_id=pair.id,
price=price_int,
volume=int(volume),
timestamp=int(time.time()),
source=self.SOURCE,
publisher=self.publisher,
expiry_timestamp=expiry_timestamp * 1000,
)
]
2 changes: 0 additions & 2 deletions pragma-sdk/pragma_sdk/offchain/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from pragma_sdk.common.utils import add_sync_methods, get_cur_from_pair
from pragma_sdk.common.types.pair import Pair
from pragma_sdk.common.types.client import PragmaClient
import time
from pragma_sdk.onchain.types.types import PublishEntriesOnChainResult

from pragma_sdk.offchain.exceptions import PragmaAPIError
Expand Down Expand Up @@ -174,7 +173,6 @@ async def _create_entries(
"PRAGMA-SIGNATURE-EXPIRATION": str(expiry),
"x-api-key": self.api_key,
}

sig, _ = self.offchain_signer.sign_publish_message(entries, data_type)
# Convert entries to JSON string
data = {
Expand Down
31 changes: 14 additions & 17 deletions pragma-sdk/pragma_sdk/offchain/signer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,42 +18,39 @@ def build_publish_message(
"""

message = {
# TODO: We want to update `revision` to `1` but that would require some changes
# in the `pragma-node` repository - where we check the signature.
# See: https://github.com/astraly-labs/pragma-sdk/issues/151
"domain": {"name": "Pragma", "version": "1", "chainId": "1", "revision": "0"},
"domain": {"name": "Pragma", "version": "1", "chainId": "1", "revision": "1"},
"primaryType": "Request",
"message": {
"action": "Publish",
"entries": Entry.serialize_entries(entries),
},
"types": {
"StarkNetDomain": [
{"name": "name", "type": "felt"},
{"name": "version", "type": "felt"},
{"name": "chainId", "type": "felt"},
{"name": "revision", "type": "felt"},
"StarknetDomain": [
{"name": "name", "type": "shortstring"},
{"name": "version", "type": "shortstring"},
{"name": "chainId", "type": "shortstring"},
{"name": "revision", "type": "shortstring"},
],
"Request": [
{"name": "action", "type": "felt"},
{"name": "action", "type": "shortstring"},
{"name": "entries", "type": "Entry*"},
],
"Entry": [
{"name": "base", "type": "Base"},
{"name": "pair_id", "type": "felt"},
{"name": "price", "type": "felt"},
{"name": "volume", "type": "felt"},
{"name": "pair_id", "type": "shortstring"},
{"name": "price", "type": "u128"},
{"name": "volume", "type": "u128"},
],
"Base": [
{"name": "publisher", "type": "felt"},
{"name": "source", "type": "felt"},
{"name": "timestamp", "type": "felt"},
{"name": "publisher", "type": "shortstring"},
{"name": "source", "type": "shortstring"},
{"name": "timestamp", "type": "timestamp"},
],
},
}
if data_type == DataTypes.FUTURE:
message["types"]["Entry"] += [ # type: ignore[index]
{"name": "expiration_timestamp", "type": "felt"},
{"name": "expiration_timestamp", "type": "timestamp"},
]

return TypedData.from_dict(message)
Expand Down
2 changes: 1 addition & 1 deletion pragma-sdk/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pragma-sdk"
version = "2.3.2"
version = "2.4.0"
authors = ["0xevolve <[email protected]>"]
description = "Core package for rollup-native Pragma Oracle"
readme = "README.md"
Expand Down
60 changes: 1 addition & 59 deletions price-pusher/config/config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,64 +2,6 @@
spot:
- BTC/USD
- ETH/USD
- SOL/USD
- BNB/USD
- LTC/USD
- LINK/USD
- AVAX/USD
- MATIC/USD
- XRP/USD
- DOGE/USD
- 1000PEPE/USD
- AAVE/USD
- TRX/USD
- SUI/USD
- WIF/USD
- TIA/USD
- TON/USD
- LDO/USD
- ARB/USD
- OP/USD
- ORDI/USD
- JTO/USD
- JUP/USD
- UNI/USD
- OKB/USD
- ATOM/USD
- NEAR/USD
- 1000SATS/USD
- ONDO/USD

future:
- BTC/USDT
- ETH/USDT
- SOL/USDT
- BNB/USDT
- LTC/USDT
- LINK/USDT
- AVAX/USDT
- MATIC/USDT
- XRP/USDT
- DOGE/USDT
- 1000PEPE/USDT
- AAVE/USDT
- TRX/USDT
- SUI/USDT
- WIF/USDT
- TIA/USDT
- TON/USDT
- LDO/USDT
- ARB/USDT
- OP/USDT
- ORDI/USDT
- JTO/USDT
- JUP/USDT
- UNI/USDT
- OKB/USDT
- ATOM/USDT
- NEAR/USDT
- 1000SATS/USDT
- ONDO/USDT


time_difference: 1
price_deviation: 0.025
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ build-backend = "poetry.core.masonry.api"

[tool.commitizen]
name = "cz_conventional_commits"
version = "2.3.2"
version = "2.4.0"
tag_format = "v$version"
version_files = [
"VERSION",
Expand Down

0 comments on commit 99524a3

Please sign in to comment.