@@ -24,20 +24,6 @@ export interface ThreeRouteChain {
2424 hops : ThreeRouteHop [ ] ;
2525}
2626
27- // TODO: add axios adapter and change type if precision greater than of standard js number type is necessary
28- export interface ThreeRouteClassicSwapResponse {
29- input : number ;
30- output : number ;
31- chains : ThreeRouteChain [ ] ;
32- }
33-
34- export interface ThreeRouteSirsSwapResponse {
35- input : number ;
36- output : number ;
37- tzbtcChain : ThreeRouteClassicSwapResponse ;
38- xtzChain : ThreeRouteClassicSwapResponse ;
39- }
40-
4127interface ThreeRouteTokenCommon {
4228 id : number ;
4329 symbol : string ;
@@ -96,14 +82,10 @@ export interface ThreeRouteDex {
9682 token2 : ThreeRouteToken ;
9783}
9884
99- type ThreeRouteQueryParams = object | SwapQueryParams ;
100- type ThreeRouteQueryResponse =
101- | ThreeRouteClassicSwapResponse
102- | ThreeRouteSirsSwapResponse
103- | ThreeRouteDex [ ]
104- | ThreeRouteToken [ ] ;
85+ type ThreeRouteExchangeRates = Record < string , { ask : number ; bid : number } > ;
10586
106- export type ThreeRouteSwapResponse = ThreeRouteClassicSwapResponse | ThreeRouteSirsSwapResponse ;
87+ type ThreeRouteQueryParams = object | SwapQueryParams ;
88+ type ThreeRouteQueryResponse = ThreeRouteExchangeRates | ThreeRouteToken [ ] ;
10789
10890export const THREE_ROUTE_SIRS_SYMBOL = 'SIRS' ;
10991
@@ -113,17 +95,6 @@ const threeRouteBuildQueryFn = makeBuildQueryFn<ThreeRouteQueryParams, ThreeRout
11395 { headers : { Authorization : `Basic ${ EnvVars . THREE_ROUTE_API_AUTH_TOKEN } ` } }
11496) ;
11597
116- export const getThreeRouteSwap = threeRouteBuildQueryFn < SwapQueryParams , ThreeRouteSwapResponse > (
117- ( { inputTokenSymbol, outputTokenSymbol, realAmount } ) => {
118- const isSirsSwap = inputTokenSymbol === THREE_ROUTE_SIRS_SYMBOL || outputTokenSymbol === THREE_ROUTE_SIRS_SYMBOL ;
119-
120- return `/${ isSirsSwap ? 'swap-sirs' : 'swap' } /${ inputTokenSymbol } /${ outputTokenSymbol } /${ realAmount } ` ;
121- }
122- ) ;
123-
124- export const getThreeRouteDexes = threeRouteBuildQueryFn < object , ThreeRouteDex [ ] > ( '/dexes' , [ ] ) ;
125-
12698export const getThreeRouteTokens = threeRouteBuildQueryFn < object , ThreeRouteToken [ ] > ( '/tokens' , [ ] ) ;
12799
128- export const getChains = ( response : ThreeRouteSwapResponse ) =>
129- 'chains' in response ? response . chains : [ ...response . xtzChain . chains , ...response . tzbtcChain . chains ] ;
100+ export const getThreeRouteExchangeRates = threeRouteBuildQueryFn < object , ThreeRouteExchangeRates > ( '/prices' , [ ] ) ;
0 commit comments