Skip to content

Commit c012079

Browse files
committed
fix: usn sources
1 parent cd340c3 commit c012079

File tree

4 files changed

+58
-36
lines changed

4 files changed

+58
-36
lines changed

deployments/mainnet/declarations.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"pragma_Oracle": "0x5df039f55ebfbdaa71aecea779f72017cd136c81d70d59e58b4cbe0daf90d64",
2+
"pragma_Oracle": "0x4d6370214accdaac8cc249db34a916c92464235b87cf03641a85889d2f6d8e7",
33
"pragma_Ownable": "0x7b50a7a9bbb75d08248135003f1c87f0d44ba23018dc0ca480ac37a901531f3",
44
"pragma_PublisherRegistry": "0x306288971002bd7906e3a607d504dfb28dcbdc7655a115984e567dce3b67e8f",
55
"pragma_SummaryStats": "0x3b5bf1c2f918de14620b3c63e2c6543cf0a138df258bce3d03e3fb0b7d2183a",

pragma-deployer/pragma_deployer/add_pairs.py

Lines changed: 46 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,20 @@
119119
0x0, # Replace with actual starknet_address if available
120120
0x0000000000000000000000000000000000000000,
121121
)
122+
USN = Currency(
123+
"USN",
124+
18,
125+
0,
126+
0x0, # Replace with actual starknet_address if available
127+
0x0000000000000000000000000000000000000000,
128+
)
129+
SUSN = Currency(
130+
"SUSN",
131+
18,
132+
0,
133+
0x0, # Replace with actual starknet_address if available
134+
0x0000000000000000000000000000000000000000,
135+
)
122136

123137
# BTC LST pairs
124138
xwbtc_usd_pair = Pair(XWBTC, USD)
@@ -131,29 +145,29 @@
131145
mre7yield_usd_pair = Pair(MRE7YIELD, USD)
132146
lbtc_usd_pair = Pair(LBTC, USD)
133147
unibtc_usd_pair = Pair(UNIBTC, USD)
148+
usn_usd_pair = Pair(USN, USD)
149+
susn_usd_pair = Pair(SUSN, USD)
134150

135-
CURRENCIES_TO_ADD = [XWBTC, XTBTC, XLBTC, XSBTC]
151+
CURRENCIES_TO_ADD = [USN, SUSN]
136152

137153
PAIRS_TO_ADD = [
138-
xwbtc_usd_pair,
139-
xtbtc_usd_pair,
140-
xlbtc_usd_pair,
141-
xsbtc_usd_pair,
154+
usn_usd_pair,
155+
susn_usd_pair,
142156
]
143157

144158
PAIRS_TO_UPDATE = [
145-
{
146-
"pair_id": 384270964630611589151504336040458606883082949444,
147-
"pair": [384270964630611589151504336040458606883082949444, XWBTC.id, USD.id],
148-
},
149-
{
150-
"pair_id": 384270964630611589151504336040242434100969165636,
151-
"pair": [384270964630611589151504336040242434100969165636, XTBTC.id, USD.id],
152-
},
153-
{
154-
"pair_id": 384270964630611589151504336039665973348665742148,
155-
"pair": [384270964630611589151504336039665973348665742148, XLBTC.id, USD.id],
156-
},
159+
# {
160+
# "pair_id": 384270964630611589151504336040458606883082949444,
161+
# "pair": [384270964630611589151504336040458606883082949444, XWBTC.id, USD.id],
162+
# },
163+
# {
164+
# "pair_id": 384270964630611589151504336040242434100969165636,
165+
# "pair": [384270964630611589151504336040242434100969165636, XTBTC.id, USD.id],
166+
# },
167+
# {
168+
# "pair_id": 384270964630611589151504336039665973348665742148,
169+
# "pair": [384270964630611589151504336039665973348665742148, XLBTC.id, USD.id],
170+
# },
157171
# Pair(XSTRK, USD),
158172
# Pair("SSTRK/USD", "SSTRK", "USD"),
159173
# Pair("WSTETH/USD", "WSTETH", "USD"),
@@ -176,25 +190,25 @@ async def main(port: Optional[int]) -> None:
176190
# logger.info(f"Added currency {currency} with tx hash {hex(tx_hash)}")
177191

178192
# # Update Pairs
179-
for pair in PAIRS_TO_UPDATE:
180-
tx_hash = await invoke(
181-
"pragma_Oracle",
182-
"update_pair",
183-
[pair["pair_id"]] + pair["pair"],
184-
port=port,
185-
)
186-
logger.info(f"Updated pair {pair} with tx hash {hex(tx_hash)}")
187-
188-
# # Add Pairs
189-
# for pair in PAIRS_TO_ADD[2:]:
193+
# for pair in PAIRS_TO_UPDATE:
190194
# tx_hash = await invoke(
191195
# "pragma_Oracle",
192-
# "add_pair",
193-
# (pair.id, pair.quote_currency.id, pair.base_currency.id),
196+
# "update_pair",
197+
# [pair["pair_id"]] + pair["pair"],
194198
# port=port,
195199
# )
196-
# await asyncio.sleep(1)
197-
# logger.info(f"Added pair {pair} with tx hash {hex(tx_hash)}")
200+
# logger.info(f"Updated pair {pair} with tx hash {hex(tx_hash)}")
201+
202+
# # Add Pairs
203+
for pair in PAIRS_TO_ADD:
204+
tx_hash = await invoke(
205+
"pragma_Oracle",
206+
"add_pair",
207+
(pair.id, pair.quote_currency.id, pair.base_currency.id),
208+
port=port,
209+
)
210+
await asyncio.sleep(1)
211+
logger.info(f"Added pair {pair} with tx hash {hex(tx_hash)}")
198212

199213
# for pair in PAIRS_TO_ADD:
200214
# tx_hash = await invoke(

pragma-deployer/pragma_deployer/register_publishers.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@
5050
"BITGET",
5151
"RE7_ONCHAIN",
5252
"CHAINLINK",
53-
"REDSTONE"
53+
"REDSTONE",
54+
"USN_ORACLE",
55+
"SUSN_VAULT",
5456
]
5557

5658
BTCFI_SOURCES = [
@@ -73,7 +75,9 @@
7375
"BITSTAMP",
7476
"COINBASE",
7577
"DEFILLAMA",
76-
"STARKNET"
78+
"STARKNET",
79+
"USN_ORACLE",
80+
"SUSN_VAULT",
7781
]
7882

7983
DEX_SOURCES = ["MYSWAP", "MYSWAPV2", "EKUBO", "SITHSWAP", "JEDISWAP", "10KSWAP"]

pragma-oracle/src/oracle/oracle.cairo

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,11 @@ mod Oracle {
541541
DataType::GenericEntry(pair_id) => pair_id,
542542
};
543543

544+
if pair_id == 'USN/USD' || pair_id == 'SUSN/USD' {
545+
let sources = IOracleABI::get_all_sources(self, data_type);
546+
return IOracleABI::get_data_for_sources(self, data_type, aggregation_mode, sources);
547+
}
548+
544549
let registered_conversion_rate_pairs = self.get_registered_conversion_rate_pairs();
545550
if registered_conversion_rate_pairs.contains(pair_id)
546551
|| aggregation_mode == AggregationMode::ConversionRate {
@@ -1615,7 +1620,6 @@ mod Oracle {
16151620
registered_pairs.append(new_pair_id);
16161621
}
16171622

1618-
16191623
// @notice add a new currency to the oracle (e.g ETH)
16201624
// @dev can be called only by the admin
16211625
// @param new_currency: the new currency to be added

0 commit comments

Comments
 (0)