From 0d80c922b86c9cec7d5abee0ba01f3eb868e7a23 Mon Sep 17 00:00:00 2001 From: Alexander Belokon Date: Thu, 11 Apr 2024 16:13:16 +0200 Subject: [PATCH] fix: use cow api directly --- modules/stonks/utils/fetchOffChainOrder.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/modules/stonks/utils/fetchOffChainOrder.ts b/modules/stonks/utils/fetchOffChainOrder.ts index c1f9d97e..903e516a 100644 --- a/modules/stonks/utils/fetchOffChainOrder.ts +++ b/modules/stonks/utils/fetchOffChainOrder.ts @@ -2,13 +2,24 @@ import { CHAINS } from '@lido-sdk/constants' import { fetcherStandard } from 'modules/network/utils/fetcherStandard' import { OffChainOrder } from '../types' +const COWSWAP_API_ENDPOINTS: Partial> = { + [CHAINS.Mainnet]: 'https://api.cow.fi/mainnet/api/v1', + [CHAINS.Goerli]: 'https://api.cow.fi/goerli/api/v1', +} + export const fetchOffChainOrder = async ( orderAddress: string, chainId: CHAINS, ) => { try { + const cowApiEndpoint = COWSWAP_API_ENDPOINTS[chainId] + + if (!cowApiEndpoint) { + throw new Error(`NO_CHAIN_${chainId}`) + } + const ordersByOwner = await fetcherStandard( - `/api/stonks/orders/${orderAddress}?chainId=${chainId}`, + `${cowApiEndpoint}/account/${orderAddress}/orders`, ) if (!ordersByOwner?.length) {