Skip to content

Commit

Permalink
Merge pull request #95 from balancer/refactor-tests
Browse files Browse the repository at this point in the history
Refactor tests
  • Loading branch information
johngrantuk authored Sep 21, 2023
2 parents 5ea7e26 + ccef327 commit 346cb9d
Show file tree
Hide file tree
Showing 4 changed files with 328 additions and 415 deletions.
8 changes: 4 additions & 4 deletions src/entities/join/weighted/weightedJoin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class WeightedJoin implements BaseJoin {

const userData = this.encodeUserData(input.kind, amounts);

const queryArgs = parseJoinArgs({
const { args, tokensIn } = parseJoinArgs({
useNativeAssetAsWrappedAmountIn:
!!input.useNativeAssetAsWrappedAmountIn,
chainId: input.chainId,
Expand All @@ -48,14 +48,14 @@ export class WeightedJoin implements BaseJoin {
const queryResult = await doQueryJoin(
input.rpcUrl,
input.chainId,
queryArgs,
args,
);

const bpt = new Token(input.chainId, poolState.address, 18);
const bptOut = TokenAmount.fromRawAmount(bpt, queryResult.bptOut);

const amountsIn = queryResult.amountsIn.map((a, i) =>
TokenAmount.fromRawAmount(sortedTokens[i], a),
TokenAmount.fromRawAmount(tokensIn[i], a),
);

return {
Expand All @@ -79,7 +79,7 @@ export class WeightedJoin implements BaseJoin {

const userData = this.encodeUserData(input.joinKind, amounts);

const args = parseJoinArgs({
const { args } = parseJoinArgs({
...input,
sortedTokens: input.amountsIn.map((a) => a.token),
maxAmountsIn: amounts.maxAmountsIn,
Expand Down
5 changes: 4 additions & 1 deletion src/entities/utils/parseJoinArgs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,8 @@ export function parseJoinArgs({
fromInternalBalance,
};

return [poolId, sender, recipient, joinPoolRequest] as const;
return {
args: [poolId, sender, recipient, joinPoolRequest] as const,
tokensIn,
};
}
Loading

0 comments on commit 346cb9d

Please sign in to comment.