|
@@ -160,27 +160,44 @@ export class OnchainMonitor {
|
|
|
logger.info(`Waiting 60 seconds for Byreal API to sync...`);
|
|
logger.info(`Waiting 60 seconds for Byreal API to sync...`);
|
|
|
await sleep(60000);
|
|
await sleep(60000);
|
|
|
|
|
|
|
|
- // Fetch position details from Byreal API
|
|
|
|
|
- logger.info(`Fetching position details from Byreal API...`);
|
|
|
|
|
- const positionDetail = await ByrealAPI.getPositionDetail(parentPosition);
|
|
|
|
|
|
|
+ // Fetch target wallet's positions to find the copied position
|
|
|
|
|
+ logger.info(`Fetching target wallet positions to find copied position...`);
|
|
|
|
|
+ const { positions } = await ByrealAPI.fetchTargetPositions(CONFIG.TARGET_WALLET);
|
|
|
|
|
+
|
|
|
|
|
+ // Find the position that references this parent position
|
|
|
|
|
+ const copiedPosition = positions.find(p =>
|
|
|
|
|
+ p.parentPositionAddress === parentPosition
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ if (!copiedPosition) {
|
|
|
|
|
+ logger.error(`Could not find copied position for parent ${parentPosition} in target wallet`);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ logger.info(`Found copied position: ${copiedPosition.positionAddress}`);
|
|
|
|
|
+
|
|
|
|
|
+ // Fetch the copied position details (this is the position created by target wallet)
|
|
|
|
|
+ logger.info(`Fetching copied position details from Byreal API...`);
|
|
|
|
|
+ const positionDetail = await ByrealAPI.getPositionDetail(copiedPosition.positionAddress);
|
|
|
|
|
|
|
|
if (!positionDetail) {
|
|
if (!positionDetail) {
|
|
|
- logger.error(`Failed to fetch position detail from Byreal API: ${parentPosition}`);
|
|
|
|
|
|
|
+ logger.error(`Failed to fetch copied position detail from Byreal API: ${copiedPosition.positionAddress}`);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- logger.success(`Position details fetched successfully!`);
|
|
|
|
|
|
|
+ logger.success(`Copied position details fetched successfully!`);
|
|
|
logger.info(` Pool: ${positionDetail.pool?.mintA?.symbol}/${positionDetail.pool?.mintB?.symbol}`);
|
|
logger.info(` Pool: ${positionDetail.pool?.mintA?.symbol}/${positionDetail.pool?.mintB?.symbol}`);
|
|
|
logger.info(` NFT Mint: ${positionDetail.nftMintAddress || positionDetail.nftMint}`);
|
|
logger.info(` NFT Mint: ${positionDetail.nftMintAddress || positionDetail.nftMint}`);
|
|
|
- logger.info(` USD Value: $${positionDetail.totalDeposit || positionDetail.totalUsdValue || positionDetail.liquidityUsd || 0}`);
|
|
|
|
|
|
|
+ logger.info(` Total Deposit (Target's amount): $${positionDetail.totalDeposit || positionDetail.totalUsdValue || positionDetail.liquidityUsd || 0}`);
|
|
|
|
|
+ logger.info(` Parent Position: ${positionDetail.parentPositionAddress}`);
|
|
|
|
|
|
|
|
// Call the callback with position info from Byreal API
|
|
// Call the callback with position info from Byreal API
|
|
|
if (this.callback) {
|
|
if (this.callback) {
|
|
|
await this.callback({
|
|
await this.callback({
|
|
|
parentPositionAddress: parentPosition,
|
|
parentPositionAddress: parentPosition,
|
|
|
- targetPositionAddress: signature,
|
|
|
|
|
|
|
+ targetPositionAddress: copiedPosition.positionAddress, // Target's copied position
|
|
|
transactionSignature: signature,
|
|
transactionSignature: signature,
|
|
|
- positionDetail: positionDetail // Full position detail from Byreal API
|
|
|
|
|
|
|
+ positionDetail: positionDetail // Full position detail from Byreal API (TARGET's position)
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|