@@ -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 ===
129142Latest TVL: { data ["Latest TVL" ]}
130- TVL 24h Change: { data ["TVL 24h Change" ]}
143+ TVL 24h Change: { data ["TVL 24h Change" ]} (Direction: { tvl_direction } )
131144Total 7d Volume: { data ["Total 7d Volume" ]}
132145Today's Volume: { data ["Today's Volume" ]}
133146Previous Day's Volume: { data ["Previous Day's Volume" ]}
147+ Volume Change: { volume_change } { abs (volume_change_pct ):.2f} %
134148Statistics 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