From a9435e86eaea353c9c299898fc2f95b542184e6e Mon Sep 17 00:00:00 2001 From: ChefJoJo <94336009+chef-jojo@users.noreply.github.com> Date: Wed, 26 Oct 2022 18:13:16 +0800 Subject: [PATCH] docs: Update README and doc (#5090) doc: Update README and doc --- README.md | 42 ++++- ...a929ecfc8f299203dfff63b95ccb6bfe19850fa.ts | 164 ------------------ doc/Farms.md | 2 +- doc/Info.md | 16 +- doc/Pools.md | 4 +- doc/Tokens.md | 2 +- packages/aptos-swap-sdk/README.md | 3 + packages/swap-sdk/README.md | 2 +- 8 files changed, 54 insertions(+), 181 deletions(-) delete mode 100644 cli/aptos-codegen/0xc7efb4076dbe143cbcd98cfaaa929ecfc8f299203dfff63b95ccb6bfe19850fa.ts create mode 100644 packages/aptos-swap-sdk/README.md diff --git a/README.md b/README.md index 5ccf5440db873..9d42dd7a42c1c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,11 @@ # 🥞 Pancake Frontend +

+ + + +

+ This project contains the main features of the pancake application. If you want to contribute, please refer to the [contributing guidelines](./CONTRIBUTING.md) of this project. @@ -9,11 +15,13 @@ If you want to contribute, please refer to the [contributing guidelines](./CONTR - [Info](doc/Info.md) - [Cypress tests](doc/Cypress.md) +> Install dependencies using **yarn** -## Quick Start - -install dependencies using **yarn** - +## `apps/web` +
+ +How to start + ```sh yarn ``` @@ -30,3 +38,29 @@ yarn build # start the application after build yarn start ``` +
+ +## `apps/aptos` +
+ +How to start + +```sh +yarn dev:aptos +``` +```sh +yarn turbo run build --filter=aptos-web +``` +
+ + +## Packages + +| Package | Description | +|---------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------| +| [sdk](/packages/swap-sdk) | An SDK for building applications on top of Pancakeswap | +| [aptos-swap-sdk](/packages/aptos-swap-sdk) | Aptos version of Swap SDK | +| [swap-sdk-core](/packages/swap-sdk-core) | Swap SDK Shared code | +| [wagmi](/packages/wagmi) | Extension for [wagmi](https://github.com/wagmi-dev/wagmi), including bsc chain and binance wallet connector | +| [awgmi](/packages/awgmi) | connect to Aptos with similar wagmi React hooks. | + diff --git a/cli/aptos-codegen/0xc7efb4076dbe143cbcd98cfaaa929ecfc8f299203dfff63b95ccb6bfe19850fa.ts b/cli/aptos-codegen/0xc7efb4076dbe143cbcd98cfaaa929ecfc8f299203dfff63b95ccb6bfe19850fa.ts deleted file mode 100644 index 4965dc220cea2..0000000000000 --- a/cli/aptos-codegen/0xc7efb4076dbe143cbcd98cfaaa929ecfc8f299203dfff63b95ccb6bfe19850fa.ts +++ /dev/null @@ -1,164 +0,0 @@ -/* eslint-disable camelcase */ -import { Types } from 'aptos' - -export const ADDRESS = '0xc7efb4076dbe143cbcd98cfaaa929ecfc8f299203dfff63b95ccb6bfe19850fa' as const - -export const SWAP_MODULE_NAME = 'swap' as const -export const ROUTER_MODULE_NAME = 'router' as const - -export type SwapSetAdminArgs = [string] - -export const swapSetAdmin = (args: SwapSetAdminArgs): Types.TransactionPayload_EntryFunctionPayload => { - return { - type: 'entry_function_payload', - type_arguments: [], - arguments: args, - function: `${ADDRESS}::${SWAP_MODULE_NAME}::set_admin` - } -} - -export type SwapSetFeeToArgs = [string] - -export const swapSetFeeTo = (args: SwapSetFeeToArgs): Types.TransactionPayload_EntryFunctionPayload => { - return { - type: 'entry_function_payload', - type_arguments: [], - arguments: args, - function: `${ADDRESS}::${SWAP_MODULE_NAME}::set_fee_to` - } -} - -export type SwapUpgradeSwapArgs = [number[] | Uint8Array, number[] | Uint8Array] - -export const swapUpgradeSwap = (args: SwapUpgradeSwapArgs): Types.TransactionPayload_EntryFunctionPayload => { - return { - type: 'entry_function_payload', - type_arguments: [], - arguments: args, - function: `${ADDRESS}::${SWAP_MODULE_NAME}::upgrade_swap` - } -} - -export const swapWithdrawFee = (typeArgs: [string, string]): Types.TransactionPayload_EntryFunctionPayload => { - return { - type: 'entry_function_payload', - type_arguments: typeArgs, - arguments: [], - function: `${ADDRESS}::${SWAP_MODULE_NAME}::withdraw_fee` - } -} - -export type RouterAddLiquidityArgs = [bigint | string, bigint | string, bigint | string, bigint | string] - -export const routerAddLiquidity = (args: RouterAddLiquidityArgs, typeArgs: [string, string]): Types.TransactionPayload_EntryFunctionPayload => { - return { - type: 'entry_function_payload', - type_arguments: typeArgs, - arguments: args, - function: `${ADDRESS}::${ROUTER_MODULE_NAME}::add_liquidity` - } -} - -export const routerCreatePair = (typeArgs: [string, string]): Types.TransactionPayload_EntryFunctionPayload => { - return { - type: 'entry_function_payload', - type_arguments: typeArgs, - arguments: [], - function: `${ADDRESS}::${ROUTER_MODULE_NAME}::create_pair` - } -} - -export const routerRegisterLp = (typeArgs: [string, string]): Types.TransactionPayload_EntryFunctionPayload => { - return { - type: 'entry_function_payload', - type_arguments: typeArgs, - arguments: [], - function: `${ADDRESS}::${ROUTER_MODULE_NAME}::register_lp` - } -} - -export const routerRegisterToken = (typeArgs: [string]): Types.TransactionPayload_EntryFunctionPayload => { - return { - type: 'entry_function_payload', - type_arguments: typeArgs, - arguments: [], - function: `${ADDRESS}::${ROUTER_MODULE_NAME}::register_token` - } -} - -export type RouterRemoveLiquidityArgs = [bigint | string, bigint | string, bigint | string] - -export const routerRemoveLiquidity = (args: RouterRemoveLiquidityArgs, typeArgs: [string, string]): Types.TransactionPayload_EntryFunctionPayload => { - return { - type: 'entry_function_payload', - type_arguments: typeArgs, - arguments: args, - function: `${ADDRESS}::${ROUTER_MODULE_NAME}::remove_liquidity` - } -} - -export type RouterSwapExactInputArgs = [bigint | string, bigint | string] - -export const routerSwapExactInput = (args: RouterSwapExactInputArgs, typeArgs: [string, string]): Types.TransactionPayload_EntryFunctionPayload => { - return { - type: 'entry_function_payload', - type_arguments: typeArgs, - arguments: args, - function: `${ADDRESS}::${ROUTER_MODULE_NAME}::swap_exact_input` - } -} - -export type RouterSwapExactInputDoublehopArgs = [bigint | string, bigint | string] - -export const routerSwapExactInputDoublehop = (args: RouterSwapExactInputDoublehopArgs, typeArgs: [string, string, string]): Types.TransactionPayload_EntryFunctionPayload => { - return { - type: 'entry_function_payload', - type_arguments: typeArgs, - arguments: args, - function: `${ADDRESS}::${ROUTER_MODULE_NAME}::swap_exact_input_doublehop` - } -} - -export type RouterSwapExactInputTriplehopArgs = [bigint | string, bigint | string] - -export const routerSwapExactInputTriplehop = (args: RouterSwapExactInputTriplehopArgs, typeArgs: [string, string, string, string]): Types.TransactionPayload_EntryFunctionPayload => { - return { - type: 'entry_function_payload', - type_arguments: typeArgs, - arguments: args, - function: `${ADDRESS}::${ROUTER_MODULE_NAME}::swap_exact_input_triplehop` - } -} - -export type RouterSwapExactOutputArgs = [bigint | string, bigint | string] - -export const routerSwapExactOutput = (args: RouterSwapExactOutputArgs, typeArgs: [string, string]): Types.TransactionPayload_EntryFunctionPayload => { - return { - type: 'entry_function_payload', - type_arguments: typeArgs, - arguments: args, - function: `${ADDRESS}::${ROUTER_MODULE_NAME}::swap_exact_output` - } -} - -export type RouterSwapExactOutputDoublehopArgs = [bigint | string, bigint | string] - -export const routerSwapExactOutputDoublehop = (args: RouterSwapExactOutputDoublehopArgs, typeArgs: [string, string, string]): Types.TransactionPayload_EntryFunctionPayload => { - return { - type: 'entry_function_payload', - type_arguments: typeArgs, - arguments: args, - function: `${ADDRESS}::${ROUTER_MODULE_NAME}::swap_exact_output_doublehop` - } -} - -export type RouterSwapExactOutputTriplehopArgs = [bigint | string, bigint | string] - -export const routerSwapExactOutputTriplehop = (args: RouterSwapExactOutputTriplehopArgs, typeArgs: [string, string, string, string]): Types.TransactionPayload_EntryFunctionPayload => { - return { - type: 'entry_function_payload', - type_arguments: typeArgs, - arguments: args, - function: `${ADDRESS}::${ROUTER_MODULE_NAME}::swap_exact_output_triplehop` - } -} diff --git a/doc/Farms.md b/doc/Farms.md index fbaf2625769b7..2cf29446916e0 100644 --- a/doc/Farms.md +++ b/doc/Farms.md @@ -2,7 +2,7 @@ ## How to add a new farm -- Add an entry in `/config/constants/farms.ts`, below the farm with the pid 0 +- Add an entry in `packages/farms/constants/[chainId].ts`, below the farm with the pid 0 - Insert informations, with the LP address and the correct tokens (See [Tokens](./Tokens.md)) - Run `yarn test:config` to make sure the data you set in the config match the data on chain diff --git a/doc/Info.md b/doc/Info.md index 82e342e62575c..185c4aea75079 100644 --- a/doc/Info.md +++ b/doc/Info.md @@ -4,21 +4,21 @@ A brief overview how Info part of PancakeSwap website works. ## Code structure -In terms of React components Info section is just another view (located in [src/views/Info](../src/views/Info)) that is assigned route (in [App.tsx](../src/App.tsx)). -There are also some Info-related components inside [src/components](../src/components) (InfoNav, InfoCharts, InfoTables and InfoSearch at the time of writing). +In terms of React components Info section is just another view (located in [apps/web/src/views/Info](../apps/web/src/views/Info)) that is assigned route (in [pages](../apps/web/src/pages)). +There are also some Info-related components inside [apps/web/src/components](../apps/web/src/components) (InfoNav, InfoCharts, InfoTables and InfoSearch at the time of writing). -There are helper functions to handle data formatting and requests - [src/utils/infoDataHelpers.ts](../src/utils/infoDataHelpers.ts) and [src/utils/infoQueryHelpers.ts](../src/utils/infoQueryHelpers.ts) +There are helper functions to handle data formatting and requests - [apps/web/src/views/Info/utils/infoDataHelpers.ts](../apps/web/src/views/Info/utils/infoDataHelpers.ts) and [apps/web/src/views/Info/utils/infoQueryHelpers.ts](../apps/web/src/views/Info/utils/infoQueryHelpers.ts) -Info section has it's own reducer in Redux store - [src/state/info](../src/state/info). It handles all data about pools, tokens and overall protocol. The only exception is token/pool watchlist that is stored under [src/state/user](../src/state/user) reducer. +Info section has it's own reducer in Redux store - [apps/web/src/state/info](../apps/web/src/state/info). It handles all data about pools, tokens and overall protocol. The only exception is token/pool watchlist that is stored under [src/state/user](../apps/web/src/state/user) reducer. -GraphQL request logic lives under [src/state/info/queries](../src/state/info/queries) directory. Code over there handles firing requests to StreamingFast subgraph as well as formatting returned values and calculating all the derived data we need. +GraphQL request logic lives under [apps/web/src/state/info/queries](../apps/web/src/state/info/queries) directory. Code over there handles firing requests to StreamingFast subgraph as well as formatting returned values and calculating all the derived data we need. ## Requests flow When user visits Info page the following requests are fired (names as declared in [src/state/info/queries](../src/state/info/queries)): -`overview` - gets basic protocol data like volume, liquidity and transaction count. 3 requests are fired for current, 24h ago and 48h ago data. -`overviewCharts` - gets data to show liquidity and volume charts on overview page. +`overview` - gets basic protocol data like volume, liquidity and transaction count. 3 requests are fired for current, 24h ago and 48h ago data. +`overviewCharts` - gets data to show liquidity and volume charts on overview page. `overviewTransactions` - gets data to show transaction table on overview page `prices` - gets BNB prices (current, 24h, 48 and 7d ago) used in calculations (see [src/hooks/useBnbPrices.ts](../src/hooks/useBnbPrices.ts)) @@ -31,6 +31,6 @@ When user visits Info page the following requests are fired (names as declared i There are also multiple `blocks` queries to retrieve block numbers at different timestamps. -The flow is controlled by [src/state/info/updaters.ts](../src/state/info/updaters.ts). When user navigates through the site more pools and tokens are automatically loaded, (e.g. you click on BNB token and pools for BNB are loaded automatically, if you click on BNB-BTCB then BTCB token will be loaded, etc) +The flow is controlled by [apps/web/src/state/info/updaters.ts](../apps/web/src/state/info/updaters.ts). When user navigates through the site more pools and tokens are automatically loaded, (e.g. you click on BNB token and pools for BNB are loaded automatically, if you click on BNB-BTCB then BTCB token will be loaded, etc) There are additional requests for price chart and search that are fired when user uses these features. diff --git a/doc/Pools.md b/doc/Pools.md index a4b65968096b9..2faeb8e15841e 100644 --- a/doc/Pools.md +++ b/doc/Pools.md @@ -2,7 +2,7 @@ ## How to add a new pool -- Add an entry in `/config/constants/pools.ts`, below the pool with the id 0 +- Add an entry in `apps/web/src/config/constants/pools.tsx`, below the pool with the id 0 - Insert informations, with the contract address and the correct tokens (See [Tokens](./Tokens.md)) - Run `yarn test:config` to make sure the data you set in the config match the data on chain @@ -10,4 +10,4 @@ Pools APRs depend on farm data to compute prices ## Pools data -Data are stored in the global redux state (`/state/pools`). +Data are stored in the global redux state (`apps/web/src/state/pools`). diff --git a/doc/Tokens.md b/doc/Tokens.md index fdce6e3ba6c38..31399b0905e88 100644 --- a/doc/Tokens.md +++ b/doc/Tokens.md @@ -1,6 +1,6 @@ # Tokens management -All the tokens are in `/config/constans/tokens.ts`. They are instances of the `Token` class defined in the SDK. +All the tokens are in `/packages/tokens/src/[chainId].ts`. They are instances of the `Token` class defined in the SDK. Before adding a new **farm** or **pool** you need to make sure the Tokens are in this file. To add a Token to the exchange lists: diff --git a/packages/aptos-swap-sdk/README.md b/packages/aptos-swap-sdk/README.md new file mode 100644 index 0000000000000..f95b57dfb5e32 --- /dev/null +++ b/packages/aptos-swap-sdk/README.md @@ -0,0 +1,3 @@ +# PancakeSwap Aptos Swap SDK + +You can refer to the Uniswap SDK documentation [uniswap.org](https://docs.uniswap.org/sdk/2.0.0/). diff --git a/packages/swap-sdk/README.md b/packages/swap-sdk/README.md index 9f863fbd5c15b..8237044e95fb5 100644 --- a/packages/swap-sdk/README.md +++ b/packages/swap-sdk/README.md @@ -1,4 +1,4 @@ -# Pancakeswap SDK +# PancakeSwap SDK Forked from the [Uniswap SDK](https://github.com/Uniswap/uniswap-v2-sdk/commit/a88048e9c4198a5bdaea00883ca00c8c8e582605).