Skip to content

Commit

Permalink
Fix tbtc / btc price feed (#513)
Browse files Browse the repository at this point in the history
* temporary-fix

this is a temporary fix, until a long term fix where real is swapped to just btc and the spot things are tbtc

* version bump

* Use pythFeeds.json instead of extras

* Rename settings to pyth_feed_id_btc and pyth_feed_id_tbtc

* Fix Use pythFeeds.json instead of extras

* fix Perps_Trading.e2e.js

* fix Spot_Market_BTC.e2e.js

* Add tBTC collateral price before liquidating position (as both eth and tbtc were deposited as collaterals)

---------

Co-authored-by: Noisekit <[email protected]>
  • Loading branch information
kaleb-keny and noisekit authored Oct 25, 2024
1 parent 9dc2a5e commit 91f1ec8
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 27 deletions.
11 changes: 2 additions & 9 deletions e2e/tasks/doAllPriceUpdates.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,9 @@ async function doAllPriceUpdates({ wallet }) {
const priceVerificationContract =
extras.pyth_price_verification_address || extras.pythPriceVerificationAddress;

const possiblyDuplicateFeedIds = Object.entries(extras)
.filter(
([key]) =>
key.startsWith('pyth_feed_id_') || (key.startsWith('pyth') && key.endsWith('FeedId'))
)
.map(([_key, value]) => value);
const feedIds = Array.from(new Set(possiblyDuplicateFeedIds));

const feedIds = require('../deployments/pythFeeds.json');
log({ feeds: feedIds.length, feedIds });
const batches = splitIntoChunks(feedIds, 50);
const batches = splitIntoChunks(feedIds, 200);

for (const batch of batches) {
await doPriceUpdateForPyth({ wallet, feedId: batch, priceVerificationContract });
Expand Down
4 changes: 2 additions & 2 deletions e2e/tests/omnibus-arbitrum-mainnet.toml/Perps_Trading.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ describe(require('path').basename(__filename, '.e2e.js'), function () {
it('should wrap 5 tBTC', async () => {
await doPriceUpdateForPyth({
wallet,
feedId: extras.pyth_feed_id_btc,
feedId: extras.pyth_feed_id_tbtc,
priceVerificationContract: extras.pyth_price_verification_address,
});
const balance = await wrapCollateral({
Expand Down Expand Up @@ -400,7 +400,7 @@ describe(require('path').basename(__filename, '.e2e.js'), function () {

await doPriceUpdateForPyth({
wallet,
feedId: extras.pyth_feed_id_eth,
feedId: [extras.pyth_feed_id_eth, extras.pyth_feed_id_tbtc],
priceVerificationContract: extras.pyth_price_verification_address,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ describe(require('path').basename(__filename, '.e2e.js'), function () {
it(`should do strict price update`, async () => {
await doPriceUpdateForPyth({
wallet,
feedId: require('../../deployments/extras.json').pyth_feed_id_btc,
feedId: require('../../deployments/extras.json').pyth_feed_id_tbtc,
priceVerificationContract: require('../../deployments/extras.json')
.pyth_price_verification_address,
});
Expand Down
6 changes: 4 additions & 2 deletions omnibus-arbitrum-mainnet.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name = "synthetix-omnibus"
version = "35"
version = "36"
description = "Includes the full synthetix system with configurations applied"
preset = "main"
include = [
Expand Down Expand Up @@ -111,6 +111,7 @@ include = [
"tomls/omnibus-arbitrum-mainnet/oracles/pyth-susde.toml",
"tomls/omnibus-arbitrum-mainnet/oracles/pyth-sushi.toml",
"tomls/omnibus-arbitrum-mainnet/oracles/pyth-tao.toml",
"tomls/omnibus-arbitrum-mainnet/oracles/pyth-tbtc.toml",
"tomls/omnibus-arbitrum-mainnet/oracles/pyth-tia.toml",
"tomls/omnibus-arbitrum-mainnet/oracles/pyth-ton.toml",
"tomls/omnibus-arbitrum-mainnet/oracles/pyth-trx.toml",
Expand Down Expand Up @@ -369,7 +370,7 @@ pyth_feed_id_blur = "0x856aac602516addee497edf6f50d39e8c95ae5fb0da1ed434a8c2ab9c
pyth_feed_id_bnb = "0x2f95862b045670cd22bee3114c39763a4a08beeb663b145d283c31d7d1101c4f"
pyth_feed_id_bome = "0x30e4780570973e438fdb3f1b7ad22618b2fc7333b65c7853a7ca144c39052f7a"
pyth_feed_id_bonk = "0x72b021217ca3fe68922a19aaf990109cb9d84e9ad004b4d2025ad6f529314419"
pyth_feed_id_btc = "0x56a3121958b01f99fdc4e1fd01e81050602c7ace3a571918bb55c6a96657cca9"
pyth_feed_id_btc = "0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43"
pyth_feed_id_comp = "0x4a8e42861cabc5ecb50996f92e7cfa2bce3fd0a2423b0c44c9b423fb2bd25478"
pyth_feed_id_crv = "0xa19d04ac696c7a6616d291c7e5d1377cc8be437c327b75adb5dc1bad745fcae8"
pyth_feed_id_doge = "0xdcef50dd0a4cd2dcc17e45df1676dcb336a11a61c69df7a0299b0150c672d25c"
Expand Down Expand Up @@ -424,6 +425,7 @@ pyth_feed_id_sui = "0x23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6d
pyth_feed_id_susde = "0xca3ba9a619a4b3755c10ac7d5e760275aa95e9823d38a84fedd416856cdba37c"
pyth_feed_id_sushi = "0x26e4f737fde0263a9eea10ae63ac36dcedab2aaf629261a994e1eeb6ee0afe53"
pyth_feed_id_tao = "0x410f41de235f2db824e562ea7ab2d3d3d4ff048316c61d629c0b93f58584e1af"
pyth_feed_id_tbtc = "0x56a3121958b01f99fdc4e1fd01e81050602c7ace3a571918bb55c6a96657cca9"
pyth_feed_id_tia = "0x09f7c1d7dfbb7df2b8fe3d3d87ee94a2259d212da4f30c1f0540d066dfa44723"
pyth_feed_id_ton = "0x8963217838ab4cf5cadc172203c1f0b763fbaa45f346d8ee50ba994bbcac3026"
pyth_feed_id_trx = "0x67aed5a24fdad045475e7195c98a98aea119c763f272d4523f5bac93a4f33c2b"
Expand Down
22 changes: 11 additions & 11 deletions tomls/omnibus-arbitrum-mainnet/oracles/pyth-btc.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[invoke.OracleManagerProxy_registerNode_pyth_BTC]
[invoke.OracleManagerProxy_registerNode_pyth_real_BTC]
description = "Latest Pyth Price. This registers a staleness node that looks to Pyth for a fresh enough price, or otherwise reverts with an ERC-7412 compatible error"
target = ["system.oracle_manager.Proxy"]
func = "registerNode"
Expand All @@ -8,10 +8,10 @@ args = [
[
],
]
extra.btc_pyth_oracle_id.event = "NodeRegistered"
extra.btc_pyth_oracle_id.arg = 0
extra.real_btc_pyth_oracle_id.event = "NodeRegistered"
extra.real_btc_pyth_oracle_id.arg = 0

[invoke.OracleManagerProxy_registerNode_pyth_offchain_lookup_BTC]
[invoke.OracleManagerProxy_registerNode_pyth_offchain_lookup_real_BTC]
description = "Pyth Off-chain Lookup"
target = ["system.oracle_manager.Proxy"]
func = "registerNode"
Expand All @@ -21,20 +21,20 @@ args = [
[
],
]
extra.btc_lookup_oracle_id.event = "NodeRegistered"
extra.btc_lookup_oracle_id.arg = 0
extra.real_btc_lookup_oracle_id.event = "NodeRegistered"
extra.real_btc_lookup_oracle_id.arg = 0

# Staleness Node
[invoke.OracleManagerProxy_registerNode_staleness_BTC]
[invoke.OracleManagerProxy_registerNode_staleness_real_BTC]
target = ["system.oracle_manager.Proxy"]
func = "registerNode"
args = [
7, # 7 = staleness circuit breaker
"<%= defaultAbiCoder.encode(['uint256'], [settings.default_staleness_tolerance]) %>",
[
"<%= extras.btc_pyth_oracle_id %>",
"<%= extras.btc_lookup_oracle_id %>",
"<%= extras.real_btc_pyth_oracle_id %>",
"<%= extras.real_btc_lookup_oracle_id %>",
],
]
extra.btc_oracle_id.event = "NodeRegistered"
extra.btc_oracle_id.arg = 0
extra.real_btc_oracle_id.event = "NodeRegistered"
extra.real_btc_oracle_id.arg = 0
40 changes: 40 additions & 0 deletions tomls/omnibus-arbitrum-mainnet/oracles/pyth-tbtc.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[invoke.OracleManagerProxy_registerNode_pyth_BTC]
description = "Latest Pyth Price. This registers a staleness node that looks to Pyth for a fresh enough price, or otherwise reverts with an ERC-7412 compatible error"
target = ["system.oracle_manager.Proxy"]
func = "registerNode"
args = [
5, # 5 = pyth aggregator type
"<%= defaultAbiCoder.encode(['address', 'bytes32', 'bool'], [settings.pyth_price_verification_address, settings.pyth_feed_id_tbtc, false]) %>",
[
],
]
extra.btc_pyth_oracle_id.event = "NodeRegistered"
extra.btc_pyth_oracle_id.arg = 0

[invoke.OracleManagerProxy_registerNode_pyth_offchain_lookup_BTC]
description = "Pyth Off-chain Lookup"
target = ["system.oracle_manager.Proxy"]
func = "registerNode"
args = [
9, # 9 = PythOffchainLookupNode
"<%= defaultAbiCoder.encode(['address', 'bytes32', 'uint256'], [imports.pyth_erc7412_wrapper.contracts.PythERC7412Wrapper.address, settings.pyth_feed_id_tbtc, settings.default_staleness_tolerance]) %>",
[
],
]
extra.btc_lookup_oracle_id.event = "NodeRegistered"
extra.btc_lookup_oracle_id.arg = 0

# Staleness Node
[invoke.OracleManagerProxy_registerNode_staleness_BTC]
target = ["system.oracle_manager.Proxy"]
func = "registerNode"
args = [
7, # 7 = staleness circuit breaker
"<%= defaultAbiCoder.encode(['uint256'], [settings.default_staleness_tolerance]) %>",
[
"<%= extras.btc_pyth_oracle_id %>",
"<%= extras.btc_lookup_oracle_id %>",
],
]
extra.btc_oracle_id.event = "NodeRegistered"
extra.btc_oracle_id.arg = 0
2 changes: 1 addition & 1 deletion tomls/omnibus-arbitrum-mainnet/perps/markets/btc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fromCall.func = "owner"
func = "updatePriceData"
args = [
"<%= settings.btc_perps_market_id %>",
"<%= extras.btc_oracle_id %>",
"<%= extras.real_btc_oracle_id %>",
"<%= settings.strict_staleness_tolerance %>",
]

Expand Down
2 changes: 1 addition & 1 deletion tomls/omnibus-arbitrum-mainnet/spot/tbtc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func = "setSettlementStrategy"
args = [
"<%= extras.synth_btc_market_id %>",
"<%= extras.synth_btc_settlement_strategy_id %>",
{ strategyType = "1", settlementDelay = "<%= settings.settlement_delay %>", settlementWindowDuration = "<%= settings.settlement_window_duration %>", priceVerificationContract = "<%= imports.pyth_erc7412_wrapper.contracts.PythERC7412Wrapper.address %>", feedId = "<%= settings.pyth_feed_id_btc %>", url = "<%= settings.pyth_feed_url %>", settlementReward = "<%= settings.settlement_reward %>", minimumUsdExchangeAmount = "<%= settings.settlement_minimum_usd_exchange_amount %>", maxRoundingLoss = "<%= settings.settlement_max_rounding_loss %>", priceDeviationTolerance = "<%= settings.price_deviation_tolerance %>", disabled = true },
{ strategyType = "1", settlementDelay = "<%= settings.settlement_delay %>", settlementWindowDuration = "<%= settings.settlement_window_duration %>", priceVerificationContract = "<%= imports.pyth_erc7412_wrapper.contracts.PythERC7412Wrapper.address %>", feedId = "<%= settings.pyth_feed_id_tbtc %>", url = "<%= settings.pyth_feed_url %>", settlementReward = "<%= settings.settlement_reward %>", minimumUsdExchangeAmount = "<%= settings.settlement_minimum_usd_exchange_amount %>", maxRoundingLoss = "<%= settings.settlement_max_rounding_loss %>", priceDeviationTolerance = "<%= settings.price_deviation_tolerance %>", disabled = true },
] # note that the actual btc price feed is used due to lack of liquidity of tbtc spot token, until a better redemption price is available

[invoke.CoreProxy_configureCollateral_tBTC]
Expand Down

0 comments on commit 91f1ec8

Please sign in to comment.