Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add swaptype to response #163

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/sor/sor.gql
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type GqlSorGetSwapPaths {
The token address of the tokenOut provided
"""
tokenOut: String!
swapType: GqlSorSwapType!
swaps: [GqlSorSwap!]! #used by cowswap
paths: [GqlSorPath!]! #used by b-sdk
tokenInAmount: AmountHumanReadable!
Expand Down
5 changes: 5 additions & 0 deletions modules/sor/sorV2/sorV2.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ export class SorV2Service implements SwapService {
return {
vaultVersion: 2,
paths: paths,
swapType: this.mapSwapKindToSwapType(swap.swapKind),
swaps: this.mapSwaps(swap.swaps, swap.assets),
tokenIn: replaceZeroAddressWithEth(inputAmount.token.address),
tokenOut: replaceZeroAddressWithEth(outputAmount.token.address),
Expand All @@ -227,6 +228,10 @@ export class SorV2Service implements SwapService {
return swapType === 'EXACT_IN' ? SwapKind.GivenIn : SwapKind.GivenOut;
}

private mapSwapKindToSwapType(swapKind: SwapKind): GqlSorSwapType {
return swapKind === SwapKind.GivenIn ? 'EXACT_IN' : 'EXACT_OUT';
}

private mapSwaps(swaps: BatchSwapStep[] | SingleSwap, assets: string[]): GqlSorSwap[] {
if (Array.isArray(swaps)) {
return swaps.map((swap) => {
Expand Down
1 change: 1 addition & 0 deletions modules/sor/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const swapPathsZeroResponse = (tokenIn: string, tokenOut: string): GqlSor
return {
swaps: [],
paths: [],
swapType: 'EXACT_IN',
vaultVersion: 2,
tokenIn: replaceZeroAddressWithEth(tokenIn),
tokenOut: replaceZeroAddressWithEth(tokenOut),
Expand Down
Loading