Skip to content

Commit

Permalink
feat: Position Managers (#7113)
Browse files Browse the repository at this point in the history
<!--
Before opening a pull request, please read the [contributing
guidelines](https://github.com/pancakeswap/pancake-frontend/blob/develop/CONTRIBUTING.md)
first
-->

<!--
copilot:all
-->
### <samp>🤖 Generated by Copilot at 195239b</samp>

### Summary
🚀📦🛠️

<!--
1. 🚀 - This emoji represents the addition of a new feature or
functionality, such as the position managers feature in the web app.
2. 📦 - This emoji represents the creation or modification of a package
or workspace, such as the `@pancakeswap/position-managers` package in
the monorepo.
3. 🛠️ - This emoji represents the fixing of a bug or error, such as the
syntax error in the `next.config.mjs` file.
-->
This pull request adds a new feature to the web app that allows users to
manage their liquidity positions across different chains. It introduces
a new `@pancakeswap/position-managers` package that contains the logic
and types for the feature, and a new page and view component in the web
app that display the feature. It also updates the dependencies and
configuration files for the web app and the position managers package.

> _`position-managers`_
> _New feature for web app users_
> _Autumn of liquidity_

### Walkthrough
* Add the `@pancakeswap/position-managers` package as a new workspace in
the monorepo and declare its metadata, dependencies, constants, types,
and exports
([link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-93d327b5200a18ff6a4a34a9ccbe4ff89f8937b260e131e964486e2e49e06d66R1),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-1ed2b1245149f57164abbf7db733ca5d2836dabbcb4b2d5decc2e1c6f1b0c9d5R1-R31),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-14c6ec0f991698b50606b47d892d8a319f7880fa5e1ac89e986a0a62c1cc901aR1),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-e349e2e4d8f12a0b7cf06dddf1cf8a7d1ef03071789521e8fe58cb8c5ef1b61eR1-R5),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-158cb35322573e79423b8ca53dbf6c731d80a20b3a2d525f50ac0b56604830e5R1),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-85043a95f7c7606aebdc80534f55556896d547da5aab96b14c3be75f442d7d98R1-R12),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-a9cb7c9b5e8959aea1c4c2cdb5b5c3e6d53f118594e2ec3812210db9f6d6e0baR1-R9))
* Add the `@pancakeswap/position-managers` package as a dependency of
the web app and configure the `next.config.mjs` file to enable the
position managers feature
([link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-197cd8ca285a4abd2f21479e0bf6e36e90b08528fcd7f3bdbe8d1221897e377dR59),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-197cd8ca285a4abd2f21479e0bf6e36e90b08528fcd7f3bdbe8d1221897e377dL188-R189),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-14b60f636e1a2b0061da57aaf231cb1ed15a5dc0c592425ed82e58fec95d42d8R42))
* Create a new page and a new view component for the position managers
feature in the web app and export them from their source directories
([link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-aa62fe482d9d1378569330e920bc4fae0cb19590945938bb0596e7ea0f49d6a1R1-R9),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-5cc22ea8dc37e7cf4b13720d5da0421ab17ae24e38c11f6d6507b957eaee56a6R1-R3))
* Increase the concurrency limit for the `dev` script in the root
`package.json` file to accommodate the new position managers package
([link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519L14-R14))
* Update the `pnpm-lock.yaml` file with the new dependency information
for the position managers package, the react-countup package, and other
updated packages, and remove unnecessary dependencies from some packages
([link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbR580-R582),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL711-R714),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbR1191-R1233),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL1207-R1253),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL1972-R2021),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbR2027),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL1994-R2044),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbR2086),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL2125-R2173),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL2141-R2189),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL2196-R2244),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL2250-R2298),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL2293-R2341),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL2304-R2352),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbR4246-R4262),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL5333-R5398),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL5775-R5840),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL6497-R6562),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL7526-R7610),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL7751-R7835),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL8713-R8797),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL10237-R10321),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL10265-R10349),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL10303-R10387),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL10323-R10407),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL10358-R10442),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL10378-R10462),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL10407-R10491),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL10428-R10512),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL10782-R10868),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL10802-R10888),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL12183-R12267),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL12191-R12275),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbR14810),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL14738),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL14927-R15011),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL15583-R15667),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL16108-R16192),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL16180-R16264),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL17071-R17155),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL17552-R17636),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL17562-R17646),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL17589-R17673),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL17599-R17683),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL18223-R18307),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL19030-R19114),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL19061-R19145),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL20352-R20436),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL21322-R21406),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL21892-R21976),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL21971-R22055),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL22162-R22261),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL23505-R23604),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL24100-R24199),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL24189),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL24389-R24511),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL24750-R24872),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL24960-R25082),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL25431-R25553),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL25454-R25576),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL25476-R25598),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL25498-R25620),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL25521-R25643),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL25541-R25663),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL25676-R25798),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL25740-R25862),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbR26069-R26107),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7113/files?diff=unified&w=0#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbR26146))

---------

Co-authored-by: chefmomota <[email protected]>
Co-authored-by: Chef Yogi <[email protected]>
  • Loading branch information
3 people authored Oct 30, 2023
1 parent cddf570 commit 05f9db6
Show file tree
Hide file tree
Showing 89 changed files with 4,883 additions and 63 deletions.
29 changes: 15 additions & 14 deletions apps/web/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ const withVanillaExtract = createVanillaExtractPlugin()
const sentryWebpackPluginOptions =
process.env.VERCEL_ENV === 'production'
? {
// Additional config options for the Sentry Webpack plugin. Keep in mind that
// the following options are set automatically, and overriding them is not
// recommended:
// release, url, org, project, authToken, configFile, stripPrefix,
// urlPrefix, include, ignore
silent: false, // Logging when deploying to check if there is any problem
validate: true,
hideSourceMaps: false,
// https://github.com/getsentry/sentry-webpack-plugin#options.
}
// Additional config options for the Sentry Webpack plugin. Keep in mind that
// the following options are set automatically, and overriding them is not
// recommended:
// release, url, org, project, authToken, configFile, stripPrefix,
// urlPrefix, include, ignore
silent: false, // Logging when deploying to check if there is any problem
validate: true,
hideSourceMaps: false,
// https://github.com/getsentry/sentry-webpack-plugin#options.
}
: {
hideSourceMaps: false,
silent: true, // Suppresses all logs
dryRun: !process.env.SENTRY_AUTH_TOKEN,
}
hideSourceMaps: false,
silent: true, // Suppresses all logs
dryRun: !process.env.SENTRY_AUTH_TOKEN,
}

const workerDeps = Object.keys(smartRouterPkgs.dependencies)
.map((d) => d.replace('@pancakeswap/', 'packages/'))
Expand All @@ -56,6 +56,7 @@ const config = {
},
transpilePackages: [
'@pancakeswap/farms',
'@pancakeswap/position-managers',
'@pancakeswap/localization',
'@pancakeswap/hooks',
'@pancakeswap/utils',
Expand Down
1 change: 1 addition & 0 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"@pancakeswap/localization": "workspace:*",
"@pancakeswap/multicall": "workspace:*",
"@pancakeswap/pools": "workspace:*",
"@pancakeswap/position-managers": "workspace:*",
"@pancakeswap/sdk": "workspace:*",
"@pancakeswap/smart-router": "workspace:*",
"@pancakeswap/swap-sdk-core": "workspace:*",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
62 changes: 62 additions & 0 deletions apps/web/src/components/CurrencyInput/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { useMemo, useCallback, ReactNode, MouseEvent } from 'react'
import { Currency, CurrencyAmount } from '@pancakeswap/sdk'
import { CurrencyLogo } from '@pancakeswap/widgets-internal'
import { BalanceInput, Text, Flex, Button } from '@pancakeswap/uikit'

interface Props {
value: string | number
onChange: (val: string) => void
currency?: Currency
balance?: CurrencyAmount<Currency>
balanceText?: ReactNode
maxText?: ReactNode
}

export function CurrencyInput({ currency, balance, value, onChange, balanceText, maxText = 'Max', ...rest }: Props) {
const isMax = useMemo(() => balance && value && balance.toExact() === value, [balance, value])
const onMaxClick = useCallback(
(e: MouseEvent) => {
e.stopPropagation()
e.preventDefault()
onChange?.(balance?.toExact() || '')
},
[onChange, balance],
)

const currencyDisplay = currency ? (
<Flex justifyContent="flex-end">
<CurrencyLogo currency={currency} />
<Text bold ml="4px">
{currency.symbol}
</Text>
</Flex>
) : null

const balanceDisplay = balance ? (
<Flex justifyContent="flex-end" alignItems="center">
<Text color="textSubtle" fontSize={1}>
{balanceText}
</Text>
<Button
onClick={onMaxClick}
scale="xs"
ml="4px"
variant={isMax ? 'primary' : 'secondary'}
style={{ textTransform: 'uppercase' }}
>
{maxText}
</Button>
</Flex>
) : null

return (
<BalanceInput
{...rest}
inputProps={{ style: { textAlign: 'left' } }}
value={value}
onUserInput={onChange}
unit={currencyDisplay}
currencyValue={balanceDisplay}
/>
)
}
7 changes: 7 additions & 0 deletions apps/web/src/components/Menu/config/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ContextApi } from '@pancakeswap/localization'
import { SUPPORTED_CHAIN_IDS as POOL_SUPPORTED_CHAINS } from '@pancakeswap/pools'
import { SUPPORTED_CHAIN_IDS as POSITION_MANAGERS_SUPPORTED_CHAINS } from '@pancakeswap/position-managers'
import {
NftIcon,
NftFillIcon,
Expand Down Expand Up @@ -114,6 +115,12 @@ const config: (
href: '/pools',
supportChainIds: POOL_SUPPORTED_CHAINS,
},
{
label: t('Position Manager'),
href: '/position-managers',
supportChainIds: POSITION_MANAGERS_SUPPORTED_CHAINS,
status: { text: t('New'), color: 'success' },
},
{
label: t('Liquid Staking'),
href: '/liquid-staking',
Expand Down
22 changes: 21 additions & 1 deletion apps/web/src/hooks/useContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
getBCakeFarmBoosterContract,
getBCakeFarmBoosterProxyFactoryContract,
getBCakeFarmBoosterV3Contract,
getPositionManagerWrapperContract,
getPositionManagerAdapterContract,
getBCakeProxyContract,
getBunnyFactoryContract,
getCakeFlexibleSideVaultV2Contract,
Expand Down Expand Up @@ -313,6 +315,24 @@ export function useBCakeFarmBoosterV3Contract() {
return useMemo(() => getBCakeFarmBoosterV3Contract(signer ?? undefined, chainId), [signer, chainId])
}

export function usePositionManagerWrapperContract(address: Address) {
const { chainId } = useActiveChainId()
const { data: signer } = useWalletClient()
return useMemo(
() => getPositionManagerWrapperContract(address, signer ?? undefined, chainId),
[signer, chainId, address],
)
}

export function usePositionManagerAdepterContract(address: Address) {
const { chainId } = useActiveChainId()
const { data: signer } = useWalletClient()
return useMemo(
() => getPositionManagerAdapterContract(address, signer ?? undefined, chainId),
[signer, chainId, address],
)
}

export function useBCakeFarmBoosterProxyFactoryContract() {
const { data: signer } = useWalletClient()
return useMemo(() => getBCakeFarmBoosterProxyFactoryContract(signer ?? undefined), [signer])
Expand Down Expand Up @@ -433,5 +453,5 @@ export const useFixedStakingContract = () => {

const { data: signer } = useWalletClient()

return useMemo(() => getFixedStakingContract(signer, chainId), [chainId, signer])
return useMemo(() => getFixedStakingContract(signer ?? undefined, chainId), [chainId, signer])
}
80 changes: 80 additions & 0 deletions apps/web/src/hooks/usePositionPrices.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { Currency } from '@pancakeswap/sdk'
import { tickToPrice } from '@pancakeswap/v3-sdk'
import { useCallback, useMemo, useState } from 'react'

interface PositionInfo {
currencyA?: Currency
currencyB?: Currency
tickLower?: number
tickUpper?: number
tickCurrent?: number
}

export function usePositionPrices({
currencyA: initialBaseCurrency,
currencyB: initialQuoteCurrency,
tickLower,
tickUpper,
tickCurrent,
}: PositionInfo) {
const [invert, setInvert] = useState(false)
const toggleInvert = useCallback(() => setInvert(!invert), [invert])
const currencyA = useMemo(
() => (invert ? initialQuoteCurrency : initialBaseCurrency),
[invert, initialBaseCurrency, initialQuoteCurrency],
)
const currencyB = useMemo(
() => (invert ? initialBaseCurrency : initialQuoteCurrency),
[invert, initialBaseCurrency, initialQuoteCurrency],
)

const sorted = useMemo(
() =>
Boolean(
currencyA?.wrapped &&
currencyB?.wrapped &&
!currencyA.wrapped.equals(currencyB.wrapped) &&
currencyA.wrapped.sortsBefore(currencyB.wrapped),
),
[currencyA, currencyB],
)

const tickLowerPrice = useMemo(
() =>
currencyA?.wrapped &&
currencyB?.wrapped &&
typeof tickLower === 'number' &&
tickToPrice(currencyA.wrapped, currencyB.wrapped, tickLower),
[tickLower, currencyA, currencyB],
)
const tickUpperPrice = useMemo(
() =>
currencyA?.wrapped &&
currencyB?.wrapped &&
typeof tickUpper === 'number' &&
tickToPrice(currencyA.wrapped, currencyB.wrapped, tickUpper),
[tickUpper, currencyA, currencyB],
)
const [priceLower, priceUpper] = useMemo(
() => (sorted ? [tickLowerPrice, tickUpperPrice] : [tickUpperPrice, tickLowerPrice]),
[sorted, tickLowerPrice, tickUpperPrice],
)
const priceCurrent = useMemo(
() =>
currencyA?.wrapped &&
currencyB?.wrapped &&
typeof tickCurrent === 'number' &&
tickToPrice(currencyA.wrapped, currencyB.wrapped, tickCurrent),
[tickCurrent, currencyA, currencyB],
)

return {
currencyA,
currencyB,
priceLower,
priceUpper,
priceCurrent,
invert: toggleInvert,
inverted: invert,
}
}
32 changes: 32 additions & 0 deletions apps/web/src/pages/position-managers/[[...slug]].tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { SUPPORTED_CHAIN_IDS } from '@pancakeswap/position-managers'
import type { GetStaticPaths, GetStaticProps } from 'next'

import { PositionManagers } from 'views/PositionManagers'

const Page = () => <PositionManagers />

Page.chains = SUPPORTED_CHAIN_IDS

export const getStaticProps: GetStaticProps = async () => {
return { props: {} }
}

export const getStaticPaths: GetStaticPaths = async () => {
return {
paths: [
{
params: {
slug: [],
},
},
{
params: {
slug: ['history'],
},
},
],
fallback: false,
}
}

export default Page
21 changes: 20 additions & 1 deletion apps/web/src/utils/contractHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import { affiliateProgramABI } from 'config/abi/affiliateProgram'
import { bCakeFarmBoosterABI } from 'config/abi/bCakeFarmBooster'
import { bCakeFarmBoosterProxyFactoryABI } from 'config/abi/bCakeFarmBoosterProxyFactory'
import { bCakeFarmBoosterV3ABI } from 'config/abi/bCakeFarmBoosterV3'
import { positionManagerAdapterABI, positionManagerWrapperABI } from '@pancakeswap/position-managers'
import { bCakeProxyABI } from 'config/abi/bCakeProxy'
import { bunnyFactoryABI } from 'config/abi/bunnyFactory'
import { chainlinkOracleABI } from 'config/abi/chainlinkOracle'
Expand Down Expand Up @@ -247,6 +248,24 @@ export const getBCakeFarmBoosterV3Contract = (signer?: WalletClient, chainId?: n
return getContract({ abi: bCakeFarmBoosterV3ABI, address: getBCakeFarmBoosterV3Address(chainId), signer, chainId })
}

export const getPositionManagerWrapperContract = (address: `0x${string}`, signer?: WalletClient, chainId?: number) => {
return getContract({
abi: positionManagerWrapperABI,
address,
signer,
chainId,
})
}

export const getPositionManagerAdapterContract = (address: `0x${string}`, signer?: WalletClient, chainId?: number) => {
return getContract({
abi: positionManagerAdapterABI,
address,
signer,
chainId,
})
}

export const getBCakeFarmBoosterProxyFactoryContract = (signer?: WalletClient) => {
return getContract({
abi: bCakeFarmBoosterProxyFactoryABI,
Expand Down Expand Up @@ -348,7 +367,7 @@ export const getMasterChefV3Contract = (signer?: WalletClient, chainId?: number)
return mcv3Address
? getContract({
abi: masterChefV3ABI,
address: getMasterChefV3Address(chainId),
address: mcv3Address,
chainId,
signer,
})
Expand Down
Loading

2 comments on commit 05f9db6

@vercel
Copy link

@vercel vercel bot commented on 05f9db6 Oct 30, 2023

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:

uikit – ./packages/uikit

uikit-git-develop.pancake.run
uikit.pancake.run

@vercel
Copy link

@vercel vercel bot commented on 05f9db6 Oct 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.