Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
fix: Removed suffix on yearn vaults (#694)
Browse files Browse the repository at this point in the history
* fix: removed suffix on yearn's vault

* chore: cleanup synthetix
  • Loading branch information
wpoulin committed Jun 21, 2022
1 parent eb6a38f commit 8a1166c
Show file tree
Hide file tree
Showing 15 changed files with 94 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import { Network } from '~types/network.interface';
import { SynthetixContractFactory, SynthetixRewards } from '../contracts';
import { SYNTHETIX_DEFINITION } from '../synthetix.definition';

@Register.ContractPositionBalanceFetcher({
appId: SYNTHETIX_DEFINITION.id,
groupId: SYNTHETIX_DEFINITION.groups.farm.id,
network: Network.ETHEREUM_MAINNET,
})
const appId = SYNTHETIX_DEFINITION.id;
const groupId = SYNTHETIX_DEFINITION.groups.farm.id;
const network = Network.ETHEREUM_MAINNET;

@Register.ContractPositionBalanceFetcher({ appId, groupId, network })
export class EthereumSynthetixFarmContractPositionBalanceFetcher
implements PositionBalanceFetcher<ContractPositionBalance>
{
Expand All @@ -25,9 +25,9 @@ export class EthereumSynthetixFarmContractPositionBalanceFetcher
async getBalances(address: string) {
return this.appToolkit.helpers.singleStakingContractPositionBalanceHelper.getBalances<SynthetixRewards>({
address,
appId: SYNTHETIX_DEFINITION.id,
groupId: SYNTHETIX_DEFINITION.groups.farm.id,
network: Network.ETHEREUM_MAINNET,
appId,
groupId,
network,
resolveContract: ({ address, network }) => this.synthetixContractFactory.synthetixRewards({ address, network }),
resolveStakedTokenBalance: ({ contract, address, multicall }) => multicall.wrap(contract).balanceOf(address),
resolveRewardTokenBalances: ({ contract, address, multicall }) => multicall.wrap(contract).earned(address),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ const FARMS = [
},
];

@Register.ContractPositionFetcher({
appId: SYNTHETIX_DEFINITION.id,
groupId: SYNTHETIX_DEFINITION.groups.farm.id,
network: Network.ETHEREUM_MAINNET,
})
const appId = SYNTHETIX_DEFINITION.id;
const groupId = SYNTHETIX_DEFINITION.groups.farm.id;
const network = Network.ETHEREUM_MAINNET;

@Register.ContractPositionFetcher({ appId, groupId, network })
export class EthereumSynthetixFarmContractPositionFetcher implements PositionFetcher<ContractPosition> {
constructor(
@Inject(APP_TOOLKIT)
Expand All @@ -65,19 +65,19 @@ export class EthereumSynthetixFarmContractPositionFetcher implements PositionFet

async getPositions() {
return this.appToolkit.helpers.singleStakingFarmContractPositionHelper.getContractPositions<SynthetixRewards>({
network: Network.ETHEREUM_MAINNET,
appId: SYNTHETIX_DEFINITION.id,
groupId: SYNTHETIX_DEFINITION.groups.farm.id,
network,
appId,
groupId,
dependencies: [
{
appId: BALANCER_V1_DEFINITION.id,
groupIds: [BALANCER_V1_DEFINITION.groups.pool.id],
network: Network.ETHEREUM_MAINNET,
network,
},
{
appId: CURVE_DEFINITION.id,
groupIds: [CURVE_DEFINITION.groups.pool.id],
network: Network.ETHEREUM_MAINNET,
network,
},
],
resolveFarmDefinitions: async () => FARMS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import { Network } from '~types/network.interface';
import { SynthetixMintrContractPositionBalanceHelper } from '../helpers/synthetix.mintr.contract-position-balance-helper';
import { SYNTHETIX_DEFINITION } from '../synthetix.definition';

@Register.ContractPositionBalanceFetcher({
appId: SYNTHETIX_DEFINITION.id,
groupId: SYNTHETIX_DEFINITION.groups.mintr.id,
network: Network.ETHEREUM_MAINNET,
})
const appId = SYNTHETIX_DEFINITION.id;
const groupId = SYNTHETIX_DEFINITION.groups.mintr.id;
const network = Network.ETHEREUM_MAINNET;

@Register.ContractPositionBalanceFetcher({ appId, groupId, network })
export class EthereumSynthetixMintrContractPositionBalanceFetcher
implements PositionBalanceFetcher<ContractPositionBalance>
{
Expand All @@ -22,6 +22,6 @@ export class EthereumSynthetixMintrContractPositionBalanceFetcher
) {}

async getBalances(address: string) {
return this.synthetixMintrContractPositionBalanceHelper.getBalances({ address, network: Network.ETHEREUM_MAINNET });
return this.synthetixMintrContractPositionBalanceHelper.getBalances({ address, network });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import { Network } from '~types/network.interface';
import { SynthetixSynthTokenBalanceHelper } from '../helpers/synthetix.synth.token-balance-helper';
import { SYNTHETIX_DEFINITION } from '../synthetix.definition';

@Register.TokenPositionBalanceFetcher({
appId: SYNTHETIX_DEFINITION.id,
groupId: SYNTHETIX_DEFINITION.groups.synth.id,
network: Network.ETHEREUM_MAINNET,
})
const appId = SYNTHETIX_DEFINITION.id;
const groupId = SYNTHETIX_DEFINITION.groups.synth.id;
const network = Network.ETHEREUM_MAINNET;

@Register.TokenPositionBalanceFetcher({ appId, groupId, network })
export class EthereumSynthetixSynthTokenBalanceFetcher implements PositionBalanceFetcher<AppTokenPositionBalance> {
constructor(
@Inject(SynthetixSynthTokenBalanceHelper)
Expand All @@ -22,7 +22,7 @@ export class EthereumSynthetixSynthTokenBalanceFetcher implements PositionBalanc
async getBalances(address: string) {
return this.tokenBalanceHelper.getBalances({
address,
network: Network.ETHEREUM_MAINNET,
network,
resolverAddress: '0x823be81bbf96bec0e25ca13170f5aacb5b79ba83',
});
}
Expand Down
12 changes: 6 additions & 6 deletions src/apps/synthetix/ethereum/synthetix.synth.token-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ import { Network } from '~types/network.interface';
import { SynthetixSynthTokenHelper } from '../helpers/synthetix.synth.token-helper';
import { SYNTHETIX_DEFINITION } from '../synthetix.definition';

@Register.TokenPositionFetcher({
appId: SYNTHETIX_DEFINITION.id,
groupId: SYNTHETIX_DEFINITION.groups.synth.id,
network: Network.ETHEREUM_MAINNET,
})
const appId = SYNTHETIX_DEFINITION.id;
const groupId = SYNTHETIX_DEFINITION.groups.synth.id;
const network = Network.ETHEREUM_MAINNET;

@Register.TokenPositionFetcher({ appId, groupId, network })
export class EthereumSynthetixSynthTokenFetcher implements PositionFetcher<AppTokenPosition> {
constructor(@Inject(SynthetixSynthTokenHelper) private readonly tokenHelper: SynthetixSynthTokenHelper) {}

async getPositions() {
return this.tokenHelper.getTokens({
network: Network.ETHEREUM_MAINNET,
network,
resolverAddress: '0x823be81bbf96bec0e25ca13170f5aacb5b79ba83',
exchangeable: true,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ import { Network } from '~types/network.interface';
import { SynthetixTrasnferrableSnxTokenBalanceHelper } from '../helpers/synthetix.transferable-snx.token-balance-helper';
import { SYNTHETIX_DEFINITION } from '../synthetix.definition';

@Register.TokenPositionBalanceFetcher({
appId: SYNTHETIX_DEFINITION.id,
groupId: SYNTHETIX_DEFINITION.groups.transferableSnx.id,
network: Network.ETHEREUM_MAINNET,
})
const appId = SYNTHETIX_DEFINITION.id;
const groupId = SYNTHETIX_DEFINITION.groups.transferableSnx.id;
const network = Network.ETHEREUM_MAINNET;

@Register.TokenPositionBalanceFetcher({ appId, groupId, network })
export class EthereumSynthetixTransferableSnxBalanceFetcher implements PositionBalanceFetcher<AppTokenPositionBalance> {
constructor(
@Inject(SynthetixTrasnferrableSnxTokenBalanceHelper)
private readonly tokenBalanceHelper: SynthetixTrasnferrableSnxTokenBalanceHelper,
) {}

async getBalances(address: string) {
return this.tokenBalanceHelper.getBalances({ address, network: Network.ETHEREUM_MAINNET });
return this.tokenBalanceHelper.getBalances({ address, network });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ import { Network } from '~types/network.interface';
import { SynthetixTrasnferrableSnxTokenHelper } from '../helpers/synthetix.trasnferable-snx.token-helper';
import { SYNTHETIX_DEFINITION } from '../synthetix.definition';

@Register.TokenPositionFetcher({
appId: SYNTHETIX_DEFINITION.id,
groupId: SYNTHETIX_DEFINITION.groups.transferableSnx.id,
network: Network.ETHEREUM_MAINNET,
})
const appId = SYNTHETIX_DEFINITION.id;
const groupId = SYNTHETIX_DEFINITION.groups.transferableSnx.id;
const network = Network.ETHEREUM_MAINNET;

@Register.TokenPositionFetcher({ appId, groupId, network })
export class EthereumSynthetixTransferableSnxTokenFetcher implements PositionFetcher<AppTokenPosition> {
constructor(
@Inject(SynthetixTrasnferrableSnxTokenHelper) private readonly tokenHelper: SynthetixTrasnferrableSnxTokenHelper,
) {}

async getPositions() {
return this.tokenHelper.getTokens({ network: Network.ETHEREUM_MAINNET });
return this.tokenHelper.getTokens({ network });
}
}
19 changes: 15 additions & 4 deletions src/apps/synthetix/helpers/synthetix.synth.token-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { APP_TOOLKIT, IAppToolkit } from '~app-toolkit/app-toolkit.interface';
import { buildDollarDisplayItem } from '~app-toolkit/helpers/presentation/display-item.present';
import { getTokenImg } from '~app-toolkit/helpers/presentation/image.present';
import { ContractType } from '~position/contract.interface';
import { AppTokenPosition, ExchangeableAppTokenDataProps } from '~position/position.interface';
import { AppTokenPosition } from '~position/position.interface';
import { Network } from '~types/network.interface';

import { SynthetixContractFactory } from '../contracts';
Expand All @@ -19,6 +19,11 @@ export type SynthetixSynthTokenHelperParams = {
exchangeable?: boolean;
};

export type SynthetixAppTokenDataProps = {
exchangeable: boolean;
liquidity: number;
};

@Injectable()
export class SynthetixSynthTokenHelper {
constructor(
Expand Down Expand Up @@ -55,17 +60,19 @@ export class SynthetixSynthTokenHelper {
const price = Number(synthPrices[i]) / 10 ** 18;
const pricePerShare = 1;
const tokens = [];
const liquidity = supply * price;

// Display Props
const label = symbol;
const secondaryLabel = buildDollarDisplayItem(price);
const images = [getTokenImg(address, network)];
const statsItems = [{ label: 'Liquidity', value: buildDollarDisplayItem(liquidity) }];

const token: AppTokenPosition<ExchangeableAppTokenDataProps> = {
const token: AppTokenPosition<SynthetixAppTokenDataProps> = {
type: ContractType.APP_TOKEN,
appId: SYNTHETIX_DEFINITION.id,
groupId: SYNTHETIX_DEFINITION.groups.synth.id,
network: network,
network,
address,
symbol,
decimals,
Expand All @@ -74,12 +81,16 @@ export class SynthetixSynthTokenHelper {
pricePerShare,
tokens,

dataProps: { exchangeable },
dataProps: {
exchangeable,
liquidity,
},

displayProps: {
label,
secondaryLabel,
images,
statsItems,
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import { Network } from '~types/network.interface';
import { SynthetixMintrContractPositionBalanceHelper } from '../helpers/synthetix.mintr.contract-position-balance-helper';
import { SYNTHETIX_DEFINITION } from '../synthetix.definition';

@Register.ContractPositionBalanceFetcher({
appId: SYNTHETIX_DEFINITION.id,
groupId: SYNTHETIX_DEFINITION.groups.mintr.id,
network: Network.OPTIMISM_MAINNET,
})
const appId = SYNTHETIX_DEFINITION.id;
const groupId = SYNTHETIX_DEFINITION.groups.mintr.id;
const network = Network.OPTIMISM_MAINNET;

@Register.ContractPositionBalanceFetcher({ appId, groupId, network })
export class OptimismSynthetixMintrContractPositionBalanceFetcher
implements PositionBalanceFetcher<ContractPositionBalance>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import { Network } from '~types/network.interface';
import { SynthetixSynthTokenBalanceHelper } from '../helpers/synthetix.synth.token-balance-helper';
import { SYNTHETIX_DEFINITION } from '../synthetix.definition';

@Register.TokenPositionBalanceFetcher({
appId: SYNTHETIX_DEFINITION.id,
groupId: SYNTHETIX_DEFINITION.groups.synth.id,
network: Network.OPTIMISM_MAINNET,
})
const appId = SYNTHETIX_DEFINITION.id;
const groupId = SYNTHETIX_DEFINITION.groups.synth.id;
const network = Network.OPTIMISM_MAINNET;

@Register.TokenPositionBalanceFetcher({ appId, groupId, network })
export class OptimismSynthetixSynthTokenBalanceFetcher implements PositionBalanceFetcher<AppTokenPositionBalance> {
constructor(
@Inject(SynthetixSynthTokenBalanceHelper)
Expand All @@ -22,7 +22,7 @@ export class OptimismSynthetixSynthTokenBalanceFetcher implements PositionBalanc
async getBalances(address: string) {
return this.tokenBalanceHelper.getBalances({
address,
network: Network.OPTIMISM_MAINNET,
network,
resolverAddress: '0x95a6a3f44a70172e7d50a9e28c85dfd712756b8c',
});
}
Expand Down
12 changes: 6 additions & 6 deletions src/apps/synthetix/optimism/synthetix.synth.token-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ import { Network } from '~types/network.interface';
import { SynthetixSynthTokenHelper } from '../helpers/synthetix.synth.token-helper';
import { SYNTHETIX_DEFINITION } from '../synthetix.definition';

@Register.TokenPositionFetcher({
appId: SYNTHETIX_DEFINITION.id,
groupId: SYNTHETIX_DEFINITION.groups.synth.id,
network: Network.OPTIMISM_MAINNET,
})
const appId = SYNTHETIX_DEFINITION.id;
const groupId = SYNTHETIX_DEFINITION.groups.synth.id;
const network = Network.OPTIMISM_MAINNET;

@Register.TokenPositionFetcher({ appId, groupId, network })
export class OptimismSynthetixSynthTokenFetcher implements PositionFetcher<AppTokenPosition> {
constructor(@Inject(SynthetixSynthTokenHelper) private readonly tokenHelper: SynthetixSynthTokenHelper) {}

async getPositions() {
return this.tokenHelper.getTokens({
network: Network.OPTIMISM_MAINNET,
network,
resolverAddress: '0x95a6a3f44a70172e7d50a9e28c85dfd712756b8c',
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ import { Network } from '~types/network.interface';
import { SynthetixTrasnferrableSnxTokenBalanceHelper } from '../helpers/synthetix.transferable-snx.token-balance-helper';
import { SYNTHETIX_DEFINITION } from '../synthetix.definition';

@Register.TokenPositionBalanceFetcher({
appId: SYNTHETIX_DEFINITION.id,
groupId: SYNTHETIX_DEFINITION.groups.transferableSnx.id,
network: Network.OPTIMISM_MAINNET,
})
const appId = SYNTHETIX_DEFINITION.id;
const groupId = SYNTHETIX_DEFINITION.groups.transferableSnx.id;
const network = Network.OPTIMISM_MAINNET;

@Register.TokenPositionBalanceFetcher({ appId, groupId, network })
export class OptimismSynthetixTransferableSnxBalanceFetcher implements PositionBalanceFetcher<AppTokenPositionBalance> {
constructor(
@Inject(SynthetixTrasnferrableSnxTokenBalanceHelper)
private readonly tokenBalanceHelper: SynthetixTrasnferrableSnxTokenBalanceHelper,
) {}

async getBalances(address: string) {
return this.tokenBalanceHelper.getBalances({ address, network: Network.OPTIMISM_MAINNET });
return this.tokenBalanceHelper.getBalances({ address, network });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ import { Network } from '~types/network.interface';
import { SynthetixTrasnferrableSnxTokenHelper } from '../helpers/synthetix.trasnferable-snx.token-helper';
import { SYNTHETIX_DEFINITION } from '../synthetix.definition';

@Register.TokenPositionFetcher({
appId: SYNTHETIX_DEFINITION.id,
groupId: SYNTHETIX_DEFINITION.groups.transferableSnx.id,
network: Network.OPTIMISM_MAINNET,
})
const appId = SYNTHETIX_DEFINITION.id;
const groupId = SYNTHETIX_DEFINITION.groups.transferableSnx.id;
const network = Network.OPTIMISM_MAINNET;

@Register.TokenPositionFetcher({ appId, groupId, network })
export class OptimismSynthetixTransferableSnxTokenFetcher implements PositionFetcher<AppTokenPosition> {
constructor(
@Inject(SynthetixTrasnferrableSnxTokenHelper) private readonly tokenHelper: SynthetixTrasnferrableSnxTokenHelper,
) {}

async getPositions() {
return this.tokenHelper.getTokens({ network: Network.OPTIMISM_MAINNET });
return this.tokenHelper.getTokens({ network });
}
}
2 changes: 1 addition & 1 deletion src/apps/yearn/helpers/yearn.vault.token-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class YearnVaultTokenHelper {
const isBlocked = vault.emergencyShutdown || vault.type === 'v1' || vault.migration?.available;

// Display props
const label = `${getLabelFromToken(underlyingToken)} Vault`;
const label = getLabelFromToken(underlyingToken);
const secondaryLabel = buildDollarDisplayItem(price);
const images = getImagesFromToken(underlyingToken);
const statsItems = [
Expand Down
2 changes: 1 addition & 1 deletion src/apps/yearn/yearn.definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const YEARN_DEFINITION = appDefinition({
name: 'Yearn',
description: `Automate your yield. DeFi made simple.`,
groups: {
farm: { id: 'farm', type: GroupType.POSITION, label: 'Governance', isHiddenFromExplore: true },
farm: { id: 'farm', type: GroupType.POSITION, label: 'Governance' },
vault: { id: 'vault', type: GroupType.TOKEN, label: 'Vaults' },
yield: { id: 'yield', type: GroupType.TOKEN, label: 'Yield Tokens', isHiddenFromExplore: true }, // We seem to have these twice e.g. the same yUSDT is here and in vaults
},
Expand Down

0 comments on commit 8a1166c

Please sign in to comment.