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

feat(curve): Fix missing stETH/ETH, add missing logo for nereus #1070

Merged
merged 1 commit into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion src/apps/curve/helpers/curve.pool.on-chain.coin-strategy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { compact, range } from 'lodash';

import { ETH_ADDR_ALIAS, ZERO_ADDRESS } from '~app-toolkit/constants/address';
import { isMulticallUnderlyingError } from '~multicall/multicall.ethers';
import { IMulticallWrapper } from '~multicall/multicall.interface';

Expand All @@ -23,7 +24,10 @@ export class CurvePoolOnChainCoinStrategy {
),
);

return compact(coinAddresses).map(v => v.toLowerCase());
return compact(coinAddresses)
.filter(v => v !== ZERO_ADDRESS)
.map(v => v.toLowerCase())
.map(v => v.replace(ETH_ADDR_ALIAS, ZERO_ADDRESS));
};
}
}
14 changes: 1 addition & 13 deletions src/apps/curve/helpers/curve.pool.registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { range, uniqBy } from 'lodash';
import moment from 'moment';

import { APP_TOOLKIT, IAppToolkit } from '~app-toolkit/app-toolkit.interface';
import { ETH_ADDR_ALIAS, ZERO_ADDRESS } from '~app-toolkit/constants/address';
import { ZERO_ADDRESS } from '~app-toolkit/constants/address';
import {
CurveContractFactory,
CurveCryptoFactory,
Expand Down Expand Up @@ -55,7 +55,6 @@ export class CurvePoolRegistry {
resolveSourceCount: ({ contract }) => contract.pool_count(),
resolveSwapAddress: ({ contract, index }) => contract.pool_list(index),
resolveTokenAddress: ({ contract, swapAddress }) => contract.get_lp_token(swapAddress),
resolveCoinAddresses: ({ contract, swapAddress }) => contract.get_coins(swapAddress),
}),
// Stable Swap Factory
this.retrieveFromSource<CurveStableFactory>({
Expand All @@ -66,7 +65,6 @@ export class CurvePoolRegistry {
resolveSourceCount: ({ contract }) => contract.pool_count(),
resolveSwapAddress: ({ contract, index }) => contract.pool_list(index),
resolveTokenAddress: ({ swapAddress }) => swapAddress,
resolveCoinAddresses: ({ contract, swapAddress }) => contract.get_coins(swapAddress),
}),
// Crypto Swap Registry
this.retrieveFromSource<CurveCryptoRegistry>({
Expand All @@ -77,7 +75,6 @@ export class CurvePoolRegistry {
resolveSourceCount: ({ contract }) => contract.pool_count(),
resolveSwapAddress: ({ contract, index }) => contract.pool_list(index),
resolveTokenAddress: ({ contract, swapAddress }) => contract.get_lp_token(swapAddress),
resolveCoinAddresses: ({ contract, swapAddress }) => contract.get_coins(swapAddress),
}),
];

Expand All @@ -92,7 +89,6 @@ export class CurvePoolRegistry {
resolveSourceCount: ({ contract }) => contract.pool_count(),
resolveSwapAddress: ({ contract, index }) => contract.pool_list(index),
resolveTokenAddress: ({ contract, swapAddress }) => contract.get_token(swapAddress),
resolveCoinAddresses: ({ contract, swapAddress }) => contract.get_coins(swapAddress),
}),
);
}
Expand Down Expand Up @@ -128,15 +124,13 @@ export class CurvePoolRegistry {
resolveSourceCount,
resolveSwapAddress,
resolveTokenAddress,
resolveCoinAddresses,
}: {
network: Network;
poolType: CurvePoolType;
resolveSourceContract: (opts: { address: string; network: Network }) => T;
resolveSourceCount: (opts: { contract: T }) => BigNumberish | Promise<BigNumberish>;
resolveSwapAddress: (opts: { contract: T; index: number }) => string | Promise<string>;
resolveTokenAddress: (opts: { contract: T; swapAddress: string }) => string | Promise<string>;
resolveCoinAddresses: (opts: { contract: T; swapAddress: string }) => string[] | Promise<string[]>;
}) {
const multicall = this.appToolkit.getMulticall(network);
const gauges = await this.curveGaugeRegistry.getCachedGauges(network);
Expand All @@ -158,12 +152,6 @@ export class CurvePoolRegistry {
const tokenAddressRaw = await resolveTokenAddress({ contract: multicallWrappedSource, swapAddress });
const tokenAddress = tokenAddressRaw.toLowerCase();

const coinAddressesRaw = await resolveCoinAddresses({ contract: multicallWrappedSource, swapAddress });
const coinAddresses = coinAddressesRaw
.filter(v => v !== ZERO_ADDRESS)
.map(v => v.toLowerCase())
.map(v => v.replace(ETH_ADDR_ALIAS, ZERO_ADDRESS));

const gaugeAddresses = gauges.filter(v => v.swapAddress === swapAddress).map(v => v.gaugeAddress);
const poolApyData = allPoolApyData.find(v => v.swapAddress === swapAddress);
const apy = poolApyData?.apy ?? 0;
Expand Down
3 changes: 2 additions & 1 deletion src/apps/curve/helpers/curve.pool.token-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { BigNumberish } from 'ethers';
import { compact, partition } from 'lodash';

import { APP_TOOLKIT, IAppToolkit } from '~app-toolkit/app-toolkit.interface';
import { ETH_ADDR_ALIAS, ZERO_ADDRESS } from '~app-toolkit/constants/address';
import {
buildDollarDisplayItem,
buildNumberDisplayItem,
Expand Down Expand Up @@ -195,7 +196,7 @@ export class CurvePoolTokenHelper {
if (definition.coinAddresses) return definition;
const poolContract = resolvePoolContract({ network, address: definition.swapAddress });
const rawCoinAddresses = await resolvePoolCoinAddresses({ multicall, poolContract });
const coinAddresses = rawCoinAddresses.map(v => v.toLowerCase());
const coinAddresses = rawCoinAddresses.map(v => v.toLowerCase().replace(ETH_ADDR_ALIAS, ZERO_ADDRESS));
return { ...definition, coinAddresses };
}),
);
Expand Down
Binary file added src/apps/nereus-finance/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.