Skip to content

Commit

Permalink
fix: cannot serialize bigint
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveVodrazka committed Sep 17, 2024
1 parent bf32f1f commit 7f55b2a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
17 changes: 13 additions & 4 deletions src/components/ImpermanentLoss/ImpermanentLossWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { longInteger, shortInteger } from "../../utils/computations";
import { TransactionState } from "../../types/network";
import { useAccount } from "../../hooks/useAccount";
import { useCurrency } from "../../hooks/useCurrency";
import { openWalletConnectDialog } from "../ConnectWallet/Button";

import styles from "./imp_loss.module.css";

Expand Down Expand Up @@ -279,25 +280,33 @@ export const ImpermanentLossWidget = () => {
</div>
</div>
<div className="topmargin">
{txStatus === TransactionState.Initial && (
{account === undefined && (
<button
className="primary active mainbutton"
onClick={openWalletConnectDialog}
>
Connect Wallet
</button>
)}
{account && txStatus === TransactionState.Initial && (
<button
className="primary active mainbutton"
onClick={handleBuy}
>
Protect
</button>
)}
{txStatus === TransactionState.Success && (
{account && txStatus === TransactionState.Success && (
<button className="green active mainbutton" onClick={handleBuy}>
Success
</button>
)}
{txStatus === TransactionState.Fail && (
{account && txStatus === TransactionState.Fail && (
<button className="red active mainbutton" onClick={handleBuy}>
Fail
</button>
)}
{txStatus === TransactionState.Processing && (
{account && txStatus === TransactionState.Processing && (
<button className="primary active mainbutton" disabled>
<LoadingAnimation size={20} />
</button>
Expand Down
6 changes: 3 additions & 3 deletions src/components/ImpermanentLoss/getPrice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,15 @@ export const buyImpLoss = async (
}

const getSizeWithSlippage = (size: bigint, slippage: bigint) => {
return (size * (200n + slippage)) / 100n;
return (size * (100n + slippage)) / 100n;
};

const approveBase: Call = {
contractAddress: tokenPair.baseToken.address,
entrypoint: "approve",
calldata: [
IMP_LOSS_ADDRESS,
getSizeWithSlippage(price.basePrice, 25n),
getSizeWithSlippage(price.basePrice, 10n).toString(10),
"0",
],
};
Expand All @@ -119,7 +119,7 @@ export const buyImpLoss = async (
entrypoint: "approve",
calldata: [
IMP_LOSS_ADDRESS,
getSizeWithSlippage(price.quotePrice, 25n),
getSizeWithSlippage(price.quotePrice, 10n).toString(10),
"0",
],
};
Expand Down

0 comments on commit 7f55b2a

Please sign in to comment.