|
@@ -12,12 +12,14 @@ import {
|
|
|
Typography,
|
|
Typography,
|
|
|
Tag,
|
|
Tag,
|
|
|
InputNumber,
|
|
InputNumber,
|
|
|
|
|
+ Select,
|
|
|
} from 'antd'
|
|
} from 'antd'
|
|
|
import type { ColumnsType, TablePaginationConfig } from 'antd/es/table'
|
|
import type { ColumnsType, TablePaginationConfig } from 'antd/es/table'
|
|
|
import dayjs from 'dayjs'
|
|
import dayjs from 'dayjs'
|
|
|
import pLimit from 'p-limit'
|
|
import pLimit from 'p-limit'
|
|
|
|
|
|
|
|
interface MintInfo {
|
|
interface MintInfo {
|
|
|
|
|
+ mint: string
|
|
|
symbol: string
|
|
symbol: string
|
|
|
decimals: number
|
|
decimals: number
|
|
|
logoURI: string
|
|
logoURI: string
|
|
@@ -71,6 +73,9 @@ function MyLPPageContent() {
|
|
|
const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([])
|
|
const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([])
|
|
|
const [batchClosing, setBatchClosing] = useState(false)
|
|
const [batchClosing, setBatchClosing] = useState(false)
|
|
|
const inputNumberRef = useRef<React.ComponentRef<typeof InputNumber>>(null)
|
|
const inputNumberRef = useRef<React.ComponentRef<typeof InputNumber>>(null)
|
|
|
|
|
+ const [mintList, setMintList] = useState<MintInfo[]>([])
|
|
|
|
|
+ const [tokenAddress, setTokenAddress] = useState<string>('')
|
|
|
|
|
+
|
|
|
const fetchLPDetail = async (positions: RecordInfo[]) => {
|
|
const fetchLPDetail = async (positions: RecordInfo[]) => {
|
|
|
message.loading(`正在查询当前页面仓位详细信息,请稍等...`)
|
|
message.loading(`正在查询当前页面仓位详细信息,请稍等...`)
|
|
|
|
|
|
|
@@ -147,7 +152,8 @@ function MyLPPageContent() {
|
|
|
|
|
|
|
|
const fetchLPList = async (
|
|
const fetchLPList = async (
|
|
|
adddr: string,
|
|
adddr: string,
|
|
|
- pagination?: { page: number; pageSize: number }
|
|
|
|
|
|
|
+ pagination?: { page: number; pageSize: number },
|
|
|
|
|
+ tokenAddress?: string
|
|
|
) => {
|
|
) => {
|
|
|
if (!adddr) return
|
|
if (!adddr) return
|
|
|
const newPage = pagination?.page || page
|
|
const newPage = pagination?.page || page
|
|
@@ -155,7 +161,7 @@ function MyLPPageContent() {
|
|
|
setLoading(true)
|
|
setLoading(true)
|
|
|
try {
|
|
try {
|
|
|
const response = await fetch(
|
|
const response = await fetch(
|
|
|
- `/api/my-lp?userAddress=${encodeURIComponent(adddr)}&page=${newPage}&pageSize=${newPageSize}`
|
|
|
|
|
|
|
+ `/api/my-lp?userAddress=${encodeURIComponent(adddr)}&tokenAddress=${tokenAddress || ''}&page=${newPage}&pageSize=${newPageSize}&status=0`
|
|
|
)
|
|
)
|
|
|
const data = await response.json()
|
|
const data = await response.json()
|
|
|
const { positions, total, poolMap } = data.result?.data
|
|
const { positions, total, poolMap } = data.result?.data
|
|
@@ -257,6 +263,14 @@ function MyLPPageContent() {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ function fetchMintList() {
|
|
|
|
|
+ fetch('/api/my-lp/mintList')
|
|
|
|
|
+ .then((res) => res.json())
|
|
|
|
|
+ .then((data) => {
|
|
|
|
|
+ setMintList(data.records as MintInfo[])
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
function handleAddPosition(record: RecordInfo) {
|
|
function handleAddPosition(record: RecordInfo) {
|
|
|
message.loading({
|
|
message.loading({
|
|
|
key: 'addPosition',
|
|
key: 'addPosition',
|
|
@@ -659,14 +673,34 @@ function MyLPPageContent() {
|
|
|
} else {
|
|
} else {
|
|
|
fetchAddress()
|
|
fetchAddress()
|
|
|
}
|
|
}
|
|
|
|
|
+ fetchMintList()
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
}, [])
|
|
}, [])
|
|
|
|
|
|
|
|
|
|
+ function onMintChange(value: string) {
|
|
|
|
|
+ setTokenAddress(value)
|
|
|
|
|
+ fetchLPList(userAddress, { page: 1, pageSize: 50 }, value)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return (
|
|
return (
|
|
|
<main style={{ padding: '24px' }}>
|
|
<main style={{ padding: '24px' }}>
|
|
|
<div className="mb-4">
|
|
<div className="mb-4">
|
|
|
{userAddress ? (
|
|
{userAddress ? (
|
|
|
<div className="flex items-center gap-2 mb-4">
|
|
<div className="flex items-center gap-2 mb-4">
|
|
|
|
|
+ <Select
|
|
|
|
|
+ value={tokenAddress}
|
|
|
|
|
+ placeholder="选择 LP Token"
|
|
|
|
|
+ style={{ width: 200 }}
|
|
|
|
|
+ allowClear
|
|
|
|
|
+ showSearch
|
|
|
|
|
+ options={mintList.map((mint) => ({
|
|
|
|
|
+ label: mint.symbol,
|
|
|
|
|
+ value: mint.address,
|
|
|
|
|
+ }))}
|
|
|
|
|
+ onChange={(value) => {
|
|
|
|
|
+ onMintChange(value)
|
|
|
|
|
+ }}
|
|
|
|
|
+ />
|
|
|
<p className="text-lg font-bold">你的地址: {userAddress}</p>
|
|
<p className="text-lg font-bold">你的地址: {userAddress}</p>
|
|
|
<Button type="primary" onClick={handleAddressChange}>
|
|
<Button type="primary" onClick={handleAddressChange}>
|
|
|
更换地址
|
|
更换地址
|