Skip to content

Commit 805ba10

Browse files
keshan3262alex-tsx
andauthored
TW-1282: Use /prices 3route API entry (#143)
* TW-1282 Use /prices 3route API entry * TW-1282 Fix throwing an error Co-authored-by: Alex <[email protected]> * TW-1282 Fix ts errors --------- Co-authored-by: Alex <[email protected]>
1 parent 0cc1152 commit 805ba10

File tree

4 files changed

+45
-369
lines changed

4 files changed

+45
-369
lines changed

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import { getSignedMoonPayUrl } from './utils/moonpay/get-signed-moonpay-url';
3737
import { getSigningNonce } from './utils/signing-nonce';
3838
import SingleQueryDataProvider from './utils/SingleQueryDataProvider';
3939
import { tezExchangeRateProvider } from './utils/tezos';
40-
import { getExchangeRatesFromDB } from './utils/tokens';
40+
import { getExchangeRates } from './utils/tokens';
4141

4242
const PINO_LOGGER = {
4343
logger: logger.child({ name: 'web' }),
@@ -172,7 +172,7 @@ app.get('/api/abtest', (_, res) => {
172172
app.get('/api/exchange-rates/tez', makeProviderDataRequestHandler(tezExchangeRateProvider));
173173

174174
app.get('/api/exchange-rates', async (_req, res) => {
175-
const tokensExchangeRates = await getExchangeRatesFromDB();
175+
const tokensExchangeRates = await getExchangeRates();
176176
const { data: tezExchangeRate, error: tezExchangeRateError } = await getProviderStateWithTimeout(
177177
tezExchangeRateProvider
178178
);

src/utils/block-finder.ts

Lines changed: 0 additions & 57 deletions
This file was deleted.

src/utils/three-route.ts

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
4127
interface 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

10890
export 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-
12698
export 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

Comments
 (0)