Skip to content

Commit 3810e24

Browse files
committed
chore: refactors data parsing and formatting in PendleDataTrackerTool
1 parent 34a48d9 commit 3810e24

File tree

2 files changed

+36
-7
lines changed

2 files changed

+36
-7
lines changed

openagent/tools/pendle/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from openagent.tools.pendle.market_analysis import PendleMarketTool
2+
from openagent.tools.pendle.voter_apy_analysis import PendleVoterApyTool
3+
from openagent.tools.pendle.data_tracker import PendleDataTrackerTool
4+
5+
__all__ = ["PendleMarketTool", "PendleVoterApyTool", "PendleDataTrackerTool"]

openagent/tools/pendle/data_tracker.py

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,23 +115,47 @@ async def __call__(self) -> str:
115115
created_at=datetime.now(UTC),
116116
)
117117

118-
# Check if TVL increased
119-
if tvl_change_percent <= 0:
120-
return "TVL has not increased, no tweet needed."
121-
122-
# Store the data
118+
# Store the data (without TVL increase check)
123119
self.session.add(stats)
124120
self.session.commit()
125121

126-
# Format response - directly use the readable format from PendleTracker
122+
# Calculate volume change
123+
volume_change = "up" if volume_today > volume_prev else "down"
124+
volume_change_pct = (
125+
((volume_today - volume_prev) / volume_prev * 100)
126+
if volume_prev > 0
127+
else 0
128+
)
129+
130+
# Format TVL change direction
131+
tvl_direction = (
132+
"up"
133+
if tvl_change_percent > 0
134+
else "down"
135+
if tvl_change_percent < 0
136+
else "flat"
137+
)
138+
139+
# Format response with explicit guidance for the AI
127140
formatted_response = f"""
128141
=== Pendle Data Statistics ===
129142
Latest TVL: {data["Latest TVL"]}
130-
TVL 24h Change: {data["TVL 24h Change"]}
143+
TVL 24h Change: {data["TVL 24h Change"]} (Direction: {tvl_direction})
131144
Total 7d Volume: {data["Total 7d Volume"]}
132145
Today's Volume: {data["Today's Volume"]}
133146
Previous Day's Volume: {data["Previous Day's Volume"]}
147+
Volume Change: {volume_change} {abs(volume_change_pct):.2f}%
134148
Statistics time: {datetime.now().strftime("%Y-%m-%d %H:%M")}
149+
150+
FORMATTED DATA FOR TWEET:
151+
- TVL: ${tvl_value / 1e9:.2f}B ({tvl_direction} {abs(tvl_change_percent):.2f}%)
152+
- Today's Volume: ${volume_today / 1e6:.2f}M ({volume_change} {abs(volume_change_pct):.2f}% from yesterday)
153+
- 7-Day Volume: ${volume_7d / 1e9:.2f}B
154+
155+
EXAMPLE TWEET FORMAT:
156+
pendle tvl at ${tvl_value / 1e9:.2f}B, {tvl_direction} {abs(tvl_change_percent):.2f}%
157+
daily volume ${volume_today / 1e6:.2f}M, {volume_change} {abs(volume_change_pct):.2f}% from yesterday
158+
yield farmers [your sarcastic comment here]
135159
"""
136160

137161
logger.info(f"{self.name} tool response: {formatted_response.strip()}.")

0 commit comments

Comments
 (0)