floe-agentkit-actions 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- floe_agentkit_actions-0.1.0/.gitignore +21 -0
- floe_agentkit_actions-0.1.0/LICENSE +21 -0
- floe_agentkit_actions-0.1.0/PKG-INFO +165 -0
- floe_agentkit_actions-0.1.0/README.md +130 -0
- floe_agentkit_actions-0.1.0/examples/.env.example +11 -0
- floe_agentkit_actions-0.1.0/examples/chatbot.py +53 -0
- floe_agentkit_actions-0.1.0/examples/standalone.py +56 -0
- floe_agentkit_actions-0.1.0/pyproject.toml +68 -0
- floe_agentkit_actions-0.1.0/src/floe_agentkit_actions/__init__.py +28 -0
- floe_agentkit_actions-0.1.0/src/floe_agentkit_actions/action_provider.py +1942 -0
- floe_agentkit_actions-0.1.0/src/floe_agentkit_actions/cli/__init__.py +1 -0
- floe_agentkit_actions-0.1.0/src/floe_agentkit_actions/cli/__main__.py +13 -0
- floe_agentkit_actions-0.1.0/src/floe_agentkit_actions/cli/ai_factory.py +174 -0
- floe_agentkit_actions-0.1.0/src/floe_agentkit_actions/cli/app.py +355 -0
- floe_agentkit_actions-0.1.0/src/floe_agentkit_actions/cli/config.py +50 -0
- floe_agentkit_actions-0.1.0/src/floe_agentkit_actions/cli/display.py +56 -0
- floe_agentkit_actions-0.1.0/src/floe_agentkit_actions/cli/prompts.py +155 -0
- floe_agentkit_actions-0.1.0/src/floe_agentkit_actions/cli/wallet_factory.py +63 -0
- floe_agentkit_actions-0.1.0/src/floe_agentkit_actions/constants.py +536 -0
- floe_agentkit_actions-0.1.0/src/floe_agentkit_actions/flash_arb_bytecode.py +20 -0
- floe_agentkit_actions-0.1.0/src/floe_agentkit_actions/integrations/__init__.py +1 -0
- floe_agentkit_actions-0.1.0/src/floe_agentkit_actions/integrations/langchain.py +42 -0
- floe_agentkit_actions-0.1.0/src/floe_agentkit_actions/integrations/openai_agents.py +41 -0
- floe_agentkit_actions-0.1.0/src/floe_agentkit_actions/py.typed +0 -0
- floe_agentkit_actions-0.1.0/src/floe_agentkit_actions/schemas.py +571 -0
- floe_agentkit_actions-0.1.0/src/floe_agentkit_actions/types.py +156 -0
- floe_agentkit_actions-0.1.0/src/floe_agentkit_actions/utils.py +103 -0
- floe_agentkit_actions-0.1.0/tests/__init__.py +0 -0
- floe_agentkit_actions-0.1.0/tests/conftest.py +104 -0
- floe_agentkit_actions-0.1.0/tests/test_action_provider.py +64 -0
- floe_agentkit_actions-0.1.0/tests/test_schemas.py +210 -0
- floe_agentkit_actions-0.1.0/tests/test_utils.py +71 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.py[cod]
|
|
3
|
+
*$py.class
|
|
4
|
+
*.egg-info/
|
|
5
|
+
dist/
|
|
6
|
+
build/
|
|
7
|
+
.eggs/
|
|
8
|
+
*.egg
|
|
9
|
+
.venv/
|
|
10
|
+
venv/
|
|
11
|
+
.env
|
|
12
|
+
.env.*
|
|
13
|
+
!.env.example
|
|
14
|
+
.mypy_cache/
|
|
15
|
+
.pytest_cache/
|
|
16
|
+
.ruff_cache/
|
|
17
|
+
*.so
|
|
18
|
+
.coverage
|
|
19
|
+
htmlcov/
|
|
20
|
+
.floe-agent.json
|
|
21
|
+
.wallet-data.json
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Floe
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: floe-agentkit-actions
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Coinbase AgentKit ActionProvider for Floe DeFi lending protocol on Base
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Keywords: agentkit,ai-agent,base,coinbase,defi,floe,lending
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Requires-Python: >=3.10
|
|
17
|
+
Requires-Dist: coinbase-agentkit>=0.7.0
|
|
18
|
+
Requires-Dist: pydantic>=2.0.0
|
|
19
|
+
Requires-Dist: web3>=7.0.0
|
|
20
|
+
Provides-Extra: cli
|
|
21
|
+
Requires-Dist: anthropic>=0.30.0; extra == 'cli'
|
|
22
|
+
Requires-Dist: openai>=1.0.0; extra == 'cli'
|
|
23
|
+
Requires-Dist: questionary>=2.0.0; extra == 'cli'
|
|
24
|
+
Requires-Dist: rich>=13.0.0; extra == 'cli'
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: mypy>=1.10.0; extra == 'dev'
|
|
27
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest-cov>=5.0.0; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
30
|
+
Requires-Dist: ruff>=0.4.0; extra == 'dev'
|
|
31
|
+
Provides-Extra: langchain
|
|
32
|
+
Requires-Dist: coinbase-agentkit-langchain>=0.1.0; extra == 'langchain'
|
|
33
|
+
Requires-Dist: langchain-openai>=0.1.0; extra == 'langchain'
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
|
|
36
|
+
# floe-agentkit-actions
|
|
37
|
+
|
|
38
|
+
Coinbase AgentKit ActionProvider for the **Floe DeFi lending protocol** on Base.
|
|
39
|
+
|
|
40
|
+
23 AI-agent actions for intent-based lending, flash loan arbitrage, and loan management.
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install floe-agentkit-actions
|
|
46
|
+
|
|
47
|
+
# With CLI support
|
|
48
|
+
pip install floe-agentkit-actions[cli]
|
|
49
|
+
|
|
50
|
+
# With LangChain integration
|
|
51
|
+
pip install floe-agentkit-actions[langchain]
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Quick Start
|
|
55
|
+
|
|
56
|
+
### As an AgentKit Provider
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from coinbase_agentkit import AgentKit, AgentKitConfig
|
|
60
|
+
from floe_agentkit_actions import floe_action_provider
|
|
61
|
+
|
|
62
|
+
agentkit = AgentKit(AgentKitConfig(
|
|
63
|
+
wallet_provider=wallet_provider,
|
|
64
|
+
action_providers=[floe_action_provider()],
|
|
65
|
+
))
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Standalone Usage
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
from floe_agentkit_actions import floe_action_provider
|
|
72
|
+
|
|
73
|
+
floe = floe_action_provider()
|
|
74
|
+
result = floe.get_price(wallet_provider, {
|
|
75
|
+
"collateral_token": "0x4200000000000000000000000000000000000006", # WETH
|
|
76
|
+
"loan_token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", # USDC
|
|
77
|
+
})
|
|
78
|
+
print(result)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### CLI
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
floe-agent
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Interactive AI-powered DeFi agent with support for OpenAI, Claude, and Ollama.
|
|
88
|
+
|
|
89
|
+
## Actions (23)
|
|
90
|
+
|
|
91
|
+
### Read (8)
|
|
92
|
+
- `get_markets` — Query lending market info
|
|
93
|
+
- `get_loan` — Get loan details
|
|
94
|
+
- `get_my_loans` — All loans for connected wallet
|
|
95
|
+
- `check_loan_health` — Health status and liquidation distance
|
|
96
|
+
- `get_price` — Oracle price (Chainlink + Pyth)
|
|
97
|
+
- `get_accrued_interest` — Interest accrued on a loan
|
|
98
|
+
- `get_liquidation_quote` — Liquidation profit/loss breakdown
|
|
99
|
+
- `get_intent_book` — Look up on-chain intent by hash
|
|
100
|
+
|
|
101
|
+
### Write (7)
|
|
102
|
+
- `post_lend_intent` — Post lending offer at fixed rate
|
|
103
|
+
- `post_borrow_intent` — Post borrow request with collateral
|
|
104
|
+
- `match_intents` — Match lend + borrow intents to create loan
|
|
105
|
+
- `repay_loan` — Fully or partially repay loan
|
|
106
|
+
- `add_collateral` — Add collateral to improve health
|
|
107
|
+
- `withdraw_collateral` — Withdraw excess collateral
|
|
108
|
+
- `liquidate_loan` — Liquidate unhealthy loan
|
|
109
|
+
|
|
110
|
+
### Flash Loans (5)
|
|
111
|
+
- `get_flash_loan_fee` — Query protocol flash fee
|
|
112
|
+
- `estimate_flash_arb_profit` — Simulate multi-leg arb profit
|
|
113
|
+
- `flash_loan` — Raw flash loan (receiver must be smart contract)
|
|
114
|
+
- `flash_arb` — Flash arb via FlashArbReceiver
|
|
115
|
+
- `get_flash_arb_balance` — Check accumulated profit
|
|
116
|
+
|
|
117
|
+
### Deploy (3)
|
|
118
|
+
- `deploy_flash_arb_receiver` — Deploy FlashArbReceiver with pre-flight checks
|
|
119
|
+
- `check_flash_arb_readiness` — Environment readiness check
|
|
120
|
+
- `verify_flash_arb_receiver` — Validate receiver configuration
|
|
121
|
+
|
|
122
|
+
## Wallet Providers
|
|
123
|
+
|
|
124
|
+
| Provider | Use Case |
|
|
125
|
+
|----------|----------|
|
|
126
|
+
| Private Key (`EvmWalletProvider`) | Development / scripting |
|
|
127
|
+
| CDP (`CdpWalletProvider`) | Production agents (MPC) |
|
|
128
|
+
|
|
129
|
+
## Framework Integrations
|
|
130
|
+
|
|
131
|
+
### LangChain
|
|
132
|
+
|
|
133
|
+
```python
|
|
134
|
+
from floe_agentkit_actions.integrations.langchain import get_floe_langchain_tools
|
|
135
|
+
tools = get_floe_langchain_tools(wallet_provider)
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### OpenAI Function Calling
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
from floe_agentkit_actions.integrations.openai_agents import get_floe_openai_tools
|
|
142
|
+
tools = get_floe_openai_tools(wallet_provider)
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Environment Variables
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
PRIVATE_KEY=0x... # Wallet private key
|
|
149
|
+
CDP_API_KEY_NAME=... # Coinbase CDP API key name
|
|
150
|
+
CDP_API_KEY_PRIVATE_KEY=... # Coinbase CDP API secret
|
|
151
|
+
OPENAI_API_KEY=sk-... # OpenAI (for CLI)
|
|
152
|
+
ANTHROPIC_API_KEY=sk-ant-... # Anthropic (for CLI)
|
|
153
|
+
BASE_RPC_URL=https://... # Custom Base RPC (recommended)
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Development
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
pip install -e ".[dev]"
|
|
160
|
+
pytest
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## License
|
|
164
|
+
|
|
165
|
+
MIT
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# floe-agentkit-actions
|
|
2
|
+
|
|
3
|
+
Coinbase AgentKit ActionProvider for the **Floe DeFi lending protocol** on Base.
|
|
4
|
+
|
|
5
|
+
23 AI-agent actions for intent-based lending, flash loan arbitrage, and loan management.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install floe-agentkit-actions
|
|
11
|
+
|
|
12
|
+
# With CLI support
|
|
13
|
+
pip install floe-agentkit-actions[cli]
|
|
14
|
+
|
|
15
|
+
# With LangChain integration
|
|
16
|
+
pip install floe-agentkit-actions[langchain]
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
### As an AgentKit Provider
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
from coinbase_agentkit import AgentKit, AgentKitConfig
|
|
25
|
+
from floe_agentkit_actions import floe_action_provider
|
|
26
|
+
|
|
27
|
+
agentkit = AgentKit(AgentKitConfig(
|
|
28
|
+
wallet_provider=wallet_provider,
|
|
29
|
+
action_providers=[floe_action_provider()],
|
|
30
|
+
))
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Standalone Usage
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from floe_agentkit_actions import floe_action_provider
|
|
37
|
+
|
|
38
|
+
floe = floe_action_provider()
|
|
39
|
+
result = floe.get_price(wallet_provider, {
|
|
40
|
+
"collateral_token": "0x4200000000000000000000000000000000000006", # WETH
|
|
41
|
+
"loan_token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", # USDC
|
|
42
|
+
})
|
|
43
|
+
print(result)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### CLI
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
floe-agent
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Interactive AI-powered DeFi agent with support for OpenAI, Claude, and Ollama.
|
|
53
|
+
|
|
54
|
+
## Actions (23)
|
|
55
|
+
|
|
56
|
+
### Read (8)
|
|
57
|
+
- `get_markets` — Query lending market info
|
|
58
|
+
- `get_loan` — Get loan details
|
|
59
|
+
- `get_my_loans` — All loans for connected wallet
|
|
60
|
+
- `check_loan_health` — Health status and liquidation distance
|
|
61
|
+
- `get_price` — Oracle price (Chainlink + Pyth)
|
|
62
|
+
- `get_accrued_interest` — Interest accrued on a loan
|
|
63
|
+
- `get_liquidation_quote` — Liquidation profit/loss breakdown
|
|
64
|
+
- `get_intent_book` — Look up on-chain intent by hash
|
|
65
|
+
|
|
66
|
+
### Write (7)
|
|
67
|
+
- `post_lend_intent` — Post lending offer at fixed rate
|
|
68
|
+
- `post_borrow_intent` — Post borrow request with collateral
|
|
69
|
+
- `match_intents` — Match lend + borrow intents to create loan
|
|
70
|
+
- `repay_loan` — Fully or partially repay loan
|
|
71
|
+
- `add_collateral` — Add collateral to improve health
|
|
72
|
+
- `withdraw_collateral` — Withdraw excess collateral
|
|
73
|
+
- `liquidate_loan` — Liquidate unhealthy loan
|
|
74
|
+
|
|
75
|
+
### Flash Loans (5)
|
|
76
|
+
- `get_flash_loan_fee` — Query protocol flash fee
|
|
77
|
+
- `estimate_flash_arb_profit` — Simulate multi-leg arb profit
|
|
78
|
+
- `flash_loan` — Raw flash loan (receiver must be smart contract)
|
|
79
|
+
- `flash_arb` — Flash arb via FlashArbReceiver
|
|
80
|
+
- `get_flash_arb_balance` — Check accumulated profit
|
|
81
|
+
|
|
82
|
+
### Deploy (3)
|
|
83
|
+
- `deploy_flash_arb_receiver` — Deploy FlashArbReceiver with pre-flight checks
|
|
84
|
+
- `check_flash_arb_readiness` — Environment readiness check
|
|
85
|
+
- `verify_flash_arb_receiver` — Validate receiver configuration
|
|
86
|
+
|
|
87
|
+
## Wallet Providers
|
|
88
|
+
|
|
89
|
+
| Provider | Use Case |
|
|
90
|
+
|----------|----------|
|
|
91
|
+
| Private Key (`EvmWalletProvider`) | Development / scripting |
|
|
92
|
+
| CDP (`CdpWalletProvider`) | Production agents (MPC) |
|
|
93
|
+
|
|
94
|
+
## Framework Integrations
|
|
95
|
+
|
|
96
|
+
### LangChain
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
from floe_agentkit_actions.integrations.langchain import get_floe_langchain_tools
|
|
100
|
+
tools = get_floe_langchain_tools(wallet_provider)
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### OpenAI Function Calling
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
from floe_agentkit_actions.integrations.openai_agents import get_floe_openai_tools
|
|
107
|
+
tools = get_floe_openai_tools(wallet_provider)
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Environment Variables
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
PRIVATE_KEY=0x... # Wallet private key
|
|
114
|
+
CDP_API_KEY_NAME=... # Coinbase CDP API key name
|
|
115
|
+
CDP_API_KEY_PRIVATE_KEY=... # Coinbase CDP API secret
|
|
116
|
+
OPENAI_API_KEY=sk-... # OpenAI (for CLI)
|
|
117
|
+
ANTHROPIC_API_KEY=sk-ant-... # Anthropic (for CLI)
|
|
118
|
+
BASE_RPC_URL=https://... # Custom Base RPC (recommended)
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Development
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
pip install -e ".[dev]"
|
|
125
|
+
pytest
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## License
|
|
129
|
+
|
|
130
|
+
MIT
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Wallet (choose one)
|
|
2
|
+
PRIVATE_KEY=0x...your_private_key_here
|
|
3
|
+
# CDP_API_KEY_NAME=your_cdp_api_key_name
|
|
4
|
+
# CDP_API_KEY_PRIVATE_KEY=your_cdp_api_key_private_key
|
|
5
|
+
|
|
6
|
+
# AI Provider (choose one)
|
|
7
|
+
OPENAI_API_KEY=sk-...your_openai_key
|
|
8
|
+
# ANTHROPIC_API_KEY=sk-ant-...your_anthropic_key
|
|
9
|
+
|
|
10
|
+
# Optional: Custom RPC (recommended for production)
|
|
11
|
+
# BASE_RPC_URL=https://mainnet.base.org
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"""LangChain chatbot example with Floe actions.
|
|
2
|
+
|
|
3
|
+
Run: PRIVATE_KEY=0x... OPENAI_API_KEY=sk-... python examples/chatbot.py
|
|
4
|
+
Requires: pip install floe-agentkit-actions[langchain] langchain-openai langgraph
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import os
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def main() -> None:
|
|
13
|
+
from coinbase_agentkit.wallet_providers import EvmWalletProvider
|
|
14
|
+
from langchain_openai import ChatOpenAI
|
|
15
|
+
from langgraph.prebuilt import create_react_agent
|
|
16
|
+
|
|
17
|
+
from floe_agentkit_actions.integrations.langchain import get_floe_langchain_tools
|
|
18
|
+
|
|
19
|
+
# Create wallet
|
|
20
|
+
private_key = os.environ.get("PRIVATE_KEY")
|
|
21
|
+
if not private_key:
|
|
22
|
+
print("Error: Set PRIVATE_KEY environment variable")
|
|
23
|
+
return
|
|
24
|
+
|
|
25
|
+
wallet_provider = EvmWalletProvider(
|
|
26
|
+
private_key=private_key,
|
|
27
|
+
network_id="base-mainnet",
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
# Get Floe tools as LangChain tools
|
|
31
|
+
tools = get_floe_langchain_tools(wallet_provider)
|
|
32
|
+
print(f"Loaded {len(tools)} Floe tools\n")
|
|
33
|
+
|
|
34
|
+
# Create LangChain agent
|
|
35
|
+
llm = ChatOpenAI(model="gpt-4o")
|
|
36
|
+
agent = create_react_agent(llm, tools)
|
|
37
|
+
|
|
38
|
+
# Chat loop
|
|
39
|
+
print("Floe DeFi Agent (type 'exit' to quit)\n")
|
|
40
|
+
while True:
|
|
41
|
+
user_input = input("You: ").strip()
|
|
42
|
+
if not user_input:
|
|
43
|
+
continue
|
|
44
|
+
if user_input.lower() in ("exit", "quit"):
|
|
45
|
+
break
|
|
46
|
+
|
|
47
|
+
response = agent.invoke({"messages": [("user", user_input)]})
|
|
48
|
+
last_msg = response["messages"][-1]
|
|
49
|
+
print(f"\nAssistant: {last_msg.content}\n")
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
if __name__ == "__main__":
|
|
53
|
+
main()
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"""Standalone usage of FloeActionProvider — no AI framework required.
|
|
2
|
+
|
|
3
|
+
Run: PRIVATE_KEY=0x... python examples/standalone.py
|
|
4
|
+
Requires: PRIVATE_KEY environment variable
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import os
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def main() -> None:
|
|
13
|
+
from coinbase_agentkit.wallet_providers import EvmWalletProvider
|
|
14
|
+
|
|
15
|
+
from floe_agentkit_actions import FloeConfig, floe_action_provider
|
|
16
|
+
|
|
17
|
+
# Create wallet provider
|
|
18
|
+
private_key = os.environ.get("PRIVATE_KEY")
|
|
19
|
+
if not private_key:
|
|
20
|
+
print("Error: Set PRIVATE_KEY environment variable")
|
|
21
|
+
return
|
|
22
|
+
|
|
23
|
+
rpc_url = os.environ.get("BASE_RPC_URL")
|
|
24
|
+
wallet_provider = EvmWalletProvider(
|
|
25
|
+
private_key=private_key,
|
|
26
|
+
network_id="base-mainnet",
|
|
27
|
+
**({"rpc_url": rpc_url} if rpc_url else {}),
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
address = wallet_provider.get_address()
|
|
31
|
+
print(f"Connected: {address}\n")
|
|
32
|
+
|
|
33
|
+
# Create Floe action provider
|
|
34
|
+
floe = floe_action_provider(FloeConfig())
|
|
35
|
+
|
|
36
|
+
# Example: Get oracle price
|
|
37
|
+
print("--- Oracle Price ---")
|
|
38
|
+
result = floe.get_price(wallet_provider, {
|
|
39
|
+
"collateral_token": "0x4200000000000000000000000000000000000006", # WETH
|
|
40
|
+
"loan_token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", # USDC
|
|
41
|
+
})
|
|
42
|
+
print(result)
|
|
43
|
+
|
|
44
|
+
# Example: Get my loans
|
|
45
|
+
print("\n--- My Loans ---")
|
|
46
|
+
result = floe.get_my_loans(wallet_provider, {})
|
|
47
|
+
print(result)
|
|
48
|
+
|
|
49
|
+
# Example: Check flash loan fee
|
|
50
|
+
print("\n--- Flash Loan Fee ---")
|
|
51
|
+
result = floe.get_flash_loan_fee(wallet_provider, {})
|
|
52
|
+
print(result)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
if __name__ == "__main__":
|
|
56
|
+
main()
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "floe-agentkit-actions"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Coinbase AgentKit ActionProvider for Floe DeFi lending protocol on Base"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
keywords = ["defi", "lending", "agentkit", "coinbase", "ai-agent", "floe", "base"]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 3 - Alpha",
|
|
15
|
+
"Intended Audience :: Developers",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Programming Language :: Python :: 3.10",
|
|
19
|
+
"Programming Language :: Python :: 3.11",
|
|
20
|
+
"Programming Language :: Python :: 3.12",
|
|
21
|
+
"Programming Language :: Python :: 3.13",
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
dependencies = [
|
|
25
|
+
"coinbase-agentkit>=0.7.0",
|
|
26
|
+
"web3>=7.0.0",
|
|
27
|
+
"pydantic>=2.0.0",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
[project.optional-dependencies]
|
|
31
|
+
cli = [
|
|
32
|
+
"questionary>=2.0.0",
|
|
33
|
+
"rich>=13.0.0",
|
|
34
|
+
"openai>=1.0.0",
|
|
35
|
+
"anthropic>=0.30.0",
|
|
36
|
+
]
|
|
37
|
+
langchain = [
|
|
38
|
+
"coinbase-agentkit-langchain>=0.1.0",
|
|
39
|
+
"langchain-openai>=0.1.0",
|
|
40
|
+
]
|
|
41
|
+
dev = [
|
|
42
|
+
"pytest>=8.0.0",
|
|
43
|
+
"pytest-cov>=5.0.0",
|
|
44
|
+
"pytest-asyncio>=0.23.0",
|
|
45
|
+
"ruff>=0.4.0",
|
|
46
|
+
"mypy>=1.10.0",
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
[project.scripts]
|
|
50
|
+
floe-agent = "floe_agentkit_actions.cli.__main__:main"
|
|
51
|
+
|
|
52
|
+
[tool.hatch.build.targets.wheel]
|
|
53
|
+
packages = ["src/floe_agentkit_actions"]
|
|
54
|
+
|
|
55
|
+
[tool.ruff]
|
|
56
|
+
target-version = "py310"
|
|
57
|
+
line-length = 100
|
|
58
|
+
|
|
59
|
+
[tool.ruff.lint]
|
|
60
|
+
select = ["E", "F", "I", "N", "W"]
|
|
61
|
+
|
|
62
|
+
[tool.pytest.ini_options]
|
|
63
|
+
testpaths = ["tests"]
|
|
64
|
+
asyncio_mode = "auto"
|
|
65
|
+
|
|
66
|
+
[tool.mypy]
|
|
67
|
+
python_version = "3.10"
|
|
68
|
+
strict = true
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""Coinbase AgentKit ActionProvider for Floe DeFi lending protocol on Base.
|
|
2
|
+
|
|
3
|
+
Usage::
|
|
4
|
+
|
|
5
|
+
from floe_agentkit_actions import floe_action_provider
|
|
6
|
+
|
|
7
|
+
provider = floe_action_provider()
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
from .action_provider import FloeActionProvider
|
|
13
|
+
from .types import FloeConfig
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def floe_action_provider(config: FloeConfig | None = None) -> FloeActionProvider:
|
|
17
|
+
"""Create a new FloeActionProvider instance.
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
config: Optional configuration with custom contract addresses and market IDs.
|
|
21
|
+
|
|
22
|
+
Returns:
|
|
23
|
+
A FloeActionProvider ready to register with AgentKit.
|
|
24
|
+
"""
|
|
25
|
+
return FloeActionProvider(config)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
__all__ = ["FloeActionProvider", "FloeConfig", "floe_action_provider"]
|