Skip to content

Commit

Permalink
Merge pull request #259 from lidofinance/fix/cow-swap-api
Browse files Browse the repository at this point in the history
fix: use CoW API without proxy
  • Loading branch information
AnnaSila authored Apr 11, 2024
2 parents c7b1e84 + 0d80c92 commit af3bb0f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion modules/stonks/utils/fetchOffChainOrder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Record<CHAINS, string | undefined>> = {
[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<OffChainOrder[] | undefined>(
`/api/stonks/orders/${orderAddress}?chainId=${chainId}`,
`${cowApiEndpoint}/account/${orderAddress}/orders`,
)

if (!ordersByOwner?.length) {
Expand Down

0 comments on commit af3bb0f

Please sign in to comment.