Skip to content

Commit

Permalink
refactor: save baseAsset as Token entity
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyar committed Dec 6, 2024
1 parent e9071bd commit c7677f4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion subgraphs/protocol-reserve/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type TokenConverter @entity {
address: Bytes!
converterNetwork: ConverterNetwork
destinationAddress: Bytes!
baseAsset: Bytes!
baseAsset: Token!
configs: [TokenConverterConfig!]! @derivedFrom(field: "tokenConverter")
paused: Boolean!
priceOracleAddress: Bytes!
Expand Down
11 changes: 6 additions & 5 deletions subgraphs/protocol-reserve/src/operations/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ export function createTokenConverter(tokenConverterAddress: Address): TokenConve

if (tokenConverterAddress.equals(riskFundConverterAddress)) {
const riskFund = RiskFund.bind(riskFundAddress);
tokenConverter.baseAsset = valueOrNotAvailableAddressIfReverted(
riskFund.try_convertibleBaseAsset(),
);
const baseAsset = valueOrNotAvailableAddressIfReverted(riskFund.try_convertibleBaseAsset());

tokenConverter.baseAsset = getOrCreateToken(baseAsset).id;
} else {
tokenConverter.baseAsset = valueOrNotAvailableAddressIfReverted(
const baseAsset = (tokenConverter.baseAsset = valueOrNotAvailableAddressIfReverted(
tokenConverterContract.try_baseAsset(),
);
));
tokenConverter.baseAsset = getOrCreateToken(baseAsset).id;
}
tokenConverter.priceOracleAddress = valueOrNotAvailableAddressIfReverted(
tokenConverterContract.try_priceOracle(),
Expand Down

0 comments on commit c7677f4

Please sign in to comment.