hak-saucerswap-plugin 1.0.0 → 2.0.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 Juanma Gomez
3
+ Copyright (c) 2026 Juan Manuel Gómez López
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -15,6 +15,14 @@ lets AI agents:
15
15
  - Add/remove liquidity via router transactions
16
16
  - Discover farming opportunities
17
17
 
18
+ ## Documentation
19
+
20
+ - **[Configuration](./docs/CONFIGURATION.md)** — full settings table, env vs. plugin-config
21
+ precedence, and pointers to the official SaucerSwap contract deployment list.
22
+ - **[Tools](./docs/TOOLS.md)** — per-tool reference (parameters, return shape, example prompts,
23
+ error behavior) for all six tools registered by the plugin.
24
+ - **[Examples](./docs/EXAMPLES.md)** — dry-run swap, CLI wrapper, and integration smoke test.
25
+
18
26
  ## Installation
19
27
 
20
28
  ```bash
@@ -26,106 +34,22 @@ npm install hak-saucerswap-plugin
26
34
  ```ts
27
35
  import { saucerswapPlugin } from "hak-saucerswap-plugin";
28
36
 
29
- const agent = new HederaAgent({
30
- plugins: [saucerswapPlugin]
31
- });
32
- ```
33
-
34
- ## Configuration
35
-
36
- Provide router contract IDs and (optionally) token aliases via environment or plugin config.
37
-
38
- ```bash
39
- export SAUCERSWAP_ROUTER_CONTRACT_ID=0.0.123456
40
- export SAUCERSWAP_ROUTER_V2_CONTRACT_ID=0.0.654321
41
- export SAUCERSWAP_WRAPPED_HBAR_TOKEN_ID=0.0.987654
42
- ```
43
-
44
- ```ts
45
37
  const agent = new HederaAgent({
46
38
  plugins: [saucerswapPlugin],
47
39
  config: {
48
40
  saucerswap: {
49
- routerContractId: "0.0.123456",
50
- routerV2ContractId: "0.0.654321",
51
- wrappedHbarTokenId: "0.0.987654",
52
- tokenAliases: { HBAR: "0.0.987654" },
53
- defaultPoolVersion: "v2"
54
- }
55
- }
56
- });
57
- ```
58
-
59
- ## Tools
60
-
61
- - `saucerswap_get_swap_quote` - Fetches swap quotes from SaucerSwap API.
62
- - `saucerswap_swap_tokens` - Builds/executes swap transactions with slippage protection.
63
- - `saucerswap_get_pools` - Lists pools or finds a pool by token pair.
64
- - `saucerswap_add_liquidity` - Builds/executes add-liquidity transactions.
65
- - `saucerswap_remove_liquidity` - Builds/executes remove-liquidity transactions.
66
- - `saucerswap_get_farms` - Lists farming opportunities.
67
-
68
- ## Dry-Run Swap Example
69
-
70
- Build a swap transaction without executing it by setting `mode` to `returnBytes`.
71
-
72
- ```ts
73
- import { Client } from "@hashgraph/sdk";
74
- import { saucerswapPlugin } from "@your-org/hak-saucerswap-plugin";
75
-
76
- const client = Client.forTestnet();
77
- client.setOperator(process.env.HEDERA_ACCOUNT_ID!, process.env.HEDERA_PRIVATE_KEY!);
78
-
79
- const context = { mode: "returnBytes" };
80
- const tools = saucerswapPlugin.tools(context);
81
- const swapTool = tools.find((tool) => tool.method === "saucerswap_swap_tokens");
82
-
83
- if (!swapTool) {
84
- throw new Error("Swap tool not registered.");
85
- }
86
-
87
- const result = await swapTool.execute(client, context, {
88
- fromToken: "0.0.123456",
89
- toToken: "0.0.654321",
90
- amount: "1.5",
91
- slippageTolerance: 0.5
41
+ apiKey: process.env.SAUCERSWAP_API_KEY,
42
+ routerV2ContractId: "0.0.1414040",
43
+ wrappedHbarTokenId: "0.0.15058",
44
+ },
45
+ },
92
46
  });
93
-
94
- console.log(result);
95
- ```
96
-
97
- Or run the built-in CLI wrapper after building:
98
-
99
- ```bash
100
- npm run build
101
-
102
- export HEDERA_NETWORK=testnet
103
- export HEDERA_ACCOUNT_ID=0.0.1234
104
- export HEDERA_PRIVATE_KEY=302e020100300506032b657004220420...
105
- export SAUCERSWAP_ROUTER_CONTRACT_ID=0.0.123456
106
- export SAUCERSWAP_SWAP_FROM=0.0.111111
107
- export SAUCERSWAP_SWAP_TO=0.0.222222
108
- export SAUCERSWAP_SWAP_AMOUNT=1.5
109
-
110
- npm run dry-run:swap
111
- ```
112
-
113
- ## Integration Smoke Test
114
-
115
- Hit the SaucerSwap API and print basic counts.
116
-
117
- ```bash
118
- npm run test:integration
119
47
  ```
120
48
 
121
- Optional environment overrides:
122
-
123
- ```bash
124
- export SAUCERSWAP_BASE_URL=https://api.saucerswap.finance
125
- export SAUCERSWAP_TEST_FROM_TOKEN=0.0.123456
126
- export SAUCERSWAP_TEST_TO_TOKEN=0.0.654321
127
- export SAUCERSWAP_TEST_AMOUNT=1
128
- ```
49
+ The SaucerSwap API requires an `x-api-key` header. Get a key from
50
+ [saucerswap.finance](https://www.saucerswap.finance) and supply it via either
51
+ `SAUCERSWAP_API_KEY` in the environment or `config.saucerswap.apiKey`. See
52
+ [`.env.example`](./.env.example) for a copy-paste template of all supported environment variables.
129
53
 
130
54
  ## Development
131
55