Skip to content

Commit

Permalink
Update to work with viem v2
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoguerios committed Jan 17, 2024
1 parent 2370310 commit ef5c88d
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 30 deletions.
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"editor.defaultFormatter": "biomejs.biome",
"editor.formatOnSave": true
"editor.formatOnSave": true,
"[typescript]": {
"editor.defaultFormatter": "biomejs.biome"
}
}
2 changes: 1 addition & 1 deletion examples/addLiquidityNested.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,4 @@ const exampleSetup = async (): Promise<{
};
};

export default addLiquidityNested;
export default addLiquidityNested;
4 changes: 1 addition & 3 deletions examples/createPoolComposableStable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
32 changes: 16 additions & 16 deletions src/data/providers/balancer-api/modules/nested-pool-state/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,14 @@ export class NestedPools {
constructor(private readonly balancerApiClient: BalancerApiClient) {}

fetchNestedPoolState = async (id: string): Promise<NestedPoolState> => {
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,
Expand Down Expand Up @@ -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}`);
}
};
}
4 changes: 2 additions & 2 deletions src/entities/utils/doRemoveLiquidityQuery.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/sor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions test/lib/utils/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 0 additions & 3 deletions test/v2/data/balancerApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,7 @@ describe(
const nestedPoolState: NestedPoolState =
await balancerApi.nestedPools.fetchNestedPoolState(poolId);



expect(nestedPoolState.mainTokens).toHaveLength(4);

});
},
{
Expand Down

0 comments on commit ef5c88d

Please sign in to comment.