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 zap in widget #2541

Open
wants to merge 64 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
8b41b9f
widget test
viet-nv Apr 1, 2024
51c1ae7
feat: pancake test
viet-nv Jun 7, 2024
25683c7
fix: modal
viet-nv Jun 7, 2024
05ccb75
chore: update version
viet-nv Jun 10, 2024
c13f156
pump widget ver
viet-nv Jun 10, 2024
f038a40
pump widget version
viet-nv Jun 10, 2024
5726c07
pump widget version
viet-nv Jun 12, 2024
1f6efd0
pump widget version
viet-nv Jun 12, 2024
11ba38a
pump widget version
viet-nv Jun 13, 2024
60342fb
pump widget version
viet-nv Jun 13, 2024
e239dd9
pump widget version
viet-nv Jun 13, 2024
2f9d56d
pump
viet-nv Jun 14, 2024
eba9686
pump
viet-nv Jun 14, 2024
d015a9b
pump version
viet-nv Jun 14, 2024
233eb06
pump version
viet-nv Jun 14, 2024
e9b6266
pump version
viet-nv Jun 14, 2024
d2f9097
pump version
viet-nv Jun 14, 2024
041415a
pump version
viet-nv Jun 14, 2024
e9efb2f
pump version
viet-nv Jun 14, 2024
35e5f39
pump version
viet-nv Jun 14, 2024
5913691
pump version
viet-nv Jun 14, 2024
a553573
widget prod test
viet-nv Jun 14, 2024
04ac57a
feat: add gas fee
viet-nv Jun 14, 2024
b6ec24a
fix: gas fee tooltip
viet-nv Jun 14, 2024
d0de6a1
fix: gas fee tooltip
viet-nv Jun 14, 2024
b22fe94
fix: pool estimated price after zap
viet-nv Jun 16, 2024
e3ac7a1
pump widget version
viet-nv Jun 18, 2024
91eadcd
feat: improvement warning and display info
viet-nv Jun 19, 2024
4ac8dec
tmp
viet-nv Jun 24, 2024
9f22bb0
remove styled
viet-nv Jun 26, 2024
2a9c5bf
fix: pos id
viet-nv Jul 12, 2024
085a5b6
fix: pos id
viet-nv Jul 12, 2024
8a25616
multiple token
viet-nv Aug 13, 2024
fffdd68
fix: liq widget version
viet-nv Aug 14, 2024
d2fdbdc
feat: import token
viet-nv Aug 22, 2024
e905bd6
Fix zap in multi token widget
tienkane Oct 1, 2024
001b177
Fix text color
tienkane Oct 1, 2024
b5ee92d
Add Zap summary
tienkane Oct 1, 2024
d802e4a
Add fee & fix protocol name
tienkane Oct 1, 2024
255a41d
Change zap in widget lib to new repo version
tienkane Oct 2, 2024
d785f22
Update new zap in widget version
tienkane Oct 3, 2024
dacd803
Update zap in widget version
tienkane Oct 3, 2024
d0d27d7
Update new zap in widget version
tienkane Oct 3, 2024
8790c4f
add new zap in widget version & add a default pool address
tienkane Oct 3, 2024
66a5b8f
Add new zap in widget version
tienkane Oct 3, 2024
030cdb3
add zap in widget new version
tienkane Oct 4, 2024
4f6d3e5
Add new zap in widget version
tienkane Oct 4, 2024
a9d0167
Hide liquidity chart
tienkane Oct 4, 2024
0a10c3f
Fix some UI
tienkane Oct 4, 2024
9a7559c
Add import token & change logic get zap route api even when insuffici…
tienkane Oct 7, 2024
3414ee8
Fix warning logic
tienkane Oct 8, 2024
836f287
Fix increase liquidity UI
tienkane Oct 8, 2024
2c59a01
Add security to token info
tienkane Oct 9, 2024
59e5225
Update
tienkane Oct 10, 2024
0bf95db
.
tienkane Oct 10, 2024
1789a01
Update
tienkane Oct 10, 2024
e48505d
Update
tienkane Oct 10, 2024
40909a1
Update
tienkane Oct 14, 2024
de4ad6e
Update
tienkane Oct 14, 2024
1e569b1
Update
tienkane Oct 14, 2024
db571cd
Update
tienkane Oct 14, 2024
e90f169
Update
tienkane Oct 14, 2024
67460c6
Update
tienkane Oct 15, 2024
bc38ff1
Update
tienkane Oct 15, 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
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@
"@blocto/wagmi-connector": "^2.0.4",
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
"@holdstation/paymaster-helper": "^2.0.20",
"@kyberswap/krystal-walletconnect-v2": "0.0.1",
"@kyberswap/ks-sdk-classic": "^1.0.3",
"@kyberswap/ks-sdk-core": "1.1.5",
"@kyberswap/ks-sdk-elastic": "^1.1.2",
"kyberswap-liquidity-widgets": "1.0.30",
"@kyberswap/oauth2": "1.0.2",
"@lingui/macro": "^4.6.0",
"@lingui/react": "^4.6.0",
Expand Down
2 changes: 1 addition & 1 deletion src/components/Header/groups/SwapNavGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const SwapNavGroup = () => {
</IconWrapper>
<Flex alignItems={'center'} sx={{ flex: 1 }} justifyContent={'space-between'}>
<Trans>Cross-Chain</Trans>
<img src={SquidLogoLight} alt="kyberswap with Squid" height={16} />
<img src={SquidLogoLight} alt="kyberswap with Squid" style={{ height: 16 }} />
</Flex>
</Flex>
</StyledNavLink>
Expand Down
3 changes: 3 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 @@ -308,6 +309,8 @@ export default function App() {

<Route path={APP_PATHS.ELASTIC_SNAPSHOT} element={<ElasticSnapshot />} />
<Route path={APP_PATHS.MARKET_OVERVIEW} element={<MarketOverview />} />
<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
186 changes: 186 additions & 0 deletions src/pages/LiquidityWidget.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
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('0x641C00A822e8b671738d32a431a4Fb6074E5c79d')
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)

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%',
color: '#fff',
}}
>
<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