@liqdlad/plugin-a2a-swap 0.1.0 → 0.1.4

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/dist/index.d.mts CHANGED
@@ -15,8 +15,11 @@ import { Plugin, Action } from '@elizaos/core';
15
15
  declare const simulateSwapAction: Action;
16
16
  declare const swapTokensAction: Action;
17
17
  declare const provideLiquidityAction: Action;
18
+ declare const removeLiquidityAction: Action;
19
+ declare const claimFeesAction: Action;
20
+ declare const activePoolsAction: Action;
18
21
  declare const poolInfoAction: Action;
19
22
  declare const myFeesAction: Action;
20
23
  declare const a2aSwapPlugin: Plugin;
21
24
 
22
- export { a2aSwapPlugin, a2aSwapPlugin as default, myFeesAction, poolInfoAction, provideLiquidityAction, simulateSwapAction, swapTokensAction };
25
+ export { a2aSwapPlugin, activePoolsAction, claimFeesAction, a2aSwapPlugin as default, myFeesAction, poolInfoAction, provideLiquidityAction, removeLiquidityAction, simulateSwapAction, swapTokensAction };
package/dist/index.d.ts CHANGED
@@ -15,8 +15,11 @@ import { Plugin, Action } from '@elizaos/core';
15
15
  declare const simulateSwapAction: Action;
16
16
  declare const swapTokensAction: Action;
17
17
  declare const provideLiquidityAction: Action;
18
+ declare const removeLiquidityAction: Action;
19
+ declare const claimFeesAction: Action;
20
+ declare const activePoolsAction: Action;
18
21
  declare const poolInfoAction: Action;
19
22
  declare const myFeesAction: Action;
20
23
  declare const a2aSwapPlugin: Plugin;
21
24
 
22
- export { a2aSwapPlugin, a2aSwapPlugin as default, myFeesAction, poolInfoAction, provideLiquidityAction, simulateSwapAction, swapTokensAction };
25
+ export { a2aSwapPlugin, activePoolsAction, claimFeesAction, a2aSwapPlugin as default, myFeesAction, poolInfoAction, provideLiquidityAction, removeLiquidityAction, simulateSwapAction, swapTokensAction };
package/dist/index.js CHANGED
@@ -21,10 +21,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
23
  a2aSwapPlugin: () => a2aSwapPlugin,
24
+ activePoolsAction: () => activePoolsAction,
25
+ claimFeesAction: () => claimFeesAction,
24
26
  default: () => index_default,
25
27
  myFeesAction: () => myFeesAction,
26
28
  poolInfoAction: () => poolInfoAction,
27
29
  provideLiquidityAction: () => provideLiquidityAction,
30
+ removeLiquidityAction: () => removeLiquidityAction,
28
31
  simulateSwapAction: () => simulateSwapAction,
29
32
  swapTokensAction: () => swapTokensAction
30
33
  });
@@ -233,6 +236,158 @@ var provideLiquidityAction = {
233
236
  }
234
237
  }
235
238
  };
239
+ var removeLiquidityAction = {
240
+ name: "A2A_REMOVE_LIQUIDITY",
241
+ description: "Burn LP shares and withdraw proportional tokens from an A2A-Swap pool. Fees are synced but not transferred \u2014 run A2A_CLAIM_FEES after. Accepts: mintA, mintB, lpShares, optional minA, optional minB (slippage guards).",
242
+ similes: [
243
+ "remove liquidity",
244
+ "withdraw liquidity",
245
+ "exit pool",
246
+ "burn LP shares",
247
+ "redeem LP",
248
+ "withdraw from pool"
249
+ ],
250
+ examples: [
251
+ [
252
+ {
253
+ name: "user",
254
+ content: { text: "Remove 1000000 LP shares from the SOL/USDC pool on A2A-Swap" }
255
+ },
256
+ {
257
+ name: "agent",
258
+ content: {
259
+ text: "Removing liquidity from SOL/USDC pool \u2026",
260
+ action: "A2A_REMOVE_LIQUIDITY"
261
+ }
262
+ }
263
+ ]
264
+ ],
265
+ validate: async (_runtime, _message, _state) => true,
266
+ handler: async (_runtime, _message, _state, options, callback) => {
267
+ try {
268
+ const client = buildClient();
269
+ const keypair = loadKeypair();
270
+ const params = {
271
+ mintA: parseMint(opt(options, "mintA") ?? ""),
272
+ mintB: parseMint(opt(options, "mintB") ?? ""),
273
+ lpShares: BigInt(opt(options, "lpShares") ?? "0"),
274
+ minA: BigInt(opt(options, "minA") ?? "0"),
275
+ minB: BigInt(opt(options, "minB") ?? "0")
276
+ };
277
+ const result = await client.removeLiquidity(keypair, params);
278
+ await callback?.({
279
+ text: `Liquidity removed!
280
+ Signature: ${result.signature}
281
+ LP burned: ${result.lpShares}
282
+ Expected A: ${result.expectedA}
283
+ Expected B: ${result.expectedB}
284
+ Run A2A_CLAIM_FEES to collect any accrued fees.`,
285
+ data: result
286
+ });
287
+ } catch (err) {
288
+ await callback?.({ text: `Remove liquidity failed: ${err.message}` });
289
+ }
290
+ }
291
+ };
292
+ var claimFeesAction = {
293
+ name: "A2A_CLAIM_FEES",
294
+ description: "Claim accrued LP trading fees from one A2A-Swap pool position. If auto_compound is enabled, fees are reinvested as LP shares instead. Accepts: mintA, mintB (the two pool token mints).",
295
+ similes: [
296
+ "claim fees",
297
+ "collect fees",
298
+ "harvest fees",
299
+ "withdraw fees",
300
+ "claim LP fees",
301
+ "collect LP rewards"
302
+ ],
303
+ examples: [
304
+ [
305
+ {
306
+ name: "user",
307
+ content: { text: "Claim my LP fees from the SOL/USDC pool on A2A-Swap" }
308
+ },
309
+ {
310
+ name: "agent",
311
+ content: { text: "Claiming fees from SOL/USDC pool \u2026", action: "A2A_CLAIM_FEES" }
312
+ }
313
+ ]
314
+ ],
315
+ validate: async (_runtime, _message, _state) => true,
316
+ handler: async (_runtime, _message, _state, options, callback) => {
317
+ try {
318
+ const client = buildClient();
319
+ const keypair = loadKeypair();
320
+ const mintA = parseMint(opt(options, "mintA") ?? "");
321
+ const mintB = parseMint(opt(options, "mintB") ?? "");
322
+ const result = await client.claimFees(keypair, mintA, mintB);
323
+ const mode = result.autoCompound ? "auto-compounded \u2192 LP shares" : "transferred to wallet";
324
+ await callback?.({
325
+ text: `Fees claimed!
326
+ Signature: ${result.signature}
327
+ Fees A: ${result.feesA}
328
+ Fees B: ${result.feesB}
329
+ Mode: ${mode}`,
330
+ data: result
331
+ });
332
+ } catch (err) {
333
+ await callback?.({ text: `Claim fees failed: ${err.message}` });
334
+ }
335
+ }
336
+ };
337
+ var activePoolsAction = {
338
+ name: "A2A_ACTIVE_POOLS",
339
+ description: "List every liquidity pool on A2A-Swap with live reserves, spot price, LP supply, and fee rate. No parameters needed. Use this for discovery \u2014 call it to learn which token pairs are available before deciding what to swap.",
340
+ similes: [
341
+ "list pools",
342
+ "active pools",
343
+ "available pools",
344
+ "what pools exist",
345
+ "show all pools",
346
+ "what can I swap",
347
+ "what tokens are on a2a swap",
348
+ "discover pools"
349
+ ],
350
+ examples: [
351
+ [
352
+ { name: "user", content: { text: "What pools are available on A2A-Swap?" } },
353
+ { name: "agent", content: { text: "Fetching all active pools \u2026", action: "A2A_ACTIVE_POOLS" } }
354
+ ],
355
+ [
356
+ { name: "user", content: { text: "List all A2A-Swap liquidity pools" } },
357
+ { name: "agent", content: { text: "Listing active pools \u2026", action: "A2A_ACTIVE_POOLS" } }
358
+ ]
359
+ ],
360
+ validate: async (_runtime, _message, _state) => true,
361
+ handler: async (_runtime, _message, _state, _options, callback) => {
362
+ try {
363
+ const client = buildClient();
364
+ const pools = await client.activePools();
365
+ if (pools.length === 0) {
366
+ await callback?.({ text: "No active pools found on A2A-Swap." });
367
+ return;
368
+ }
369
+ const lines = [`Active pools on A2A-Swap (${pools.length}):`];
370
+ for (const [i, p] of pools.entries()) {
371
+ lines.push(
372
+ ` [${i + 1}] Pool: ${p.pool.toBase58()}`,
373
+ ` Mint A: ${p.mintA.toBase58()}`,
374
+ ` Mint B: ${p.mintB.toBase58()}`,
375
+ ` Reserve A: ${p.reserveA}`,
376
+ ` Reserve B: ${p.reserveB}`,
377
+ ` LP supply: ${p.lpSupply}`,
378
+ ` Fee rate: ${p.feeRateBps} bps`,
379
+ ` Spot price: ${p.spotPrice.toFixed(6)} (B per A)`
380
+ );
381
+ }
382
+ await callback?.({
383
+ text: lines.join("\n"),
384
+ data: { pools: pools.map((p) => ({ ...p, pool: p.pool.toBase58(), mintA: p.mintA.toBase58(), mintB: p.mintB.toBase58() })) }
385
+ });
386
+ } catch (err) {
387
+ await callback?.({ text: `Active pools failed: ${err.message}` });
388
+ }
389
+ }
390
+ };
236
391
  var poolInfoAction = {
237
392
  name: "A2A_POOL_INFO",
238
393
  description: "Fetch A2A-Swap pool reserves, spot price, LP supply, and fee rate. Accepts: mintA, mintB (the two token mint addresses).",
@@ -332,6 +487,9 @@ var a2aSwapPlugin = {
332
487
  simulateSwapAction,
333
488
  swapTokensAction,
334
489
  provideLiquidityAction,
490
+ removeLiquidityAction,
491
+ claimFeesAction,
492
+ activePoolsAction,
335
493
  poolInfoAction,
336
494
  myFeesAction
337
495
  ]
@@ -340,9 +498,12 @@ var index_default = a2aSwapPlugin;
340
498
  // Annotate the CommonJS export names for ESM import in node:
341
499
  0 && (module.exports = {
342
500
  a2aSwapPlugin,
501
+ activePoolsAction,
502
+ claimFeesAction,
343
503
  myFeesAction,
344
504
  poolInfoAction,
345
505
  provideLiquidityAction,
506
+ removeLiquidityAction,
346
507
  simulateSwapAction,
347
508
  swapTokensAction
348
509
  });
package/dist/index.mjs CHANGED
@@ -205,6 +205,158 @@ var provideLiquidityAction = {
205
205
  }
206
206
  }
207
207
  };
208
+ var removeLiquidityAction = {
209
+ name: "A2A_REMOVE_LIQUIDITY",
210
+ description: "Burn LP shares and withdraw proportional tokens from an A2A-Swap pool. Fees are synced but not transferred \u2014 run A2A_CLAIM_FEES after. Accepts: mintA, mintB, lpShares, optional minA, optional minB (slippage guards).",
211
+ similes: [
212
+ "remove liquidity",
213
+ "withdraw liquidity",
214
+ "exit pool",
215
+ "burn LP shares",
216
+ "redeem LP",
217
+ "withdraw from pool"
218
+ ],
219
+ examples: [
220
+ [
221
+ {
222
+ name: "user",
223
+ content: { text: "Remove 1000000 LP shares from the SOL/USDC pool on A2A-Swap" }
224
+ },
225
+ {
226
+ name: "agent",
227
+ content: {
228
+ text: "Removing liquidity from SOL/USDC pool \u2026",
229
+ action: "A2A_REMOVE_LIQUIDITY"
230
+ }
231
+ }
232
+ ]
233
+ ],
234
+ validate: async (_runtime, _message, _state) => true,
235
+ handler: async (_runtime, _message, _state, options, callback) => {
236
+ try {
237
+ const client = buildClient();
238
+ const keypair = loadKeypair();
239
+ const params = {
240
+ mintA: parseMint(opt(options, "mintA") ?? ""),
241
+ mintB: parseMint(opt(options, "mintB") ?? ""),
242
+ lpShares: BigInt(opt(options, "lpShares") ?? "0"),
243
+ minA: BigInt(opt(options, "minA") ?? "0"),
244
+ minB: BigInt(opt(options, "minB") ?? "0")
245
+ };
246
+ const result = await client.removeLiquidity(keypair, params);
247
+ await callback?.({
248
+ text: `Liquidity removed!
249
+ Signature: ${result.signature}
250
+ LP burned: ${result.lpShares}
251
+ Expected A: ${result.expectedA}
252
+ Expected B: ${result.expectedB}
253
+ Run A2A_CLAIM_FEES to collect any accrued fees.`,
254
+ data: result
255
+ });
256
+ } catch (err) {
257
+ await callback?.({ text: `Remove liquidity failed: ${err.message}` });
258
+ }
259
+ }
260
+ };
261
+ var claimFeesAction = {
262
+ name: "A2A_CLAIM_FEES",
263
+ description: "Claim accrued LP trading fees from one A2A-Swap pool position. If auto_compound is enabled, fees are reinvested as LP shares instead. Accepts: mintA, mintB (the two pool token mints).",
264
+ similes: [
265
+ "claim fees",
266
+ "collect fees",
267
+ "harvest fees",
268
+ "withdraw fees",
269
+ "claim LP fees",
270
+ "collect LP rewards"
271
+ ],
272
+ examples: [
273
+ [
274
+ {
275
+ name: "user",
276
+ content: { text: "Claim my LP fees from the SOL/USDC pool on A2A-Swap" }
277
+ },
278
+ {
279
+ name: "agent",
280
+ content: { text: "Claiming fees from SOL/USDC pool \u2026", action: "A2A_CLAIM_FEES" }
281
+ }
282
+ ]
283
+ ],
284
+ validate: async (_runtime, _message, _state) => true,
285
+ handler: async (_runtime, _message, _state, options, callback) => {
286
+ try {
287
+ const client = buildClient();
288
+ const keypair = loadKeypair();
289
+ const mintA = parseMint(opt(options, "mintA") ?? "");
290
+ const mintB = parseMint(opt(options, "mintB") ?? "");
291
+ const result = await client.claimFees(keypair, mintA, mintB);
292
+ const mode = result.autoCompound ? "auto-compounded \u2192 LP shares" : "transferred to wallet";
293
+ await callback?.({
294
+ text: `Fees claimed!
295
+ Signature: ${result.signature}
296
+ Fees A: ${result.feesA}
297
+ Fees B: ${result.feesB}
298
+ Mode: ${mode}`,
299
+ data: result
300
+ });
301
+ } catch (err) {
302
+ await callback?.({ text: `Claim fees failed: ${err.message}` });
303
+ }
304
+ }
305
+ };
306
+ var activePoolsAction = {
307
+ name: "A2A_ACTIVE_POOLS",
308
+ description: "List every liquidity pool on A2A-Swap with live reserves, spot price, LP supply, and fee rate. No parameters needed. Use this for discovery \u2014 call it to learn which token pairs are available before deciding what to swap.",
309
+ similes: [
310
+ "list pools",
311
+ "active pools",
312
+ "available pools",
313
+ "what pools exist",
314
+ "show all pools",
315
+ "what can I swap",
316
+ "what tokens are on a2a swap",
317
+ "discover pools"
318
+ ],
319
+ examples: [
320
+ [
321
+ { name: "user", content: { text: "What pools are available on A2A-Swap?" } },
322
+ { name: "agent", content: { text: "Fetching all active pools \u2026", action: "A2A_ACTIVE_POOLS" } }
323
+ ],
324
+ [
325
+ { name: "user", content: { text: "List all A2A-Swap liquidity pools" } },
326
+ { name: "agent", content: { text: "Listing active pools \u2026", action: "A2A_ACTIVE_POOLS" } }
327
+ ]
328
+ ],
329
+ validate: async (_runtime, _message, _state) => true,
330
+ handler: async (_runtime, _message, _state, _options, callback) => {
331
+ try {
332
+ const client = buildClient();
333
+ const pools = await client.activePools();
334
+ if (pools.length === 0) {
335
+ await callback?.({ text: "No active pools found on A2A-Swap." });
336
+ return;
337
+ }
338
+ const lines = [`Active pools on A2A-Swap (${pools.length}):`];
339
+ for (const [i, p] of pools.entries()) {
340
+ lines.push(
341
+ ` [${i + 1}] Pool: ${p.pool.toBase58()}`,
342
+ ` Mint A: ${p.mintA.toBase58()}`,
343
+ ` Mint B: ${p.mintB.toBase58()}`,
344
+ ` Reserve A: ${p.reserveA}`,
345
+ ` Reserve B: ${p.reserveB}`,
346
+ ` LP supply: ${p.lpSupply}`,
347
+ ` Fee rate: ${p.feeRateBps} bps`,
348
+ ` Spot price: ${p.spotPrice.toFixed(6)} (B per A)`
349
+ );
350
+ }
351
+ await callback?.({
352
+ text: lines.join("\n"),
353
+ data: { pools: pools.map((p) => ({ ...p, pool: p.pool.toBase58(), mintA: p.mintA.toBase58(), mintB: p.mintB.toBase58() })) }
354
+ });
355
+ } catch (err) {
356
+ await callback?.({ text: `Active pools failed: ${err.message}` });
357
+ }
358
+ }
359
+ };
208
360
  var poolInfoAction = {
209
361
  name: "A2A_POOL_INFO",
210
362
  description: "Fetch A2A-Swap pool reserves, spot price, LP supply, and fee rate. Accepts: mintA, mintB (the two token mint addresses).",
@@ -304,6 +456,9 @@ var a2aSwapPlugin = {
304
456
  simulateSwapAction,
305
457
  swapTokensAction,
306
458
  provideLiquidityAction,
459
+ removeLiquidityAction,
460
+ claimFeesAction,
461
+ activePoolsAction,
307
462
  poolInfoAction,
308
463
  myFeesAction
309
464
  ]
@@ -311,10 +466,13 @@ var a2aSwapPlugin = {
311
466
  var index_default = a2aSwapPlugin;
312
467
  export {
313
468
  a2aSwapPlugin,
469
+ activePoolsAction,
470
+ claimFeesAction,
314
471
  index_default as default,
315
472
  myFeesAction,
316
473
  poolInfoAction,
317
474
  provideLiquidityAction,
475
+ removeLiquidityAction,
318
476
  simulateSwapAction,
319
477
  swapTokensAction
320
478
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liqdlad/plugin-a2a-swap",
3
- "version": "0.1.0",
3
+ "version": "0.1.4",
4
4
  "description": "A2A-Swap plugin for ElizaOS — autonomous token swaps and liquidity management on Solana via a constant-product AMM built for AI agents",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -12,7 +12,11 @@
12
12
  "require": "./dist/index.js"
13
13
  }
14
14
  },
15
- "files": ["dist", "images", "README.md"],
15
+ "files": [
16
+ "dist",
17
+ "images",
18
+ "README.md"
19
+ ],
16
20
  "scripts": {
17
21
  "build": "tsup src/index.ts --format cjs,esm --dts --clean",
18
22
  "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
@@ -46,14 +50,14 @@
46
50
  "@elizaos/core": ">=1.0.0"
47
51
  },
48
52
  "dependencies": {
49
- "@liqdlad/a2a-swap-sdk": "^0.1.0",
53
+ "@liqdlad/a2a-swap-sdk": "^0.1.2",
50
54
  "@solana/web3.js": "^1.95.4"
51
55
  },
52
56
  "devDependencies": {
53
57
  "@elizaos/core": "^1.0.0",
58
+ "@types/node": "^20.0.0",
54
59
  "tsup": "^8.0.0",
55
- "typescript": "^5.3.0",
56
- "@types/node": "^20.0.0"
60
+ "typescript": "^5.3.0"
57
61
  },
58
62
  "publishConfig": {
59
63
  "access": "public"
@@ -76,5 +80,8 @@
76
80
  "secret": true
77
81
  }
78
82
  }
79
- }
83
+ },
84
+ "packageType": "plugin",
85
+ "platform": "node",
86
+ "npmPackage": "@liqdlad/plugin-a2a-swap"
80
87
  }