Miniswap
is a amm dapp that allows tokens to be exchanged like Uniswap
.
App link (vercel): https://avax-amm.vercel.app/
Tutorial document: https://github.com/unchain-dev/UNCHAIN-projects/tree/main/docs/AVAX-AMM/ja
Add the following network before:
Network Name: Avalanche FUJI C-Chain
New RPC URL: https://api.avax-test.network/ext/bc/C/rpc
ChainID: 43113
Symbol: AVAX
Explorer: https://testnet.snowtrace.io/
Get the two tokens (fake USDC and fake JOE) from faucet.
First, sign transaction that approve amm contract to move token.
↓
Sign transaction to call swap.
First, sign two transactions that approve amm contract to move tokens.
↓
Sign transaction to call provide.
Withdraw tokens equivalent to the share.
git clone [this_repository]
cd [this_repository]
yarn install
yarn client dev
After executing the above command, access localhost:3000
in your browser.
contract
- Solidity
test & deploy
- hardhat
- typescript
Root: package/contract
AMM.sol
Implementing AMM contract code.ERC20Tokens.sol
Implementing ERC20 contracts To simulate the AMM
-
function:
provide
Provide liquidity with the address and quantity of the token as arguments.
The contract records share (likeLP token
) for the user who calls this function. -
function:
withdraw
Withdraw tokens deposited with share as an argument. -
function:
swap
Swap tokens.
Using the formula:k = x * y
for calculation, and there is a 0.3% fee for swapping.
- typescript
- React.js
- Next.js
Root: package/client
components
,hooks
,pages
,styles
,public
Contains client side codeutils
Contains the contracts ABI and utility functions.