Skip to content
This repository was archived by the owner on Jun 24, 2022. It is now read-only.

Commit

Permalink
paths, fixed type, and renaming stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
W3stside committed Dec 15, 2021
1 parent 27bb626 commit 25b0439
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/custom/api/gnosisProtocol/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { FeeQuoteParams, PriceInformation, PriceQuoteParams, SimpleGetQuoteRespo
import { DEFAULT_NETWORK_FOR_LISTS } from 'constants/lists'
import { GAS_FEE_ENDPOINTS } from 'constants/index'
import * as Sentry from '@sentry/browser'
import { ZERO_ADDRESS } from '@src/constants/misc'
import { ZERO_ADDRESS } from 'constants/misc'
import { getAppDataHash } from 'constants/appDataHash'

function getGnosisProtocolUrl(): Partial<Record<ChainId, string>> {
Expand Down
9 changes: 4 additions & 5 deletions src/custom/hooks/useGetGpPriceStrategy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import ms from 'ms.macro'
import { useState, useEffect } from 'react'

export const DEFAULT_GP_PRICE_STRATEGY = 'LEGACY'
import { DEFAULT_GP_PRICE_STRATEGY } from 'constants/index'

export type GpPriceStrategy = 'COWSWAP' | 'LEGACY'
// TODO: use actual API call
Expand All @@ -20,7 +19,7 @@ export default function useGetGpPriceStrategy(
useEffect(() => {
console.debug('[useGetGpPriceStrategy::GP Price Strategy]::', gpPriceStrategy)

const checkStatus = () => {
const getStrategy = () => {
checkGpPriceStrategy()
.then(setGpPriceStrategy)
.catch((err: Error) => {
Expand All @@ -31,11 +30,11 @@ export default function useGetGpPriceStrategy(
}

// Create initial call on mount
checkStatus()
getStrategy()

// set interval for GP_PRICE_STRATEGY_INTERVAL_TIME (30 min)
const intervalId = setInterval(() => {
checkStatus()
getStrategy()
}, GP_PRICE_STRATEGY_INTERVAL_TIME)

return () => clearInterval(intervalId)
Expand Down
6 changes: 3 additions & 3 deletions src/custom/utils/price.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export type SimpleGetQuoteResponse = Pick<GetQuoteResponse, 'from'> & {
validTo: string
feeAmount: string
}
expirationDate: string
expiration: string
}

export class PriceQuoteError extends Error {
Expand Down Expand Up @@ -258,7 +258,7 @@ export async function getBestPrice(params: PriceQuoteParams, options?: GetBestPr
*/
export async function getFullQuote({ quoteParams }: { quoteParams: FeeQuoteParams }): Promise<QuoteResult> {
const { kind } = quoteParams
const { quote, expirationDate } = await getQuote(quoteParams)
const { quote, expiration: expirationDate } = await getQuote(quoteParams)

const price = {
amount: kind === OrderKind.SELL ? quote.buyAmount : quote.sellAmount,
Expand Down Expand Up @@ -286,7 +286,7 @@ export async function getBestQuoteLegacy({
// Get a new fee quote (if required)
const feePromise =
fetchFee || !previousFee
? getQuote(quoteParams).then((resp) => ({ amount: resp.quote.feeAmount, expirationDate: resp.expirationDate }))
? getQuote(quoteParams).then((resp) => ({ amount: resp.quote.feeAmount, expirationDate: resp.expiration }))
: Promise.resolve(previousFee)

// Get a new price quote
Expand Down

0 comments on commit 25b0439

Please sign in to comment.