Skip to content

Commit b98af43

Browse files
committed
fix: Remove telegram bot link hard-coded
1 parent e7e46e2 commit b98af43

File tree

2 files changed

+55
-56
lines changed

2 files changed

+55
-56
lines changed

meteora-lp-bot/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ Create the .env file with the following data:
1717
BOT_TOKEN
1818
RPC_URL
1919
WEBAPP_URL
20+
BOT_NAME
2021
```

meteora-lp-bot/src/telegram/components.ts

+54-56
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { calculateTokenPercentages, formatNumber } from "../utils/solana";
44
import { Pair } from "../models/Pair";
55

66
export function poolsInfoMessage(positions: Position[]) {
7+
let botName = process.env.BOT_NAME;
78
let poolInfoMessage = "";
89

910
for (var position of positions) {
@@ -12,111 +13,108 @@ export function poolsInfoMessage(positions: Position[]) {
1213
const tokenPercentages = calculateTokenPercentages(position);
1314
const isOutRange =
1415
tokenPercentages.tokenX === 100 || tokenPercentages.tokenY === 100;
15-
const urlPositionDetail = `https://t.me/meteora_lp_test_bot?start=position_${position.poolKey}`;
16+
const urlPositionDetail = `https://t.me/${botName}?start=position_${position.poolKey}`;
1617

1718
poolInfoMessage += `
18-
${
19-
isOutRange ? "🔴" : "🟢"
20-
} <a href="${urlPositionDetail}"><b>${tokenXSymbol}-${tokenYSymbol}</b></a> - Current price (${position.totalCurrent.exchangeRate.toFixed(
21-
8
22-
)}) - <a href="https://app.meteora.ag/dlmm/${position.poolKey}">🪐</a>
19+
${isOutRange ? "🔴" : "🟢"
20+
} <a href="${urlPositionDetail}"><b>${tokenXSymbol}-${tokenYSymbol}</b></a> - Current price (${position.totalCurrent.exchangeRate.toFixed(
21+
8
22+
)}) - <a href="https://app.meteora.ag/dlmm/${position.poolKey}">🪐</a>
2323
<code>${position.poolKey}</code>
2424
2525
• <b>Range:</b> ${parseFloat(position.startBinPricePerToken).toFixed(
26-
8
27-
)} - ${parseFloat(position.lastBinPricePerToken).toFixed(8)} ${
28-
isOutRange ? "⚠️ Out of range" : ""
29-
}
26+
8
27+
)} - ${parseFloat(position.lastBinPricePerToken).toFixed(8)} ${isOutRange ? "⚠️ Out of range" : ""
28+
}
3029
• <b>${tokenXSymbol}:</b> ${tokenPercentages.tokenX}%
3130
• <b>${tokenYSymbol}:</b> ${tokenPercentages.tokenY}%
3231
3332
• <b>Liquidity:</b> $${position.totalCurrent.totalValueInTokenY.toFixed(2)}
3433
• <b>Fees Claimed:</b> $${position.totalUnclaimedFees.totalValueInTokenY.toFixed(
35-
2
36-
)}
34+
2
35+
)}
3736
• <b>Current Balance:</b> ${position.totalCurrent.tokenXBalance.toFixed(
38-
4
39-
)} ${tokenXSymbol} - ${position.totalCurrent.tokenYBalance.toFixed(
40-
4
41-
)} ${tokenYSymbol}
37+
4
38+
)} ${tokenXSymbol} - ${position.totalCurrent.tokenYBalance.toFixed(
39+
4
40+
)} ${tokenYSymbol}
4241
• <b>Unclaimed Swap Fee:</b> ${position.totalUnclaimedFees.tokenXBalance.toFixed(
43-
6
44-
)} ${tokenXSymbol} - ${position.totalUnclaimedFees.tokenYBalance.toFixed(
45-
6
46-
)} ${tokenYSymbol}
42+
6
43+
)} ${tokenXSymbol} - ${position.totalUnclaimedFees.tokenYBalance.toFixed(
44+
6
45+
)} ${tokenYSymbol}
4746
`;
4847
}
4948

5049
return poolInfoMessage;
5150
}
5251

5352
export function poolsCompletePositionInfoMessage(position: Position) {
53+
let botName = process.env.BOT_NAME;
5454
let poolInfoMessage = "";
5555

5656
const tokenXSymbol = position.tokenX.symbol;
5757
const tokenYSymbol = position.tokenY.symbol;
5858
const tokenPercentages = calculateTokenPercentages(position);
5959
const isOutRange =
6060
tokenPercentages.tokenX === 100 || tokenPercentages.tokenY === 100;
61-
const urlPositionDetail = `https://t.me/meteora_lp_test_bot?start=position_${position.poolKey}`;
61+
const urlPositionDetail = `https://t.me/${botName}?start=position_${position.poolKey}`;
6262

6363
poolInfoMessage += `
64-
${
65-
isOutRange ? "🔴" : "🟢"
66-
} <a href="${urlPositionDetail}"><b>${tokenXSymbol}-${tokenYSymbol}</b></a> - Current price (${position.totalCurrent.exchangeRate.toFixed(
67-
8
68-
)}) - <a href="https://app.meteora.ag/dlmm/${position.poolKey}">🪐</a>
64+
${isOutRange ? "🔴" : "🟢"
65+
} <a href="${urlPositionDetail}"><b>${tokenXSymbol}-${tokenYSymbol}</b></a> - Current price (${position.totalCurrent.exchangeRate.toFixed(
66+
8
67+
)}) - <a href="https://app.meteora.ag/dlmm/${position.poolKey}">🪐</a>
6968
<code>${position.poolKey}</code>
7069
7170
• <b>Bin Step:</b> ${position.pairInfo.binStep}
7271
• <b>Base Fee:</b> ${position.pairInfo.baseFeePercentage}%
7372
• <b>Max Fee:</b> ${position.pairInfo.maxFeePercentage}%
7473
7574
• <b>Pool liquidity:</b> ${formatNumber(
76-
parseFloat(position.pairInfo.liquidity)
77-
)}
75+
parseFloat(position.pairInfo.liquidity)
76+
)}
7877
• <b>Daily Yield:</b> ${position.pairInfo.apr.toFixed(2)}%
7978
• <b>24h volume:</b> ${formatNumber(position.pairInfo.tradeVolume24h)}
8079
• <b>24h fees:</b> ${formatNumber(position.pairInfo.fees24h)}
8180
8281
• <b>Range:</b> ${parseFloat(position.startBinPricePerToken).toFixed(
83-
8
84-
)} - ${parseFloat(position.lastBinPricePerToken).toFixed(8)} ${
85-
isOutRange ? "⚠️ Out of range" : ""
86-
}
82+
8
83+
)} - ${parseFloat(position.lastBinPricePerToken).toFixed(8)} ${isOutRange ? "⚠️ Out of range" : ""
84+
}
8785
• <b>${tokenXSymbol}:</b> ${tokenPercentages.tokenX}%
8886
• <b>${tokenYSymbol}:</b> ${tokenPercentages.tokenY}%
8987
9088
• <b>Liquidity:</b> $${position.totalCurrent.totalValueInTokenY.toFixed(2)}
9189
• <b>Fees Claimed:</b> $${position.totalUnclaimedFees.totalValueInTokenY.toFixed(
92-
2
93-
)}
90+
2
91+
)}
9492
• <b>Current Balance:</b> ${position.totalCurrent.tokenXBalance.toFixed(
95-
4
96-
)} ${tokenXSymbol} - ${position.totalCurrent.tokenYBalance.toFixed(
97-
4
98-
)} ${tokenYSymbol}
93+
4
94+
)} ${tokenXSymbol} - ${position.totalCurrent.tokenYBalance.toFixed(
95+
4
96+
)} ${tokenYSymbol}
9997
• <b>Unclaimed Swap Fee:</b> ${position.totalUnclaimedFees.tokenXBalance.toFixed(
100-
6
101-
)} ${tokenXSymbol} - ${position.totalUnclaimedFees.tokenYBalance.toFixed(
102-
6
103-
)} ${tokenYSymbol}
98+
6
99+
)} ${tokenXSymbol} - ${position.totalUnclaimedFees.tokenYBalance.toFixed(
100+
6
101+
)} ${tokenYSymbol}
104102
`;
105103

106104
return poolInfoMessage;
107105
}
108106

109107
export function poolsCompleteInfoMessage(pairInfo: PairInfo) {
108+
let botName = process.env.BOT_NAME;
110109
let poolInfoMessage = "";
111-
const urlPositionDetail = `https://t.me/meteora_lp_test_bot?start=pair_${pairInfo.address}`;
110+
const urlPositionDetail = `https://t.me/${botName}?start=pair_${pairInfo.address}`;
112111

113112
poolInfoMessage += `
114113
115-
<a href="${urlPositionDetail}"><b>${
116-
pairInfo.name
117-
}</b></a> - Current price (${pairInfo.currentPrice.toFixed(
118-
9
119-
)}) - <a href="https://app.meteora.ag/dlmm/${pairInfo.address}">🪐</a>
114+
<a href="${urlPositionDetail}"><b>${pairInfo.name
115+
}</b></a> - Current price (${pairInfo.currentPrice.toFixed(
116+
9
117+
)}) - <a href="https://app.meteora.ag/dlmm/${pairInfo.address}">🪐</a>
120118
<code>${pairInfo.address}</code>
121119
122120
• <b>Bin Step:</b> ${pairInfo.binStep}
@@ -135,6 +133,7 @@ export function poolsCompleteInfoMessage(pairInfo: PairInfo) {
135133
}
136134

137135
export function pairListMessage(pairResponse: PairResponse) {
136+
let botName = process.env.BOT_NAME;
138137
let pairInfoMessage = "";
139138

140139
for (var group of pairResponse.groups) {
@@ -159,8 +158,8 @@ export function pairListMessage(pairResponse: PairResponse) {
159158
return sum + (isNaN(fee) ? 0 : fee);
160159
}, 0);
161160
const numPools = group.pairs.length;
162-
const urlPairListDetail = `https://t.me/meteora_lp_test_bot?start=pairListDetail_${pairName}`;
163-
const urlPairDetail = `https://t.me/meteora_lp_test_bot?start=pair_`;
161+
const urlPairListDetail = `https://t.me/${botName}?start=pairListDetail_${pairName}`;
162+
const urlPairDetail = `https://t.me/${botName}?start=pair_`;
164163

165164
if (!isOnlyOnePool) {
166165
pairInfoMessage += `
@@ -189,6 +188,7 @@ export function pairListMessage(pairResponse: PairResponse) {
189188
}
190189

191190
export function pairListDetailMessage(pairs: Pair[]) {
191+
let botName = process.env.BOT_NAME;
192192
let pairInfoMessage = "";
193193

194194
for (var pair of pairs) {
@@ -198,15 +198,13 @@ export function pairListDetailMessage(pairs: Pair[]) {
198198
const totalTvl = parseFloat(pair.liquidity);
199199
const totalVolume24h = pair.tradeVolume24h;
200200
const totalFee24h = pair.fees24h;
201-
const urlPairDetail = `https://t.me/meteora_lp_test_bot?start=pair_`;
201+
const urlPairDetail = `https://t.me/${botName}?start=pair_`;
202202

203203
pairInfoMessage += `
204204
205-
<a href="${urlPairDetail}${
206-
pair.address
207-
}"><b>${pairName}</b></a> - <a href="https://app.meteora.ag/dlmm/${
208-
pair.address
209-
}">🪐</a>
205+
<a href="${urlPairDetail}${pair.address
206+
}"><b>${pairName}</b></a> - <a href="https://app.meteora.ag/dlmm/${pair.address
207+
}">🪐</a>
210208
<code>${pair.address}</code>
211209
212210
• <b>Bin Step:</b> ${binStep}

0 commit comments

Comments
 (0)