Skip to content

Commit 692d2e9

Browse files
Update SDK docs
1 parent d7dd92d commit 692d2e9

File tree

9 files changed

+2960
-2294
lines changed

9 files changed

+2960
-2294
lines changed

docs/hypernative-sdk/README.md

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
---
2+
icon: python
3+
---
4+
5+
# Hypernative Agents SDK
6+
7+
Welcome to the Invariantive SDK documentation! This comprehensive guide will help you build powerful blockchain monitoring and automation agents using our Python SDK.
8+
9+
### What is Invariantive?
10+
11+
Invariantive is a Python-based SDK for creating blockchain monitoring and automation agents. It enables you to:
12+
13+
* **Monitor on-chain events** and transactions across multiple blockchains
14+
* **Create complex calculations** and correlations
15+
* **Access historical blockchain data** for analysis
16+
* **Maintain persistent state** across executions
17+
* **Trigger automated responses** based on conditions
18+
* **Stream metrics** to dashboards and notification systems
19+
20+
### Quick Navigation
21+
22+
#### Getting Started
23+
24+
* **Installation** - Set up the SDK and configure credentials
25+
* **Core Concepts** - Understand the architecture and key components
26+
* **Quick Start** - Build your first agent in minutes
27+
28+
#### Learning and Reference
29+
30+
* **Examples** - Practical examples and common patterns
31+
* **Real-World Examples** - Production examples with advanced patterns
32+
* **Model Reference** - Complete documentation of all classes and methods
33+
* **Advanced Features** - Sophisticated patterns and techniques
34+
35+
#### Best Practices and Support
36+
37+
* **Best Practices** - Production-ready development guidelines
38+
* **Troubleshooting** - Common issues and solutions
39+
40+
### Architecture Overview
41+
42+
Every Invariantive agent consists of four main components:
43+
44+
```
45+
┌─────────────┐ ┌──────────────┐ ┌────────────┐ ┌─────────────┐
46+
│ Trigger │───▶│ Variables │───▶│ Alert │───▶│ Notification│
47+
│ │ │ │ │ │ │ │
48+
│ When to run │ │ Data extract │ │ Conditions │ │ Send alert │
49+
└─────────────┘ └──────────────┘ └────────────┘ └─────────────┘
50+
```
51+
52+
1. **Trigger**: Defines when your agent executes (every block, on events, or function calls)
53+
2. **Variables**: Extract and process data from blockchains, APIs, or custom logic
54+
3. **Alert**: Evaluate conditions and generate notifications
55+
4. **Notification**: Send alerts to configured channels
56+
57+
### Key Features
58+
59+
#### 🔗 Multi-Chain Support
60+
61+
Monitor across 80+ blockchains including Ethereum, Arbitrum, Polygon, Base, Solana, Bitcoin, StarkNet, and many more EVM and non-EVM chains.
62+
63+
#### 📊 Rich Data Sources
64+
65+
* Smart contract state reading
66+
* Historical event analysis
67+
* External API integration
68+
* Custom Python processing
69+
70+
#### 🚀 Production Ready
71+
72+
* Error handling and informative error descriptions
73+
* Object Oriented Programming
74+
* Performance optimization
75+
* Secret management
76+
* Comprehensive testing
77+
78+
#### 🔔 Flexible Alerting
79+
80+
* Multiple notification channels
81+
* Templated messages
82+
* State-based and one-shot alerts
83+
* Custom severity levels
84+
85+
### Quick Example
86+
87+
Here's a simple agent that monitors USDT total supply:
88+
89+
```python
90+
from invariantive.model.agent import Agent
91+
from invariantive.model.trigger import BlockTrigger
92+
from invariantive.model.variable import GenericContractReadVariable
93+
from invariantive.model.alert import AlertConfig
94+
from invariantive.model.run import RunConfig
95+
from invariantive.common.consts import Chain
96+
from invariantive.common.environment import set_default_chain
97+
98+
set_default_chain(Chain.ethereum)
99+
100+
# 1. Create trigger
101+
trigger = BlockTrigger(period=1, period_unit="blocks")
102+
103+
# 2. Create agent
104+
agent = Agent(trigger=trigger)
105+
106+
# 3. Add variable to monitor USDT supply
107+
supply_var = GenericContractReadVariable(
108+
contract_address="0xdAC17F958D2ee523a2206206994597C13D831ec7",
109+
func_sig="totalSupply",
110+
output_index="output_arg_0",
111+
var_name="total_supply"
112+
)
113+
agent.add_variable(supply_var)
114+
115+
# 4. Configure alert
116+
alert = AlertConfig(
117+
var_name="total_supply",
118+
operator="gt",
119+
operands=[80000000000000],
120+
description="USDT supply exceeded threshold: {{total_supply}}"
121+
)
122+
agent.set_alert(alert)
123+
124+
# 5. Test and deploy
125+
findings = agent.run(RunConfig(blocks=[0]))
126+
print("num findings:", len(findings["findings"]))
127+
for f in findings["findings"]:
128+
print(f["description"])
129+
print("extracted variables during the run:", f["extracted_variables"])
130+
agent.save_config("usdt_monitor.json")
131+
```
132+
133+
### Use Cases
134+
135+
#### DeFi Monitoring
136+
137+
* Protocol health monitoring
138+
* Liquidity pool analysis
139+
* Utilization rate monitoring
140+
* Position health monitoring
141+
142+
#### Security Monitoring
143+
144+
* Unusual transaction patterns
145+
* Update monitoring agents based on contract deployment
146+
* Integration with screener products
147+
* Cross-chain correlation
148+
149+
#### Compliance and Risk
150+
151+
* Transaction volume thresholds
152+
* Blacklist monitoring
153+
* Data streaming
154+
* Offchain data source integration via API
155+
156+
#### Portfolio Management
157+
158+
* Balance tracking
159+
* Performance analysis
160+
* Rebalancing triggers
161+
* Market opportunity detection
162+
163+
### Supported Chains
164+
165+
**EVM Compatible:**\
166+
Ethereum, Arbitrum, Base, Polygon, Optimism, Avalanche, BSC, Fantom, Gnosis, Linea, Scroll, and more
167+
168+
**Non-EVM:**\
169+
Bitcoin, Solana, Starknet
170+
171+
**Testnets:**\
172+
Ethereum Sepolia, Ethereum Holesky
173+
174+
See the Model Reference for the complete list.
175+
176+
### Learning Path
177+
178+
#### Beginner
179+
180+
1. Start with Installation
181+
2. Read Core Concepts
182+
3. Follow the Quick Start guide
183+
4. Try the basic examples in Examples
184+
185+
#### Intermediate
186+
187+
1. Explore advanced patterns in Examples
188+
2. Learn about Advanced Features
189+
3. Review Best Practices
190+
4. Build custom agents for your use case
191+
192+
#### Advanced
193+
194+
1. Master complex patterns from Advanced Features
195+
2. Implement production systems using Best Practices
196+
3. Contribute to the community with your own patterns
197+
198+
199+
200+
### What's Next?
201+
202+
Ready to start building? Choose your path:
203+
204+
* **New to blockchain monitoring?** → Start with [Core Concepts](core-concepts.md)
205+
* **Want to jump right in?** → Go to [Quick Start](quick-start.md)
206+
* **Looking for specific examples?**[Browse Examples](examples.md)
207+
* **Building for production?** → Review Best Practices
208+

0 commit comments

Comments
 (0)