'use client' import { useState } from 'react' import { Card, Input, Button, Form, InputNumber, message, Descriptions, Typography, Space, } from 'antd' import { CopyOutlined, LoadingOutlined } from '@ant-design/icons' const { Title, Text } = Typography export default function LpCopyPage() { const [loading, setLoading] = useState(false) const [positionInfo, setPositionInfo] = useState<{ poolAddress: string tickLower: number tickUpper: number base: string baseAmount: string otherAmountMax: string estimatedValue: number priceLower: string priceUpper: string } | null>(null) const [form] = Form.useForm() const handleCopy = async (values: { positionAddress: string maxUsdValue: number }) => { setLoading(true) setPositionInfo(null) try { const response = await fetch('/api/lp-copy', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ positionAddress: values.positionAddress, maxUsdValue: values.maxUsdValue, }), }) const data = await response.json() if (!response.ok) { throw new Error(data.error || 'Failed to copy position') } setPositionInfo(data.positionInfo) message.success('Position copied successfully!') message.info(`Transaction ID: ${data.txid}`) } catch (error: unknown) { const errorMessage = error instanceof Error ? error.message : 'Failed to copy position' message.error(errorMessage) } finally { setLoading(false) } } return (
LP Position Copy Copy an existing LP position with a limited investment amount. The system will automatically calculate the optimal token amounts.
`$ ${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',') } parser={(value) => { const parsed = value?.replace(/\$\s?|(,*)/g, '') || '0' return parseFloat(parsed) || 0 }} />
{positionInfo && ( {positionInfo.poolAddress} {positionInfo.tickLower} - {positionInfo.tickUpper} {positionInfo.priceLower} - {positionInfo.priceUpper} {positionInfo.base} {positionInfo.baseAmount} {positionInfo.otherAmountMax} ${positionInfo.estimatedValue.toFixed(2)} USD )} How it works: 1. Enter the NFT mint address of the position you want to copy 2. Set your maximum investment amount in USD 3. The system will automatically: • Fetch the position details (price range, pool info) • Calculate optimal token amounts within your budget • Create a new position with the same price range • Add a memo linking to the original position
) }