@stellar-agent-kit/plugin-asset 0.1.9 → 0.1.10
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.ts +42 -1
- package/dist/index.js +174 -16
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -36,6 +36,47 @@ declare const getOrderbook: Action;
|
|
|
36
36
|
|
|
37
37
|
declare const friendbotFund: Action;
|
|
38
38
|
|
|
39
|
+
declare const knownIssuers: Action;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Verified-canonical asset issuers per network. Use this to avoid LLM
|
|
43
|
+
* hallucination of issuer addresses when the user says "trustline USDC" without
|
|
44
|
+
* specifying which one.
|
|
45
|
+
*
|
|
46
|
+
* Sources (verified 2026-05-08):
|
|
47
|
+
* - USDC mainnet: Circle's official issuer (https://stellar.expert/explorer/public/asset/USDC-GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN)
|
|
48
|
+
* - USDC testnet: Circle's testnet issuer (https://stellar.expert/explorer/testnet/asset/USDC-GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5)
|
|
49
|
+
* - EURC mainnet: Circle's official EURC issuer
|
|
50
|
+
* - AQUA mainnet: Aquarius DEX governance token
|
|
51
|
+
* - yXLM, yUSDC mainnet: Ultracapital yield assets
|
|
52
|
+
*
|
|
53
|
+
* NOTE: testnet has MULTIPLE USDC issuers (Circle, Blend, Etherfuse). We
|
|
54
|
+
* default to Circle's. To use a different one, callers must pass the issuer
|
|
55
|
+
* explicitly to ASSET_TRUSTLINE_ADD.
|
|
56
|
+
*/
|
|
57
|
+
interface KnownAssetEntry {
|
|
58
|
+
code: string;
|
|
59
|
+
issuer: string;
|
|
60
|
+
/** Stellar Asset Contract address — for Soroswap / Soroban interactions. */
|
|
61
|
+
sac?: string;
|
|
62
|
+
description?: string;
|
|
63
|
+
}
|
|
64
|
+
declare const KNOWN_ASSETS_MAINNET: Record<string, KnownAssetEntry>;
|
|
65
|
+
declare const KNOWN_ASSETS_TESTNET: Record<string, KnownAssetEntry>;
|
|
66
|
+
type StellarNetworkTag = "mainnet" | "testnet" | "futurenet";
|
|
67
|
+
declare function networkTag(passphrase: string): StellarNetworkTag;
|
|
68
|
+
/**
|
|
69
|
+
* Look up a known asset by code on the current network. Returns null if the
|
|
70
|
+
* code isn't in the registry. Codes are matched case-insensitively but the
|
|
71
|
+
* registry's canonical casing wins.
|
|
72
|
+
*/
|
|
73
|
+
declare function lookupKnownAsset(passphrase: string, code: string): KnownAssetEntry | null;
|
|
74
|
+
/**
|
|
75
|
+
* Render a compact summary of known assets for inclusion in the agent's
|
|
76
|
+
* system prompt. Helps the LLM pick the right issuer without guessing.
|
|
77
|
+
*/
|
|
78
|
+
declare function describeKnownAssets(passphrase: string): string;
|
|
79
|
+
|
|
39
80
|
declare const StellarAssetPlugin: Plugin;
|
|
40
81
|
|
|
41
|
-
export { StellarAssetPlugin, balance, cancelOffer, claimableBalanceClaim, claimableBalanceCreate, StellarAssetPlugin as default, friendbotFund, getOrderbook, issue, manageBuyOffer, manageSellOffer, pathPaymentStrictReceive, pathPaymentStrictSend, setOptions, transfer, trustlineAdd, trustlineRemove };
|
|
82
|
+
export { KNOWN_ASSETS_MAINNET, KNOWN_ASSETS_TESTNET, type KnownAssetEntry, StellarAssetPlugin, type StellarNetworkTag, balance, cancelOffer, claimableBalanceClaim, claimableBalanceCreate, StellarAssetPlugin as default, describeKnownAssets, friendbotFund, getOrderbook, issue, knownIssuers, lookupKnownAsset, manageBuyOffer, manageSellOffer, networkTag, pathPaymentStrictReceive, pathPaymentStrictSend, setOptions, transfer, trustlineAdd, trustlineRemove };
|
package/dist/index.js
CHANGED
|
@@ -217,56 +217,158 @@ var pathPaymentStrictReceive = {
|
|
|
217
217
|
// src/actions/trustline.ts
|
|
218
218
|
import { z as z4 } from "zod";
|
|
219
219
|
import { Operation as Operation5 } from "@stellar/stellar-sdk";
|
|
220
|
+
|
|
221
|
+
// src/knownAssets.ts
|
|
222
|
+
import { Networks } from "@stellar/stellar-sdk";
|
|
223
|
+
var KNOWN_ASSETS_MAINNET = {
|
|
224
|
+
XLM: {
|
|
225
|
+
code: "XLM",
|
|
226
|
+
issuer: "native",
|
|
227
|
+
sac: "CAS3J7GYLGXMF6TDJBBYYSE3HQ6BBSMLNUQ34T6TZMYMW2EVH34XOWMA",
|
|
228
|
+
description: "Native Stellar lumens. No trustline needed."
|
|
229
|
+
},
|
|
230
|
+
USDC: {
|
|
231
|
+
code: "USDC",
|
|
232
|
+
issuer: "GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN",
|
|
233
|
+
sac: "CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75",
|
|
234
|
+
description: "Circle's official mainnet USDC."
|
|
235
|
+
},
|
|
236
|
+
EURC: {
|
|
237
|
+
code: "EURC",
|
|
238
|
+
issuer: "GDHU6WRG4IEQXM5NZ4BMPKOXHW76MZM4Y2IEMFDVXBSDP6SJY4ITNPP2",
|
|
239
|
+
sac: "CDTKPWPLOURQA2SGTKTUQOWRCBZEORB4BWBOMJ3D3ZTQQSGE5F6JBQLV",
|
|
240
|
+
description: "Circle's official mainnet EURC."
|
|
241
|
+
},
|
|
242
|
+
AQUA: {
|
|
243
|
+
code: "AQUA",
|
|
244
|
+
issuer: "GBNZILSTVQZ4R7IKQDGHYGY2QXL5QOFJYQMXPKWRRM5PAV7Y4M67AQUA",
|
|
245
|
+
sac: "CAUIKL3IYGMERDRUN6YSCLWVAKIFG5Q4YJHUKM4S4NJZQIA3BAS6OJPK",
|
|
246
|
+
description: "Aquarius DEX governance token."
|
|
247
|
+
},
|
|
248
|
+
YXLM: {
|
|
249
|
+
code: "yXLM",
|
|
250
|
+
issuer: "GARDNV3Q7YGT4AKSDF25LT32YSCCW4EV22Y2TV3I2PU2MMXJTEDL5T55",
|
|
251
|
+
description: "Ultracapital yield XLM."
|
|
252
|
+
},
|
|
253
|
+
YUSDC: {
|
|
254
|
+
code: "yUSDC",
|
|
255
|
+
issuer: "GDGTVWSM4MGS4T7Z6W4RPWOCHE2I6RDFCIFZGS3DOA63LWQTRNZNTTFF",
|
|
256
|
+
sac: "CDOFW7HNKLUZRLFZST4EW7V3AV4JI5IHMT6BPXXSY2IEFZ4NE5TWU2P4",
|
|
257
|
+
description: "Ultracapital yield USDC."
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
var KNOWN_ASSETS_TESTNET = {
|
|
261
|
+
XLM: {
|
|
262
|
+
code: "XLM",
|
|
263
|
+
issuer: "native",
|
|
264
|
+
description: "Native Stellar lumens (testnet). No trustline needed."
|
|
265
|
+
},
|
|
266
|
+
USDC: {
|
|
267
|
+
code: "USDC",
|
|
268
|
+
issuer: "GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5",
|
|
269
|
+
description: "Circle's testnet USDC. NOTE: testnet has multiple USDC issuers (Circle / Blend / Etherfuse) that don't share liquidity \u2014 pass an explicit issuer to use a different one."
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
function networkTag(passphrase) {
|
|
273
|
+
if (passphrase === Networks.PUBLIC) return "mainnet";
|
|
274
|
+
if (passphrase === Networks.FUTURENET) return "futurenet";
|
|
275
|
+
return "testnet";
|
|
276
|
+
}
|
|
277
|
+
function lookupKnownAsset(passphrase, code) {
|
|
278
|
+
const network = networkTag(passphrase);
|
|
279
|
+
const reg = network === "mainnet" ? KNOWN_ASSETS_MAINNET : KNOWN_ASSETS_TESTNET;
|
|
280
|
+
const upper = code.toUpperCase();
|
|
281
|
+
return reg[code] ?? reg[upper] ?? null;
|
|
282
|
+
}
|
|
283
|
+
function describeKnownAssets(passphrase) {
|
|
284
|
+
const network = networkTag(passphrase);
|
|
285
|
+
const reg = network === "mainnet" ? KNOWN_ASSETS_MAINNET : KNOWN_ASSETS_TESTNET;
|
|
286
|
+
const lines = [`Known canonical assets on ${network}:`];
|
|
287
|
+
for (const entry of Object.values(reg)) {
|
|
288
|
+
if (entry.issuer === "native") {
|
|
289
|
+
lines.push(` - ${entry.code} (native, no trustline needed)`);
|
|
290
|
+
} else {
|
|
291
|
+
lines.push(
|
|
292
|
+
` - ${entry.code}: issuer=${entry.issuer}${entry.sac ? `, SAC=${entry.sac}` : ""}`
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
if (network === "testnet") {
|
|
297
|
+
lines.push(
|
|
298
|
+
" Note: testnet has multiple USDC issuers (Circle / Blend / Etherfuse) that DON'T share liquidity."
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
return lines.join("\n");
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// src/actions/trustline.ts
|
|
220
305
|
var trustlineAdd = {
|
|
221
306
|
name: "ASSET_TRUSTLINE_ADD",
|
|
222
307
|
similes: ["change trust", "add trustline", "trust asset"],
|
|
223
|
-
description: "Establish or update a trustline from the agent's wallet for a non-native Stellar asset.",
|
|
308
|
+
description: "Establish or update a trustline from the agent's wallet for a non-native Stellar asset. If `issuer` is omitted, the kit auto-resolves it from a verified canonical-asset registry (USDC, EURC, AQUA, etc. \u2014 see ASSET_KNOWN_ISSUERS). On testnet there are multiple USDC issuers (Circle / Blend / Etherfuse); the auto-resolver picks Circle's. To use a different one, pass `issuer` explicitly.",
|
|
224
309
|
examples: [
|
|
225
310
|
[
|
|
226
311
|
{
|
|
227
|
-
input: { assetCode: "USDC"
|
|
228
|
-
output: { hash: "...", ledger: 1 },
|
|
229
|
-
explanation: "Trustline USDC
|
|
312
|
+
input: { assetCode: "USDC" },
|
|
313
|
+
output: { hash: "...", ledger: 1, resolvedIssuer: "GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN" },
|
|
314
|
+
explanation: "Trustline mainnet Circle USDC (issuer auto-resolved)"
|
|
230
315
|
}
|
|
231
316
|
]
|
|
232
317
|
],
|
|
233
318
|
schema: z4.object({
|
|
234
319
|
assetCode: z4.string(),
|
|
235
|
-
issuer: z4.string()
|
|
320
|
+
issuer: z4.string().optional().describe(
|
|
321
|
+
"Issuer G-address. If omitted, auto-resolved from the canonical-asset registry for the active network."
|
|
322
|
+
),
|
|
236
323
|
limit: z4.string().optional().describe("Trust limit (omit for max). String decimal, e.g. 1000000")
|
|
237
324
|
}),
|
|
238
325
|
handler: async (agent, input) => {
|
|
239
|
-
const
|
|
326
|
+
const issuer = await resolveIssuer(agent, input.assetCode, input.issuer);
|
|
327
|
+
const asset = makeAsset({ code: input.assetCode, issuer });
|
|
240
328
|
const { hash, ledger } = await buildSubmitClassic(
|
|
241
329
|
agent,
|
|
242
330
|
(b) => b.addOperation(Operation5.changeTrust({ asset, ...input.limit ? { limit: input.limit } : {} }))
|
|
243
331
|
);
|
|
244
|
-
return { hash, ledger };
|
|
332
|
+
return { hash, ledger, resolvedIssuer: issuer };
|
|
245
333
|
}
|
|
246
334
|
};
|
|
247
335
|
var trustlineRemove = {
|
|
248
336
|
name: "ASSET_TRUSTLINE_REMOVE",
|
|
249
337
|
similes: ["remove trustline", "untrust asset"],
|
|
250
|
-
description: "Remove a trustline by setting its limit to 0. The agent's balance for that asset must already be 0.",
|
|
338
|
+
description: "Remove a trustline by setting its limit to 0. The agent's balance for that asset must already be 0. Issuer is auto-resolved if omitted (see ASSET_TRUSTLINE_ADD).",
|
|
251
339
|
examples: [
|
|
252
340
|
[
|
|
253
341
|
{
|
|
254
|
-
input: { assetCode: "USDC"
|
|
342
|
+
input: { assetCode: "USDC" },
|
|
255
343
|
output: { hash: "...", ledger: 1 },
|
|
256
|
-
explanation: "Remove a USDC trustline"
|
|
344
|
+
explanation: "Remove a USDC trustline (issuer auto-resolved)"
|
|
257
345
|
}
|
|
258
346
|
]
|
|
259
347
|
],
|
|
260
|
-
schema: z4.object({
|
|
348
|
+
schema: z4.object({
|
|
349
|
+
assetCode: z4.string(),
|
|
350
|
+
issuer: z4.string().optional()
|
|
351
|
+
}),
|
|
261
352
|
handler: async (agent, input) => {
|
|
262
|
-
const
|
|
353
|
+
const issuer = await resolveIssuer(agent, input.assetCode, input.issuer);
|
|
354
|
+
const asset = makeAsset({ code: input.assetCode, issuer });
|
|
263
355
|
const { hash, ledger } = await buildSubmitClassic(
|
|
264
356
|
agent,
|
|
265
357
|
(b) => b.addOperation(Operation5.changeTrust({ asset, limit: "0" }))
|
|
266
358
|
);
|
|
267
|
-
return { hash, ledger };
|
|
359
|
+
return { hash, ledger, resolvedIssuer: issuer };
|
|
268
360
|
}
|
|
269
361
|
};
|
|
362
|
+
async function resolveIssuer(agent, assetCode, explicit) {
|
|
363
|
+
if (explicit) return explicit;
|
|
364
|
+
const known = lookupKnownAsset(agent.config.networkPassphrase, assetCode);
|
|
365
|
+
if (known && known.issuer && known.issuer !== "native") return known.issuer;
|
|
366
|
+
const err = new Error(
|
|
367
|
+
`Asset ${assetCode} is not in the canonical-asset registry for this network. Pass \`issuer\` explicitly, or use ASSET_KNOWN_ISSUERS to see what's available.`
|
|
368
|
+
);
|
|
369
|
+
err.code = "ISSUER_REQUIRED";
|
|
370
|
+
throw err;
|
|
371
|
+
}
|
|
270
372
|
|
|
271
373
|
// src/actions/balance.ts
|
|
272
374
|
import { z as z5 } from "zod";
|
|
@@ -652,7 +754,7 @@ var getOrderbook = {
|
|
|
652
754
|
|
|
653
755
|
// src/actions/friendbot.ts
|
|
654
756
|
import { z as z11 } from "zod";
|
|
655
|
-
import { Networks } from "@stellar/stellar-sdk";
|
|
757
|
+
import { Networks as Networks2 } from "@stellar/stellar-sdk";
|
|
656
758
|
var friendbotFund = {
|
|
657
759
|
name: "ACCOUNT_FRIENDBOT_FUND",
|
|
658
760
|
similes: ["friendbot", "fund testnet account", "airdrop testnet xlm"],
|
|
@@ -671,7 +773,7 @@ var friendbotFund = {
|
|
|
671
773
|
}),
|
|
672
774
|
handler: async (agent, input) => {
|
|
673
775
|
const account = input.account ?? agent.wallet.publicKey;
|
|
674
|
-
if (agent.config.networkPassphrase ===
|
|
776
|
+
if (agent.config.networkPassphrase === Networks2.PUBLIC) {
|
|
675
777
|
console.warn(
|
|
676
778
|
"[ACCOUNT_FRIENDBOT_FUND] Agent is configured for the public network; Friendbot only funds testnet accounts."
|
|
677
779
|
);
|
|
@@ -695,6 +797,55 @@ var friendbotFund = {
|
|
|
695
797
|
}
|
|
696
798
|
};
|
|
697
799
|
|
|
800
|
+
// src/actions/knownIssuers.ts
|
|
801
|
+
import { z as z12 } from "zod";
|
|
802
|
+
var knownIssuers = {
|
|
803
|
+
name: "ASSET_KNOWN_ISSUERS",
|
|
804
|
+
similes: [
|
|
805
|
+
"list known issuers",
|
|
806
|
+
"canonical asset issuers",
|
|
807
|
+
"which usdc",
|
|
808
|
+
"verified usdc issuer",
|
|
809
|
+
"what issuer to use"
|
|
810
|
+
],
|
|
811
|
+
description: "Return the kit's verified canonical-asset registry for the active network. Use this when the user mentions a well-known asset by code (USDC, EURC, AQUA, etc.) and you need the correct issuer G-address to avoid hallucinating one. If `assetCode` is provided, returns just that entry (or null). Otherwise returns the full registry for the network.",
|
|
812
|
+
examples: [
|
|
813
|
+
[
|
|
814
|
+
{
|
|
815
|
+
input: { assetCode: "USDC" },
|
|
816
|
+
output: {
|
|
817
|
+
network: "testnet",
|
|
818
|
+
asset: {
|
|
819
|
+
code: "USDC",
|
|
820
|
+
issuer: "GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5",
|
|
821
|
+
description: "Circle's testnet USDC. NOTE: testnet has multiple USDC issuers..."
|
|
822
|
+
}
|
|
823
|
+
},
|
|
824
|
+
explanation: "Look up Circle USDC on testnet before adding a trustline."
|
|
825
|
+
}
|
|
826
|
+
],
|
|
827
|
+
[
|
|
828
|
+
{
|
|
829
|
+
input: {},
|
|
830
|
+
output: { network: "mainnet", assets: [{ code: "XLM", issuer: "native" }] },
|
|
831
|
+
explanation: "List the full registry for the active network."
|
|
832
|
+
}
|
|
833
|
+
]
|
|
834
|
+
],
|
|
835
|
+
schema: z12.object({
|
|
836
|
+
assetCode: z12.string().optional().describe("Optional: lookup a single asset by code (case-insensitive).")
|
|
837
|
+
}),
|
|
838
|
+
handler: async (agent, input) => {
|
|
839
|
+
const network = networkTag(agent.config.networkPassphrase);
|
|
840
|
+
if (input.assetCode) {
|
|
841
|
+
const asset = lookupKnownAsset(agent.config.networkPassphrase, input.assetCode);
|
|
842
|
+
return { network, asset };
|
|
843
|
+
}
|
|
844
|
+
const reg = network === "mainnet" ? KNOWN_ASSETS_MAINNET : KNOWN_ASSETS_TESTNET;
|
|
845
|
+
return { network, assets: Object.values(reg) };
|
|
846
|
+
}
|
|
847
|
+
};
|
|
848
|
+
|
|
698
849
|
// src/index.ts
|
|
699
850
|
var StellarAssetPlugin = {
|
|
700
851
|
name: "stellar-asset",
|
|
@@ -714,24 +865,31 @@ var StellarAssetPlugin = {
|
|
|
714
865
|
manageBuyOffer,
|
|
715
866
|
cancelOffer,
|
|
716
867
|
getOrderbook,
|
|
717
|
-
friendbotFund
|
|
868
|
+
friendbotFund,
|
|
869
|
+
knownIssuers
|
|
718
870
|
],
|
|
719
871
|
initialize() {
|
|
720
872
|
}
|
|
721
873
|
};
|
|
722
874
|
var index_default = StellarAssetPlugin;
|
|
723
875
|
export {
|
|
876
|
+
KNOWN_ASSETS_MAINNET,
|
|
877
|
+
KNOWN_ASSETS_TESTNET,
|
|
724
878
|
StellarAssetPlugin,
|
|
725
879
|
balance,
|
|
726
880
|
cancelOffer,
|
|
727
881
|
claimableBalanceClaim,
|
|
728
882
|
claimableBalanceCreate,
|
|
729
883
|
index_default as default,
|
|
884
|
+
describeKnownAssets,
|
|
730
885
|
friendbotFund,
|
|
731
886
|
getOrderbook,
|
|
732
887
|
issue,
|
|
888
|
+
knownIssuers,
|
|
889
|
+
lookupKnownAsset,
|
|
733
890
|
manageBuyOffer,
|
|
734
891
|
manageSellOffer,
|
|
892
|
+
networkTag,
|
|
735
893
|
pathPaymentStrictReceive,
|
|
736
894
|
pathPaymentStrictSend,
|
|
737
895
|
setOptions,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stellar-agent-kit/plugin-asset",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "Classic Stellar asset operations (transfer, path payment, trustline, issuance, claimable balances) as agent actions.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -22,13 +22,13 @@
|
|
|
22
22
|
"zod": "^3.23.8"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@stellar-agent-kit/core": "0.1.
|
|
25
|
+
"@stellar-agent-kit/core": "0.1.10"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"tsup": "^8.3.5",
|
|
29
29
|
"typescript": "^5.7.2",
|
|
30
30
|
"vitest": "^2.1.8",
|
|
31
|
-
"@stellar-agent-kit/core": "0.1.
|
|
31
|
+
"@stellar-agent-kit/core": "0.1.10"
|
|
32
32
|
},
|
|
33
33
|
"publishConfig": {
|
|
34
34
|
"access": "public"
|