Skip to content

Commit b283e26

Browse files
defispartangrothem
andauthored
fix: switch from composite to simple oracle on type revert (#96)
* fix: switch from composite to simple oracle on type revert * chore: update comment * fix: fixed logic for defaulting to simple oracle type --------- Co-authored-by: Mark Grothe <[email protected]>
1 parent 27fa875 commit b283e26

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/mapping/proxy-price-provider/ethereum.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,12 @@ export function priceFeedUpdated(
6868
let priceAggregatorInstance = IExtendedPriceAggregator.bind(assetOracleAddress);
6969

7070
// check is it composite or simple asset.
71-
// In case its chainlink source, this call will revert, and will not update priceOracleAsset type
72-
// so it will stay as simple, as it is the default type
71+
// In case its chainlink source, this call will revert, and oracle type is updated to simple, which is the default
7372
let tokenTypeCall = priceAggregatorInstance.try_getTokenType();
7473
if (!tokenTypeCall.reverted) {
7574
priceOracleAsset.type = getPriceOracleAssetType(tokenTypeCall.value);
75+
} else {
76+
priceOracleAsset.type = PRICE_ORACLE_ASSET_TYPE_SIMPLE;
7677
}
7778

7879
// Type simple means that the source is chainlink source
@@ -301,10 +302,13 @@ function chainLinkAggregatorUpdated(
301302
if (!assetOracleAddress.equals(zeroAddress())) {
302303
let priceAggregatorInstance = IExtendedPriceAggregator.bind(assetOracleAddress);
303304

304-
// // check is it composite or simple asset
305+
// check is it composite or simple asset.
306+
// In case its chainlink source, this call will revert, and oracle type is updated to simple, which is the default
305307
let tokenTypeCall = priceAggregatorInstance.try_getTokenType();
306308
if (!tokenTypeCall.reverted) {
307309
priceOracleAsset.type = getPriceOracleAssetType(tokenTypeCall.value);
310+
} else {
311+
priceOracleAsset.type = PRICE_ORACLE_ASSET_TYPE_SIMPLE;
308312
}
309313

310314
if (priceOracleAsset.type == PRICE_ORACLE_ASSET_TYPE_SIMPLE) {

0 commit comments

Comments
 (0)