@andrewkimjoseph/celina 0.2.7 → 0.2.9
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/README.md +16 -4
- package/assets/logo.png +0 -0
- package/build/clients/aave-client.d.ts +2 -0
- package/build/clients/aave-client.js +3 -0
- package/build/clients/aave-client.js.map +1 -0
- package/build/clients/aave-send.d.ts +7 -0
- package/build/clients/aave-send.js +49 -0
- package/build/clients/aave-send.js.map +1 -0
- package/build/config/aave.d.ts +5 -0
- package/build/config/aave.js +6 -0
- package/build/config/aave.js.map +1 -0
- package/build/config/load-env.d.ts +1 -0
- package/build/config/load-env.js +4 -0
- package/build/config/load-env.js.map +1 -0
- package/build/context/app-context.d.ts +2 -0
- package/build/context/app-context.js +2 -0
- package/build/context/app-context.js.map +1 -1
- package/build/http.d.ts +1 -1
- package/build/http.js +1 -0
- package/build/http.js.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.js +4 -1
- package/build/index.js.map +1 -1
- package/build/server/instructions.js +2 -1
- package/build/server/instructions.js.map +1 -1
- package/build/services/aave.service.d.ts +28 -0
- package/build/services/aave.service.js +144 -0
- package/build/services/aave.service.js.map +1 -0
- package/build/tools/aave.tools.d.ts +2 -0
- package/build/tools/aave.tools.js +56 -0
- package/build/tools/aave.tools.js.map +1 -0
- package/build/tools/index.js +2 -0
- package/build/tools/index.js.map +1 -1
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="assets/logo.png" alt="Celina logo — stylized green C with a profile silhouette" width="160" />
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
<h1 align="center">Celina — Celo MCP Server</h1>
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
<p align="center">
|
|
8
|
+
<strong>Celina</strong> is an open-source <a href="https://modelcontextprotocol.io">Model Context Protocol</a> server that gives LLMs read + write access to <strong>Celo mainnet</strong> — balances, stablecoins, sends, and chain reads.
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://celina.andrewkimjoseph.com">Website</a>
|
|
13
|
+
·
|
|
14
|
+
<a href="https://www.npmjs.com/package/@andrewkimjoseph/celina">npm</a>
|
|
15
|
+
</p>
|
|
6
16
|
|
|
7
17
|
## Install
|
|
8
18
|
|
|
@@ -260,6 +270,8 @@ Token symbols are resolved case-insensitively. Legacy aliases `cUSD` and `cEUR`
|
|
|
260
270
|
| `get_mento_fx_quote` | read | Mento FX expected output (no wallet) |
|
|
261
271
|
| `estimate_mento_fx` | read* | Mento FX gas estimate (*needs encrypted or env key) |
|
|
262
272
|
| `execute_mento_fx` | write | Execute Mento FX conversion |
|
|
273
|
+
| `supply_aave_usdt` | write | Supply USDT to Aave V3 on Celo |
|
|
274
|
+
| `withdraw_aave_usdt` | write | Withdraw USDT from Aave V3 on Celo |
|
|
263
275
|
|
|
264
276
|
## Adding a new tool
|
|
265
277
|
|
|
@@ -286,7 +298,7 @@ No changes to `src/index.ts` or server bootstrap required.
|
|
|
286
298
|
## Roadmap
|
|
287
299
|
|
|
288
300
|
- [x] Mento FX routing (`get_mento_fx_quote`, `estimate_mento_fx`, `execute_mento_fx`)
|
|
289
|
-
- [
|
|
301
|
+
- [x] Aave lending tools (`supply_aave_usdt`, `withdraw_aave_usdt`)
|
|
290
302
|
- [ ] Self proof verification (`ai.self.xyz`)
|
|
291
303
|
- [ ] Self Agent ID check
|
|
292
304
|
|
package/assets/logo.png
ADDED
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aave-client.js","sourceRoot":"","sources":["../../src/clients/aave-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TransactionExecutionResult } from "@aave/client";
|
|
2
|
+
import type { ExecutionPlan } from "@aave/graphql";
|
|
3
|
+
import type { PublicClient, WalletClient } from "viem";
|
|
4
|
+
export declare function sendExecutionPlan(wallet: WalletClient, publicClient: PublicClient, plan: ExecutionPlan): Promise<{
|
|
5
|
+
result: TransactionExecutionResult;
|
|
6
|
+
approvalHash?: `0x${string}`;
|
|
7
|
+
}>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { txHash } from "@aave/types";
|
|
2
|
+
function toTxParams(request) {
|
|
3
|
+
return {
|
|
4
|
+
to: request.to,
|
|
5
|
+
data: request.data,
|
|
6
|
+
value: BigInt(request.value),
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
async function sendTransactionRequest(wallet, publicClient, request) {
|
|
10
|
+
const account = wallet.account;
|
|
11
|
+
if (!account) {
|
|
12
|
+
throw new Error("Wallet account unavailable.");
|
|
13
|
+
}
|
|
14
|
+
const chain = publicClient.chain;
|
|
15
|
+
if (!chain) {
|
|
16
|
+
throw new Error("Chain configuration missing.");
|
|
17
|
+
}
|
|
18
|
+
const hash = await wallet.sendTransaction({
|
|
19
|
+
chain,
|
|
20
|
+
account,
|
|
21
|
+
...toTxParams(request),
|
|
22
|
+
});
|
|
23
|
+
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
24
|
+
if (receipt.status === "reverted") {
|
|
25
|
+
throw new Error(`Transaction reverted: ${hash}`);
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
txHash: txHash(hash),
|
|
29
|
+
operation: request.operation ?? null,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export async function sendExecutionPlan(wallet, publicClient, plan) {
|
|
33
|
+
switch (plan.__typename) {
|
|
34
|
+
case "InsufficientBalanceError":
|
|
35
|
+
throw new Error(`Insufficient balance: required ${plan.required.value}, available ${plan.available.value}.`);
|
|
36
|
+
case "TransactionRequest": {
|
|
37
|
+
const result = await sendTransactionRequest(wallet, publicClient, plan);
|
|
38
|
+
return { result };
|
|
39
|
+
}
|
|
40
|
+
case "ApprovalRequired": {
|
|
41
|
+
const approval = await sendTransactionRequest(wallet, publicClient, plan.approval);
|
|
42
|
+
const result = await sendTransactionRequest(wallet, publicClient, plan.originalTransaction);
|
|
43
|
+
return { result, approvalHash: approval.txHash };
|
|
44
|
+
}
|
|
45
|
+
default:
|
|
46
|
+
throw new Error(`Unknown execution plan: ${plan.__typename}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=aave-send.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aave-send.js","sourceRoot":"","sources":["../../src/clients/aave-send.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,SAAS,UAAU,CAAC,OAA2B;IAC7C,OAAO;QACL,EAAE,EAAE,OAAO,CAAC,EAAmB;QAC/B,IAAI,EAAE,OAAO,CAAC,IAAqB;QACnC,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;KAC7B,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,sBAAsB,CACnC,MAAoB,EACpB,YAA0B,EAC1B,OAA2B;IAE3B,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAC/B,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACjD,CAAC;IAED,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC;IACjC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAClD,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC;QACxC,KAAK;QACL,OAAO;QACP,GAAG,UAAU,CAAC,OAAO,CAAC;KACvB,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,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celo mainnet — from bgd-labs/aave-address-book AaveV3Celo */
|
|
2
|
+
export declare const AAVE_POOL: "0x3E59A31363E2ad014dcbc521c4a0d5757d9f3402";
|
|
3
|
+
export declare const AAVE_USDT: "0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e";
|
|
4
|
+
export declare const AAVE_USDT_A_TOKEN: "0xDeE98402A302e4D707fB9bf2bac66fAEEc31e8Df";
|
|
5
|
+
export declare const AAVE_CHAIN_ID = 42220;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Aave V3 on Celo mainnet — from bgd-labs/aave-address-book AaveV3Celo */
|
|
2
|
+
export const AAVE_POOL = "0x3E59A31363E2ad014dcbc521c4a0d5757d9f3402";
|
|
3
|
+
export const AAVE_USDT = "0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e";
|
|
4
|
+
export const AAVE_USDT_A_TOKEN = "0xDeE98402A302e4D707fB9bf2bac66fAEEc31e8Df";
|
|
5
|
+
export const AAVE_CHAIN_ID = 42220;
|
|
6
|
+
//# sourceMappingURL=aave.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aave.js","sourceRoot":"","sources":["../../src/config/aave.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,MAAM,CAAC,MAAM,SAAS,GAAG,4CAAqD,CAAC;AAC/E,MAAM,CAAC,MAAM,SAAS,GAAG,4CAAqD,CAAC;AAC/E,MAAM,CAAC,MAAM,iBAAiB,GAC5B,4CAAqD,CAAC;AACxD,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-env.js","sourceRoot":"","sources":["../../src/config/load-env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,kFAAkF;AAClF,MAAM,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC"}
|
|
@@ -5,6 +5,7 @@ import { TokenService } from "../services/token.service.js";
|
|
|
5
5
|
import { TransactionService } from "../services/transaction.service.js";
|
|
6
6
|
import { MentoFxService } from "../services/mento-fx.service.js";
|
|
7
7
|
import { GoodDollarService } from "../services/gooddollar.service.js";
|
|
8
|
+
import { AaveService } from "../services/aave.service.js";
|
|
8
9
|
export interface AppContext {
|
|
9
10
|
config: {
|
|
10
11
|
hasWallet: boolean;
|
|
@@ -16,5 +17,6 @@ export interface AppContext {
|
|
|
16
17
|
transaction: TransactionService;
|
|
17
18
|
mentoFx: MentoFxService;
|
|
18
19
|
gooddollar: GoodDollarService;
|
|
20
|
+
aave: AaveService;
|
|
19
21
|
}
|
|
20
22
|
export declare function createAppContext(clientFactory: CeloClientFactory, walletAddress?: `0x${string}`): AppContext;
|
|
@@ -4,6 +4,7 @@ import { TokenService } from "../services/token.service.js";
|
|
|
4
4
|
import { TransactionService } from "../services/transaction.service.js";
|
|
5
5
|
import { MentoFxService } from "../services/mento-fx.service.js";
|
|
6
6
|
import { GoodDollarService } from "../services/gooddollar.service.js";
|
|
7
|
+
import { AaveService } from "../services/aave.service.js";
|
|
7
8
|
export function createAppContext(clientFactory, walletAddress) {
|
|
8
9
|
return {
|
|
9
10
|
config: {
|
|
@@ -16,6 +17,7 @@ export function createAppContext(clientFactory, walletAddress) {
|
|
|
16
17
|
transaction: new TransactionService(clientFactory),
|
|
17
18
|
mentoFx: new MentoFxService(clientFactory),
|
|
18
19
|
gooddollar: new GoodDollarService(clientFactory),
|
|
20
|
+
aave: new AaveService(clientFactory),
|
|
19
21
|
};
|
|
20
22
|
}
|
|
21
23
|
//# sourceMappingURL=app-context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-context.js","sourceRoot":"","sources":["../../src/context/app-context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"app-context.js","sourceRoot":"","sources":["../../src/context/app-context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAgB1D,MAAM,UAAU,gBAAgB,CAC9B,aAAgC,EAChC,aAA6B;IAE7B,OAAO;QACL,MAAM,EAAE;YACN,SAAS,EAAE,OAAO,CAAC,aAAa,CAAC;YACjC,aAAa;SACd;QACD,UAAU,EAAE,IAAI,iBAAiB,CAAC,aAAa,CAAC;QAChD,OAAO,EAAE,IAAI,cAAc,CAAC,aAAa,CAAC;QAC1C,KAAK,EAAE,IAAI,YAAY,CAAC,aAAa,CAAC;QACtC,WAAW,EAAE,IAAI,kBAAkB,CAAC,aAAa,CAAC;QAClD,OAAO,EAAE,IAAI,cAAc,CAAC,aAAa,CAAC;QAC1C,UAAU,EAAE,IAAI,iBAAiB,CAAC,aAAa,CAAC;QAChD,IAAI,EAAE,IAAI,WAAW,CAAC,aAAa,CAAC;KACrC,CAAC;AACJ,CAAC"}
|
package/build/http.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
import "./config/load-env.js";
|
package/build/http.js
CHANGED
package/build/http.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,GAAG,EAAE,MAAM,6BAA6B,CAAC;AAElD,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,OAAO,EAAE,EAAE,CAAC,CAAC;AAEvD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,6BAA6B,EAAE,CAAC;IAC/C,OAAO,CAAC,IAAI,CACV,yGAAyG,CAC1G,CAAC;AACJ,CAAC;AAED,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE;IAC/B,OAAO,CAAC,GAAG,CAAC,wCAAwC,IAAI,EAAE,CAAC,CAAC;AAC9D,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;IACxB,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;IACvC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":";AACA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,EAAE,GAAG,EAAE,MAAM,6BAA6B,CAAC;AAElD,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,OAAO,EAAE,EAAE,CAAC,CAAC;AAEvD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,6BAA6B,EAAE,CAAC;IAC/C,OAAO,CAAC,IAAI,CACV,yGAAyG,CAC1G,CAAC;AACJ,CAAC;AAED,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE;IAC/B,OAAO,CAAC,GAAG,CAAC,wCAAwC,IAAI,EAAE,CAAC,CAAC;AAC9D,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;IACxB,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;IACvC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/build/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
import "./config/load-env.js";
|
package/build/index.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import "./config/load-env.js";
|
|
2
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
4
|
import { createServer } from "./server/create-server.js";
|
|
4
5
|
async function main() {
|
|
5
6
|
const server = createServer();
|
|
6
7
|
const transport = new StdioServerTransport();
|
|
7
8
|
await server.connect(transport);
|
|
8
|
-
|
|
9
|
+
if (process.env.CELINA_DEBUG === "1") {
|
|
10
|
+
console.error("Celina running on stdio");
|
|
11
|
+
}
|
|
9
12
|
}
|
|
10
13
|
main().catch((error) => {
|
|
11
14
|
console.error("Fatal error:", error);
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,KAAK,UAAU,IAAI;IACjB,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;IAC9B,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,KAAK,UAAU,IAAI;IACjB,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;IAC9B,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,KAAK,GAAG,EAAE,CAAC;QACrC,OAAO,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC3C,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -10,7 +10,8 @@ Guidelines:
|
|
|
10
10
|
- Use get_stablecoin_balances to scan all stablecoins at once; use get_celo_balances with a tokens list for specific symbols.
|
|
11
11
|
- Use get_gooddollar_whitelisting_info to check GoodDollar IdentityV4 whitelist status, whitelisting date, and reverification progress for a wallet.
|
|
12
12
|
- Mento FX tools (get_mento_fx_quote, estimate_mento_fx, execute_mento_fx) convert between Mento oracle-priced tokens (USDm, EURm, CELO, etc.). They are unavailable when the Mento FX market is closed.
|
|
13
|
+
- Aave tools (supply_aave_usdt, withdraw_aave_usdt) supply and withdraw USDT on Aave V3 Celo. Use get_celo_balances with tokens ["USDT"] before supplying; use withdrawMax on withdraw to redeem the full supplied balance.
|
|
13
14
|
|
|
14
|
-
Future tools (add as new modules in src/tools/):
|
|
15
|
+
Future tools (add as new modules in src/tools/): Self verify, Self Agent ID check.
|
|
15
16
|
`.trim();
|
|
16
17
|
//# sourceMappingURL=instructions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instructions.js","sourceRoot":"","sources":["../../src/server/instructions.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mBAAmB,GAAG
|
|
1
|
+
{"version":3,"file":"instructions.js","sourceRoot":"","sources":["../../src/server/instructions.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;CAelC,CAAC,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { CeloClientFactory } from "../clients/celo-client.js";
|
|
2
|
+
export declare class AaveService {
|
|
3
|
+
private readonly clientFactory;
|
|
4
|
+
private readonly tokenService;
|
|
5
|
+
constructor(clientFactory: CeloClientFactory);
|
|
6
|
+
private resolveClients;
|
|
7
|
+
private formatAaveError;
|
|
8
|
+
private assertUsdtBalance;
|
|
9
|
+
private assertSuppliedBalance;
|
|
10
|
+
supplyUsdt(amount: string, encryptedPrivateKey?: string): Promise<{
|
|
11
|
+
from: `0x${string}`;
|
|
12
|
+
amount: string;
|
|
13
|
+
token: string;
|
|
14
|
+
market: "0x3E59A31363E2ad014dcbc521c4a0d5757d9f3402";
|
|
15
|
+
hash: import("@aave/types").TxHash;
|
|
16
|
+
approvalHash: `0x${string}` | undefined;
|
|
17
|
+
operation: string;
|
|
18
|
+
}>;
|
|
19
|
+
withdrawUsdt(amount: string | undefined, encryptedPrivateKey?: string, withdrawMax?: boolean): Promise<{
|
|
20
|
+
from: `0x${string}`;
|
|
21
|
+
amount: string;
|
|
22
|
+
token: string;
|
|
23
|
+
market: "0x3E59A31363E2ad014dcbc521c4a0d5757d9f3402";
|
|
24
|
+
hash: import("@aave/types").TxHash;
|
|
25
|
+
operation: string;
|
|
26
|
+
withdrawMax: boolean;
|
|
27
|
+
}>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { supply, withdraw } from "@aave/client/actions";
|
|
2
|
+
import { bigDecimal, chainId, evmAddress } from "@aave/types";
|
|
3
|
+
import { erc20Abi } from "viem";
|
|
4
|
+
import { aaveClient } from "../clients/aave-client.js";
|
|
5
|
+
import { sendExecutionPlan } from "../clients/aave-send.js";
|
|
6
|
+
import { AAVE_CHAIN_ID, AAVE_POOL, AAVE_USDT, AAVE_USDT_A_TOKEN, } from "../config/aave.js";
|
|
7
|
+
import { decryptPrivateKey } from "../crypto/wallet-key-crypto.js";
|
|
8
|
+
import { TokenService } from "./token.service.js";
|
|
9
|
+
export class AaveService {
|
|
10
|
+
clientFactory;
|
|
11
|
+
tokenService;
|
|
12
|
+
constructor(clientFactory) {
|
|
13
|
+
this.clientFactory = clientFactory;
|
|
14
|
+
this.tokenService = new TokenService(clientFactory);
|
|
15
|
+
}
|
|
16
|
+
resolveClients(encryptedPrivateKey) {
|
|
17
|
+
if (encryptedPrivateKey) {
|
|
18
|
+
const privateKey = decryptPrivateKey(encryptedPrivateKey);
|
|
19
|
+
return this.clientFactory.getClientsForAccount(privateKey);
|
|
20
|
+
}
|
|
21
|
+
const clients = this.clientFactory.getClients();
|
|
22
|
+
if (!clients.wallet || !clients.accountAddress) {
|
|
23
|
+
throw new Error("No wallet configured. Provide encryptedPrivateKey (encrypt with get_wallet_encryption_public_key) or set CELO_PRIVATE_KEY for local mode.");
|
|
24
|
+
}
|
|
25
|
+
return clients;
|
|
26
|
+
}
|
|
27
|
+
formatAaveError(error) {
|
|
28
|
+
if (error && typeof error === "object" && "name" in error && "message" in error) {
|
|
29
|
+
const named = error;
|
|
30
|
+
throw new Error(`${named.name}: ${named.message}`);
|
|
31
|
+
}
|
|
32
|
+
throw error instanceof Error ? error : new Error(String(error));
|
|
33
|
+
}
|
|
34
|
+
async assertUsdtBalance(publicClient, owner, amount) {
|
|
35
|
+
const usdt = this.tokenService.resolveToken("USDT");
|
|
36
|
+
const required = this.tokenService.parseAmount(amount, usdt.decimals);
|
|
37
|
+
const balance = await publicClient.readContract({
|
|
38
|
+
address: AAVE_USDT,
|
|
39
|
+
abi: erc20Abi,
|
|
40
|
+
functionName: "balanceOf",
|
|
41
|
+
args: [owner],
|
|
42
|
+
});
|
|
43
|
+
if (balance < required) {
|
|
44
|
+
throw new Error(`Insufficient USDT balance. Required ${amount} USDT, available ${balance.toString()} raw units.`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async assertSuppliedBalance(publicClient, owner, amount) {
|
|
48
|
+
const usdt = this.tokenService.resolveToken("USDT");
|
|
49
|
+
const required = this.tokenService.parseAmount(amount, usdt.decimals);
|
|
50
|
+
const balance = await publicClient.readContract({
|
|
51
|
+
address: AAVE_USDT_A_TOKEN,
|
|
52
|
+
abi: erc20Abi,
|
|
53
|
+
functionName: "balanceOf",
|
|
54
|
+
args: [owner],
|
|
55
|
+
});
|
|
56
|
+
if (balance < required) {
|
|
57
|
+
throw new Error(`Insufficient Aave USDT supply balance. Required ${amount} USDT, available ${balance.toString()} raw aToken units.`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
async supplyUsdt(amount, encryptedPrivateKey) {
|
|
61
|
+
const { public: publicClient, wallet, accountAddress: from } = this.resolveClients(encryptedPrivateKey);
|
|
62
|
+
if (!wallet || !from) {
|
|
63
|
+
throw new Error("Wallet client unavailable. Provide encryptedPrivateKey or set CELO_PRIVATE_KEY.");
|
|
64
|
+
}
|
|
65
|
+
await this.assertUsdtBalance(publicClient, from, amount);
|
|
66
|
+
const planResult = await supply(aaveClient, {
|
|
67
|
+
market: evmAddress(AAVE_POOL),
|
|
68
|
+
amount: {
|
|
69
|
+
erc20: {
|
|
70
|
+
currency: evmAddress(AAVE_USDT),
|
|
71
|
+
value: bigDecimal(amount),
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
sender: evmAddress(from),
|
|
75
|
+
chainId: chainId(AAVE_CHAIN_ID),
|
|
76
|
+
});
|
|
77
|
+
if (planResult.isErr()) {
|
|
78
|
+
this.formatAaveError(planResult.error);
|
|
79
|
+
}
|
|
80
|
+
const { result, approvalHash } = await sendExecutionPlan(wallet, publicClient, planResult.value);
|
|
81
|
+
const waitResult = await aaveClient.waitForTransaction(result);
|
|
82
|
+
if (waitResult.isErr()) {
|
|
83
|
+
this.formatAaveError(waitResult.error);
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
from,
|
|
87
|
+
amount,
|
|
88
|
+
token: "USDT",
|
|
89
|
+
market: AAVE_POOL,
|
|
90
|
+
hash: waitResult.value,
|
|
91
|
+
approvalHash,
|
|
92
|
+
operation: "SUPPLY",
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
async withdrawUsdt(amount, encryptedPrivateKey, withdrawMax) {
|
|
96
|
+
const { public: publicClient, wallet, accountAddress: from } = this.resolveClients(encryptedPrivateKey);
|
|
97
|
+
if (!wallet || !from) {
|
|
98
|
+
throw new Error("Wallet client unavailable. Provide encryptedPrivateKey or set CELO_PRIVATE_KEY.");
|
|
99
|
+
}
|
|
100
|
+
if (!withdrawMax && !amount) {
|
|
101
|
+
throw new Error("Provide amount or set withdrawMax to true.");
|
|
102
|
+
}
|
|
103
|
+
if (!withdrawMax && amount) {
|
|
104
|
+
await this.assertSuppliedBalance(publicClient, from, amount);
|
|
105
|
+
}
|
|
106
|
+
const withdrawAmount = withdrawMax
|
|
107
|
+
? {
|
|
108
|
+
erc20: {
|
|
109
|
+
currency: evmAddress(AAVE_USDT),
|
|
110
|
+
value: { max: true },
|
|
111
|
+
},
|
|
112
|
+
}
|
|
113
|
+
: {
|
|
114
|
+
erc20: {
|
|
115
|
+
currency: evmAddress(AAVE_USDT),
|
|
116
|
+
value: { exact: bigDecimal(amount) },
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
const planResult = await withdraw(aaveClient, {
|
|
120
|
+
market: evmAddress(AAVE_POOL),
|
|
121
|
+
amount: withdrawAmount,
|
|
122
|
+
sender: evmAddress(from),
|
|
123
|
+
chainId: chainId(AAVE_CHAIN_ID),
|
|
124
|
+
});
|
|
125
|
+
if (planResult.isErr()) {
|
|
126
|
+
this.formatAaveError(planResult.error);
|
|
127
|
+
}
|
|
128
|
+
const { result } = await sendExecutionPlan(wallet, publicClient, planResult.value);
|
|
129
|
+
const waitResult = await aaveClient.waitForTransaction(result);
|
|
130
|
+
if (waitResult.isErr()) {
|
|
131
|
+
this.formatAaveError(waitResult.error);
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
from,
|
|
135
|
+
amount: withdrawMax ? "max" : amount,
|
|
136
|
+
token: "USDT",
|
|
137
|
+
market: AAVE_POOL,
|
|
138
|
+
hash: waitResult.value,
|
|
139
|
+
operation: "WITHDRAW",
|
|
140
|
+
withdrawMax: Boolean(withdrawMax),
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=aave.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aave.service.js","sourceRoot":"","sources":["../../src/services/aave.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAEhC,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EACL,aAAa,EACb,SAAS,EACT,SAAS,EACT,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,OAAO,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AG,MAAM,UAAU,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;QAC/D,IAAI,UAAU,CAAC,KAAK,EAAE,EAAE,CAAC;YACvB,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QACzC,CAAC;QAED,OAAO;YACL,IAAI;YACJ,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAO;YACrC,KAAK,EAAE,MAAM;YACb,MAAM,EAAE,SAAS;YACjB,IAAI,EAAE,UAAU,CAAC,KAAK;YACtB,SAAS,EAAE,UAAU;YACrB,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC;SAClC,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { err, ok } from "./helpers.js";
|
|
3
|
+
const encryptedPrivateKeySchema = z
|
|
4
|
+
.string()
|
|
5
|
+
.optional()
|
|
6
|
+
.describe("RSA-OAEP encrypted private key (base64). Encrypt locally with get_wallet_encryption_public_key.");
|
|
7
|
+
export const aaveTools = {
|
|
8
|
+
register(server, ctx) {
|
|
9
|
+
server.registerTool("supply_aave_usdt", {
|
|
10
|
+
title: "Supply Aave USDT",
|
|
11
|
+
description: "Supply (lend) USDT to Aave V3 on Celo mainnet. Deposits USDT and receives aUSDT interest-bearing tokens. Sends ERC-20 approval first if needed. User must encrypt their private key with the server's public key (get_wallet_encryption_public_key) before calling.",
|
|
12
|
+
inputSchema: z.object({
|
|
13
|
+
amount: z.string().describe("Human-readable USDT amount, e.g. 100"),
|
|
14
|
+
encryptedPrivateKey: encryptedPrivateKeySchema,
|
|
15
|
+
}),
|
|
16
|
+
annotations: {
|
|
17
|
+
destructiveHint: true,
|
|
18
|
+
openWorldHint: true,
|
|
19
|
+
},
|
|
20
|
+
}, async ({ amount, encryptedPrivateKey }) => {
|
|
21
|
+
try {
|
|
22
|
+
return ok(await ctx.aave.supplyUsdt(amount, encryptedPrivateKey));
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
return err(error instanceof Error ? error.message : String(error));
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
server.registerTool("withdraw_aave_usdt", {
|
|
29
|
+
title: "Withdraw Aave USDT",
|
|
30
|
+
description: "Withdraw USDT from Aave V3 on Celo mainnet by redeeming aUSDT. User must encrypt their private key with the server's public key (get_wallet_encryption_public_key) before calling.",
|
|
31
|
+
inputSchema: z.object({
|
|
32
|
+
amount: z
|
|
33
|
+
.string()
|
|
34
|
+
.optional()
|
|
35
|
+
.describe("Human-readable USDT amount, e.g. 100 (omit when withdrawMax is true)"),
|
|
36
|
+
withdrawMax: z
|
|
37
|
+
.boolean()
|
|
38
|
+
.optional()
|
|
39
|
+
.describe("Withdraw the full supplied USDT balance from Aave"),
|
|
40
|
+
encryptedPrivateKey: encryptedPrivateKeySchema,
|
|
41
|
+
}),
|
|
42
|
+
annotations: {
|
|
43
|
+
destructiveHint: true,
|
|
44
|
+
openWorldHint: true,
|
|
45
|
+
},
|
|
46
|
+
}, async ({ amount, withdrawMax, encryptedPrivateKey }) => {
|
|
47
|
+
try {
|
|
48
|
+
return ok(await ctx.aave.withdrawUsdt(amount, encryptedPrivateKey, withdrawMax));
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
return err(error instanceof Error ? error.message : String(error));
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=aave.tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aave.tools.js","sourceRoot":"","sources":["../../src/tools/aave.tools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAEvC,MAAM,yBAAyB,GAAG,CAAC;KAChC,MAAM,EAAE;KACR,QA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WAAW,EAAE;gBACX,eAAe,EAAE,IAAI;gBACrB,aAAa,EAAE,IAAI;aACpB;SACF,EACD,KAAK,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,mBAAmB,EAAE,EAAE,EAAE;YACrD,IAAI,CAAC;gBACH,OAAO,EAAE,CACP,MAAM,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,mBAAmB,EAAE,WAAW,CAAC,CACtE,CAAC;YACJ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,GAAG,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YACrE,CAAC;QACH,CAAC,CACF,CAAC;IACJ,CAAC;CACF,CAAC"}
|
package/build/tools/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { gooddollarTools } from "./gooddollar.tools.js";
|
|
|
3
3
|
import { tokenTools } from "./token.tools.js";
|
|
4
4
|
import { transactionTools } from "./transaction.tools.js";
|
|
5
5
|
import { mentoFxTools } from "./mento-fx.tools.js";
|
|
6
|
+
import { aaveTools } from "./aave.tools.js";
|
|
6
7
|
import { walletTools } from "./wallet.tools.js";
|
|
7
8
|
export const toolModules = [
|
|
8
9
|
blockchainTools,
|
|
@@ -11,6 +12,7 @@ export const toolModules = [
|
|
|
11
12
|
walletTools,
|
|
12
13
|
transactionTools,
|
|
13
14
|
mentoFxTools,
|
|
15
|
+
aaveTools,
|
|
14
16
|
gooddollarTools,
|
|
15
17
|
];
|
|
16
18
|
export function registerAllTools(server, ctx) {
|
package/build/tools/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAA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,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC/B,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@andrewkimjoseph/celina",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"description": "Celina — MCP server for Celo mainnet. Balances, transfers, and chain reads for LLM agents.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "build/index.js",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"files": [
|
|
14
14
|
"build/",
|
|
15
15
|
"bin/",
|
|
16
|
+
"assets/",
|
|
16
17
|
"README.md",
|
|
17
18
|
"LICENSE"
|
|
18
19
|
],
|
|
@@ -40,8 +41,10 @@
|
|
|
40
41
|
"author": "Andrew Kim Joseph",
|
|
41
42
|
"license": "MIT",
|
|
42
43
|
"dependencies": {
|
|
44
|
+
"@aave/client": "^0.9.3",
|
|
43
45
|
"@mento-protocol/mento-sdk": "^3.2.8",
|
|
44
46
|
"@modelcontextprotocol/sdk": "^1.22.0",
|
|
47
|
+
"dotenv": "^17.4.2",
|
|
45
48
|
"express": "^5.2.1",
|
|
46
49
|
"viem": "^2.39.3",
|
|
47
50
|
"zod": "^3.24.3"
|