Skip to content

Commit

Permalink
fix: add token symbol override for vault.tokens (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
jstashh authored Sep 3, 2021
1 parent 04537bb commit 3d392b5
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/interfaces/vault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,20 +177,28 @@ export class VaultInterface<T extends ChainId> extends ServiceInterface<T> {
*/
async tokens(overrides?: CallOverrides): Promise<Token[]> {
const adapters = Object.values(this.yearn.services.lens.adapters.vaults);
await this.yearn.services.asset.ready;
return await Promise.all(
adapters.map(async adapter => {
const tokenAddresses = await adapter.tokens(overrides);
const tokens = await this.yearn.services.helper.tokens(tokenAddresses, overrides);
const icons = this.yearn.services.asset.icon(tokenAddresses.concat(EthAddress));
const tokensMetadata = await this.yearn.tokens.metadata(tokenAddresses);
return Promise.all(
tokens.map(async token => ({
...token,
icon: icons[token.address],
supported: {},
priceUsdc: await this.yearn.services.oracle.getPriceUsdc(token.address, overrides),
metadata: tokensMetadata.find(metadata => metadata.address === token.address)
}))
tokens.map(async token => {
const result = {
...token,
icon: icons[token.address],
supported: {},
priceUsdc: await this.yearn.services.oracle.getPriceUsdc(token.address, overrides),
metadata: tokensMetadata.find(metadata => metadata.address === token.address)
};
const symbolOverride = this.yearn.services.asset.alias(token.address)?.symbol;
if (symbolOverride) {
result.symbol = symbolOverride;
}
return result;
})
);
})
).then(arr => arr.flat());
Expand Down

0 comments on commit 3d392b5

Please sign in to comment.