@dfm-fi/agent 0.2.1543 → 0.2.1549

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.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=recover-app-wallet-assets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recover-app-wallet-assets.d.ts","sourceRoot":"","sources":["../../src/examples/recover-app-wallet-assets.ts"],"names":[],"mappings":""}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Recover what a test cycle stranded in the app wallet: every non-USDC, non-share
3
+ * token goes OUT to one destination, in one pass, so it can be swapped back to
4
+ * USDC from a wallet whose key is local (`contracts/scripts/swap-wallet-tokens-to-usdc.js`).
5
+ *
6
+ * An in-kind cancel and the per-leg surplus refunds pay the user in BASKET TOKENS,
7
+ * and the app wallet has no swap surface — so the value sits there until it is
8
+ * moved. This is the move.
9
+ *
10
+ * Dry-run by default; `--execute` sends. Fund shares are skipped (redeem them, do
11
+ * not transfer them) and so is USDC (it is already the thing we want).
12
+ *
13
+ * DFM_API_URL=https://n2-api.dfm.finance \
14
+ * DFM_AGENT_KEYPAIR_PATH=~/.config/dfm/test-6vch.json \
15
+ * DEST=<address> MIN_USD=0.05 npx tsx src/examples/recover-app-wallet-assets.ts [--execute]
16
+ *
17
+ * Prints the `MINTS=` line the swap script takes, so the two steps chain.
18
+ */
19
+ import { loadConfig } from '../config.js';
20
+ import { SiwsSession } from '../session.js';
21
+ import { DfmApiClient } from '../api-client.js';
22
+ const USDC = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v';
23
+ async function main() {
24
+ const execute = process.argv.includes('--execute');
25
+ const config = loadConfig();
26
+ const api = new DfmApiClient(config, new SiwsSession(config));
27
+ const dest = process.env.DEST;
28
+ if (!dest)
29
+ throw new Error('DEST (the receiving address) is required');
30
+ const minUsd = Number(process.env.MIN_USD ?? '0.05');
31
+ const assets = (await api.authRequest('/agent/operating/assets', { method: 'GET' }));
32
+ // Dust below the floor costs more in rent and fees than it returns; a fund
33
+ // share is a CLAIM, not value in hand — it leaves through redeem, never here.
34
+ const movable = assets.assets.filter((a) => a.mint !== USDC && !a.isFundShare && (a.valueUsd ?? 0) >= minUsd);
35
+ const total = movable.reduce((sum, a) => sum + (a.valueUsd ?? 0), 0);
36
+ console.log(`app wallet ${assets.operatingWalletAddress} → ${dest}`);
37
+ console.log(`${movable.length} tokens worth ~$${total.toFixed(2)} (floor $${minUsd})\n`);
38
+ for (const a of movable)
39
+ console.log(` ${a.mint.slice(0, 8)}… ${a.uiAmount} ≈ $${(a.valueUsd ?? 0).toFixed(3)}`);
40
+ // The destination has to pay for its own swaps afterwards, and a test wallet
41
+ // that just spent its SOL on rent cannot. Move gas in the same pass.
42
+ const solLamports = Number(process.env.SOL_LAMPORTS ?? '0');
43
+ if (!execute) {
44
+ if (solLamports > 0)
45
+ console.log(`\nwould also send ${(solLamports / 1e9).toFixed(4)} SOL for gas`);
46
+ console.log('\nDRY-RUN — nothing sent. Re-run with --execute.');
47
+ }
48
+ else {
49
+ console.log('');
50
+ if (solLamports > 0) {
51
+ try {
52
+ const r = await api.authRequest('/agent/operating/float/withdraw', {
53
+ method: 'POST',
54
+ body: JSON.stringify({ solLamports, destination: dest }),
55
+ });
56
+ console.log(`sent ${(solLamports / 1e9).toFixed(4)} SOL for gas — ${r.signature}`);
57
+ }
58
+ catch (e) {
59
+ console.log(`FAILED SOL gas — ${e.message.slice(0, 140)}`);
60
+ }
61
+ }
62
+ for (const a of movable) {
63
+ try {
64
+ const r = await api.authRequest('/agent/operating/assets/withdraw', {
65
+ method: 'POST',
66
+ body: JSON.stringify({ mint: a.mint, all: true, destination: dest }),
67
+ });
68
+ console.log(`sent ${a.mint.slice(0, 8)}… ${r.sentAmount} — ${r.signature}`);
69
+ }
70
+ catch (e) {
71
+ console.log(`FAILED ${a.mint.slice(0, 8)}… ${e.message.slice(0, 140)}`);
72
+ }
73
+ }
74
+ }
75
+ console.log(`\nMINTS="${movable.map((a) => `${a.label ?? a.mint.slice(0, 4)}:${a.mint}`).join(',')}"`);
76
+ }
77
+ main().catch((e) => {
78
+ console.error('FAILED', e instanceof Error ? e.message : e);
79
+ process.exit(1);
80
+ });
81
+ //# sourceMappingURL=recover-app-wallet-assets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recover-app-wallet-assets.js","sourceRoot":"","sources":["../../src/examples/recover-app-wallet-assets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,MAAM,IAAI,GAAG,8CAA8C,CAAC;AAW5D,KAAK,UAAU,IAAI;IACjB,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IACnD,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;IAC5B,MAAM,GAAG,GAAG,IAAI,YAAY,CAAC,MAAM,EAAE,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;IAC9D,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;IAC9B,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IACvE,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,MAAM,CAAC,CAAC;IAErD,MAAM,MAAM,GAAG,CAAC,MAAO,GAErB,CAAC,WAAW,CAAC,yBAAyB,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IAE9D,2EAA2E;IAC3E,8EAA8E;IAC9E,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAClC,CAAC,CAAC,EAAE,EA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AE,GAAG,CAAC,EAAE,CAAC,CAAC;YACrF,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,YAAY,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACzG,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;IACjB,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dfm-fi/agent",
3
- "version": "0.2.1543",
3
+ "version": "0.2.1549",
4
4
  "description": "DFM v2 MCP server — drive the full DTF launch → deposit → redeem (+ manage) lifecycle from an AI agent against the live API.",
5
5
  "type": "module",
6
6
  "bin": {