diff --git a/modules/beethoven/balancer-sdk.gql b/modules/beethoven/balancer-sdk.gql index a2d9e8d26..161c685a7 100644 --- a/modules/beethoven/balancer-sdk.gql +++ b/modules/beethoven/balancer-sdk.gql @@ -1,6 +1,6 @@ extend type Query { sorGetSwaps( - chain: GqlChain! + chain: GqlChain tokenIn: String! tokenOut: String! swapType: GqlSorSwapType! diff --git a/modules/beethoven/balancer-sdk.resolvers.ts b/modules/beethoven/balancer-sdk.resolvers.ts index ccedce89b..cab3456ca 100644 --- a/modules/beethoven/balancer-sdk.resolvers.ts +++ b/modules/beethoven/balancer-sdk.resolvers.ts @@ -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; @@ -18,6 +26,7 @@ const balancerSdkResolvers: Resolvers = { const swaps = await sorService.getBeetsSwaps({ ...args, + chain, tokenIn, tokenOut, graphTraversalConfig,