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

Commit

Permalink
feat(studio): Fix migration to Viem issues (#3043)
Browse files Browse the repository at this point in the history
  • Loading branch information
immasandwich authored Nov 14, 2023
1 parent 7f743cb commit 3859bd2
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export abstract class AaveV2ClaimablePositionFetcher extends ContractPositionTem

// Resolve all supply, stable debt, and variable debt token addresses
const reserveTokens = await lendingContract.read.getAllReservesTokens();
const reserveTokenAddresses = reserveTokens.map(v => v[1].toLowerCase());
const reserveTokenAddresses = reserveTokens.map(v => v.tokenAddress.toLowerCase());
const tokenAddresses = await Promise.all(
reserveTokenAddresses.map(async reserveTokenAddress => {
const tokenAddresses = await lendingContract.read.getReserveTokensAddresses([reserveTokenAddress]);
Expand Down
2 changes: 1 addition & 1 deletion src/apps/aave-v2/common/aave-v2.lending.token-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export abstract class AaveV2LendingTokenFetcher extends AppTokenTemplatePosition
);

const reserveTokens = await pool.read.getAllReservesTokens();
const reserveTokenAddreses = reserveTokens.map(v => v[1]);
const reserveTokenAddreses = reserveTokens.map(v => v.tokenAddress);
const reserveTokensData = await Promise.all(
reserveTokenAddreses.map(r => pool.read.getReserveTokensAddresses([r])),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { AppTokenTemplatePositionFetcher } from '~position/template/app-token.te
import {
DefaultAppTokenDataProps,
GetAddressesParams,
GetDefinitionsParams,
GetDisplayPropsParams,
GetPricePerShareParams,
GetUnderlyingTokensParams,
Expand Down Expand Up @@ -37,7 +38,7 @@ export abstract class BarnbridgeSmartAlphaJuniorPoolTokenFetcher extends AppToke
super(appToolkit);
}

async getDefinitions({ multicall }): Promise<BarnbridgeSmartAlphaJuniorPoolTokenDefinition[]> {
async getDefinitions({ multicall }: GetDefinitionsParams): Promise<BarnbridgeSmartAlphaJuniorPoolTokenDefinition[]> {
const poolAlphaPositions = await Promise.all(
this.poolAlphaAddresses.map(async poolAddress => {
const poolContract = this.contractFactory.barnbridgeSmartAlphaPool({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { AppTokenTemplatePositionFetcher } from '~position/template/app-token.te
import {
DefaultAppTokenDataProps,
GetAddressesParams,
GetDefinitionsParams,
GetDisplayPropsParams,
GetPricePerShareParams,
GetUnderlyingTokensParams,
Expand Down Expand Up @@ -37,7 +38,7 @@ export abstract class BarnbridgeSmartAlphaSeniorPoolTokenFetcher extends AppToke
super(appToolkit);
}

async getDefinitions({ multicall }): Promise<BarnbridgeSmartAlphaSeniorPoolTokenDefinition[]> {
async getDefinitions({ multicall }: GetDefinitionsParams): Promise<BarnbridgeSmartAlphaSeniorPoolTokenDefinition[]> {
const poolAlphaPositions = await Promise.all(
this.poolAlphaAddresses.map(async poolAddress => {
const poolContract = this.contractFactory.barnbridgeSmartAlphaPool({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export abstract class CurvePoolGaugeV6ContractPositionFetcher<

const inflationRateRaw = await contract.read.inflation_rate();
const workingSupplyRaw = await contract.read.working_supply();
const relativeWeightRaw = await multicall.wrap(controller)['gauge_relative_weight(address)'](address);
const relativeWeightRaw = await multicall.wrap(controller).read.gauge_relative_weight([address]);

const inflationRate = Number(inflationRateRaw) / 10 ** 18;
const workingSupply = Number(workingSupplyRaw) / 10 ** 18;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export abstract class CurvePoolGaugeContractPositionFetcher<

const inflationRateRaw = await contract.read.inflation_rate();
const workingSupplyRaw = await contract.read.working_supply();
const relativeWeightRaw = await multicall.wrap(controller)['gauge_relative_weight(address)'](address);
const relativeWeightRaw = await multicall.wrap(controller).read.gauge_relative_weight([address]);

const inflationRate = Number(inflationRateRaw) / 10 ** 18;
const workingSupply = Number(workingSupplyRaw) / 10 ** 18;
Expand Down
7 changes: 4 additions & 3 deletions src/apps/unagii/common/unagii.vault-token-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
DefaultAppTokenDataProps,
DefaultAppTokenDefinition,
GetAddressesParams,
GetDefinitionsParams,
GetPricePerShareParams,
GetUnderlyingTokensParams,
} from '~position/template/app-token.template.types';
Expand Down Expand Up @@ -34,16 +35,16 @@ export abstract class UnagiiVaultTokenFetcher extends AppTokenTemplatePositionFe
super(appToolkit);
}

async getDefinitions({ multicall }): Promise<UnagiiTokenDefinition[]> {
async getDefinitions({ multicall }: GetDefinitionsParams): Promise<UnagiiTokenDefinition[]> {
const vaultDefinitions = await Promise.all(
this.vaultManagerAddresses.map(async vaultAddress => {
const vaultManagerContract = this.contractFactory.unagiiV2Vault({
address: vaultAddress,
network: this.network,
});
const [uTokenAddress, underlyingTokenAddressRaw] = await Promise.all([
multicall.wrap(vaultManagerContract).uToken(),
multicall.wrap(vaultManagerContract).token(),
multicall.wrap(vaultManagerContract).read.uToken(),
multicall.wrap(vaultManagerContract).read.token(),
]);
return {
address: uTokenAddress.toLowerCase(),
Expand Down
6 changes: 3 additions & 3 deletions src/multicall/errors/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { MulticallWrappedReadDecodeError, MulticallWrappedReadDecodeErrorType } from './multicall.decode.error';
import { MulticallWrappedReadRequestError, MulticallWrappedReadRequestErrorType } from './multicall.request.error';
import { MulticallWrappedReadDecodeErrorType } from './multicall.decode.error';
import { MulticallWrappedReadRequestErrorType } from './multicall.request.error';

export type MulticallWrappedReadErrorType = MulticallWrappedReadRequestErrorType | MulticallWrappedReadDecodeErrorType;

export { MulticallWrappedReadRequestError, MulticallWrappedReadRequestErrorType } from './multicall.request.error';
export { MulticallWrappedReadDecodeError, MulticallWrappedReadDecodeErrorType } from './multicall.decode.error';

export const isViemMulticallUnderlyingError = (error: any): error is MulticallWrappedReadErrorType => {
return error instanceof MulticallWrappedReadRequestError || error instanceof MulticallWrappedReadDecodeError;
return error.name === 'MulticallWrappedReadRequestError' || error.name === 'MulticallWrappedReadDecodeError';
};
2 changes: 1 addition & 1 deletion src/multicall/impl/multicall.viem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export class ViemMulticallDataLoader {

const readProxy = new Proxy(contract, {
get: (target, functionName: string) => {
return (args: any[]) => this.load({ abi, address, functionName, args, stack });
return (args: any[] = []) => this.load({ abi, address, functionName, args, stack });
},
});

Expand Down

0 comments on commit 3859bd2

Please sign in to comment.