Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jorbuedo committed Nov 19, 2024
1 parent 51ea966 commit 79bc03c
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 123 deletions.
2 changes: 2 additions & 0 deletions packages/swap/src/adapters/api/dexhunter/transformers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ export const transformersMaker = ({
total_input = 0,
total_output = 0,
}: LimitBuildResponse): Swap.CreateResponse => ({
aggregator: Swap.Aggregator.Dexhunter,
cbor,
splits: splits?.map(transformSplit) ?? [],
batcherFee: batcher_fee,
Expand Down Expand Up @@ -336,6 +337,7 @@ export const transformersMaker = ({
total_output = 0,
total_output_without_slippage = 0,
}: BuildResponse): Swap.CreateResponse => ({
aggregator: Swap.Aggregator.Dexhunter,
cbor,
splits: splits?.map(transformSplit) ?? [],
batcherFee: batcher_fee,
Expand Down
24 changes: 8 additions & 16 deletions packages/swap/src/adapters/api/muesliswap/transformers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,22 +247,14 @@ export const transformersMaker = ({
response: (
res: ConstructSwapDatumResponse,
estimate: Swap.EstimateResponse,
): Swap.CreateResponse => {
const cbor: string = swapCreateCbor(res)

return {
cbor,
...estimate,
totalInput: estimate.totalInput ?? estimate.splits[0]?.amountIn ?? 0,
}
},
): Swap.CreateResponse => ({
aggregator: Swap.Aggregator.Muesliswap,
contractAddress: res.address,
datumData: res.datum,
datumHash: res.hash,
...estimate,
totalInput: estimate.totalInput ?? estimate.splits[0]?.amountIn ?? 0,
}),
},
} as const
}

// TODO: Transform contractAddress, datum, hash into cbor, code in StartSwapOrderScreen.tsx
const swapCreateCbor = ({
address: contractAddress,
datum,
hash,
}: ConstructSwapDatumResponse) => `${contractAddress}${datum}${hash}`
34 changes: 0 additions & 34 deletions packages/swap/src/fixtures/ErrorBoundary.tsx

This file was deleted.

16 changes: 0 additions & 16 deletions packages/swap/src/fixtures/SuspenseBoundary.tsx

This file was deleted.

25 changes: 0 additions & 25 deletions packages/swap/src/fixtures/manager-wrapper.tsx

This file was deleted.

14 changes: 0 additions & 14 deletions packages/swap/src/fixtures/query-client.ts

This file was deleted.

16 changes: 0 additions & 16 deletions packages/swap/src/helpers/getLiquidityProviderFee.ts

This file was deleted.

19 changes: 17 additions & 2 deletions packages/types/src/swap/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ export type SwapCreateRequest = {
}
)

// Leaks aggregator because of current challenge creating a cbor inside package
export type SwapCreateResponse = {
cbor: string
splits: SwapSplit[]
batcherFee: number
deposits: number
Expand All @@ -107,7 +107,22 @@ export type SwapCreateResponse = {
totalInput: number
totalOutput: number
totalOutputWithoutSlippage?: number
}
} & (
| {
aggregator: typeof SwapAggregator.Muesliswap
datumData: string
datumHash: string
contractAddress: string
cbor?: undefined
}
| {
aggregator: typeof SwapAggregator.Dexhunter
datumData?: undefined
datumHash?: undefined
contractAddress?: undefined
cbor: string
}
)

export type SwapCancelRequest = {
order: SwapOrder
Expand Down

0 comments on commit 79bc03c

Please sign in to comment.