Skip to content

Commit

Permalink
change refresh time for pricing
Browse files Browse the repository at this point in the history
  • Loading branch information
Asfiroth committed Dec 5, 2024
1 parent a80c04f commit 20fb935
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const BalancePayment = ({ onNext, transactionData }: IProps) => {
return BigInt(Math.ceil(neededFromBalance));
};

const handleContinue = () => {
const handleContinue = (): void => {
const processedAmount = getAmountToProcess(selectedBalance);
switch (selectedBalance.currency) {
case 'dimo':
Expand Down
8 changes: 7 additions & 1 deletion src/components/BuyCreditsModal/BuyCredits/CryptoExchange.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,13 @@ export const CryptoExchange = ({ onNext, transactionData }: IProps) => {
LoadingStatus.None,
);

const mintDCX = async () => {
const mintDCX = async (): Promise<
{
to: `0x${string}`;
value: bigint;
data: `0x${string}`;
}[]
> => {
const transactions = [];
const expendableDimo = transactionData!.requiredDimoAmount!;

Expand Down
8 changes: 5 additions & 3 deletions src/hooks/useGlobalAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,13 @@ export const useGlobalAccount = () => {
config.SwapRouterAddress,
]);

return BigInt(Math.ceil(Number(utils.fromWei(allowance as bigint, 'ether'))));
return BigInt(
Math.ceil(Number(utils.fromWei(allowance as bigint, 'ether'))),
);
} catch (e) {
console.error('Error getting wmatic allowance', e);
return BigInt(0);
};
}
};

const depositWmatic = async (
Expand Down Expand Up @@ -343,7 +345,7 @@ export const useGlobalAccount = () => {
}

// call exactInputSingle
const deadLine = Math.floor(Date.now() / 1000) + (60 * 10);
const deadLine = Math.floor(Date.now() / 1000) + 60 * 10;
transactions.push({
to: config.SwapRouterAddress,
value: BigInt(0),
Expand Down
8 changes: 4 additions & 4 deletions src/services/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,28 @@ const getCurrentWMaticPrice = async (): Promise<number> => {
return data.data.WMATIC[0].quote.USD.price;
};

const oneDay = 60 * 60 * 24;
const oneHour = 60 * 60 * 1;

export const getCachedDimoPrice = cache(
async () => {
return await getCurrentDimoPrice();
},
['dimo-price'],
{ revalidate: oneDay, tags: ['dimo-price'] },
{ revalidate: oneHour, tags: ['dimo-price'] },
);

export const getCachedPolPrice = cache(
async () => {
return await getCurrentPolPrice();
},
['pol-price'],
{ revalidate: oneDay, tags: ['pol-price'] },
{ revalidate: oneHour, tags: ['pol-price'] },
);

export const getCachedWmaticPrice = cache(
async () => {
return await getCurrentWMaticPrice();
},
['wmatic-price'],
{ revalidate: oneDay, tags: ['wmatic-price'] },
{ revalidate: oneHour, tags: ['wmatic-price'] },
);

0 comments on commit 20fb935

Please sign in to comment.