Skip to content

Commit

Permalink
chain param optional
Browse files Browse the repository at this point in the history
  • Loading branch information
franzns committed Dec 8, 2023
1 parent be0630c commit f58ac63
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/beethoven/balancer-sdk.gql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extend type Query {
sorGetSwaps(
chain: GqlChain!
chain: GqlChain
tokenIn: String!
tokenOut: String!
swapType: GqlSorSwapType!
Expand Down
9 changes: 9 additions & 0 deletions modules/beethoven/balancer-sdk.resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@ import { tokenService } from '../token/token.service';
import { sorService } from '../sor/sor.service';
import { getTokenAmountHuman } from '../sor/utils';
import { GraphTraversalConfig } from '../sor/types';
import { headerChain } from '../context/header-chain';

const balancerSdkResolvers: Resolvers = {
Query: {
sorGetSwaps: async (parent, args, context) => {
const currentChain = headerChain();
if (!args.chain && currentChain) {
args.chain = currentChain;
} else if (!args.chain) {
throw new Error('poolGetPool error: Provide "chain" param');
}
const chain = args.chain;
const tokenIn = args.tokenIn.toLowerCase();
const tokenOut = args.tokenOut.toLowerCase();
const amountToken = args.swapType === 'EXACT_IN' ? tokenIn : tokenOut;
Expand All @@ -18,6 +26,7 @@ const balancerSdkResolvers: Resolvers = {

const swaps = await sorService.getBeetsSwaps({
...args,
chain,
tokenIn,
tokenOut,
graphTraversalConfig,
Expand Down

0 comments on commit f58ac63

Please sign in to comment.