|
|
@@ -1,8 +1,8 @@
|
|
|
-// watch.mjs - 监控 top-positions 并发送到 Discord
|
|
|
+import { TOKEN_MAP } from './const.js'
|
|
|
|
|
|
const API_URL = 'https://app-byreal-table.trrlzk.easypanel.host/api/top-positions'
|
|
|
const DISCORD_WEBHOOK_URL = 'https://discord.com/api/webhooks/1449354624225120378/7gOkPXzZkaoQF7XWKFZRsevVSKXcUOuim2Rhtx_gWzBd9b7wphFMQiAIqBnRT3Gmkog4'
|
|
|
-const DEFAULT_POOL_ADDRESS = 'FPBW9dtVRoUug2BeUKZAzaknd6iiet9jHM8RcTvwUkyC'
|
|
|
+const DEFAULT_POOL_ADDRESS = TOKEN_MAP['MON']
|
|
|
const INTERVAL_MS = 5 * 60 * 1000 // 5分钟
|
|
|
const MAX_AGE_MS = 10 * 60 * 1000 // 10分钟
|
|
|
|
|
|
@@ -39,7 +39,12 @@ async function fetchTopPositions() {
|
|
|
return []
|
|
|
}
|
|
|
|
|
|
- return result.result.data.records
|
|
|
+ const poolMap = Object.values(result.result.data.poolMap)[0]
|
|
|
+
|
|
|
+ return {
|
|
|
+ records: result.result.data.records,
|
|
|
+ symbol: `${poolMap.mintA.symbol}/${poolMap.mintB.symbol}`,
|
|
|
+ }
|
|
|
} catch (error) {
|
|
|
console.error('获取数据失败:', error)
|
|
|
return []
|
|
|
@@ -49,7 +54,7 @@ async function fetchTopPositions() {
|
|
|
/**
|
|
|
* 发送消息到 Discord
|
|
|
*/
|
|
|
-async function sendToDiscord(position) {
|
|
|
+async function sendToDiscord(position, symbol) {
|
|
|
try {
|
|
|
const ageMinutes = Math.floor(position.positionAgeMs / 1000 / 60)
|
|
|
const ageSeconds = Math.floor((position.positionAgeMs / 1000) % 60)
|
|
|
@@ -68,6 +73,11 @@ async function sendToDiscord(position) {
|
|
|
value: `\`${position.positionAddress}\``,
|
|
|
inline: false,
|
|
|
},
|
|
|
+ {
|
|
|
+ name: '交易对',
|
|
|
+ value: `\`${symbol}\``,
|
|
|
+ inline: true,
|
|
|
+ },
|
|
|
{
|
|
|
name: '流动性',
|
|
|
value: `$${Number(position.liquidityUsd).toFixed(2)}`,
|
|
|
@@ -145,7 +155,7 @@ function calculateAPR(position) {
|
|
|
async function processPositions() {
|
|
|
console.log(`\n[${new Date().toLocaleString('zh-CN')}] 开始检查新仓位...`)
|
|
|
|
|
|
- const records = await fetchTopPositions()
|
|
|
+ const { records, symbol } = await fetchTopPositions()
|
|
|
|
|
|
if (records.length === 0) {
|
|
|
console.log('未获取到数据')
|
|
|
@@ -172,7 +182,7 @@ async function processPositions() {
|
|
|
for (const position of unsentPositions) {
|
|
|
const address = position.positionAddress
|
|
|
if (address) {
|
|
|
- const success = await sendToDiscord(position)
|
|
|
+ const success = await sendToDiscord(position, symbol)
|
|
|
if (success) {
|
|
|
sentPositions.add(address)
|
|
|
}
|