nebula-ai-plugin-onchain 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.
Files changed (54) hide show
  1. package/README.md +26 -0
  2. package/abis/erc20.json +78 -0
  3. package/abis/factory.json +236 -0
  4. package/abis/gimo-pool.json +53 -0
  5. package/abis/multicall3.json +76 -0
  6. package/abis/quoter.json +193 -0
  7. package/abis/stog.json +58 -0
  8. package/abis/swap-router.json +565 -0
  9. package/abis/weth9.json +65 -0
  10. package/data/tokens.json +94 -0
  11. package/package.json +52 -0
  12. package/src/aave.ts +193 -0
  13. package/src/abis.ts +84 -0
  14. package/src/allowance.ts +77 -0
  15. package/src/analysis.ts +195 -0
  16. package/src/approval.ts +99 -0
  17. package/src/balances.ts +262 -0
  18. package/src/bybit.ts +118 -0
  19. package/src/constants.ts +102 -0
  20. package/src/defillama.ts +127 -0
  21. package/src/guidance.ts +23 -0
  22. package/src/index.ts +139 -0
  23. package/src/mint-block.ts +53 -0
  24. package/src/moe.ts +111 -0
  25. package/src/nansen.ts +85 -0
  26. package/src/policy.ts +213 -0
  27. package/src/quoter.ts +87 -0
  28. package/src/raw-logs.ts +49 -0
  29. package/src/risk.ts +79 -0
  30. package/src/simulate.ts +121 -0
  31. package/src/swap.ts +108 -0
  32. package/src/tokens.ts +232 -0
  33. package/src/tools/aave.ts +425 -0
  34. package/src/tools/account-balance.ts +67 -0
  35. package/src/tools/account.ts +111 -0
  36. package/src/tools/analysis.ts +371 -0
  37. package/src/tools/balance.ts +119 -0
  38. package/src/tools/blockchain.ts +95 -0
  39. package/src/tools/cex.ts +54 -0
  40. package/src/tools/defillama.ts +83 -0
  41. package/src/tools/generic.ts +213 -0
  42. package/src/tools/identity.ts +139 -0
  43. package/src/tools/moe.ts +245 -0
  44. package/src/tools/nansen.ts +71 -0
  45. package/src/tools/policy-show.ts +74 -0
  46. package/src/tools/risk.ts +134 -0
  47. package/src/tools/simulate-tx.ts +98 -0
  48. package/src/tools/swap-best.ts +218 -0
  49. package/src/tools/swap.ts +253 -0
  50. package/src/tools/tokens-info.ts +49 -0
  51. package/src/tools/transfer.ts +164 -0
  52. package/src/tools/wrap.ts +183 -0
  53. package/src/types.ts +53 -0
  54. package/src/wait-receipt.ts +34 -0
package/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # nebula-ai-plugin-onchain
2
+
3
+ The **Mantle limbs** for **nebula** — the brain tools that do real on-chain work,
4
+ every value-moving call routed through the deterministic policy → simulation →
5
+ approval pipeline:
6
+
7
+ - **Wallet / account** — `account.info`, `chain.balance`, `tokens.info`
8
+ - **Transfers** — `chain.send`, `chain.wrap`, `chain.unwrap`
9
+ - **Trading** — `swap.best` / `swap.compare` (**Agni Finance** + **Merchant Moe**
10
+ best-execution), `swap.quote` / `swap.execute`, `moe.quote` / `moe.swap`
11
+ - **Lending** — full **Aave V3** suite: `aave.markets` / `position` / `supply` /
12
+ `withdraw` / `borrow` / `repay`
13
+ - **Discovery + risk** — `defi.yields` (DeFiLlama), `risk.token`, `nansen.labels`,
14
+ `cex.balance` (Bybit, read-only)
15
+ - **Identity** — `identity.resolve` / `identity.register` (**ERC-8004** Trustless
16
+ Agents)
17
+ - **Controls + analysis** — `policy.show`, `tx.simulate`, `chain.read` /
18
+ `chain.write`, `chain.tx` / `chain.contract` / `chain.activity`, `chain.block` /
19
+ `chain.gas`
20
+
21
+ ## Install
22
+
23
+ Auto-installed with [`nebula-treasury`](https://www.npmjs.com/package/nebula-treasury).
24
+ Or directly: `bun add nebula-ai-plugin-onchain`.
25
+
26
+ See the [root README](https://github.com/rstfulzz/nebula#readme) for the full tool reference.
@@ -0,0 +1,78 @@
1
+ [
2
+ {
3
+ "type": "function",
4
+ "name": "name",
5
+ "inputs": [],
6
+ "outputs": [{ "name": "", "type": "string" }],
7
+ "stateMutability": "view"
8
+ },
9
+ {
10
+ "type": "function",
11
+ "name": "symbol",
12
+ "inputs": [],
13
+ "outputs": [{ "name": "", "type": "string" }],
14
+ "stateMutability": "view"
15
+ },
16
+ {
17
+ "type": "function",
18
+ "name": "decimals",
19
+ "inputs": [],
20
+ "outputs": [{ "name": "", "type": "uint8" }],
21
+ "stateMutability": "view"
22
+ },
23
+ {
24
+ "type": "function",
25
+ "name": "totalSupply",
26
+ "inputs": [],
27
+ "outputs": [{ "name": "", "type": "uint256" }],
28
+ "stateMutability": "view"
29
+ },
30
+ {
31
+ "type": "function",
32
+ "name": "balanceOf",
33
+ "inputs": [{ "name": "account", "type": "address" }],
34
+ "outputs": [{ "name": "", "type": "uint256" }],
35
+ "stateMutability": "view"
36
+ },
37
+ {
38
+ "type": "function",
39
+ "name": "allowance",
40
+ "inputs": [{ "name": "owner", "type": "address" }, { "name": "spender", "type": "address" }],
41
+ "outputs": [{ "name": "", "type": "uint256" }],
42
+ "stateMutability": "view"
43
+ },
44
+ {
45
+ "type": "function",
46
+ "name": "transfer",
47
+ "inputs": [{ "name": "to", "type": "address" }, { "name": "amount", "type": "uint256" }],
48
+ "outputs": [{ "name": "", "type": "bool" }],
49
+ "stateMutability": "nonpayable"
50
+ },
51
+ {
52
+ "type": "function",
53
+ "name": "approve",
54
+ "inputs": [{ "name": "spender", "type": "address" }, { "name": "amount", "type": "uint256" }],
55
+ "outputs": [{ "name": "", "type": "bool" }],
56
+ "stateMutability": "nonpayable"
57
+ },
58
+ {
59
+ "type": "event",
60
+ "name": "Transfer",
61
+ "inputs": [
62
+ { "name": "from", "type": "address", "indexed": true },
63
+ { "name": "to", "type": "address", "indexed": true },
64
+ { "name": "value", "type": "uint256", "indexed": false }
65
+ ],
66
+ "anonymous": false
67
+ },
68
+ {
69
+ "type": "event",
70
+ "name": "Approval",
71
+ "inputs": [
72
+ { "name": "owner", "type": "address", "indexed": true },
73
+ { "name": "spender", "type": "address", "indexed": true },
74
+ { "name": "value", "type": "uint256", "indexed": false }
75
+ ],
76
+ "anonymous": false
77
+ }
78
+ ]
@@ -0,0 +1,236 @@
1
+ [
2
+ {
3
+ "inputs": [],
4
+ "stateMutability": "nonpayable",
5
+ "type": "constructor"
6
+ },
7
+ {
8
+ "anonymous": false,
9
+ "inputs": [
10
+ {
11
+ "indexed": true,
12
+ "internalType": "uint24",
13
+ "name": "fee",
14
+ "type": "uint24"
15
+ },
16
+ {
17
+ "indexed": true,
18
+ "internalType": "int24",
19
+ "name": "tickSpacing",
20
+ "type": "int24"
21
+ }
22
+ ],
23
+ "name": "FeeAmountEnabled",
24
+ "type": "event"
25
+ },
26
+ {
27
+ "anonymous": false,
28
+ "inputs": [
29
+ {
30
+ "indexed": true,
31
+ "internalType": "address",
32
+ "name": "oldOwner",
33
+ "type": "address"
34
+ },
35
+ {
36
+ "indexed": true,
37
+ "internalType": "address",
38
+ "name": "newOwner",
39
+ "type": "address"
40
+ }
41
+ ],
42
+ "name": "OwnerChanged",
43
+ "type": "event"
44
+ },
45
+ {
46
+ "anonymous": false,
47
+ "inputs": [
48
+ {
49
+ "indexed": true,
50
+ "internalType": "address",
51
+ "name": "token0",
52
+ "type": "address"
53
+ },
54
+ {
55
+ "indexed": true,
56
+ "internalType": "address",
57
+ "name": "token1",
58
+ "type": "address"
59
+ },
60
+ {
61
+ "indexed": true,
62
+ "internalType": "uint24",
63
+ "name": "fee",
64
+ "type": "uint24"
65
+ },
66
+ {
67
+ "indexed": false,
68
+ "internalType": "int24",
69
+ "name": "tickSpacing",
70
+ "type": "int24"
71
+ },
72
+ {
73
+ "indexed": false,
74
+ "internalType": "address",
75
+ "name": "pool",
76
+ "type": "address"
77
+ }
78
+ ],
79
+ "name": "PoolCreated",
80
+ "type": "event"
81
+ },
82
+ {
83
+ "inputs": [
84
+ {
85
+ "internalType": "address",
86
+ "name": "tokenA",
87
+ "type": "address"
88
+ },
89
+ {
90
+ "internalType": "address",
91
+ "name": "tokenB",
92
+ "type": "address"
93
+ },
94
+ {
95
+ "internalType": "uint24",
96
+ "name": "fee",
97
+ "type": "uint24"
98
+ }
99
+ ],
100
+ "name": "createPool",
101
+ "outputs": [
102
+ {
103
+ "internalType": "address",
104
+ "name": "pool",
105
+ "type": "address"
106
+ }
107
+ ],
108
+ "stateMutability": "nonpayable",
109
+ "type": "function"
110
+ },
111
+ {
112
+ "inputs": [
113
+ {
114
+ "internalType": "uint24",
115
+ "name": "fee",
116
+ "type": "uint24"
117
+ },
118
+ {
119
+ "internalType": "int24",
120
+ "name": "tickSpacing",
121
+ "type": "int24"
122
+ }
123
+ ],
124
+ "name": "enableFeeAmount",
125
+ "outputs": [],
126
+ "stateMutability": "nonpayable",
127
+ "type": "function"
128
+ },
129
+ {
130
+ "inputs": [
131
+ {
132
+ "internalType": "uint24",
133
+ "name": "",
134
+ "type": "uint24"
135
+ }
136
+ ],
137
+ "name": "feeAmountTickSpacing",
138
+ "outputs": [
139
+ {
140
+ "internalType": "int24",
141
+ "name": "",
142
+ "type": "int24"
143
+ }
144
+ ],
145
+ "stateMutability": "view",
146
+ "type": "function"
147
+ },
148
+ {
149
+ "inputs": [
150
+ {
151
+ "internalType": "address",
152
+ "name": "",
153
+ "type": "address"
154
+ },
155
+ {
156
+ "internalType": "address",
157
+ "name": "",
158
+ "type": "address"
159
+ },
160
+ {
161
+ "internalType": "uint24",
162
+ "name": "",
163
+ "type": "uint24"
164
+ }
165
+ ],
166
+ "name": "getPool",
167
+ "outputs": [
168
+ {
169
+ "internalType": "address",
170
+ "name": "",
171
+ "type": "address"
172
+ }
173
+ ],
174
+ "stateMutability": "view",
175
+ "type": "function"
176
+ },
177
+ {
178
+ "inputs": [],
179
+ "name": "owner",
180
+ "outputs": [
181
+ {
182
+ "internalType": "address",
183
+ "name": "",
184
+ "type": "address"
185
+ }
186
+ ],
187
+ "stateMutability": "view",
188
+ "type": "function"
189
+ },
190
+ {
191
+ "inputs": [],
192
+ "name": "parameters",
193
+ "outputs": [
194
+ {
195
+ "internalType": "address",
196
+ "name": "factory",
197
+ "type": "address"
198
+ },
199
+ {
200
+ "internalType": "address",
201
+ "name": "token0",
202
+ "type": "address"
203
+ },
204
+ {
205
+ "internalType": "address",
206
+ "name": "token1",
207
+ "type": "address"
208
+ },
209
+ {
210
+ "internalType": "uint24",
211
+ "name": "fee",
212
+ "type": "uint24"
213
+ },
214
+ {
215
+ "internalType": "int24",
216
+ "name": "tickSpacing",
217
+ "type": "int24"
218
+ }
219
+ ],
220
+ "stateMutability": "view",
221
+ "type": "function"
222
+ },
223
+ {
224
+ "inputs": [
225
+ {
226
+ "internalType": "address",
227
+ "name": "_owner",
228
+ "type": "address"
229
+ }
230
+ ],
231
+ "name": "setOwner",
232
+ "outputs": [],
233
+ "stateMutability": "nonpayable",
234
+ "type": "function"
235
+ }
236
+ ]
@@ -0,0 +1,53 @@
1
+ [
2
+ {
3
+ "type": "function",
4
+ "name": "stake",
5
+ "inputs": [{ "name": "referrer", "type": "string" }],
6
+ "outputs": [],
7
+ "stateMutability": "payable"
8
+ },
9
+ {
10
+ "type": "function",
11
+ "name": "unstake",
12
+ "inputs": [{ "name": "amount", "type": "uint256" }],
13
+ "outputs": [],
14
+ "stateMutability": "nonpayable"
15
+ },
16
+ {
17
+ "type": "function",
18
+ "name": "withdraw",
19
+ "inputs": [],
20
+ "outputs": [],
21
+ "stateMutability": "nonpayable"
22
+ },
23
+ {
24
+ "type": "event",
25
+ "name": "Staked",
26
+ "inputs": [
27
+ { "name": "user", "type": "address", "indexed": true },
28
+ { "name": "amount0g", "type": "uint256", "indexed": false },
29
+ { "name": "stogMinted", "type": "uint256", "indexed": false },
30
+ { "name": "referrer", "type": "string", "indexed": false }
31
+ ],
32
+ "anonymous": false
33
+ },
34
+ {
35
+ "type": "event",
36
+ "name": "Unstaked",
37
+ "inputs": [
38
+ { "name": "user", "type": "address", "indexed": true },
39
+ { "name": "stogBurned", "type": "uint256", "indexed": false },
40
+ { "name": "amount0g", "type": "uint256", "indexed": false }
41
+ ],
42
+ "anonymous": false
43
+ },
44
+ {
45
+ "type": "event",
46
+ "name": "Withdrawn",
47
+ "inputs": [
48
+ { "name": "user", "type": "address", "indexed": true },
49
+ { "name": "amount0g", "type": "uint256", "indexed": false }
50
+ ],
51
+ "anonymous": false
52
+ }
53
+ ]
@@ -0,0 +1,76 @@
1
+ [
2
+ {
3
+ "type": "function",
4
+ "name": "aggregate3",
5
+ "inputs": [
6
+ {
7
+ "name": "calls",
8
+ "type": "tuple[]",
9
+ "components": [
10
+ { "name": "target", "type": "address" },
11
+ { "name": "allowFailure", "type": "bool" },
12
+ { "name": "callData", "type": "bytes" }
13
+ ]
14
+ }
15
+ ],
16
+ "outputs": [
17
+ {
18
+ "name": "returnData",
19
+ "type": "tuple[]",
20
+ "components": [
21
+ { "name": "success", "type": "bool" },
22
+ { "name": "returnData", "type": "bytes" }
23
+ ]
24
+ }
25
+ ],
26
+ "stateMutability": "payable"
27
+ },
28
+ {
29
+ "type": "function",
30
+ "name": "aggregate3Value",
31
+ "inputs": [
32
+ {
33
+ "name": "calls",
34
+ "type": "tuple[]",
35
+ "components": [
36
+ { "name": "target", "type": "address" },
37
+ { "name": "allowFailure", "type": "bool" },
38
+ { "name": "value", "type": "uint256" },
39
+ { "name": "callData", "type": "bytes" }
40
+ ]
41
+ }
42
+ ],
43
+ "outputs": [
44
+ {
45
+ "name": "returnData",
46
+ "type": "tuple[]",
47
+ "components": [
48
+ { "name": "success", "type": "bool" },
49
+ { "name": "returnData", "type": "bytes" }
50
+ ]
51
+ }
52
+ ],
53
+ "stateMutability": "payable"
54
+ },
55
+ {
56
+ "type": "function",
57
+ "name": "getEthBalance",
58
+ "inputs": [{ "name": "addr", "type": "address" }],
59
+ "outputs": [{ "name": "balance", "type": "uint256" }],
60
+ "stateMutability": "view"
61
+ },
62
+ {
63
+ "type": "function",
64
+ "name": "getBlockNumber",
65
+ "inputs": [],
66
+ "outputs": [{ "name": "blockNumber", "type": "uint256" }],
67
+ "stateMutability": "view"
68
+ },
69
+ {
70
+ "type": "function",
71
+ "name": "getCurrentBlockTimestamp",
72
+ "inputs": [],
73
+ "outputs": [{ "name": "timestamp", "type": "uint256" }],
74
+ "stateMutability": "view"
75
+ }
76
+ ]
@@ -0,0 +1,193 @@
1
+ [
2
+ {
3
+ "inputs": [
4
+ {
5
+ "internalType": "address",
6
+ "name": "_factory",
7
+ "type": "address"
8
+ },
9
+ {
10
+ "internalType": "address",
11
+ "name": "_WETH9",
12
+ "type": "address"
13
+ }
14
+ ],
15
+ "stateMutability": "nonpayable",
16
+ "type": "constructor"
17
+ },
18
+ {
19
+ "inputs": [],
20
+ "name": "WETH9",
21
+ "outputs": [
22
+ {
23
+ "internalType": "address",
24
+ "name": "",
25
+ "type": "address"
26
+ }
27
+ ],
28
+ "stateMutability": "view",
29
+ "type": "function"
30
+ },
31
+ {
32
+ "inputs": [],
33
+ "name": "factory",
34
+ "outputs": [
35
+ {
36
+ "internalType": "address",
37
+ "name": "",
38
+ "type": "address"
39
+ }
40
+ ],
41
+ "stateMutability": "view",
42
+ "type": "function"
43
+ },
44
+ {
45
+ "inputs": [
46
+ {
47
+ "internalType": "bytes",
48
+ "name": "path",
49
+ "type": "bytes"
50
+ },
51
+ {
52
+ "internalType": "uint256",
53
+ "name": "amountIn",
54
+ "type": "uint256"
55
+ }
56
+ ],
57
+ "name": "quoteExactInput",
58
+ "outputs": [
59
+ {
60
+ "internalType": "uint256",
61
+ "name": "amountOut",
62
+ "type": "uint256"
63
+ }
64
+ ],
65
+ "stateMutability": "nonpayable",
66
+ "type": "function"
67
+ },
68
+ {
69
+ "inputs": [
70
+ {
71
+ "internalType": "address",
72
+ "name": "tokenIn",
73
+ "type": "address"
74
+ },
75
+ {
76
+ "internalType": "address",
77
+ "name": "tokenOut",
78
+ "type": "address"
79
+ },
80
+ {
81
+ "internalType": "uint24",
82
+ "name": "fee",
83
+ "type": "uint24"
84
+ },
85
+ {
86
+ "internalType": "uint256",
87
+ "name": "amountIn",
88
+ "type": "uint256"
89
+ },
90
+ {
91
+ "internalType": "uint160",
92
+ "name": "sqrtPriceLimitX96",
93
+ "type": "uint160"
94
+ }
95
+ ],
96
+ "name": "quoteExactInputSingle",
97
+ "outputs": [
98
+ {
99
+ "internalType": "uint256",
100
+ "name": "amountOut",
101
+ "type": "uint256"
102
+ }
103
+ ],
104
+ "stateMutability": "nonpayable",
105
+ "type": "function"
106
+ },
107
+ {
108
+ "inputs": [
109
+ {
110
+ "internalType": "bytes",
111
+ "name": "path",
112
+ "type": "bytes"
113
+ },
114
+ {
115
+ "internalType": "uint256",
116
+ "name": "amountOut",
117
+ "type": "uint256"
118
+ }
119
+ ],
120
+ "name": "quoteExactOutput",
121
+ "outputs": [
122
+ {
123
+ "internalType": "uint256",
124
+ "name": "amountIn",
125
+ "type": "uint256"
126
+ }
127
+ ],
128
+ "stateMutability": "nonpayable",
129
+ "type": "function"
130
+ },
131
+ {
132
+ "inputs": [
133
+ {
134
+ "internalType": "address",
135
+ "name": "tokenIn",
136
+ "type": "address"
137
+ },
138
+ {
139
+ "internalType": "address",
140
+ "name": "tokenOut",
141
+ "type": "address"
142
+ },
143
+ {
144
+ "internalType": "uint24",
145
+ "name": "fee",
146
+ "type": "uint24"
147
+ },
148
+ {
149
+ "internalType": "uint256",
150
+ "name": "amountOut",
151
+ "type": "uint256"
152
+ },
153
+ {
154
+ "internalType": "uint160",
155
+ "name": "sqrtPriceLimitX96",
156
+ "type": "uint160"
157
+ }
158
+ ],
159
+ "name": "quoteExactOutputSingle",
160
+ "outputs": [
161
+ {
162
+ "internalType": "uint256",
163
+ "name": "amountIn",
164
+ "type": "uint256"
165
+ }
166
+ ],
167
+ "stateMutability": "nonpayable",
168
+ "type": "function"
169
+ },
170
+ {
171
+ "inputs": [
172
+ {
173
+ "internalType": "int256",
174
+ "name": "amount0Delta",
175
+ "type": "int256"
176
+ },
177
+ {
178
+ "internalType": "int256",
179
+ "name": "amount1Delta",
180
+ "type": "int256"
181
+ },
182
+ {
183
+ "internalType": "bytes",
184
+ "name": "path",
185
+ "type": "bytes"
186
+ }
187
+ ],
188
+ "name": "jaineV3SwapCallback",
189
+ "outputs": [],
190
+ "stateMutability": "view",
191
+ "type": "function"
192
+ }
193
+ ]