Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions src/mapping/proxy-price-provider/v3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,19 +143,18 @@ export function priceFeedUpdated(

// Type simple means that the source is chainlink source
if (priceOracleAsset.type == PRICE_ORACLE_ASSET_TYPE_SIMPLE) {
let aggregatorAddress = assetOracleAddress;

// get underlying aggregator from proxy (assetOracleAddress) address
let chainlinkProxyInstance = EACAggregatorProxy.bind(assetOracleAddress);
let aggregatorAddressCall = chainlinkProxyInstance.try_aggregator();
// If we can't get the aggregator, it means that the source address is not a chainlink proxy
// so it has been registered badly.
if (aggregatorAddressCall.reverted) {
log.error(
`PROXY: Simple Type must be a chainlink proxy. || asset: {} | assetOracleAddress: {}`,
[sAssetAddress, assetOracleAddress.toHexString()]
);
return;

// If aggregator() call succeeds, it's a proxy - use the underlying aggregator
// If it fails, the source address itself is the direct aggregator (e.g., PT tokens)
if (!aggregatorAddressCall.reverted) {
aggregatorAddress = aggregatorAddressCall.value;
}
let aggregatorAddress = aggregatorAddressCall.value;

priceOracleAsset.priceSource = aggregatorAddress;
// create ChainLink aggregator template entity
ChainlinkAggregatorContract.create(aggregatorAddress);
Expand Down