diff --git a/hardhat-tutorial/contracts/Exchange.sol b/hardhat-tutorial/contracts/Exchange.sol index f23840d..ecdf8ca 100644 --- a/hardhat-tutorial/contracts/Exchange.sol +++ b/hardhat-tutorial/contracts/Exchange.sol @@ -83,7 +83,7 @@ contract Exchange is ERC20 { uint256 cryptoDevTokenAmount = (getReserve() * _amount) / _totalSupply; // /从用户的钱包中烧掉LP token,因为它们已经被发送到删除流动性 _burn(msg.sender, _amount); - // 将'ethAmount'的eth从合同转移到用户的钱包 + // todo 将'ethAmount'的eth从合同转移到用户的钱包 这里为什么用payable payable(msg.sender).transfer(ethAmount); // 将“cryptoDevTokenAmount”数量的Crypto Dev token从合同转移到用户的钱包 ERC20(cryptoDevTokenAddress).transfer(msg.sender, cryptoDevTokenAmount); diff --git a/.eslintrc.json b/my-app/my-app/.eslintrc.json similarity index 100% rename from .eslintrc.json rename to my-app/my-app/.eslintrc.json diff --git a/.gitignore b/my-app/my-app/.gitignore similarity index 100% rename from .gitignore rename to my-app/my-app/.gitignore diff --git a/my-app/my-app/README.md b/my-app/my-app/README.md new file mode 100644 index 0000000..b96b748 --- /dev/null +++ b/my-app/my-app/README.md @@ -0,0 +1,15 @@ +### 建造一个类似于Uniswap的去中心化交易所😀 + +这个repo里包含了Uniswap的原理图,我整合了知乎上的一篇文章(链接在导图里面有)和LW3的教程,做了总结性的思维导图 :wink: + +总体而言,这个项目和之前的项目不同点在于 + +- 它封装了调用合约函数的方法,将这些方法放在utils文件夹里面 +- 结合了Uniswap的原理,多了一些基础的数学计算,这些我也制作了手绘图~ + +话不多说 上图:tanabata_tree: + + + + + diff --git a/address.txt b/my-app/my-app/address.txt similarity index 100% rename from address.txt rename to my-app/my-app/address.txt diff --git a/constants/index.js b/my-app/my-app/constants/index.js similarity index 100% rename from constants/index.js rename to my-app/my-app/constants/index.js diff --git a/next.config.js b/my-app/my-app/next.config.js similarity index 100% rename from next.config.js rename to my-app/my-app/next.config.js diff --git a/package-lock.json b/my-app/my-app/package-lock.json similarity index 100% rename from package-lock.json rename to my-app/my-app/package-lock.json diff --git a/package.json b/my-app/my-app/package.json similarity index 100% rename from package.json rename to my-app/my-app/package.json diff --git a/pages/_app.js b/my-app/my-app/pages/_app.js similarity index 100% rename from pages/_app.js rename to my-app/my-app/pages/_app.js diff --git a/pages/api/hello.js b/my-app/my-app/pages/api/hello.js similarity index 100% rename from pages/api/hello.js rename to my-app/my-app/pages/api/hello.js diff --git a/pages/index.js b/my-app/my-app/pages/index.js similarity index 100% rename from pages/index.js rename to my-app/my-app/pages/index.js diff --git a/public/cryptodev.svg b/my-app/my-app/public/cryptodev.svg similarity index 100% rename from public/cryptodev.svg rename to my-app/my-app/public/cryptodev.svg diff --git a/public/favicon.ico b/my-app/my-app/public/favicon.ico similarity index 100% rename from public/favicon.ico rename to my-app/my-app/public/favicon.ico diff --git a/public/vercel.svg b/my-app/my-app/public/vercel.svg similarity index 100% rename from public/vercel.svg rename to my-app/my-app/public/vercel.svg diff --git a/styles/Home.module.css b/my-app/my-app/styles/Home.module.css similarity index 100% rename from styles/Home.module.css rename to my-app/my-app/styles/Home.module.css diff --git a/styles/globals.css b/my-app/my-app/styles/globals.css similarity index 100% rename from styles/globals.css rename to my-app/my-app/styles/globals.css diff --git a/utils/addLiquidity.js b/my-app/my-app/utils/addLiquidity.js similarity index 100% rename from utils/addLiquidity.js rename to my-app/my-app/utils/addLiquidity.js diff --git a/utils/getAmounts.js b/my-app/my-app/utils/getAmounts.js similarity index 100% rename from utils/getAmounts.js rename to my-app/my-app/utils/getAmounts.js diff --git a/utils/removeLiquidity.js b/my-app/my-app/utils/removeLiquidity.js similarity index 96% rename from utils/removeLiquidity.js rename to my-app/my-app/utils/removeLiquidity.js index 6207b6e..d60f2bf 100644 --- a/utils/removeLiquidity.js +++ b/my-app/my-app/utils/removeLiquidity.js @@ -34,6 +34,7 @@ export const getTokensAfterRemove = async ( ); // 得到CD LP Token的总数 const _totalSupply = await exchangeContract.totalSupply(); + //用户remove LP Token后,返回给用户的Eth数量 // 这里我们使用的是乘法和除法的BigNumber方法 const _removeEther = _ethBalance.mul(removeLPTokensWei).div(_totalSupply); const _removeCD = cryptoDevTokenReserve @@ -43,7 +44,6 @@ export const getTokensAfterRemove = async ( _removeEther, _removeCD, }; - //用户remove LP Token后,返回给用户的Eth数量 } catch (err) { console.error(err); } diff --git a/utils/swap.js b/my-app/my-app/utils/swap.js similarity index 100% rename from utils/swap.js rename to my-app/my-app/utils/swap.js