-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from DyadStablecoin/feature/liquidate
Feature/liquidate
- Loading branch information
Showing
2 changed files
with
98 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,74 @@ | ||
export default function Sync({}) { | ||
import { useAccount, useContractWrite, usePrepareContractWrite } from "wagmi"; | ||
import { CONTRACT_dNFT } from "../consts/contract"; | ||
import { round2 } from "../utils/currency"; | ||
import PoolABI from "../abi/Pool.json"; | ||
import { useState } from "react"; | ||
import TextInput from "./TextInput"; | ||
import { parseEther } from "../utils/currency"; | ||
import { useBalances } from "../hooks/useBalances"; | ||
import PopupContent from "./PopupContent"; | ||
import useEthPrice from "../hooks/useEthPrice"; | ||
|
||
export default function Liquidate({ tokenId, onClose, setTxHash }) { | ||
const { balances } = useBalances([]); | ||
const [wETH, setWETH] = useState(""); | ||
const { address } = useAccount(); | ||
|
||
const { config } = usePrepareContractWrite({ | ||
addressOrName: CONTRACT_dNFT, | ||
contractInterface: PoolABI["abi"], | ||
functionName: "claim", | ||
args: [tokenId, address], | ||
overrides: { | ||
value: parseEther(wETH), | ||
}, | ||
}); | ||
|
||
const { write } = useContractWrite({ | ||
...config, | ||
onSuccess: (data) => { | ||
onClose(); | ||
setTxHash(data?.hash); | ||
}, | ||
}); | ||
|
||
return ( | ||
<div> | ||
<div>ttt</div> | ||
</div> | ||
<PopupContent | ||
title="Claim dNFT" | ||
btnText="CLAIM" | ||
onClick={() => { | ||
onClose(); | ||
write?.(); | ||
}} | ||
isDisabled={!write} | ||
> | ||
<div className="flex flex-col gap-2 items-center"> | ||
<div className="flex gap-4 justify-between items-between w-full"> | ||
<TextInput | ||
value={wETH} | ||
onChange={(v) => { | ||
setWETH(v); | ||
}} | ||
placeholder={0} | ||
type="number" | ||
/> | ||
<div className="items-end flex flex-col"> | ||
<div className="flex items-center justify-center gap-1"> | ||
<div> | ||
<img | ||
className="w-4" | ||
src="https://icons.iconarchive.com/icons/cjdowner/cryptocurrency-flat/1024/Ethereum-ETH-icon.png" | ||
alt="" | ||
/> | ||
</div> | ||
<div>ETH</div> | ||
</div> | ||
<div className="text-[#737E76]"> | ||
Balance:{round2(balances.balanceOfEth)} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</PopupContent> | ||
); | ||
} |
43a5de3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
frontend – ./
frontend-dyad.vercel.app
frontend-git-main-dyad.vercel.app
frontend-woad-five.vercel.app