Skip to content

Commit

Permalink
feat(SWA-99): update 0x protocol API handling after their API migrati…
Browse files Browse the repository at this point in the history
…on (#318)
  • Loading branch information
ElRodrigote authored Sep 20, 2023
1 parent 65c8f53 commit e3b6b3a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/entities/trades/0x/0xTrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { build0xApiUrl, decodeStringToPercent, platformsFromSources } from './ut

// Debuging logger. See documentation to enable logging.
const debug0X = createDebug('ecoRouter:0x')
const headers = { '0x-api-key': `${process.env.REACT_APP_ZEROX_PROTOCOL_API_KEY}` }

/**
* Represents a trade executed against a list of pairs.
Expand Down Expand Up @@ -126,7 +127,7 @@ export class ZeroXTrade extends TradeWithSwapTransaction {
sellToken,
})
// slippagePercentage for the 0X API needs to be a value between 0 and 1, others have between 0 and 100
const response = await fetch(apiUrlParams)
const response = await fetch(apiUrlParams, { headers })

if (!response.ok) throw new Error('response not ok')
const json = (await response.json()) as ApiResponse
Expand Down Expand Up @@ -191,7 +192,7 @@ export class ZeroXTrade extends TradeWithSwapTransaction {
sellToken,
})
// slippagePercentage for the 0X API needs to be a value between 0 and 1, others have between 0 and 100
const response = await fetch(apiUrlParams)
const response = await fetch(apiUrlParams, { headers })
if (!response.ok) throw new Error('response not ok')
const json = (await response.json()) as ApiResponse

Expand Down

0 comments on commit e3b6b3a

Please sign in to comment.