@andrewkimjoseph/celina-sdk 0.5.1 → 0.7.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 (47) hide show
  1. package/README.md +6 -1
  2. package/build/abis/gooddollar-broker.d.ts +77 -0
  3. package/build/abis/gooddollar-broker.js +44 -0
  4. package/build/abis/gooddollar-broker.js.map +1 -0
  5. package/build/analytics/mcp-tool-events.js +2 -0
  6. package/build/analytics/mcp-tool-events.js.map +1 -1
  7. package/build/config/gooddollar.d.ts +12 -0
  8. package/build/config/gooddollar.js +19 -0
  9. package/build/config/gooddollar.js.map +1 -1
  10. package/build/index.d.ts +3 -2
  11. package/build/index.js +1 -1
  12. package/build/index.js.map +1 -1
  13. package/build/services/ens.service.d.ts +1 -1
  14. package/build/services/ens.service.js +1 -1
  15. package/build/services/gooddollar.service.d.ts +32 -1
  16. package/build/services/gooddollar.service.js +214 -4
  17. package/build/services/gooddollar.service.js.map +1 -1
  18. package/build/services/transaction.service.d.ts +1 -1
  19. package/build/services/transaction.service.js +1 -1
  20. package/build/tools/catalog.d.ts +1 -1
  21. package/build/tools/catalog.js +2 -2
  22. package/build/tools/domains/aave.js +2 -2
  23. package/build/tools/domains/browser.d.ts +2 -0
  24. package/build/tools/domains/{celeste.js → browser.js} +7 -7
  25. package/build/tools/domains/browser.js.map +1 -0
  26. package/build/tools/domains/gooddollar.js +32 -2
  27. package/build/tools/domains/gooddollar.js.map +1 -1
  28. package/build/tools/domains/index.js +2 -2
  29. package/build/tools/domains/mento-fx.js +1 -1
  30. package/build/tools/domains/transaction.js +1 -1
  31. package/build/tools/domains/uniswap.js +1 -1
  32. package/build/tools/filter.js +1 -1
  33. package/build/tools/index.d.ts +1 -1
  34. package/build/tools/index.js +1 -1
  35. package/build/tools/schemas/common.d.ts +39 -0
  36. package/build/tools/schemas/common.js +11 -1
  37. package/build/tools/schemas/common.js.map +1 -1
  38. package/build/tools/swap-routing.d.ts +2 -2
  39. package/build/tools/swap-routing.js +68 -7
  40. package/build/tools/swap-routing.js.map +1 -1
  41. package/build/tools/types.d.ts +1 -1
  42. package/build/types/prepared.d.ts +1 -1
  43. package/package.json +1 -1
  44. package/tests/catalog/domains/defi.ts +135 -0
  45. package/tests/testing-entry.ts +1 -1
  46. package/build/tools/domains/celeste.d.ts +0 -2
  47. package/build/tools/domains/celeste.js.map +0 -1
@@ -1,5 +1,7 @@
1
1
  import type { OperationSpec } from "../types.js";
2
2
  import { assertHasKeys } from "../../helpers/assert.js";
3
+ import { getSwapQuoteWithFallback } from "../../../src/tools/swap-routing.js";
4
+ import { GOODDOLLAR_MENTO_BROKER } from "../../../src/config/gooddollar.js";
3
5
 
4
6
  function fromAddress(fx: Parameters<OperationSpec["assert"]>[1]): `0x${string}` {
5
7
  return fx.signerAddress ?? fx.wallet;
@@ -310,4 +312,137 @@ export const gooddollarOperations: OperationSpec[] = [
310
312
  assertHasKeys(result, ["hash"]);
311
313
  },
312
314
  },
315
+ {
316
+ id: "gooddollar.getReserveQuote.sell",
317
+ domain: "gooddollar",
318
+ layer: "read",
319
+ sdk: {
320
+ invoke: (client) =>
321
+ client.gooddollar.getReserveQuote("GoodDollar", "USDm", "1000"),
322
+ },
323
+ mcp: {
324
+ tool: "get_gooddollar_reserve_quote",
325
+ arguments: () => ({
326
+ token_in: "GoodDollar",
327
+ token_out: "USDm",
328
+ amount: "1000",
329
+ }),
330
+ },
331
+ assert: (result) => {
332
+ const quote = result as { protocol?: string; expectedOut?: string };
333
+ if (quote.protocol !== "gooddollar_reserve") {
334
+ throw new Error(`Expected gooddollar_reserve, got ${quote.protocol}`);
335
+ }
336
+ if (parseExpectedOut(quote.expectedOut) <= 0) {
337
+ throw new Error("Expected positive reserve output for G$ → USDm");
338
+ }
339
+ },
340
+ },
341
+ {
342
+ id: "gooddollar.getReserveQuote.buy",
343
+ domain: "gooddollar",
344
+ layer: "read",
345
+ sdk: {
346
+ invoke: (client) =>
347
+ client.gooddollar.getReserveQuote("USDm", "GoodDollar", "100"),
348
+ },
349
+ mcp: {
350
+ tool: "get_gooddollar_reserve_quote",
351
+ arguments: () => ({
352
+ token_in: "USDm",
353
+ token_out: "GoodDollar",
354
+ amount: "100",
355
+ }),
356
+ },
357
+ assert: (result) => {
358
+ const quote = result as { protocol?: string; expectedOut?: string };
359
+ if (quote.protocol !== "gooddollar_reserve") {
360
+ throw new Error(`Expected gooddollar_reserve, got ${quote.protocol}`);
361
+ }
362
+ if (parseExpectedOut(quote.expectedOut) <= 1000) {
363
+ throw new Error("Expected reserve to return substantially more G$ than Uniswap");
364
+ }
365
+ },
366
+ },
367
+ {
368
+ id: "swap.getSwapQuoteWithFallback.gdUsd",
369
+ domain: "swap",
370
+ layer: "read",
371
+ sdk: {
372
+ invoke: (client) =>
373
+ getSwapQuoteWithFallback(client, "GoodDollar", "USDm", "1000"),
374
+ },
375
+ assert: (result) => {
376
+ const quote = result as { protocol?: string };
377
+ if (quote.protocol !== "gooddollar_reserve") {
378
+ throw new Error(`Expected gooddollar_reserve, got ${quote.protocol}`);
379
+ }
380
+ },
381
+ },
382
+ {
383
+ id: "swap.getSwapQuoteWithFallback.usdGd",
384
+ domain: "swap",
385
+ layer: "read",
386
+ sdk: {
387
+ invoke: (client) =>
388
+ getSwapQuoteWithFallback(client, "USDm", "GoodDollar", "100"),
389
+ },
390
+ assert: (result) => {
391
+ const quote = result as { protocol?: string };
392
+ if (quote.protocol !== "gooddollar_reserve") {
393
+ throw new Error(`Expected gooddollar_reserve, got ${quote.protocol}`);
394
+ }
395
+ },
396
+ },
397
+ {
398
+ id: "gooddollar.prepareReserveSwap.sell",
399
+ domain: "gooddollar",
400
+ layer: "prepare",
401
+ requiresEnv: ["CELO_PRIVATE_KEY"],
402
+ sdk: {
403
+ invoke: (client, fx) =>
404
+ client.gooddollar.prepareReserveSwap(
405
+ fromAddress(fx),
406
+ "GoodDollar",
407
+ "USDm",
408
+ "1000",
409
+ ),
410
+ },
411
+ assert: (result) => {
412
+ const flow = result as { steps?: Array<{ to?: string }> };
413
+ assertHasKeys(result, ["from", "steps"]);
414
+ const last = flow.steps?.at(-1);
415
+ if (last?.to?.toLowerCase() !== GOODDOLLAR_MENTO_BROKER.toLowerCase()) {
416
+ throw new Error("Expected final reserve swap step to target MentoBroker");
417
+ }
418
+ },
419
+ },
420
+ {
421
+ id: "gooddollar.prepareReserveSwap.buy",
422
+ domain: "gooddollar",
423
+ layer: "prepare",
424
+ requiresEnv: ["CELO_PRIVATE_KEY"],
425
+ sdk: {
426
+ invoke: (client, fx) =>
427
+ client.gooddollar.prepareReserveSwap(
428
+ fromAddress(fx),
429
+ "USDm",
430
+ "GoodDollar",
431
+ "10",
432
+ ),
433
+ },
434
+ assert: (result) => {
435
+ const flow = result as { steps?: Array<{ to?: string }> };
436
+ assertHasKeys(result, ["from", "steps"]);
437
+ const last = flow.steps?.at(-1);
438
+ if (last?.to?.toLowerCase() !== GOODDOLLAR_MENTO_BROKER.toLowerCase()) {
439
+ throw new Error("Expected final reserve swap step to target MentoBroker");
440
+ }
441
+ },
442
+ },
313
443
  ];
444
+
445
+ function parseExpectedOut(value: string | undefined): number {
446
+ const n = Number(String(value ?? "").replace(/,/g, ""));
447
+ return Number.isFinite(n) ? n : 0;
448
+ }
@@ -12,7 +12,7 @@ export {
12
12
  export {
13
13
  ALL_TOOL_DEFINITIONS,
14
14
  getMcpToolNames,
15
- getCelesteToolNames,
15
+ getBrowserToolNames,
16
16
  } from "../src/tools/catalog.js";
17
17
  export { getMainnetFixtures, type MainnetFixtures } from "./fixtures/mainnet.js";
18
18
  export {
@@ -1,2 +0,0 @@
1
- import type { ToolDefinition } from "../types.js";
2
- export declare const celesteToolDefinitions: ToolDefinition[];
@@ -1 +0,0 @@
1
- {"version":3,"file":"celeste.js","sourceRoot":"","sources":["../../../src/tools/domains/celeste.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,wBAAwB,EACxB,uBAAu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