Skip to content

Commit

Permalink
Merge branch 'dev' into feat/newWagmiViem
Browse files Browse the repository at this point in the history
  • Loading branch information
brucedonovan committed Sep 26, 2023
2 parents dfc2392 + 79bbe17 commit 26921c6
Show file tree
Hide file tree
Showing 8 changed files with 192 additions and 125 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chatweb3-frontend",
"version": "0.1.4",
"version": "0.2.1",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down
Binary file modified src/components/current/CactiImages/Cacti_alt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
82 changes: 43 additions & 39 deletions src/components/current/CactiImages/Cactus1.tsx

Large diffs are not rendered by default.

81 changes: 43 additions & 38 deletions src/components/current/CactiImages/Cactus2.tsx

Large diffs are not rendered by default.

120 changes: 81 additions & 39 deletions src/components/current/CactiImages/Cactus3.tsx

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/components/current/MessageTranslator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ export const Widget = (props: WidgetProps) => {
tokenInSymbol={parsedArgs[0]}
tokenOutSymbol={parsedArgs[1]}
inputAmount={parsedArgs[3]}
transactionKeyword={parsedArgs[2]} // BUYAMOUNT or SELLAMOUNT
slippage={parsedArgs[4]}
/>
);

Expand Down
18 changes: 14 additions & 4 deletions src/components/current/WelcomeMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,17 @@ const WelcomeMessage = () => {
return (
<div className="h-full place-items-center ">
<div className="mx-auto w-full max-w-4xl space-y-20">
<Image src={cactiImage} alt="CactiChat" className="mx-auto" width={400} height={300} />
<div className="flex w-full justify-center">
<div className="w-[50%]">
<Image src={cactiImage} alt="CactiChat" className="mx-auto" />
</div>
</div>

<div className="grid grid-cols-1 gap-20 p-4 sm:grid-cols-3">
<WelcomeColumn>
<Cactus1 className="h-16" />
<div className="w-[20%] sm:w-[40%] ">
<Cactus1 className="h-16" />
</div>
<WelcomeBoxSubtitle> Explore NFTs </WelcomeBoxSubtitle>
<WelcomeBox onClick={() => sendMessage('Browse some cheetah nft collections')}>
Browse some [cheetah] NFT collections
Expand All @@ -53,7 +59,9 @@ const WelcomeMessage = () => {
</WelcomeColumn>

<WelcomeColumn>
<Cactus2 className="h-16" />
<div className="w-[20%] sm:w-[40%] ">
<Cactus2 className="h-16" />
</div>
<WelcomeBoxSubtitle>Interact with protocols</WelcomeBoxSubtitle>
<WelcomeBox onClick={() => sendMessage('Swap 0.1 ETH for DAI on Uniswap')}>
Swap 0.1 ETH for DAI on Uniswap
Expand All @@ -69,7 +77,9 @@ const WelcomeMessage = () => {
</WelcomeColumn>

<WelcomeColumn>
<Cactus3 className="h-16" />
<div className="w-[20%] sm:w-[40%] ">
<Cactus3 className="h-16" />
</div>
{/* <ExclamationTriangleIcon className="mt-3 h-12 text-gray-300" /> */}
<WelcomeBoxSubtitle>Query the Network</WelcomeBoxSubtitle>
<WelcomeBox onClick={() => sendMessage('What is the price of ETH in terms of USD')}>
Expand Down
12 changes: 8 additions & 4 deletions src/components/current/widgets/uniswap/Uniswap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,25 @@ interface UniswapProps {
tokenInSymbol: string;
tokenOutSymbol: string;
inputAmount: string;
slippage: string;
transactionKeyword: 'BUYAMOUNT' | 'SELLAMOUNT';
}

const Uniswap = ({ tokenInSymbol, tokenOutSymbol, inputAmount }: UniswapProps) => {
const Uniswap = ({ tokenInSymbol, tokenOutSymbol, inputAmount, slippage, transactionKeyword }: UniswapProps) => {
const chainId = useChainId();
const publicClient = usePublicClient();
const isBuying = transactionKeyword === 'BUYAMOUNT';

const { address: recipient } = useAccount();
const { data: tokenIn, isETH: tokenInIsETH } = useToken(tokenInSymbol);
const { isETH: tokenOutIsETH } = useToken(tokenOutSymbol);
const { data: tokenInChecked } = useToken(tokenInIsETH ? 'WETH' : tokenInSymbol);
const { data: tokenOutChecked } = useToken(tokenOutIsETH ? 'WETH' : tokenOutSymbol);
const input = useInput(inputAmount, tokenInChecked?.symbol!);
const slippage = 2.0; // in percentage terms

const slippage_ = +slippage || 0.5; // in percentage terms
const getSlippageAdjustedAmount = (amount: bigint) =>
(amount * BigInt(10000 - slippage * 100)) / BigInt(10000);
(amount * BigInt(10000 - slippage_ * 100)) / BigInt(10000);

// token out quote for amount in
const { data: quote } = useUniswapQuote({
Expand Down Expand Up @@ -226,7 +230,7 @@ const Uniswap = ({ tokenInSymbol, tokenOutSymbol, inputAmount }: UniswapProps) =
<ListResponse
title="Breakdown"
data={[
['Slippage', `${slippage}%`],
['Slippage', `${slippage_}%`],
['Minimum swap', cleanValue(amountOutMinimum_, 2)],
['Route', `${tokenInSymbol}-${tokenOutSymbol}`],
]}
Expand Down

0 comments on commit 26921c6

Please sign in to comment.