@@ -25,7 +25,7 @@ export interface ThreeRouteChain {
2525}
2626
2727// TODO: add axios adapter and change type if precision greater than of standard js number type is necessary
28- export interface ThreeRouteSwapResponse {
28+ export interface ThreeRouteClassicSwapResponse {
2929 input : number ;
3030 output : number ;
3131 chains : ThreeRouteChain [ ] ;
@@ -34,8 +34,8 @@ export interface ThreeRouteSwapResponse {
3434export interface ThreeRouteSirsSwapResponse {
3535 input : number ;
3636 output : number ;
37- tzbtcChain : ThreeRouteSwapResponse ;
38- xtzChain : ThreeRouteSwapResponse ;
37+ tzbtcChain : ThreeRouteClassicSwapResponse ;
38+ xtzChain : ThreeRouteClassicSwapResponse ;
3939}
4040
4141interface ThreeRouteTokenCommon {
@@ -98,11 +98,13 @@ export interface ThreeRouteDex {
9898
9999type ThreeRouteQueryParams = object | SwapQueryParams ;
100100type ThreeRouteQueryResponse =
101- | ThreeRouteSwapResponse
101+ | ThreeRouteClassicSwapResponse
102102 | ThreeRouteSirsSwapResponse
103103 | ThreeRouteDex [ ]
104104 | ThreeRouteToken [ ] ;
105105
106+ export type ThreeRouteSwapResponse = ThreeRouteClassicSwapResponse | ThreeRouteSirsSwapResponse ;
107+
106108export const THREE_ROUTE_SIRS_SYMBOL = 'SIRS' ;
107109
108110const threeRouteBuildQueryFn = makeBuildQueryFn < ThreeRouteQueryParams , ThreeRouteQueryResponse > (
@@ -111,18 +113,17 @@ const threeRouteBuildQueryFn = makeBuildQueryFn<ThreeRouteQueryParams, ThreeRout
111113 { headers : { Authorization : `Basic ${ EnvVars . THREE_ROUTE_API_AUTH_TOKEN } ` } }
112114) ;
113115
114- export const getThreeRouteSwap = threeRouteBuildQueryFn <
115- SwapQueryParams ,
116- ThreeRouteSwapResponse | ThreeRouteSirsSwapResponse
117- > ( ( { inputTokenSymbol, outputTokenSymbol, realAmount } ) => {
118- const isSirsSwap = inputTokenSymbol === THREE_ROUTE_SIRS_SYMBOL || outputTokenSymbol === THREE_ROUTE_SIRS_SYMBOL ;
116+ export const getThreeRouteSwap = threeRouteBuildQueryFn < SwapQueryParams , ThreeRouteSwapResponse > (
117+ ( { inputTokenSymbol, outputTokenSymbol, realAmount } ) => {
118+ const isSirsSwap = inputTokenSymbol === THREE_ROUTE_SIRS_SYMBOL || outputTokenSymbol === THREE_ROUTE_SIRS_SYMBOL ;
119119
120- return `/${ isSirsSwap ? 'swap-sirs' : 'swap' } /${ inputTokenSymbol } /${ outputTokenSymbol } /${ realAmount } ` ;
121- } ) ;
120+ return `/${ isSirsSwap ? 'swap-sirs' : 'swap' } /${ inputTokenSymbol } /${ outputTokenSymbol } /${ realAmount } ` ;
121+ }
122+ ) ;
122123
123124export const getThreeRouteDexes = threeRouteBuildQueryFn < object , ThreeRouteDex [ ] > ( '/dexes' , [ ] ) ;
124125
125126export const getThreeRouteTokens = threeRouteBuildQueryFn < object , ThreeRouteToken [ ] > ( '/tokens' , [ ] ) ;
126127
127- export const getChains = ( response : ThreeRouteSwapResponse | ThreeRouteSirsSwapResponse ) =>
128+ export const getChains = ( response : ThreeRouteSwapResponse ) =>
128129 'chains' in response ? response . chains : [ ...response . xtzChain . chains , ...response . tzbtcChain . chains ] ;
0 commit comments