@liqdlad/plugin-a2a-swap 0.1.0 → 0.1.3
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 +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +104 -0
- package/dist/index.mjs +102 -0
- package/package.json +13 -6
package/dist/index.d.mts
CHANGED
|
@@ -15,8 +15,10 @@ 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;
|
|
18
20
|
declare const poolInfoAction: Action;
|
|
19
21
|
declare const myFeesAction: Action;
|
|
20
22
|
declare const a2aSwapPlugin: Plugin;
|
|
21
23
|
|
|
22
|
-
export { a2aSwapPlugin, a2aSwapPlugin as default, myFeesAction, poolInfoAction, provideLiquidityAction, simulateSwapAction, swapTokensAction };
|
|
24
|
+
export { a2aSwapPlugin, claimFeesAction, a2aSwapPlugin as default, myFeesAction, poolInfoAction, provideLiquidityAction, removeLiquidityAction, simulateSwapAction, swapTokensAction };
|
package/dist/index.d.ts
CHANGED
|
@@ -15,8 +15,10 @@ 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;
|
|
18
20
|
declare const poolInfoAction: Action;
|
|
19
21
|
declare const myFeesAction: Action;
|
|
20
22
|
declare const a2aSwapPlugin: Plugin;
|
|
21
23
|
|
|
22
|
-
export { a2aSwapPlugin, a2aSwapPlugin as default, myFeesAction, poolInfoAction, provideLiquidityAction, simulateSwapAction, swapTokensAction };
|
|
24
|
+
export { a2aSwapPlugin, claimFeesAction, a2aSwapPlugin as default, myFeesAction, poolInfoAction, provideLiquidityAction, removeLiquidityAction, simulateSwapAction, swapTokensAction };
|
package/dist/index.js
CHANGED
|
@@ -21,10 +21,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
a2aSwapPlugin: () => a2aSwapPlugin,
|
|
24
|
+
claimFeesAction: () => claimFeesAction,
|
|
24
25
|
default: () => index_default,
|
|
25
26
|
myFeesAction: () => myFeesAction,
|
|
26
27
|
poolInfoAction: () => poolInfoAction,
|
|
27
28
|
provideLiquidityAction: () => provideLiquidityAction,
|
|
29
|
+
removeLiquidityAction: () => removeLiquidityAction,
|
|
28
30
|
simulateSwapAction: () => simulateSwapAction,
|
|
29
31
|
swapTokensAction: () => swapTokensAction
|
|
30
32
|
});
|
|
@@ -233,6 +235,104 @@ var provideLiquidityAction = {
|
|
|
233
235
|
}
|
|
234
236
|
}
|
|
235
237
|
};
|
|
238
|
+
var removeLiquidityAction = {
|
|
239
|
+
name: "A2A_REMOVE_LIQUIDITY",
|
|
240
|
+
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).",
|
|
241
|
+
similes: [
|
|
242
|
+
"remove liquidity",
|
|
243
|
+
"withdraw liquidity",
|
|
244
|
+
"exit pool",
|
|
245
|
+
"burn LP shares",
|
|
246
|
+
"redeem LP",
|
|
247
|
+
"withdraw from pool"
|
|
248
|
+
],
|
|
249
|
+
examples: [
|
|
250
|
+
[
|
|
251
|
+
{
|
|
252
|
+
name: "user",
|
|
253
|
+
content: { text: "Remove 1000000 LP shares from the SOL/USDC pool on A2A-Swap" }
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
name: "agent",
|
|
257
|
+
content: {
|
|
258
|
+
text: "Removing liquidity from SOL/USDC pool \u2026",
|
|
259
|
+
action: "A2A_REMOVE_LIQUIDITY"
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
]
|
|
263
|
+
],
|
|
264
|
+
validate: async (_runtime, _message, _state) => true,
|
|
265
|
+
handler: async (_runtime, _message, _state, options, callback) => {
|
|
266
|
+
try {
|
|
267
|
+
const client = buildClient();
|
|
268
|
+
const keypair = loadKeypair();
|
|
269
|
+
const params = {
|
|
270
|
+
mintA: parseMint(opt(options, "mintA") ?? ""),
|
|
271
|
+
mintB: parseMint(opt(options, "mintB") ?? ""),
|
|
272
|
+
lpShares: BigInt(opt(options, "lpShares") ?? "0"),
|
|
273
|
+
minA: BigInt(opt(options, "minA") ?? "0"),
|
|
274
|
+
minB: BigInt(opt(options, "minB") ?? "0")
|
|
275
|
+
};
|
|
276
|
+
const result = await client.removeLiquidity(keypair, params);
|
|
277
|
+
await callback?.({
|
|
278
|
+
text: `Liquidity removed!
|
|
279
|
+
Signature: ${result.signature}
|
|
280
|
+
LP burned: ${result.lpShares}
|
|
281
|
+
Expected A: ${result.expectedA}
|
|
282
|
+
Expected B: ${result.expectedB}
|
|
283
|
+
Run A2A_CLAIM_FEES to collect any accrued fees.`,
|
|
284
|
+
data: result
|
|
285
|
+
});
|
|
286
|
+
} catch (err) {
|
|
287
|
+
await callback?.({ text: `Remove liquidity failed: ${err.message}` });
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
var claimFeesAction = {
|
|
292
|
+
name: "A2A_CLAIM_FEES",
|
|
293
|
+
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).",
|
|
294
|
+
similes: [
|
|
295
|
+
"claim fees",
|
|
296
|
+
"collect fees",
|
|
297
|
+
"harvest fees",
|
|
298
|
+
"withdraw fees",
|
|
299
|
+
"claim LP fees",
|
|
300
|
+
"collect LP rewards"
|
|
301
|
+
],
|
|
302
|
+
examples: [
|
|
303
|
+
[
|
|
304
|
+
{
|
|
305
|
+
name: "user",
|
|
306
|
+
content: { text: "Claim my LP fees from the SOL/USDC pool on A2A-Swap" }
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
name: "agent",
|
|
310
|
+
content: { text: "Claiming fees from SOL/USDC pool \u2026", action: "A2A_CLAIM_FEES" }
|
|
311
|
+
}
|
|
312
|
+
]
|
|
313
|
+
],
|
|
314
|
+
validate: async (_runtime, _message, _state) => true,
|
|
315
|
+
handler: async (_runtime, _message, _state, options, callback) => {
|
|
316
|
+
try {
|
|
317
|
+
const client = buildClient();
|
|
318
|
+
const keypair = loadKeypair();
|
|
319
|
+
const mintA = parseMint(opt(options, "mintA") ?? "");
|
|
320
|
+
const mintB = parseMint(opt(options, "mintB") ?? "");
|
|
321
|
+
const result = await client.claimFees(keypair, mintA, mintB);
|
|
322
|
+
const mode = result.autoCompound ? "auto-compounded \u2192 LP shares" : "transferred to wallet";
|
|
323
|
+
await callback?.({
|
|
324
|
+
text: `Fees claimed!
|
|
325
|
+
Signature: ${result.signature}
|
|
326
|
+
Fees A: ${result.feesA}
|
|
327
|
+
Fees B: ${result.feesB}
|
|
328
|
+
Mode: ${mode}`,
|
|
329
|
+
data: result
|
|
330
|
+
});
|
|
331
|
+
} catch (err) {
|
|
332
|
+
await callback?.({ text: `Claim fees failed: ${err.message}` });
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
};
|
|
236
336
|
var poolInfoAction = {
|
|
237
337
|
name: "A2A_POOL_INFO",
|
|
238
338
|
description: "Fetch A2A-Swap pool reserves, spot price, LP supply, and fee rate. Accepts: mintA, mintB (the two token mint addresses).",
|
|
@@ -332,6 +432,8 @@ var a2aSwapPlugin = {
|
|
|
332
432
|
simulateSwapAction,
|
|
333
433
|
swapTokensAction,
|
|
334
434
|
provideLiquidityAction,
|
|
435
|
+
removeLiquidityAction,
|
|
436
|
+
claimFeesAction,
|
|
335
437
|
poolInfoAction,
|
|
336
438
|
myFeesAction
|
|
337
439
|
]
|
|
@@ -340,9 +442,11 @@ var index_default = a2aSwapPlugin;
|
|
|
340
442
|
// Annotate the CommonJS export names for ESM import in node:
|
|
341
443
|
0 && (module.exports = {
|
|
342
444
|
a2aSwapPlugin,
|
|
445
|
+
claimFeesAction,
|
|
343
446
|
myFeesAction,
|
|
344
447
|
poolInfoAction,
|
|
345
448
|
provideLiquidityAction,
|
|
449
|
+
removeLiquidityAction,
|
|
346
450
|
simulateSwapAction,
|
|
347
451
|
swapTokensAction
|
|
348
452
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -205,6 +205,104 @@ 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
|
+
};
|
|
208
306
|
var poolInfoAction = {
|
|
209
307
|
name: "A2A_POOL_INFO",
|
|
210
308
|
description: "Fetch A2A-Swap pool reserves, spot price, LP supply, and fee rate. Accepts: mintA, mintB (the two token mint addresses).",
|
|
@@ -304,6 +402,8 @@ var a2aSwapPlugin = {
|
|
|
304
402
|
simulateSwapAction,
|
|
305
403
|
swapTokensAction,
|
|
306
404
|
provideLiquidityAction,
|
|
405
|
+
removeLiquidityAction,
|
|
406
|
+
claimFeesAction,
|
|
307
407
|
poolInfoAction,
|
|
308
408
|
myFeesAction
|
|
309
409
|
]
|
|
@@ -311,10 +411,12 @@ var a2aSwapPlugin = {
|
|
|
311
411
|
var index_default = a2aSwapPlugin;
|
|
312
412
|
export {
|
|
313
413
|
a2aSwapPlugin,
|
|
414
|
+
claimFeesAction,
|
|
314
415
|
index_default as default,
|
|
315
416
|
myFeesAction,
|
|
316
417
|
poolInfoAction,
|
|
317
418
|
provideLiquidityAction,
|
|
419
|
+
removeLiquidityAction,
|
|
318
420
|
simulateSwapAction,
|
|
319
421
|
swapTokensAction
|
|
320
422
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@liqdlad/plugin-a2a-swap",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
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": [
|
|
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.
|
|
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
|
}
|