From ef5c88d90c551a835736232f6a472b7d975018b6 Mon Sep 17 00:00:00 2001 From: Bruno Eidam Guerios Date: Wed, 17 Jan 2024 14:21:32 -0300 Subject: [PATCH] Update to work with viem v2 --- .vscode/settings.json | 5 ++- examples/addLiquidityNested.ts | 2 +- examples/createPoolComposableStable.ts | 4 +-- .../modules/nested-pool-state/index.ts | 32 +++++++++---------- src/entities/utils/doRemoveLiquidityQuery.ts | 4 +-- src/sor.ts | 2 +- src/static.ts | 2 +- test/lib/utils/helper.ts | 4 +-- test/v2/data/balancerApi.test.ts | 3 -- 9 files changed, 28 insertions(+), 30 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 30dc8502..a4b1da58 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,7 @@ { "editor.defaultFormatter": "biomejs.biome", - "editor.formatOnSave": true + "editor.formatOnSave": true, + "[typescript]": { + "editor.defaultFormatter": "biomejs.biome" + } } diff --git a/examples/addLiquidityNested.ts b/examples/addLiquidityNested.ts index 684cd815..d2b1cc15 100644 --- a/examples/addLiquidityNested.ts +++ b/examples/addLiquidityNested.ts @@ -171,4 +171,4 @@ const exampleSetup = async (): Promise<{ }; }; -export default addLiquidityNested; \ No newline at end of file +export default addLiquidityNested; diff --git a/examples/createPoolComposableStable.ts b/examples/createPoolComposableStable.ts index fd160747..919602be 100644 --- a/examples/createPoolComposableStable.ts +++ b/examples/createPoolComposableStable.ts @@ -65,9 +65,7 @@ const createPoolComposableStable = async (): Promise<{ poolOwnerAddress: signerAddress, // Balancer DAO Multisig balancerVersion: 2, }; - const { call } = createPool.buildCall( - createPoolComposableStableInput, - ); + const { call } = createPool.buildCall(createPoolComposableStableInput); const hash = await client.sendTransaction({ to: COMPOSABLE_STABLE_POOL_FACTORY[chainId], data: call, diff --git a/src/data/providers/balancer-api/modules/nested-pool-state/index.ts b/src/data/providers/balancer-api/modules/nested-pool-state/index.ts index 4ac8a44c..43b445d3 100644 --- a/src/data/providers/balancer-api/modules/nested-pool-state/index.ts +++ b/src/data/providers/balancer-api/modules/nested-pool-state/index.ts @@ -160,14 +160,14 @@ export class NestedPools { constructor(private readonly balancerApiClient: BalancerApiClient) {} fetchNestedPoolState = async (id: string): Promise => { - const { - data: { poolGetPool }, - } = await this.balancerApiClient.fetch({ - query: this.nestedPoolStateQuery, - variables: { - id, - }, - }); + const { + data: { poolGetPool }, + } = await this.balancerApiClient.fetch({ + query: this.nestedPoolStateQuery, + variables: { + id, + }, + }); const nestedPoolState = this.mapPoolToNestedPoolState( poolGetPool as PoolGetPool, @@ -231,13 +231,13 @@ export class NestedPools { }; mapPoolType = (type: string): PoolType => { - switch (type) { - case 'WEIGHTED': - return PoolType.Weighted; - case 'COMPOSABLE_STABLE': - return PoolType.ComposableStable; - default: - throw new Error(`Unsupported pool type ${type}`); - } + switch (type) { + case 'WEIGHTED': + return PoolType.Weighted; + case 'COMPOSABLE_STABLE': + return PoolType.ComposableStable; + default: + throw new Error(`Unsupported pool type ${type}`); + } }; } diff --git a/src/entities/utils/doRemoveLiquidityQuery.ts b/src/entities/utils/doRemoveLiquidityQuery.ts index 9ffe7457..f81777c2 100644 --- a/src/entities/utils/doRemoveLiquidityQuery.ts +++ b/src/entities/utils/doRemoveLiquidityQuery.ts @@ -1,7 +1,7 @@ import { createPublicClient, http } from 'viem'; import { Address } from '../../types'; -import { BALANCER_QUERIES, CHAINS } from '../../utils/constants'; -import { balancerQueriesAbi } from '../../abi'; +import { BALANCER_QUERIES, CHAINS } from '../../utils/constants'; +import { balancerQueriesAbi } from '../../abi'; import { ExitPoolRequest } from '../removeLiquidity/types'; export async function doRemoveLiquidityQuery( diff --git a/src/sor.ts b/src/sor.ts index 00462625..4b3b3ebe 100644 --- a/src/sor.ts +++ b/src/sor.ts @@ -103,7 +103,7 @@ export class SmartOrderRouter { swapOptions, ); - if(candidatePaths.length === 0) return null; + if (candidatePaths.length === 0) return null; const bestPaths = this.router.getBestPaths( candidatePaths, diff --git a/src/static.ts b/src/static.ts index e856c6ba..9dab41b8 100644 --- a/src/static.ts +++ b/src/static.ts @@ -44,7 +44,7 @@ export async function sorGetSwapsWithPools( swapOptions?.graphTraversalConfig, ); - if(candidatePaths.length === 0) return null; + if (candidatePaths.length === 0) return null; const bestPaths = router.getBestPaths( candidatePaths, diff --git a/test/lib/utils/helper.ts b/test/lib/utils/helper.ts index 5d709388..7c9a4fd8 100644 --- a/test/lib/utils/helper.ts +++ b/test/lib/utils/helper.ts @@ -126,9 +126,9 @@ export async function sendTransactionGetBalances( value, }); - const transactionReceipt = await client.waitForTransactionReceipt({ + const transactionReceipt = (await client.waitForTransactionReceipt({ hash, - }); + })) as TransactionReceipt; const { gasUsed, effectiveGasPrice } = transactionReceipt; const gasPrice = gasUsed * effectiveGasPrice; diff --git a/test/v2/data/balancerApi.test.ts b/test/v2/data/balancerApi.test.ts index 1ba309b6..45e4bd2b 100644 --- a/test/v2/data/balancerApi.test.ts +++ b/test/v2/data/balancerApi.test.ts @@ -50,10 +50,7 @@ describe( const nestedPoolState: NestedPoolState = await balancerApi.nestedPools.fetchNestedPoolState(poolId); - - expect(nestedPoolState.mainTokens).toHaveLength(4); - }); }, {