Skip to content

Commit dac9794

Browse files
committed
hotfix: Use Math.ceil for allowance values and display aprox. UsdcValue in Payment
1 parent 42a7fb0 commit dac9794

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/shared/UsdcValue.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
export const UsdcValue = ({ value }) => {
1+
export const UsdcValue = ({ value, isAproximate = false }) => {
22
return (
33
<div className="text-primary">
4-
<span className="text-slate-500">$USDC</span> {value}
4+
<span className="text-slate-500">{isAproximate ? '~' : ''}$USDC</span> {value}
55
</div>
66
);
77
};

src/shared/projects/Payment.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export default function Payment({
7777

7878
console.log('[Payment]', {
7979
jobsTotalCost,
80+
allowanceRequired: Math.ceil(jobsTotalCost * 10 ** 6),
8081
});
8182

8283
setTotalCost(jobsTotalCost);
@@ -280,7 +281,7 @@ export default function Payment({
280281
address: config.usdcContractAddress,
281282
abi: ERC20Abi,
282283
functionName: 'approve',
283-
args: [escrowContractAddress, BigInt(totalCost * 10 ** 6)],
284+
args: [escrowContractAddress, BigInt(Math.ceil(totalCost * 10 ** 6))],
284285
});
285286

286287
const receipt = await watchTx(txHash, publicClient);
@@ -312,7 +313,7 @@ export default function Payment({
312313
return result;
313314
};
314315

315-
const hasEnoughAllowance = (): boolean => allowance !== undefined && allowance >= BigInt(totalCost * 10 ** 6);
316+
const hasEnoughAllowance = (): boolean => allowance !== undefined && allowance >= BigInt(Math.ceil(totalCost * 10 ** 6));
316317

317318
/**
318319
* Approval is required only if the allowance is less than half of the maximum allowance,
@@ -380,7 +381,7 @@ export default function Payment({
380381

381382
<div className="row gap-1.5">
382383
<div className="text-[19px] font-semibold">
383-
<UsdcValue value={parseFloat(totalCost.toFixed(2)).toLocaleString()} />
384+
<UsdcValue value={parseFloat(totalCost.toFixed(2)).toLocaleString()} isAproximate />
384385
</div>
385386

386387
{environment !== 'mainnet' && (

0 commit comments

Comments
 (0)