|
|
@@ -27,6 +27,8 @@ interface MintInfo {
|
|
|
address: string
|
|
|
}
|
|
|
interface LPInfo {
|
|
|
+ baseMint: MintInfo
|
|
|
+ quoteMint: MintInfo
|
|
|
mintA: MintInfo
|
|
|
mintB: MintInfo
|
|
|
}
|
|
|
@@ -103,12 +105,17 @@ function MyLPPageContent() {
|
|
|
let parentLiquidityUsd = 0
|
|
|
|
|
|
if (bonusInfo?.fromCreatorPosition) {
|
|
|
- const copyInfo = await Promise.all([fetch(
|
|
|
- `/api/my-lp/copyInfo?parentPositionAddress=${bonusInfo.fromCreatorPosition}&poolAddress=${pool.poolAddress}`
|
|
|
- ), fetch(
|
|
|
- `/api/my-lp/detail?address=${bonusInfo.fromCreatorPosition}`
|
|
|
- )])
|
|
|
- const [copyInfoData, detailData] = await Promise.all(copyInfo.map(res => res.json()))
|
|
|
+ const copyInfo = await Promise.all([
|
|
|
+ fetch(
|
|
|
+ `/api/my-lp/copyInfo?parentPositionAddress=${bonusInfo.fromCreatorPosition}&poolAddress=${pool.poolAddress}`
|
|
|
+ ),
|
|
|
+ fetch(
|
|
|
+ `/api/my-lp/detail?address=${bonusInfo.fromCreatorPosition}`
|
|
|
+ ),
|
|
|
+ ])
|
|
|
+ const [copyInfoData, detailData] = await Promise.all(
|
|
|
+ copyInfo.map((res) => res.json())
|
|
|
+ )
|
|
|
if (copyInfoData.retCode === 0 && copyInfoData.result) {
|
|
|
allCopys = copyInfoData.result.data.total
|
|
|
allCopyAmount = copyInfoData.result.data.records
|
|
|
@@ -236,14 +243,14 @@ function MyLPPageContent() {
|
|
|
tokenBAddress: '',
|
|
|
}
|
|
|
}
|
|
|
- const tokenA = poolInfo.mintA.symbol
|
|
|
- const tokenB = poolInfo.mintB.symbol
|
|
|
+ const tokenA = poolInfo.baseMint.symbol
|
|
|
+ const tokenB = poolInfo.quoteMint.symbol
|
|
|
return {
|
|
|
- tokenAAddress: poolInfo.mintA.address,
|
|
|
- tokenBAddress: poolInfo.mintB.address,
|
|
|
+ tokenAAddress: poolInfo.baseMint.address,
|
|
|
+ tokenBAddress: poolInfo.quoteMint.address,
|
|
|
lpToken: `${tokenA}/${tokenB}`,
|
|
|
- logoURI: [poolInfo.mintA.logoURI, poolInfo.mintB.logoURI],
|
|
|
- price: [poolInfo.mintA.price, poolInfo.mintB.price],
|
|
|
+ logoURI: [poolInfo.baseMint.logoURI, poolInfo.quoteMint.logoURI],
|
|
|
+ price: [poolInfo.baseMint.price, poolInfo.quoteMint.price],
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -619,8 +626,7 @@ function MyLPPageContent() {
|
|
|
async function handleCloseAllPositionWithoutParent() {
|
|
|
const allPositions = lpList.filter(
|
|
|
(item) =>
|
|
|
- item.bonusInfo?.fromCreatorPosition &&
|
|
|
- item.isParentPositionClosed
|
|
|
+ item.bonusInfo?.fromCreatorPosition && item.isParentPositionClosed
|
|
|
)
|
|
|
if (allPositions.length === 0) {
|
|
|
message.info('没有需要关闭的仓位')
|
|
|
@@ -663,7 +669,11 @@ function MyLPPageContent() {
|
|
|
// 只关闭 xxx/USDC 或者 xxx/USDT 的仓位, 因为 这些仓位的isInRange是正确的, 其他仓位的isInRange是错误的
|
|
|
const outOfRangePositions = lpList.filter((item) => {
|
|
|
const poolInfo = getPoolInfo(item.poolAddress)
|
|
|
- return (poolInfo.lpToken.toLowerCase().endsWith('usdc') || poolInfo.lpToken.toLowerCase().endsWith('usdt')) && !item.isInRange
|
|
|
+ return (
|
|
|
+ (poolInfo.lpToken.toLowerCase().endsWith('usdc') ||
|
|
|
+ poolInfo.lpToken.toLowerCase().endsWith('usdt')) &&
|
|
|
+ !item.isInRange
|
|
|
+ )
|
|
|
})
|
|
|
if (outOfRangePositions.length === 0) {
|
|
|
message.info('没有需要关闭的仓位')
|
|
|
@@ -685,10 +695,15 @@ function MyLPPageContent() {
|
|
|
})
|
|
|
}
|
|
|
const newLpList = lpList.filter(
|
|
|
- (item) => !outOfRangePositions.some((p) => p.nftMintAddress === item.nftMintAddress)
|
|
|
+ (item) =>
|
|
|
+ !outOfRangePositions.some(
|
|
|
+ (p) => p.nftMintAddress === item.nftMintAddress
|
|
|
+ )
|
|
|
)
|
|
|
setLpList(newLpList)
|
|
|
- message.success(`关闭出区间仓位成功,关闭了 ${outOfRangePositions.length} 个仓位`)
|
|
|
+ message.success(
|
|
|
+ `关闭出区间仓位成功,关闭了 ${outOfRangePositions.length} 个仓位`
|
|
|
+ )
|
|
|
} catch (err: unknown) {
|
|
|
console.error('Error closing positions out of range:', err)
|
|
|
message.error(err instanceof Error ? err.message : '关闭出区间仓位失败')
|
|
|
@@ -760,7 +775,6 @@ function MyLPPageContent() {
|
|
|
}
|
|
|
}, [userAddress])
|
|
|
|
|
|
-
|
|
|
function onMintChange(value: string) {
|
|
|
setTokenAddress(value)
|
|
|
setPage(1)
|