Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prod widget test #2502

Open
wants to merge 42 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
5d4bd56
widget test
viet-nv Apr 1, 2024
64645e9
Merge branch 'main' of github.com:KyberNetwork/kyberswap-interface in…
viet-nv Jun 7, 2024
d6e94c0
feat: pancake test
viet-nv Jun 7, 2024
a3523be
update ts to 5.2.2
viet-nv Jun 7, 2024
64a2249
fix: modal
viet-nv Jun 7, 2024
05f5113
chore: update version
viet-nv Jun 10, 2024
bc18717
pump widget ver
viet-nv Jun 10, 2024
fb65203
Merge branch 'main' of github.com:KyberNetwork/kyberswap-interface in…
viet-nv Jun 10, 2024
31b01b2
pump widget version
viet-nv Jun 10, 2024
f72d972
pump widget version
viet-nv Jun 12, 2024
6830ea0
Merge branch 'main' of github.com:KyberNetwork/kyberswap-interface in…
viet-nv Jun 12, 2024
5d69a79
pump widget version
viet-nv Jun 12, 2024
24a4c85
pump widget version
viet-nv Jun 13, 2024
693a5a6
pump widget version
viet-nv Jun 13, 2024
5eacab6
pump widget version
viet-nv Jun 13, 2024
d20d9f9
pump
viet-nv Jun 14, 2024
182bd65
pump
viet-nv Jun 14, 2024
24d1437
pump version
viet-nv Jun 14, 2024
d433e71
pump version
viet-nv Jun 14, 2024
fee744c
pump version
viet-nv Jun 14, 2024
d89c22a
pump version
viet-nv Jun 14, 2024
b053665
pump version
viet-nv Jun 14, 2024
aae3ffb
pump version
viet-nv Jun 14, 2024
926ed89
pump version
viet-nv Jun 14, 2024
a746829
pump version
viet-nv Jun 14, 2024
9d8f762
widget prod test
viet-nv Jun 14, 2024
4bc61d7
feat: add gas fee
viet-nv Jun 14, 2024
d72e204
fix: gas fee tooltip
viet-nv Jun 14, 2024
0564b6e
fix: gas fee tooltip
viet-nv Jun 14, 2024
1bbb90c
fix: pool estimated price after zap
viet-nv Jun 16, 2024
1feb297
pump widget version
viet-nv Jun 18, 2024
2bad4f0
Merge branch 'main' of github.com:KyberNetwork/kyberswap-interface in…
viet-nv Jun 19, 2024
07b54de
feat: improvement warning and display info
viet-nv Jun 19, 2024
d4f1e66
tmp
viet-nv Jun 24, 2024
63d8659
remove styled
viet-nv Jun 26, 2024
202a667
fix: pos id
viet-nv Jul 12, 2024
a482e0e
Merge branch 'main' of github.com:KyberNetwork/kyberswap-interface in…
viet-nv Jul 12, 2024
5ec2e0e
fix: pos id
viet-nv Jul 12, 2024
023956f
Merge branch 'main' of github.com:KyberNetwork/kyberswap-interface in…
viet-nv Aug 13, 2024
6c40011
multiple token
viet-nv Aug 13, 2024
6c4bc34
fix: liq widget version
viet-nv Aug 14, 2024
72176fe
feat: import token
viet-nv Aug 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
href="https://fonts.googleapis.com/css2?family=Work+Sans:wght@300;400;500;600&display=swap"
rel="stylesheet"
/>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Kanit:400,500,600,700" />

<title>KyberSwap - Limitless Access To DeFi</title>
<script>
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"@kyberswap/ks-sdk-classic": "^1.0.3",
"@kyberswap/ks-sdk-core": "1.1.5",
"@kyberswap/ks-sdk-elastic": "^1.1.2",
"@kyberswap/liquidity-widgets": "0.0.8-multi-token-poc-2",
"@kyberswap/oauth2": "1.0.2",
"@lingui/macro": "^4.6.0",
"@lingui/react": "^4.6.0",
Expand Down Expand Up @@ -203,7 +204,7 @@
"prom-client": "^14.2.0",
"storybook": "^7.6.2",
"ts-node": "^10.9.1",
"typescript": "4.8.4",
"typescript": "5.2.2",
"vite": "^4.3.9",
"vite-plugin-checker": "^0.5.6",
"vite-plugin-svgr": "^2.4.0",
Expand Down
2 changes: 1 addition & 1 deletion src/components/LiveChart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ function LiveChart({
</Text>
) : (
<>
<Text fontSize={12} color={different >= 0 ? '#31CB9E' : '#FF537B'} marginRight="5px">
<Text fontSize={12} color={+different >= 0 ? '#31CB9E' : '#FF537B'} marginRight="5px">
{different} ({differentPercent}%)
</Text>
{!hoverValue && (
Expand Down
2 changes: 1 addition & 1 deletion src/components/Pagination/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default function Pagination({
}

const onNext = () => {
if (currentPage < paginationRange[paginationRange.length - 1]) {
if (currentPage < +paginationRange[paginationRange.length - 1]) {
onPageChange(currentPage + 1)
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/pages/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { RedirectPathToSwapV3Network } from 'pages/SwapV3/redirects'
import { useHolidayMode } from 'state/user/hooks'
import { isSupportLimitOrder } from 'utils'

import LiquidityWidget from './LiquidityWidget'
import VerifyAuth from './Verify/VerifyAuth'

const Login = lazy(() => import('./Oauth/Login'))
Expand Down Expand Up @@ -306,6 +307,7 @@ export default function App() {
<Route path={APP_PATHS.IAM_CONSENT} element={<Consent />} />

<Route path={APP_PATHS.ELASTIC_SNAPSHOT} element={<ElasticSnapshot />} />
<Route path="/liquidity-widget" element={<LiquidityWidget />} />

<Route path={APP_PATHS.AGGREGATOR_CAMPAIGN} element={<Campaign />} />
<Route path={APP_PATHS.LIMIT_ORDER_CAMPAIGN} element={<Campaign />} />
Expand Down
179 changes: 179 additions & 0 deletions src/pages/LiquidityWidget.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
import { ChainId } from '@kyberswap/ks-sdk-core'
import { LiquidityWidget as KsLiquidityWidget, PoolType } from '@kyberswap/liquidity-widgets'
import '@kyberswap/liquidity-widgets/dist/style.css'
import { useEffect, useMemo, useState } from 'react'
import { Box } from 'rebass'

import { NotificationType } from 'components/Announcement/type'
import { ButtonPrimary } from 'components/Button'
import Input from 'components/Input'
import { NetworkSelector } from 'components/NetworkSelector'
import { useActiveWeb3React, useWeb3React } from 'hooks'
import { useChangeNetwork } from 'hooks/web3/useChangeNetwork'
import { useNotify } from 'state/application/hooks'

export default function LiquidityWidget() {
const [selectedChainId, setSelectedChainId] = useState(ChainId.ARBITRUM)
const [poolAddress, setPoolAddress] = useState('') // 0x0bacc7a9717e70ea0da5ac075889bd87d4c81197
const [positionId, setPositionId] = useState('') //24654
const [openModal, setOpenModal] = useState(false)
const { changeNetwork } = useChangeNetwork()
const [autoAfterChange, setAutoAfterChange] = useState(false)

const { chainId } = useActiveWeb3React()
const { library } = useWeb3React()
const notify = useNotify()

useEffect(() => {
if (autoAfterChange && chainId === selectedChainId) {
setOpenModal(true)
setAutoAfterChange(false)
}
}, [autoAfterChange, chainId, selectedChainId])

const pancakeTheme = useMemo(
() => ({
text: '#FFFFFF',
subText: '#B6AECF',
icons: '#a9a9a9',
layer1: '#27262C',
dialog: '#27262C',
layer2: '#363046',
stroke: '#363046',
chartRange: '#5DC5D2',
chartArea: '#457F89',
accent: '#5DC5D2',
warning: '#F4B452',
error: '#FF5353',
success: '#189470',
fontFamily: 'Kanit, Sans-serif',
borderRadius: '20px',
buttonRadius: '16px',
boxShadow: '0px 4px 4px rgba(0, 0, 0, 0.04)',
}),
[],
)

const ksTheme = useMemo(
() => ({
text: '#ffffff',
subText: '#979797',
icons: '#a9a9a9',
layer1: '#1C1C1C',
dialog: '#1c1c1c',
layer2: '#313131',
stroke: '#313131',
chartRange: '#28e0b9',
chartArea: '#047855',
accent: '#31cb9e',
warning: '#ff9901',
error: '#ff537b',
success: '#189470',
fontFamily: 'Work Sans',
borderRadius: '20px',
buttonRadius: '24px',
boxShadow: '0px 4px 4px rgba(0, 0, 0, 0.04)',
}),
[],
)

const [dexType, setType] = useState(PoolType.DEX_UNISWAPV3)
const [selectedTheme, setSelectedTheme] = useState('ks')
const [feeAddress, setFeeAddress] = useState('')
const [feePcm, setFeePcm] = useState(0)

console.log(feeAddress, feePcm)

return (
<>
{openModal ? (
<KsLiquidityWidget
provider={library}
theme={selectedTheme === 'pc' ? pancakeTheme : ksTheme}
poolAddress={poolAddress}
positionId={positionId || undefined}
feeAddress={feeAddress}
feePcm={feePcm}
poolType={dexType}
chainId={selectedChainId}
onTxSubmit={tx => {
notify(
{
title: 'Send Zap tx success',
type: NotificationType.SUCCESS,
summary: `Tx: ${tx}`,
// icon?: ReactNode
// link: getEtherscanLink(ChainId.ARBITRUM, tx, 'transaction'),
},
10_000,
)
}}
onDismiss={() => setOpenModal(false)}
source={'kyberswap-demo-zap'}
/>
) : (
<Box sx={{ display: 'flex', flexDirection: 'column', maxWidth: '500px', gap: '1rem', width: '100%' }}>
<NetworkSelector chainId={selectedChainId} customOnSelectNetwork={chain => setSelectedChainId(chain)} />
<div>
<input
type="radio"
id="kstheme"
value="ks"
checked={selectedTheme === 'ks'}
onChange={e => setSelectedTheme(e.currentTarget.value)}
/>
  <label htmlFor="kstheme">KyberSwap Theme</label>
<br />
<input
type="radio"
id="pctheme"
value="pc"
checked={selectedTheme === 'pc'}
onChange={e => setSelectedTheme(e.currentTarget.value)}
/>
  <label htmlFor="pctheme">Pancake Theme</label>
<br />
</div>

<div>
<input
type="radio"
id="html"
value={PoolType.DEX_PANCAKESWAPV3}
checked={dexType === PoolType.DEX_PANCAKESWAPV3}
onChange={e => setType(e.currentTarget.value as PoolType)}
/>
  <label htmlFor="html">Pancake</label>
<br />
<input
type="radio"
id="css"
value={PoolType.DEX_UNISWAPV3}
checked={dexType === PoolType.DEX_UNISWAPV3}
onChange={e => setType(e.currentTarget.value as PoolType)}
/>
  <label htmlFor="css">Uniswap</label>
<br />
</div>
<Input placeholder="Pool address..." value={poolAddress} onChange={e => setPoolAddress(e.target.value)} />
<Input placeholder="Position id..." value={positionId} onChange={e => setPositionId(e.target.value)} />

<Input placeholder="Fee address..." value={feeAddress} onChange={e => setFeeAddress(e.target.value)} />
<Input placeholder="Fee pcm..." value={feePcm} onChange={e => setFeePcm(+e.target.value)} />
<ButtonPrimary
onClick={() => {
if (selectedChainId !== chainId) {
changeNetwork(selectedChainId)
setAutoAfterChange(true)
} else {
setOpenModal(true)
}
}}
>
Load
</ButtonPrimary>
</Box>
)}
</>
)
}
9 changes: 9 additions & 0 deletions src/theme/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,4 +261,13 @@ export const ThemedGlobalStyle = createGlobalStyle`
padding-right: 1.5rem;
}

.ks-lw-modal-overlay {
z-index: 9999
}

.ks-lw {
width: 100%;
max-width: 900px;
}

`
24 changes: 19 additions & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"compilerOptions": {
"target": "ESNext",
"lib": ["dom", "dom.iterable", "esnext"],
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": false,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
Expand All @@ -22,13 +26,23 @@
"jsx": "react-jsx",
"downlevelIteration": true,
"allowSyntheticDefaultImports": true,
"typeRoots": ["./types"],
"typeRoots": [
"./types"
],
"baseUrl": "src",
"useUnknownInCatchVariables": false,
"paths": {
"@/*": ["./src/*"]
"@/*": [
"./src/*"
]
}
},
"exclude": ["node_modules", "cypress"],
"include": ["./src/**/*.ts", "./src/**/*.tsx"]
"exclude": [
"node_modules",
"cypress"
],
"include": [
"./src/**/*.ts",
"./src/**/*.tsx"
]
}
Loading
Loading