@gblin-protocol/mcp-server 0.1.0
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.
- package/LICENSE +21 -0
- package/README.md +213 -0
- package/dist/abi.d.ts +260 -0
- package/dist/abi.d.ts.map +1 -0
- package/dist/abi.js +52 -0
- package/dist/abi.js.map +1 -0
- package/dist/client.d.ts +11247 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +26 -0
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +26 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +36 -0
- package/dist/config.js.map +1 -0
- package/dist/helpers.d.ts +83 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +259 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +45 -0
- package/dist/index.js.map +1 -0
- package/dist/tools.d.ts +147 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +497 -0
- package/dist/tools.js.map +1 -0
- package/llms.txt +52 -0
- package/package.json +66 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 GBLIN Protocol
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
# GBLIN MCP Server
|
|
2
|
+
|
|
3
|
+
> **Treasury standard for AI agents on Base mainnet.** A Model Context Protocol (MCP) server that lets autonomous agents hold capital in GBLIN — a diversified, Crash-Shield-protected on-chain index — and Just-In-Time swap to USDC the millisecond they need to pay an [x402](https://docs.cdp.coinbase.com/x402/welcome) invoice.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@gblin-protocol/mcp-server)
|
|
6
|
+
[](https://github.com/gblinproject/GBLIN-MCP/actions/workflows/ci.yml)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
[](https://basescan.org/address/0x38DcDB3A381677239BBc652aed9811F2f8496345)
|
|
9
|
+
|
|
10
|
+
📖 **Full documentation and Quick Start:** [gblin.digital/agents](https://gblin.digital/agents)
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Why this exists
|
|
15
|
+
|
|
16
|
+
AI agents today hold their working capital in **USDC**. USDC sits flat: zero yield, full inflation exposure.
|
|
17
|
+
|
|
18
|
+
**GBLIN** is an on-chain index on Base (45% cbBTC + 45% WETH + 10% USDC) with an algorithmic Crash Shield that auto-rebalances toward USDC when a basket asset drops >20%. Agents holding GBLIN earn basket appreciation while keeping the ability to settle x402 invoices instantly via native one-tx atomic swaps.
|
|
19
|
+
|
|
20
|
+
This server exposes that capability to any LLM agent through the standard MCP protocol.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Quick start
|
|
25
|
+
|
|
26
|
+
### Claude Desktop
|
|
27
|
+
|
|
28
|
+
Add to `claude_desktop_config.json` (on Windows: `%APPDATA%\Claude\claude_desktop_config.json`):
|
|
29
|
+
|
|
30
|
+
```json
|
|
31
|
+
{
|
|
32
|
+
"mcpServers": {
|
|
33
|
+
"gblin": {
|
|
34
|
+
"command": "npx",
|
|
35
|
+
"args": ["-y", "@gblin-protocol/mcp-server"]
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Restart Claude Desktop. The 5 GBLIN tools appear in the tool picker.
|
|
42
|
+
|
|
43
|
+
### Windsurf / Cursor
|
|
44
|
+
|
|
45
|
+
Add to `~/.codeium/windsurf/mcp_config.json` (Windsurf) or the equivalent Cursor MCP config:
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"mcpServers": {
|
|
50
|
+
"gblin": {
|
|
51
|
+
"command": "npx",
|
|
52
|
+
"args": ["-y", "@gblin-protocol/mcp-server"],
|
|
53
|
+
"env": {
|
|
54
|
+
"GBLIN_RPC_URL": "https://base-rpc.publicnode.com"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Refresh MCP servers from the IDE settings (or restart). The tools become callable inline.
|
|
62
|
+
|
|
63
|
+
### Coinbase AgentKit (TypeScript)
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
import { MCPClient } from "@modelcontextprotocol/sdk/client/index.js";
|
|
67
|
+
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
68
|
+
|
|
69
|
+
const transport = new StdioClientTransport({
|
|
70
|
+
command: "npx",
|
|
71
|
+
args: ["-y", "@gblin-protocol/mcp-server"],
|
|
72
|
+
});
|
|
73
|
+
const client = new MCPClient({ name: "my-agent", version: "1.0.0" });
|
|
74
|
+
await client.connect(transport);
|
|
75
|
+
|
|
76
|
+
// List tools
|
|
77
|
+
const { tools } = await client.listTools();
|
|
78
|
+
|
|
79
|
+
// Quote a JIT payment of $0.50
|
|
80
|
+
const jit = await client.callTool({
|
|
81
|
+
name: "swap_gblin_to_usdc_jit",
|
|
82
|
+
arguments: { usdc_needed: "0.50", wallet_address: "0xYourAgent..." },
|
|
83
|
+
});
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### ElizaOS / custom
|
|
87
|
+
|
|
88
|
+
Any framework that speaks MCP over stdio works:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
npx @gblin-protocol/mcp-server
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Also supports Cline, Continue.dev, and any agent that implements the MCP client spec.
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## The 5 tools
|
|
99
|
+
|
|
100
|
+
| Tool | Purpose |
|
|
101
|
+
|---|---|
|
|
102
|
+
| `get_treasury_state` | NAV in USD + basket composition + Crash Shield status |
|
|
103
|
+
| `quote_safe_swap` | Preview buy or sell with dynamic slippage buffer |
|
|
104
|
+
| `swap_gblin_to_usdc_jit` | **The x402 magic**: generate atomic GBLIN→USDC calldata |
|
|
105
|
+
| `invest_usdc_to_gblin` | Convert USDC earnings into GBLIN treasury (MEV-safe) |
|
|
106
|
+
| `analyze_treasury_health` | Balances + gas + runway + rebalance advice |
|
|
107
|
+
|
|
108
|
+
All tools return structured JSON. All values are quoted on-chain (NAV via `quoteSellGBLIN` × Chainlink ETH/USD, with 24h staleness guard). No mock data.
|
|
109
|
+
|
|
110
|
+
**Live verification:** the test suite (`npm test`) runs all five tools against Base mainnet and confirms calldata generation, oracle freshness, and slippage math. See the [latest CI run](https://github.com/gblinproject/GBLIN-MCP/actions).
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## Architectural decisions
|
|
115
|
+
|
|
116
|
+
### Native atomic swap
|
|
117
|
+
|
|
118
|
+
The GBLIN contract exposes `sellGBLINForToken(amount, targetToken, fee, minOut)`. This burns GBLIN, swaps the basket → WETH → target token in a **single transaction**. No batched UserOp, no ERC-4337 dependency, no risk of half-finished JIT.
|
|
119
|
+
|
|
120
|
+
The MCP returns calldata that works identically on:
|
|
121
|
+
- **EOA wallets** (Privy, MetaMask, raw private key)
|
|
122
|
+
- **ERC-4337 smart accounts** (Safe, Coinbase smart account)
|
|
123
|
+
- **EIP-7702 delegated EOAs** (Pectra+)
|
|
124
|
+
|
|
125
|
+
### Dynamic slippage
|
|
126
|
+
|
|
127
|
+
Slippage tolerance scales with on-chain risk regime:
|
|
128
|
+
|
|
129
|
+
| Condition | Buffer |
|
|
130
|
+
|---|---|
|
|
131
|
+
| Normal market | **2.5%** |
|
|
132
|
+
| Crash Shield active (≥1 basket asset slashed) | **4.0%** |
|
|
133
|
+
|
|
134
|
+
The buffer is applied on top of the contract's internal `maxInternalSlippage` (200 bps), absorbing oracle drift and Uniswap pool variance.
|
|
135
|
+
|
|
136
|
+
### MEV protection
|
|
137
|
+
|
|
138
|
+
`invest_usdc_to_gblin` **never** passes `minOut = 0`. Both `minWethOut` and `minGblinOut` are computed from on-chain quotes plus the dynamic slippage buffer. This eliminates the sandwich-attack surface that plagues naïve buy-with-token tools.
|
|
139
|
+
|
|
140
|
+
### Cooldown enforcement
|
|
141
|
+
|
|
142
|
+
The contract enforces a 120-second sell lock after each buy. The JIT tool reads `lastDepositTime` and the **on-chain `block.timestamp`** (never `Date.now()`) and returns a clear `CooldownActive` error with the exact seconds remaining if the swap would revert.
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## Configuration
|
|
147
|
+
|
|
148
|
+
The server reads `GBLIN_RPC_URL` from the environment. With no env var it falls back to `https://base-rpc.publicnode.com` (free, no key, generous limits).
|
|
149
|
+
|
|
150
|
+
For production load (>100 concurrent agents) use a dedicated provider:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
export GBLIN_RPC_URL="https://base-mainnet.g.alchemy.com/v2/YOUR_KEY"
|
|
154
|
+
npx @gblin-protocol/mcp-server
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
See `.env.example` for the full list.
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## Development
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
git clone https://github.com/gblinproject/GBLIN-MCP
|
|
165
|
+
cd GBLIN-MCP
|
|
166
|
+
npm install
|
|
167
|
+
npm run build
|
|
168
|
+
npm test # live read-only smoke test against Base mainnet
|
|
169
|
+
npm start # run the compiled server
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Project layout:
|
|
173
|
+
|
|
174
|
+
```
|
|
175
|
+
src/
|
|
176
|
+
config.ts # network constants, addresses, slippage params
|
|
177
|
+
abi.ts # GBLIN_V5 + Chainlink + ERC-20 ABIs
|
|
178
|
+
client.ts # viem PublicClient + on-chain timestamp helper
|
|
179
|
+
helpers.ts # NAV, basket state, slippage, cooldown, reverse quote
|
|
180
|
+
tools.ts # the 5 tool implementations + zod schemas
|
|
181
|
+
index.ts # MCP stdio server entry
|
|
182
|
+
scripts/
|
|
183
|
+
test.ts # live smoke test
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## Security notes
|
|
189
|
+
|
|
190
|
+
- The server is **read-only**. It never holds, signs, or broadcasts.
|
|
191
|
+
- All quotes are derived from on-chain calls + Chainlink oracles. Stale or negative oracle answers cause the tool to abort with `OracleStale` / `OracleDead`.
|
|
192
|
+
- The agent's wallet is the sole signer. Calldata returned by tools is plain ABI-encoded bytes — review before broadcasting in untrusted environments.
|
|
193
|
+
- No telemetry, no analytics, no remote dependencies beyond the configured RPC.
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## Roadmap
|
|
198
|
+
|
|
199
|
+
- **v0.2**: Uniswap V3 QuoterV2 integration for sub-1% slippage precision
|
|
200
|
+
- **v0.3**: Permit2 support (skip the approve step for x402 reinvestment)
|
|
201
|
+
- **v0.4**: Streamable HTTP transport for hosted multi-agent setups
|
|
202
|
+
- **v1.0**: Audited contract integration + remote-only deployment guide
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## Links
|
|
207
|
+
|
|
208
|
+
- **Contract**: [0x38DcDB3A38…6345](https://basescan.org/address/0x38DcDB3A381677239BBc652aed9811F2f8496345)
|
|
209
|
+
- **Protocol site**: https://gblin.digital
|
|
210
|
+
- **Agent docs**: https://gblin.digital/agents
|
|
211
|
+
- **Issues**: https://github.com/gblinproject/GBLIN-MCP/issues
|
|
212
|
+
|
|
213
|
+
MIT © 2026 GBLIN Protocol
|
package/dist/abi.d.ts
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GBLIN MCP — Contract ABIs
|
|
3
|
+
*
|
|
4
|
+
* Verified directly against GBLIN_V5.sol source on Base mainnet.
|
|
5
|
+
* The basket() return signature exactly matches the Asset struct field order.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* GBLIN_V5 selected functions.
|
|
9
|
+
*
|
|
10
|
+
* IMPORTANT — basket() returns the Asset struct in declaration order:
|
|
11
|
+
* (token, oracle, poolFee, isStable, baseWeight, dynamicWeight, peakPrice, lastPeakUpdate)
|
|
12
|
+
*
|
|
13
|
+
* Common mistake: assuming a 5-field tuple. This caused real production bugs
|
|
14
|
+
* during the V4 audit cycle. Do not "simplify" this ABI.
|
|
15
|
+
*/
|
|
16
|
+
export declare const GBLIN_ABI: readonly [{
|
|
17
|
+
readonly name: "quoteBuyGBLIN";
|
|
18
|
+
readonly type: "function";
|
|
19
|
+
readonly stateMutability: "view";
|
|
20
|
+
readonly inputs: readonly [{
|
|
21
|
+
readonly type: "uint256";
|
|
22
|
+
readonly name: "ethAmount";
|
|
23
|
+
}];
|
|
24
|
+
readonly outputs: readonly [{
|
|
25
|
+
readonly type: "uint256";
|
|
26
|
+
readonly name: "gblinOut";
|
|
27
|
+
}, {
|
|
28
|
+
readonly type: "uint256";
|
|
29
|
+
readonly name: "founderFee";
|
|
30
|
+
}, {
|
|
31
|
+
readonly type: "uint256";
|
|
32
|
+
readonly name: "stabFee";
|
|
33
|
+
}];
|
|
34
|
+
}, {
|
|
35
|
+
readonly name: "quoteSellGBLIN";
|
|
36
|
+
readonly type: "function";
|
|
37
|
+
readonly stateMutability: "view";
|
|
38
|
+
readonly inputs: readonly [{
|
|
39
|
+
readonly type: "uint256";
|
|
40
|
+
readonly name: "gblinAmount";
|
|
41
|
+
}];
|
|
42
|
+
readonly outputs: readonly [{
|
|
43
|
+
readonly type: "uint256";
|
|
44
|
+
readonly name: "ethOut";
|
|
45
|
+
}];
|
|
46
|
+
}, {
|
|
47
|
+
readonly name: "basket";
|
|
48
|
+
readonly type: "function";
|
|
49
|
+
readonly stateMutability: "view";
|
|
50
|
+
readonly inputs: readonly [{
|
|
51
|
+
readonly type: "uint256";
|
|
52
|
+
readonly name: "index";
|
|
53
|
+
}];
|
|
54
|
+
readonly outputs: readonly [{
|
|
55
|
+
readonly type: "address";
|
|
56
|
+
readonly name: "token";
|
|
57
|
+
}, {
|
|
58
|
+
readonly type: "address";
|
|
59
|
+
readonly name: "oracle";
|
|
60
|
+
}, {
|
|
61
|
+
readonly type: "uint24";
|
|
62
|
+
readonly name: "poolFee";
|
|
63
|
+
}, {
|
|
64
|
+
readonly type: "bool";
|
|
65
|
+
readonly name: "isStable";
|
|
66
|
+
}, {
|
|
67
|
+
readonly type: "uint256";
|
|
68
|
+
readonly name: "baseWeight";
|
|
69
|
+
}, {
|
|
70
|
+
readonly type: "uint256";
|
|
71
|
+
readonly name: "dynamicWeight";
|
|
72
|
+
}, {
|
|
73
|
+
readonly type: "uint256";
|
|
74
|
+
readonly name: "peakPrice";
|
|
75
|
+
}, {
|
|
76
|
+
readonly type: "uint256";
|
|
77
|
+
readonly name: "lastPeakUpdate";
|
|
78
|
+
}];
|
|
79
|
+
}, {
|
|
80
|
+
readonly name: "balanceOf";
|
|
81
|
+
readonly type: "function";
|
|
82
|
+
readonly stateMutability: "view";
|
|
83
|
+
readonly inputs: readonly [{
|
|
84
|
+
readonly type: "address";
|
|
85
|
+
readonly name: "account";
|
|
86
|
+
}];
|
|
87
|
+
readonly outputs: readonly [{
|
|
88
|
+
readonly type: "uint256";
|
|
89
|
+
}];
|
|
90
|
+
}, {
|
|
91
|
+
readonly name: "totalSupply";
|
|
92
|
+
readonly type: "function";
|
|
93
|
+
readonly stateMutability: "view";
|
|
94
|
+
readonly inputs: readonly [];
|
|
95
|
+
readonly outputs: readonly [{
|
|
96
|
+
readonly type: "uint256";
|
|
97
|
+
}];
|
|
98
|
+
}, {
|
|
99
|
+
readonly name: "decimals";
|
|
100
|
+
readonly type: "function";
|
|
101
|
+
readonly stateMutability: "view";
|
|
102
|
+
readonly inputs: readonly [];
|
|
103
|
+
readonly outputs: readonly [{
|
|
104
|
+
readonly type: "uint8";
|
|
105
|
+
}];
|
|
106
|
+
}, {
|
|
107
|
+
readonly name: "lastDepositTime";
|
|
108
|
+
readonly type: "function";
|
|
109
|
+
readonly stateMutability: "view";
|
|
110
|
+
readonly inputs: readonly [{
|
|
111
|
+
readonly type: "address";
|
|
112
|
+
readonly name: "user";
|
|
113
|
+
}];
|
|
114
|
+
readonly outputs: readonly [{
|
|
115
|
+
readonly type: "uint256";
|
|
116
|
+
}];
|
|
117
|
+
}, {
|
|
118
|
+
readonly name: "buyGBLIN";
|
|
119
|
+
readonly type: "function";
|
|
120
|
+
readonly stateMutability: "payable";
|
|
121
|
+
readonly inputs: readonly [{
|
|
122
|
+
readonly type: "uint256";
|
|
123
|
+
readonly name: "minGblinOut";
|
|
124
|
+
}];
|
|
125
|
+
readonly outputs: readonly [];
|
|
126
|
+
}, {
|
|
127
|
+
readonly name: "sellGBLINForEth";
|
|
128
|
+
readonly type: "function";
|
|
129
|
+
readonly stateMutability: "nonpayable";
|
|
130
|
+
readonly inputs: readonly [{
|
|
131
|
+
readonly type: "uint256";
|
|
132
|
+
readonly name: "gblinAmount";
|
|
133
|
+
}, {
|
|
134
|
+
readonly type: "uint256";
|
|
135
|
+
readonly name: "minEthOut";
|
|
136
|
+
}];
|
|
137
|
+
readonly outputs: readonly [];
|
|
138
|
+
}, {
|
|
139
|
+
readonly name: "sellGBLINForToken";
|
|
140
|
+
readonly type: "function";
|
|
141
|
+
readonly stateMutability: "nonpayable";
|
|
142
|
+
readonly inputs: readonly [{
|
|
143
|
+
readonly type: "uint256";
|
|
144
|
+
readonly name: "gblinAmount";
|
|
145
|
+
}, {
|
|
146
|
+
readonly type: "address";
|
|
147
|
+
readonly name: "targetToken";
|
|
148
|
+
}, {
|
|
149
|
+
readonly type: "uint24";
|
|
150
|
+
readonly name: "wethToTargetFee";
|
|
151
|
+
}, {
|
|
152
|
+
readonly type: "uint256";
|
|
153
|
+
readonly name: "minTokenOut";
|
|
154
|
+
}];
|
|
155
|
+
readonly outputs: readonly [];
|
|
156
|
+
}, {
|
|
157
|
+
readonly name: "buyGBLINWithToken";
|
|
158
|
+
readonly type: "function";
|
|
159
|
+
readonly stateMutability: "nonpayable";
|
|
160
|
+
readonly inputs: readonly [{
|
|
161
|
+
readonly type: "bytes";
|
|
162
|
+
readonly name: "path";
|
|
163
|
+
}, {
|
|
164
|
+
readonly type: "uint256";
|
|
165
|
+
readonly name: "amountIn";
|
|
166
|
+
}, {
|
|
167
|
+
readonly type: "uint256";
|
|
168
|
+
readonly name: "minWethOut";
|
|
169
|
+
}, {
|
|
170
|
+
readonly type: "uint256";
|
|
171
|
+
readonly name: "minGblinOut";
|
|
172
|
+
}];
|
|
173
|
+
readonly outputs: readonly [];
|
|
174
|
+
}];
|
|
175
|
+
/**
|
|
176
|
+
* Chainlink AggregatorV3Interface — only the read we need.
|
|
177
|
+
* Note: `answer` is int256 (can be negative — we guard against that).
|
|
178
|
+
*/
|
|
179
|
+
export declare const CHAINLINK_AGGREGATOR_ABI: readonly [{
|
|
180
|
+
readonly name: "latestRoundData";
|
|
181
|
+
readonly type: "function";
|
|
182
|
+
readonly stateMutability: "view";
|
|
183
|
+
readonly inputs: readonly [];
|
|
184
|
+
readonly outputs: readonly [{
|
|
185
|
+
readonly type: "uint80";
|
|
186
|
+
readonly name: "roundId";
|
|
187
|
+
}, {
|
|
188
|
+
readonly type: "int256";
|
|
189
|
+
readonly name: "answer";
|
|
190
|
+
}, {
|
|
191
|
+
readonly type: "uint256";
|
|
192
|
+
readonly name: "startedAt";
|
|
193
|
+
}, {
|
|
194
|
+
readonly type: "uint256";
|
|
195
|
+
readonly name: "updatedAt";
|
|
196
|
+
}, {
|
|
197
|
+
readonly type: "uint80";
|
|
198
|
+
readonly name: "answeredInRound";
|
|
199
|
+
}];
|
|
200
|
+
}, {
|
|
201
|
+
readonly name: "decimals";
|
|
202
|
+
readonly type: "function";
|
|
203
|
+
readonly stateMutability: "view";
|
|
204
|
+
readonly inputs: readonly [];
|
|
205
|
+
readonly outputs: readonly [{
|
|
206
|
+
readonly type: "uint8";
|
|
207
|
+
}];
|
|
208
|
+
}];
|
|
209
|
+
/**
|
|
210
|
+
* Standard ERC-20 (USDC, etc).
|
|
211
|
+
*/
|
|
212
|
+
export declare const ERC20_ABI: readonly [{
|
|
213
|
+
readonly name: "balanceOf";
|
|
214
|
+
readonly type: "function";
|
|
215
|
+
readonly stateMutability: "view";
|
|
216
|
+
readonly inputs: readonly [{
|
|
217
|
+
readonly type: "address";
|
|
218
|
+
readonly name: "account";
|
|
219
|
+
}];
|
|
220
|
+
readonly outputs: readonly [{
|
|
221
|
+
readonly type: "uint256";
|
|
222
|
+
}];
|
|
223
|
+
}, {
|
|
224
|
+
readonly name: "decimals";
|
|
225
|
+
readonly type: "function";
|
|
226
|
+
readonly stateMutability: "view";
|
|
227
|
+
readonly inputs: readonly [];
|
|
228
|
+
readonly outputs: readonly [{
|
|
229
|
+
readonly type: "uint8";
|
|
230
|
+
}];
|
|
231
|
+
}, {
|
|
232
|
+
readonly name: "approve";
|
|
233
|
+
readonly type: "function";
|
|
234
|
+
readonly stateMutability: "nonpayable";
|
|
235
|
+
readonly inputs: readonly [{
|
|
236
|
+
readonly type: "address";
|
|
237
|
+
readonly name: "spender";
|
|
238
|
+
}, {
|
|
239
|
+
readonly type: "uint256";
|
|
240
|
+
readonly name: "amount";
|
|
241
|
+
}];
|
|
242
|
+
readonly outputs: readonly [{
|
|
243
|
+
readonly type: "bool";
|
|
244
|
+
}];
|
|
245
|
+
}, {
|
|
246
|
+
readonly name: "allowance";
|
|
247
|
+
readonly type: "function";
|
|
248
|
+
readonly stateMutability: "view";
|
|
249
|
+
readonly inputs: readonly [{
|
|
250
|
+
readonly type: "address";
|
|
251
|
+
readonly name: "owner";
|
|
252
|
+
}, {
|
|
253
|
+
readonly type: "address";
|
|
254
|
+
readonly name: "spender";
|
|
255
|
+
}];
|
|
256
|
+
readonly outputs: readonly [{
|
|
257
|
+
readonly type: "uint256";
|
|
258
|
+
}];
|
|
259
|
+
}];
|
|
260
|
+
//# sourceMappingURL=abi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abi.d.ts","sourceRoot":"","sources":["../src/abi.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqBpB,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGnC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKpB,CAAC"}
|
package/dist/abi.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GBLIN MCP — Contract ABIs
|
|
3
|
+
*
|
|
4
|
+
* Verified directly against GBLIN_V5.sol source on Base mainnet.
|
|
5
|
+
* The basket() return signature exactly matches the Asset struct field order.
|
|
6
|
+
*/
|
|
7
|
+
import { parseAbi } from "viem";
|
|
8
|
+
/**
|
|
9
|
+
* GBLIN_V5 selected functions.
|
|
10
|
+
*
|
|
11
|
+
* IMPORTANT — basket() returns the Asset struct in declaration order:
|
|
12
|
+
* (token, oracle, poolFee, isStable, baseWeight, dynamicWeight, peakPrice, lastPeakUpdate)
|
|
13
|
+
*
|
|
14
|
+
* Common mistake: assuming a 5-field tuple. This caused real production bugs
|
|
15
|
+
* during the V4 audit cycle. Do not "simplify" this ABI.
|
|
16
|
+
*/
|
|
17
|
+
export const GBLIN_ABI = parseAbi([
|
|
18
|
+
// Quotes (view, gas-free)
|
|
19
|
+
"function quoteBuyGBLIN(uint256 ethAmount) view returns (uint256 gblinOut, uint256 founderFee, uint256 stabFee)",
|
|
20
|
+
"function quoteSellGBLIN(uint256 gblinAmount) view returns (uint256 ethOut)",
|
|
21
|
+
// Basket — full struct, 8 fields, do not truncate
|
|
22
|
+
"function basket(uint256 index) view returns (address token, address oracle, uint24 poolFee, bool isStable, uint256 baseWeight, uint256 dynamicWeight, uint256 peakPrice, uint256 lastPeakUpdate)",
|
|
23
|
+
// ERC-20 surface
|
|
24
|
+
"function balanceOf(address account) view returns (uint256)",
|
|
25
|
+
"function totalSupply() view returns (uint256)",
|
|
26
|
+
"function decimals() view returns (uint8)",
|
|
27
|
+
// State helpers
|
|
28
|
+
"function lastDepositTime(address user) view returns (uint256)",
|
|
29
|
+
// Mutating — only used to build calldata (never executed by the MCP server)
|
|
30
|
+
"function buyGBLIN(uint256 minGblinOut) payable",
|
|
31
|
+
"function sellGBLINForEth(uint256 gblinAmount, uint256 minEthOut)",
|
|
32
|
+
"function sellGBLINForToken(uint256 gblinAmount, address targetToken, uint24 wethToTargetFee, uint256 minTokenOut)",
|
|
33
|
+
"function buyGBLINWithToken(bytes path, uint256 amountIn, uint256 minWethOut, uint256 minGblinOut)",
|
|
34
|
+
]);
|
|
35
|
+
/**
|
|
36
|
+
* Chainlink AggregatorV3Interface — only the read we need.
|
|
37
|
+
* Note: `answer` is int256 (can be negative — we guard against that).
|
|
38
|
+
*/
|
|
39
|
+
export const CHAINLINK_AGGREGATOR_ABI = parseAbi([
|
|
40
|
+
"function latestRoundData() view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound)",
|
|
41
|
+
"function decimals() view returns (uint8)",
|
|
42
|
+
]);
|
|
43
|
+
/**
|
|
44
|
+
* Standard ERC-20 (USDC, etc).
|
|
45
|
+
*/
|
|
46
|
+
export const ERC20_ABI = parseAbi([
|
|
47
|
+
"function balanceOf(address account) view returns (uint256)",
|
|
48
|
+
"function decimals() view returns (uint8)",
|
|
49
|
+
"function approve(address spender, uint256 amount) returns (bool)",
|
|
50
|
+
"function allowance(address owner, address spender) view returns (uint256)",
|
|
51
|
+
]);
|
|
52
|
+
//# sourceMappingURL=abi.js.map
|
package/dist/abi.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abi.js","sourceRoot":"","sources":["../src/abi.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAEhC;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,QAAQ,CAAC;IAChC,0BAA0B;IAC1B,gHAAgH;IAChH,4EAA4E;IAE5E,kDAAkD;IAClD,kMAAkM;IAElM,iBAAiB;IACjB,4DAA4D;IAC5D,+CAA+C;IAC/C,0CAA0C;IAE1C,gBAAgB;IAChB,+DAA+D;IAE/D,4EAA4E;IAC5E,gDAAgD;IAChD,kEAAkE;IAClE,mHAAmH;IACnH,mGAAmG;CACpG,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,QAAQ,CAAC;IAC/C,uIAAuI;IACvI,0CAA0C;CAC3C,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,QAAQ,CAAC;IAChC,4DAA4D;IAC5D,0CAA0C;IAC1C,kEAAkE;IAClE,2EAA2E;CAC5E,CAAC,CAAC"}
|