Skip to content

Commit e906d75

Browse files
authored
Merge pull request #208 from balancer/minor-fixes-and-refactors
Minor fixes and refactors
2 parents 2d475ed + fc21f1e commit e906d75

File tree

11 files changed

+21
-32
lines changed

11 files changed

+21
-32
lines changed

.changeset/dull-starfishes-learn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@balancer/sdk": patch
3+
---
4+
5+
Minor refactors and lint fixes

examples/addLiquidity.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const addLiquidity = async () => {
7070
slippage,
7171
sender: userAccount,
7272
recipient: userAccount,
73-
chainId
73+
chainId,
7474
});
7575

7676
console.log('\nWith slippage applied:');

examples/removeLiquidity.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ const removeLiquidity = async () => {
7474
slippage,
7575
sender: userAccount,
7676
recipient: userAccount,
77-
chainId
77+
chainId,
7878
});
7979

8080
console.log('\nWith slippage applied:');

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
"test:ci": "vitest run",
2525
"changeset": "changeset",
2626
"changeset:release": "pnpm build && changeset publish",
27-
"anvil": "anvil --fork-url $(. ./.env && echo $ETHEREUM_RPC_URL)",
2827
"example": "npx tsx ./examples/executeExample.ts"
2928
},
3029
"dependencies": {

src/data/providers/balancer-api/modules/nested-pool-state/index.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { BalancerApiClient } from '../../client';
22
import { NestedPool, NestedPoolState } from '../../../../../entities';
33
import { MinimalToken } from '../../../../types';
4-
import { Address, Hex, PoolType } from '../../../../../types';
4+
import { Address, Hex } from '../../../../../types';
55
import { mapPoolType } from '@/utils/poolTypeMapper';
66

77
type PoolGetPool = {
@@ -230,15 +230,4 @@ export class NestedPools {
230230
mainTokens,
231231
} as NestedPoolState;
232232
};
233-
234-
mapPoolType = (type: string): PoolType => {
235-
switch (type) {
236-
case 'WEIGHTED':
237-
return PoolType.Weighted;
238-
case 'COMPOSABLE_STABLE':
239-
return PoolType.ComposableStable;
240-
default:
241-
throw new Error(`Unsupported pool type ${type}`);
242-
}
243-
};
244233
}

src/entities/addLiquidity/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ type AddLiquidityBaseCall = {
6565
slippage: Slippage;
6666
sender: Address;
6767
recipient: Address;
68-
chainId: number
68+
chainId: number;
6969
};
7070

7171
export type AddLiquidityComposableStableCall = AddLiquidityBaseCall &

src/entities/removeLiquidity/removeLiquidityV2/composableStable/removeLiquidityComposableStable.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import { encodeFunctionData } from 'viem';
22
import { Token } from '../../../token';
33
import { TokenAmount } from '../../../tokenAmount';
4-
import {
5-
VAULT,
6-
MAX_UINT256,
7-
ZERO_ADDRESS,
8-
} from '../../../../utils/constants';
4+
import { VAULT, MAX_UINT256, ZERO_ADDRESS } from '../../../../utils/constants';
95
import { vaultV2Abi } from '../../../../abi';
106
import { parseRemoveLiquidityArgs } from '../../../utils/parseRemoveLiquidityArgs';
117
import {

src/entities/removeLiquidity/removeLiquidityV2/weighted/removeLiquidityWeighted.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@ import { encodeFunctionData } from 'viem';
22
import { Token } from '../../../token';
33
import { TokenAmount } from '../../../tokenAmount';
44
import { WeightedEncoder } from '../../../encoders/weighted';
5-
import {
6-
VAULT,
7-
MAX_UINT256,
8-
ZERO_ADDRESS,
9-
} from '../../../../utils/constants';
5+
import { VAULT, MAX_UINT256, ZERO_ADDRESS } from '../../../../utils/constants';
106
import { vaultV2Abi } from '../../../../abi';
117
import { parseRemoveLiquidityArgs } from '../../../utils/parseRemoveLiquidityArgs';
128
import {

src/utils/poolTypeMapper.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ export const mapPoolType = (type: string): PoolType => {
1313
const supportedPoolTypes = Object.keys(poolTypeMap);
1414

1515
if (!supportedPoolTypes.includes(type)) {
16-
throw new Error(`Unsupported pool type ${type}`);
16+
throw new Error(
17+
`Unsupported pool type ${type} - supported types are ${supportedPoolTypes.join(
18+
', ',
19+
)}`,
20+
);
1721
}
1822

1923
return poolTypeMap[type];

test/lib/utils/addLiquidityHelper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ async function sdkAddLiquidity({
5252
slippage,
5353
sender: testAddress,
5454
recipient: testAddress,
55-
chainId: addLiquidityInput.chainId
55+
chainId: addLiquidityInput.chainId,
5656
});
5757

5858
return {

test/lib/utils/removeLiquidityHelper.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const sdkRemoveLiquidity = async ({
4444
slippage,
4545
sender: testAddress,
4646
recipient: testAddress,
47-
chainId: removeLiquidityInput.chainId
47+
chainId: removeLiquidityInput.chainId,
4848
});
4949

5050
return {
@@ -188,7 +188,7 @@ export function assertRemoveLiquidityUnbalanced(
188188
removeLiquidityBuildOutput,
189189
false,
190190
slippage,
191-
chainId
191+
chainId,
192192
);
193193

194194
assertTokenDeltas(
@@ -263,7 +263,7 @@ export function assertRemoveLiquiditySingleToken(
263263
removeLiquidityBuildOutput,
264264
true,
265265
slippage,
266-
chainId
266+
chainId,
267267
);
268268

269269
assertTokenDeltas(
@@ -320,7 +320,7 @@ export function assertRemoveLiquidityProportional(
320320
removeLiquidityBuildOutput,
321321
true,
322322
slippage,
323-
chainId
323+
chainId,
324324
);
325325

326326
assertTokenDeltas(

0 commit comments

Comments
 (0)