@lutria/agentic-vault-sdk 0.0.1

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/_gen/agent.js ADDED
@@ -0,0 +1,100 @@
1
+ // Auto-generated by willow
2
+ // Program: agentic_vault
3
+ import web3 from "@solana/web3.js";
4
+ import { reader, assertArgs } from "@neuron1/willow-runtime";
5
+ const { PublicKey } = web3;
6
+
7
+ export const AGENT_SIZE = 178;
8
+
9
+ const toPubkey = (v) => (typeof v === "string" ? new PublicKey(v) : v);
10
+
11
+ /**
12
+ * @typedef {Object} AgentData
13
+ * @property {import("@solana/web3.js").PublicKey} owner
14
+ * @property {bigint} agent_id
15
+ * @property {bigint} total_assets
16
+ * @property {bigint} available_assets
17
+ * @property {bigint} allocated_assets
18
+ * @property {number} bump
19
+ * @property {import("@solana/web3.js").PublicKey} agent_address
20
+ * @property {string} name
21
+ * @property {boolean} is_active
22
+ * @property {bigint} created_at
23
+ * @property {bigint} last_activity
24
+ * @property {bigint} max_transfer_per_tx
25
+ * @property {bigint} max_transfer_per_day
26
+ * @property {bigint} transferred_today
27
+ * @property {bigint} last_transfer_day
28
+ */
29
+
30
+ export const agent_pda_args = {
31
+ agent_id: "u64",
32
+ };
33
+
34
+ export const Agent = {
35
+ programId: new PublicKey("HqGJZjR2WKHUVRq1PbZ7uV1rptNySxhmo78cZR7cks3u"),
36
+ /**
37
+ * @param {{agent_id: bigint|number} } args
38
+ * @returns {[PublicKey, number]}
39
+ */
40
+ pda: (args) => {
41
+ assertArgs(args, agent_pda_args, "pda");
42
+ const seeds = [];
43
+ seeds.push(Buffer.from("agent"));
44
+ seeds.push(reader.u64_to_bytes(args.agent_id));
45
+ return PublicKey.findProgramAddressSync(seeds, new PublicKey("HqGJZjR2WKHUVRq1PbZ7uV1rptNySxhmo78cZR7cks3u"));
46
+ },
47
+ layout: {
48
+ decode: (data) => {
49
+ const r = reader(data);
50
+ return {
51
+ owner: r.pubkey(),
52
+ agent_id: r.u64(),
53
+ total_assets: r.u64(),
54
+ available_assets: r.u64(),
55
+ allocated_assets: r.u64(),
56
+ bump: r.u8(),
57
+ agent_address: r.pubkey(),
58
+ name: r.string(32).replace(/\0/g, ""),
59
+ is_active: r.bool(),
60
+ created_at: r.i64(),
61
+ last_activity: r.i64(),
62
+ max_transfer_per_tx: r.u64(),
63
+ max_transfer_per_day: r.u64(),
64
+ transferred_today: r.u64(),
65
+ last_transfer_day: r.i64(),
66
+ };
67
+ },
68
+ }
69
+ };
70
+ /**
71
+ * @param {Buffer} data
72
+ * @returns {AgentData}
73
+ */
74
+ export function decodeAgent(data) {
75
+ return Agent.layout.decode(data);
76
+ }
77
+
78
+ /**
79
+ * @param {import("@solana/web3.js").Connection} connection
80
+ * @param {PublicKey|string} pubkey
81
+ * @returns {Promise<AgentData|null>}
82
+ */
83
+ export async function fetchAgent(connection, pubkey) {
84
+ const info = await connection.getAccountInfo(toPubkey(pubkey));
85
+ if (!info) return null;
86
+ return Agent.layout.decode(info.data);
87
+ }
88
+ /**
89
+ * @param {import("@solana/web3.js").Connection} connection
90
+ * @param {Array} filters
91
+ * @returns {Promise<Array<{pubkey: import("@solana/web3.js").PublicKey, account: AgentData}>>}
92
+ */
93
+ export async function fetchAgents(connection, filters = []) {
94
+ const programId = new PublicKey("HqGJZjR2WKHUVRq1PbZ7uV1rptNySxhmo78cZR7cks3u");
95
+ const list = Array.isArray(filters) ? [...filters] : [];
96
+ const hasSize = list.some((f) => f && typeof f === "object" && "dataSize" in f);
97
+ if (!hasSize) list.unshift({ dataSize: AGENT_SIZE });
98
+ const accounts = await connection.getProgramAccounts(programId, { filters: list });
99
+ return accounts.map((a) => ({ pubkey: a.pubkey, account: Agent.layout.decode(a.account.data) }));
100
+ }
@@ -0,0 +1,49 @@
1
+ // Auto-generated by willow
2
+ // Program: agentic_vault
3
+ import web3 from "@solana/web3.js";
4
+ import { writer, assertArgs, assertAccounts } from "@neuron1/willow-runtime";
5
+ const { PublicKey, TransactionInstruction } = web3;
6
+ const toPublicKey = (v) => {
7
+ if (typeof v === "string") return new PublicKey(v);
8
+ if (v && typeof v === "object" && v.publicKey) return v.publicKey;
9
+ return v;
10
+ };
11
+
12
+ export const agentic_credit_args = {
13
+ amount: "u64",
14
+ };
15
+
16
+ export const agentic_credit_accounts = {
17
+ agent_account: { signer: false, writable: true },
18
+ agent_usdc_account: { signer: false, writable: true },
19
+ credit_wallet_account: { signer: false, writable: true },
20
+ agent_address: { signer: true, writable: false },
21
+ token_program: { signer: false, writable: false },
22
+ };
23
+
24
+ /**
25
+ * @param {{agent_account: PublicKey|string, agent_usdc_account: PublicKey|string, credit_wallet_account: PublicKey|string, agent_address: PublicKey|string, token_program: PublicKey|string}} accounts
26
+ * @param {{amount: bigint|number}} args
27
+ * @returns {Promise<import("@solana/web3.js").TransactionInstruction>}
28
+ */
29
+ export async function agentic_credit(accounts, args) {
30
+ const programId = new PublicKey("HqGJZjR2WKHUVRq1PbZ7uV1rptNySxhmo78cZR7cks3u");
31
+ assertAccounts(accounts, agentic_credit_accounts, { allowRemaining: false });
32
+ assertArgs(args, agentic_credit_args);
33
+ const data = writer();
34
+ data.u8(4);
35
+ data.u64(args.amount);
36
+ const keys = [
37
+ { pubkey: toPublicKey(accounts.agent_account), isSigner: false, isWritable: true },
38
+ { pubkey: toPublicKey(accounts.agent_usdc_account), isSigner: false, isWritable: true },
39
+ { pubkey: toPublicKey(accounts.credit_wallet_account), isSigner: false, isWritable: true },
40
+ { pubkey: toPublicKey(accounts.agent_address), isSigner: true, isWritable: false },
41
+ { pubkey: toPublicKey(accounts.token_program), isSigner: false, isWritable: false },
42
+ ];
43
+
44
+ return new TransactionInstruction({
45
+ keys,
46
+ programId,
47
+ data: data.build(),
48
+ });
49
+ }
@@ -0,0 +1,49 @@
1
+ // Auto-generated by willow
2
+ // Program: agentic_vault
3
+ import web3 from "@solana/web3.js";
4
+ import { writer, assertArgs, assertAccounts } from "@neuron1/willow-runtime";
5
+ const { PublicKey, TransactionInstruction } = web3;
6
+ const toPublicKey = (v) => {
7
+ if (typeof v === "string") return new PublicKey(v);
8
+ if (v && typeof v === "object" && v.publicKey) return v.publicKey;
9
+ return v;
10
+ };
11
+
12
+ export const agentic_topup_args = {
13
+ amount: "u64",
14
+ };
15
+
16
+ export const agentic_topup_accounts = {
17
+ agent_account: { signer: false, writable: true },
18
+ agent_usdc_account: { signer: false, writable: true },
19
+ agent_wallet_account: { signer: false, writable: true },
20
+ agent_address: { signer: true, writable: false },
21
+ token_program: { signer: false, writable: false },
22
+ };
23
+
24
+ /**
25
+ * @param {{agent_account: PublicKey|string, agent_usdc_account: PublicKey|string, agent_wallet_account: PublicKey|string, agent_address: PublicKey|string, token_program: PublicKey|string}} accounts
26
+ * @param {{amount: bigint|number}} args
27
+ * @returns {Promise<import("@solana/web3.js").TransactionInstruction>}
28
+ */
29
+ export async function agentic_topup(accounts, args) {
30
+ const programId = new PublicKey("HqGJZjR2WKHUVRq1PbZ7uV1rptNySxhmo78cZR7cks3u");
31
+ assertAccounts(accounts, agentic_topup_accounts, { allowRemaining: false });
32
+ assertArgs(args, agentic_topup_args);
33
+ const data = writer();
34
+ data.u8(3);
35
+ data.u64(args.amount);
36
+ const keys = [
37
+ { pubkey: toPublicKey(accounts.agent_account), isSigner: false, isWritable: true },
38
+ { pubkey: toPublicKey(accounts.agent_usdc_account), isSigner: false, isWritable: true },
39
+ { pubkey: toPublicKey(accounts.agent_wallet_account), isSigner: false, isWritable: true },
40
+ { pubkey: toPublicKey(accounts.agent_address), isSigner: true, isWritable: false },
41
+ { pubkey: toPublicKey(accounts.token_program), isSigner: false, isWritable: false },
42
+ ];
43
+
44
+ return new TransactionInstruction({
45
+ keys,
46
+ programId,
47
+ data: data.build(),
48
+ });
49
+ }
@@ -0,0 +1,49 @@
1
+ // Auto-generated by willow
2
+ // Program: agentic_vault
3
+ import web3 from "@solana/web3.js";
4
+ import { writer, assertArgs, assertAccounts } from "@neuron1/willow-runtime";
5
+ const { PublicKey, TransactionInstruction } = web3;
6
+ const toPublicKey = (v) => {
7
+ if (typeof v === "string") return new PublicKey(v);
8
+ if (v && typeof v === "object" && v.publicKey) return v.publicKey;
9
+ return v;
10
+ };
11
+
12
+ export const agentic_transfer_args = {
13
+ amount: "u64",
14
+ };
15
+
16
+ export const agentic_transfer_accounts = {
17
+ agent_account: { signer: false, writable: true },
18
+ agent_usdc_account: { signer: false, writable: true },
19
+ agent_wallet_account: { signer: false, writable: true },
20
+ agent_address: { signer: true, writable: false },
21
+ token_program: { signer: false, writable: false },
22
+ };
23
+
24
+ /**
25
+ * @param {{agent_account: PublicKey|string, agent_usdc_account: PublicKey|string, agent_wallet_account: PublicKey|string, agent_address: PublicKey|string, token_program: PublicKey|string}} accounts
26
+ * @param {{amount: bigint|number}} args
27
+ * @returns {Promise<import("@solana/web3.js").TransactionInstruction>}
28
+ */
29
+ export async function agentic_transfer(accounts, args) {
30
+ const programId = new PublicKey("HqGJZjR2WKHUVRq1PbZ7uV1rptNySxhmo78cZR7cks3u");
31
+ assertAccounts(accounts, agentic_transfer_accounts, { allowRemaining: false });
32
+ assertArgs(args, agentic_transfer_args);
33
+ const data = writer();
34
+ data.u8(3);
35
+ data.u64(args.amount);
36
+ const keys = [
37
+ { pubkey: toPublicKey(accounts.agent_account), isSigner: false, isWritable: true },
38
+ { pubkey: toPublicKey(accounts.agent_usdc_account), isSigner: false, isWritable: true },
39
+ { pubkey: toPublicKey(accounts.agent_wallet_account), isSigner: false, isWritable: true },
40
+ { pubkey: toPublicKey(accounts.agent_address), isSigner: true, isWritable: false },
41
+ { pubkey: toPublicKey(accounts.token_program), isSigner: false, isWritable: false },
42
+ ];
43
+
44
+ return new TransactionInstruction({
45
+ keys,
46
+ programId,
47
+ data: data.build(),
48
+ });
49
+ }
@@ -0,0 +1,55 @@
1
+ // Auto-generated by willow
2
+ // Program: agentic_vault
3
+ import web3 from "@solana/web3.js";
4
+ import { writer, assertArgs, assertAccounts } from "@neuron1/willow-runtime";
5
+ const { PublicKey, TransactionInstruction } = web3;
6
+ const toPublicKey = (v) => {
7
+ if (typeof v === "string") return new PublicKey(v);
8
+ if (v && typeof v === "object" && v.publicKey) return v.publicKey;
9
+ return v;
10
+ };
11
+
12
+ export const deposit_args = {
13
+ amount: "u64",
14
+ };
15
+
16
+ export const deposit_accounts = {
17
+ agent_account: { signer: false, writable: true },
18
+ agent_usdc_account: { signer: false, writable: true },
19
+ owner_account: { signer: false, writable: false },
20
+ usdc_mint_account: { signer: false, writable: false },
21
+ system_program: { signer: false, writable: false },
22
+ token_program: { signer: false, writable: false },
23
+ depositor_account: { signer: true, writable: false },
24
+ depositor_usdc_account: { signer: false, writable: true },
25
+ };
26
+
27
+ /**
28
+ * @param {{agent_account: PublicKey|string, agent_usdc_account: PublicKey|string, owner_account: PublicKey|string, usdc_mint_account: PublicKey|string, system_program: PublicKey|string, token_program: PublicKey|string, depositor_account: PublicKey|string, depositor_usdc_account: PublicKey|string}} accounts
29
+ * @param {{amount: bigint|number}} args
30
+ * @returns {Promise<import("@solana/web3.js").TransactionInstruction>}
31
+ */
32
+ export async function deposit(accounts, args) {
33
+ const programId = new PublicKey("HqGJZjR2WKHUVRq1PbZ7uV1rptNySxhmo78cZR7cks3u");
34
+ assertAccounts(accounts, deposit_accounts, { allowRemaining: false });
35
+ assertArgs(args, deposit_args);
36
+ const data = writer();
37
+ data.u8(1);
38
+ data.u64(args.amount);
39
+ const keys = [
40
+ { pubkey: toPublicKey(accounts.agent_account), isSigner: false, isWritable: true },
41
+ { pubkey: toPublicKey(accounts.agent_usdc_account), isSigner: false, isWritable: true },
42
+ { pubkey: toPublicKey(accounts.owner_account), isSigner: false, isWritable: false },
43
+ { pubkey: toPublicKey(accounts.usdc_mint_account), isSigner: false, isWritable: false },
44
+ { pubkey: toPublicKey(accounts.system_program), isSigner: false, isWritable: false },
45
+ { pubkey: toPublicKey(accounts.token_program), isSigner: false, isWritable: false },
46
+ { pubkey: toPublicKey(accounts.depositor_account), isSigner: true, isWritable: false },
47
+ { pubkey: toPublicKey(accounts.depositor_usdc_account), isSigner: false, isWritable: true },
48
+ ];
49
+
50
+ return new TransactionInstruction({
51
+ keys,
52
+ programId,
53
+ data: data.build(),
54
+ });
55
+ }
@@ -0,0 +1,76 @@
1
+ // Auto-generated by willow
2
+ // Program: agentic_vault
3
+ import web3 from "@solana/web3.js";
4
+ import { writer, assertArgs, assertAccounts, reader } from "@neuron1/willow-runtime";
5
+ const { PublicKey, TransactionInstruction } = web3;
6
+ const toPublicKey = (v) => {
7
+ if (typeof v === "string") return new PublicKey(v);
8
+ if (v && typeof v === "object" && v.publicKey) return v.publicKey;
9
+ return v;
10
+ };
11
+
12
+ export const initialize_agent_args = {
13
+ agent_id: "u64",
14
+ agent_name: "string[32]",
15
+ agent_bump: "u8",
16
+ agent_address: "pubkey",
17
+ protocol_version: "u16",
18
+ max_transfer_per_tx: "u64",
19
+ max_transfer_per_day: "u64",
20
+ };
21
+
22
+ export const initialize_agent_accounts = {
23
+ agent_account: { signer: false, writable: true },
24
+ agent_usdc_account: { signer: false, writable: true },
25
+ owner_account: { signer: true, writable: false },
26
+ usdc_mint_account: { signer: false, writable: false },
27
+ system_program: { signer: false, writable: false },
28
+ token_program: { signer: false, writable: false },
29
+ protocol_account: { signer: false, writable: true },
30
+ };
31
+
32
+ /**
33
+ * @param {{agent_account: PublicKey|string, usdc_mint_account: PublicKey|string}} accounts
34
+ * @returns {[PublicKey, number]}
35
+ */
36
+ export function derive_agent_usdc_account(accounts) {
37
+ const seeds = [];
38
+ seeds.push(Buffer.from("agent_usdc"));
39
+ seeds.push(toPublicKey(accounts.agent_account).toBuffer());
40
+ return PublicKey.findProgramAddressSync(seeds, new PublicKey("HqGJZjR2WKHUVRq1PbZ7uV1rptNySxhmo78cZR7cks3u"));
41
+ }
42
+
43
+ /**
44
+ * @param {{agent_account: PublicKey|string, agent_usdc_account: PublicKey|string, owner_account: PublicKey|string, usdc_mint_account: PublicKey|string, system_program: PublicKey|string, token_program: PublicKey|string, protocol_account: PublicKey|string}} accounts
45
+ * @param {{agent_id: bigint|number, agent_name: string, agent_bump: any, agent_address: string|PublicKey, protocol_version: bigint|number, max_transfer_per_tx: bigint|number, max_transfer_per_day: bigint|number}} args
46
+ * @returns {Promise<import("@solana/web3.js").TransactionInstruction>}
47
+ */
48
+ export async function initialize_agent(accounts, args) {
49
+ const programId = new PublicKey("HqGJZjR2WKHUVRq1PbZ7uV1rptNySxhmo78cZR7cks3u");
50
+ assertAccounts(accounts, initialize_agent_accounts, { allowRemaining: false });
51
+ assertArgs(args, initialize_agent_args);
52
+ const data = writer();
53
+ data.u8(0);
54
+ data.u64(args.agent_id);
55
+ data.stringFixed(args.agent_name, 32);
56
+ data.u8(args.agent_bump);
57
+ data.pubkey(args.agent_address);
58
+ data.u16(args.protocol_version);
59
+ data.u64(args.max_transfer_per_tx);
60
+ data.u64(args.max_transfer_per_day);
61
+ const keys = [
62
+ { pubkey: toPublicKey(accounts.agent_account), isSigner: false, isWritable: true },
63
+ { pubkey: toPublicKey(accounts.agent_usdc_account), isSigner: false, isWritable: true },
64
+ { pubkey: toPublicKey(accounts.owner_account), isSigner: true, isWritable: false },
65
+ { pubkey: toPublicKey(accounts.usdc_mint_account), isSigner: false, isWritable: false },
66
+ { pubkey: toPublicKey(accounts.system_program), isSigner: false, isWritable: false },
67
+ { pubkey: toPublicKey(accounts.token_program), isSigner: false, isWritable: false },
68
+ { pubkey: toPublicKey(accounts.protocol_account), isSigner: false, isWritable: true },
69
+ ];
70
+
71
+ return new TransactionInstruction({
72
+ keys,
73
+ programId,
74
+ data: data.build(),
75
+ });
76
+ }
@@ -0,0 +1,57 @@
1
+ // Auto-generated by willow
2
+ // Program: agentic_vault
3
+ import web3 from "@solana/web3.js";
4
+ import { writer, assertArgs, assertAccounts } from "@neuron1/willow-runtime";
5
+ const { PublicKey, TransactionInstruction } = web3;
6
+ const toPublicKey = (v) => {
7
+ if (typeof v === "string") return new PublicKey(v);
8
+ if (v && typeof v === "object" && v.publicKey) return v.publicKey;
9
+ return v;
10
+ };
11
+
12
+ export const initialize_protocol_args = {
13
+ protocol_name: "string[32]",
14
+ protocol_fee: "u64",
15
+ protocol_bump: "u8",
16
+ protocol_version: "u16",
17
+ professor_address: "pubkey",
18
+ tokyo_address: "pubkey",
19
+ denver_address: "pubkey",
20
+ };
21
+
22
+ export const initialize_protocol_accounts = {
23
+ protocol_account: { signer: false, writable: true },
24
+ owner_account: { signer: true, writable: false },
25
+ system_program: { signer: false, writable: false },
26
+ };
27
+
28
+ /**
29
+ * @param {{protocol_account: PublicKey|string, owner_account: PublicKey|string, system_program: PublicKey|string}} accounts
30
+ * @param {{protocol_name: string, protocol_fee: bigint|number, protocol_bump: any, protocol_version: bigint|number, professor_address: string|PublicKey, tokyo_address: string|PublicKey, denver_address: string|PublicKey}} args
31
+ * @returns {Promise<import("@solana/web3.js").TransactionInstruction>}
32
+ */
33
+ export async function initialize_protocol(accounts, args) {
34
+ const programId = new PublicKey("HqGJZjR2WKHUVRq1PbZ7uV1rptNySxhmo78cZR7cks3u");
35
+ assertAccounts(accounts, initialize_protocol_accounts, { allowRemaining: false });
36
+ assertArgs(args, initialize_protocol_args);
37
+ const data = writer();
38
+ data.u8(27);
39
+ data.stringFixed(args.protocol_name, 32);
40
+ data.u64(args.protocol_fee);
41
+ data.u8(args.protocol_bump);
42
+ data.u16(args.protocol_version);
43
+ data.pubkey(args.professor_address);
44
+ data.pubkey(args.tokyo_address);
45
+ data.pubkey(args.denver_address);
46
+ const keys = [
47
+ { pubkey: toPublicKey(accounts.protocol_account), isSigner: false, isWritable: true },
48
+ { pubkey: toPublicKey(accounts.owner_account), isSigner: true, isWritable: false },
49
+ { pubkey: toPublicKey(accounts.system_program), isSigner: false, isWritable: false },
50
+ ];
51
+
52
+ return new TransactionInstruction({
53
+ keys,
54
+ programId,
55
+ data: data.build(),
56
+ });
57
+ }
@@ -0,0 +1,88 @@
1
+ // Auto-generated by willow
2
+ // Program: agentic_vault
3
+ import web3 from "@solana/web3.js";
4
+ import { reader, assertArgs } from "@neuron1/willow-runtime";
5
+ const { PublicKey } = web3;
6
+
7
+ export const PROTOCOL_SIZE = 179;
8
+
9
+ const toPubkey = (v) => (typeof v === "string" ? new PublicKey(v) : v);
10
+
11
+ /**
12
+ * @typedef {Object} ProtocolData
13
+ * @property {string} name
14
+ * @property {import("@solana/web3.js").PublicKey} owner
15
+ * @property {bigint} total_vaults
16
+ * @property {bigint} fee_sol
17
+ * @property {import("@solana/web3.js").PublicKey} professor_address
18
+ * @property {import("@solana/web3.js").PublicKey} tokyo_address
19
+ * @property {import("@solana/web3.js").PublicKey} denver_address
20
+ * @property {number} version
21
+ * @property {number} bump
22
+ */
23
+
24
+ export const protocol_pda_args = {
25
+ protocol_version: "u16",
26
+ };
27
+
28
+ export const Protocol = {
29
+ programId: new PublicKey("HqGJZjR2WKHUVRq1PbZ7uV1rptNySxhmo78cZR7cks3u"),
30
+ /**
31
+ * @param {{protocol_version: number} } args
32
+ * @returns {[PublicKey, number]}
33
+ */
34
+ pda: (args) => {
35
+ assertArgs(args, protocol_pda_args, "pda");
36
+ const seeds = [];
37
+ seeds.push(Buffer.from("protocol"));
38
+ seeds.push(reader.u16_to_bytes(args.protocol_version));
39
+ return PublicKey.findProgramAddressSync(seeds, new PublicKey("HqGJZjR2WKHUVRq1PbZ7uV1rptNySxhmo78cZR7cks3u"));
40
+ },
41
+ layout: {
42
+ decode: (data) => {
43
+ const r = reader(data);
44
+ return {
45
+ name: r.string(32).replace(/\0/g, ""),
46
+ owner: r.pubkey(),
47
+ total_vaults: r.u64(),
48
+ fee_sol: r.u64(),
49
+ professor_address: r.pubkey(),
50
+ tokyo_address: r.pubkey(),
51
+ denver_address: r.pubkey(),
52
+ version: r.u16(),
53
+ bump: r.u8(),
54
+ };
55
+ },
56
+ }
57
+ };
58
+ /**
59
+ * @param {Buffer} data
60
+ * @returns {ProtocolData}
61
+ */
62
+ export function decodeProtocol(data) {
63
+ return Protocol.layout.decode(data);
64
+ }
65
+
66
+ /**
67
+ * @param {import("@solana/web3.js").Connection} connection
68
+ * @param {PublicKey|string} pubkey
69
+ * @returns {Promise<ProtocolData|null>}
70
+ */
71
+ export async function fetchProtocol(connection, pubkey) {
72
+ const info = await connection.getAccountInfo(toPubkey(pubkey));
73
+ if (!info) return null;
74
+ return Protocol.layout.decode(info.data);
75
+ }
76
+ /**
77
+ * @param {import("@solana/web3.js").Connection} connection
78
+ * @param {Array} filters
79
+ * @returns {Promise<Array<{pubkey: import("@solana/web3.js").PublicKey, account: ProtocolData}>>}
80
+ */
81
+ export async function fetchProtocols(connection, filters = []) {
82
+ const programId = new PublicKey("HqGJZjR2WKHUVRq1PbZ7uV1rptNySxhmo78cZR7cks3u");
83
+ const list = Array.isArray(filters) ? [...filters] : [];
84
+ const hasSize = list.some((f) => f && typeof f === "object" && "dataSize" in f);
85
+ if (!hasSize) list.unshift({ dataSize: PROTOCOL_SIZE });
86
+ const accounts = await connection.getProgramAccounts(programId, { filters: list });
87
+ return accounts.map((a) => ({ pubkey: a.pubkey, account: Protocol.layout.decode(a.account.data) }));
88
+ }
@@ -0,0 +1,55 @@
1
+ // Auto-generated by willow
2
+ // Program: agentic_vault
3
+ import web3 from "@solana/web3.js";
4
+ import { writer, assertArgs, assertAccounts } from "@neuron1/willow-runtime";
5
+ const { PublicKey, TransactionInstruction } = web3;
6
+ const toPublicKey = (v) => {
7
+ if (typeof v === "string") return new PublicKey(v);
8
+ if (v && typeof v === "object" && v.publicKey) return v.publicKey;
9
+ return v;
10
+ };
11
+
12
+ export const withdraw_args = {
13
+ amount: "u64",
14
+ };
15
+
16
+ export const withdraw_accounts = {
17
+ agent_account: { signer: false, writable: true },
18
+ agent_usdc_account: { signer: false, writable: true },
19
+ owner_account: { signer: false, writable: false },
20
+ usdc_mint_account: { signer: false, writable: false },
21
+ system_program: { signer: false, writable: false },
22
+ token_program: { signer: false, writable: false },
23
+ receiver_account: { signer: true, writable: false },
24
+ receiver_usdc_account: { signer: false, writable: true },
25
+ };
26
+
27
+ /**
28
+ * @param {{agent_account: PublicKey|string, agent_usdc_account: PublicKey|string, owner_account: PublicKey|string, usdc_mint_account: PublicKey|string, system_program: PublicKey|string, token_program: PublicKey|string, receiver_account: PublicKey|string, receiver_usdc_account: PublicKey|string}} accounts
29
+ * @param {{amount: bigint|number}} args
30
+ * @returns {Promise<import("@solana/web3.js").TransactionInstruction>}
31
+ */
32
+ export async function withdraw(accounts, args) {
33
+ const programId = new PublicKey("HqGJZjR2WKHUVRq1PbZ7uV1rptNySxhmo78cZR7cks3u");
34
+ assertAccounts(accounts, withdraw_accounts, { allowRemaining: false });
35
+ assertArgs(args, withdraw_args);
36
+ const data = writer();
37
+ data.u8(2);
38
+ data.u64(args.amount);
39
+ const keys = [
40
+ { pubkey: toPublicKey(accounts.agent_account), isSigner: false, isWritable: true },
41
+ { pubkey: toPublicKey(accounts.agent_usdc_account), isSigner: false, isWritable: true },
42
+ { pubkey: toPublicKey(accounts.owner_account), isSigner: false, isWritable: false },
43
+ { pubkey: toPublicKey(accounts.usdc_mint_account), isSigner: false, isWritable: false },
44
+ { pubkey: toPublicKey(accounts.system_program), isSigner: false, isWritable: false },
45
+ { pubkey: toPublicKey(accounts.token_program), isSigner: false, isWritable: false },
46
+ { pubkey: toPublicKey(accounts.receiver_account), isSigner: true, isWritable: false },
47
+ { pubkey: toPublicKey(accounts.receiver_usdc_account), isSigner: false, isWritable: true },
48
+ ];
49
+
50
+ return new TransactionInstruction({
51
+ keys,
52
+ programId,
53
+ data: data.build(),
54
+ });
55
+ }
@@ -0,0 +1,9 @@
1
+ // Dev workspace (safe to edit)
2
+ import * as gen from "../_gen/agent.js";
3
+ export * from "../_gen/agent.js";
4
+
5
+ // Add custom helpers below.
6
+ // Example:
7
+ // export function customHelper(input) {
8
+ // return gen; // use gen.* helpers
9
+ // }
@@ -0,0 +1,9 @@
1
+ // Dev workspace (safe to edit)
2
+ import * as gen from "../_gen/protocol.js";
3
+ export * from "../_gen/protocol.js";
4
+
5
+ // Add custom helpers below.
6
+ // Example:
7
+ // export function customHelper(input) {
8
+ // return gen; // use gen.* helpers
9
+ // }
package/index.js ADDED
@@ -0,0 +1,39 @@
1
+ // Auto-generated by willow
2
+ // Program: agentic_vault
3
+ import * as account_protocol from "./accounts/protocol.js";
4
+ import * as account_agent from "./accounts/agent.js";
5
+ import * as ix_agentic_credit from "./instructions/agentic_credit.js";
6
+ import * as ix_initialize_protocol from "./instructions/initialize_protocol.js";
7
+ import * as ix_withdraw from "./instructions/withdraw.js";
8
+ import * as ix_initialize_agent from "./instructions/initialize_agent.js";
9
+ import * as ix_deposit from "./instructions/deposit.js";
10
+ import * as ix_agentic_topup from "./instructions/agentic_topup.js";
11
+
12
+ /** @typedef {Object} Pdas
13
+ * @property {(args: {protocol_version: number}) => [import("@solana/web3.js").PublicKey, number]} Protocol
14
+ * @property {(args: {agent_id: bigint|number}) => [import("@solana/web3.js").PublicKey, number]} Agent
15
+ * @property {(accounts: {agent_account: PublicKey|string, usdc_mint_account: PublicKey|string}) => Promise<[import("@solana/web3.js").PublicKey, number]>} derive_agent_usdc_account
16
+ */
17
+ /** @type {Pdas} */
18
+ const pdas = {
19
+ Protocol: account_protocol.Protocol,
20
+ Agent: account_agent.Agent,
21
+ derive_agent_usdc_account: async (args) => ix_initialize_agent.derive_agent_usdc_account(args),
22
+ };
23
+
24
+ export const agentic_vault_sdk = {
25
+ accounts: {
26
+ protocol: account_protocol,
27
+ agent: account_agent,
28
+ },
29
+ pdas,
30
+ instructions: {
31
+ agentic_credit: ix_agentic_credit.agentic_credit,
32
+ initialize_protocol: ix_initialize_protocol.initialize_protocol,
33
+ withdraw: ix_withdraw.withdraw,
34
+ initialize_agent: ix_initialize_agent.initialize_agent,
35
+ deposit: ix_deposit.deposit,
36
+ agentic_topup: ix_agentic_topup.agentic_topup,
37
+ },
38
+ };
39
+ export default agentic_vault_sdk;
@@ -0,0 +1,15 @@
1
+ // Dev workspace (safe to edit)
2
+ import { agentic_credit } from "../_gen/agentic_credit.js";
3
+ import { Agent, fetchAgent, fetchAgents, AGENT_SIZE } from "../_gen/agent.js";
4
+
5
+ // Add custom helpers below.
6
+ // Example:
7
+ // export function agentic_creditWithChecks(input) {
8
+ // return agentic_credit(input.programId, input.accounts, input.args);
9
+ // }
10
+
11
+ export { agentic_credit };
12
+ export { Agent };
13
+ export { fetchAgent };
14
+ export { fetchAgents };
15
+ export { AGENT_SIZE };
@@ -0,0 +1,15 @@
1
+ // Dev workspace (safe to edit)
2
+ import { agentic_topup } from "../_gen/agentic_topup.js";
3
+ import { Agent, fetchAgent, fetchAgents, AGENT_SIZE } from "../_gen/agent.js";
4
+
5
+ // Add custom helpers below.
6
+ // Example:
7
+ // export function agentic_topupWithChecks(input) {
8
+ // return agentic_topup(input.programId, input.accounts, input.args);
9
+ // }
10
+
11
+ export { agentic_topup };
12
+ export { Agent };
13
+ export { fetchAgent };
14
+ export { fetchAgents };
15
+ export { AGENT_SIZE };
@@ -0,0 +1,15 @@
1
+ // Dev workspace (safe to edit)
2
+ import { agentic_transfer } from "../_gen/agentic_transfer.js";
3
+ import { Agent, fetchAgent, fetchAgents, AGENT_SIZE } from "../_gen/agent.js";
4
+
5
+ // Add custom helpers below.
6
+ // Example:
7
+ // export function agentic_transferWithChecks(input) {
8
+ // return agentic_transfer(input.programId, input.accounts, input.args);
9
+ // }
10
+
11
+ export { agentic_transfer };
12
+ export { Agent };
13
+ export { fetchAgent };
14
+ export { fetchAgents };
15
+ export { AGENT_SIZE };
@@ -0,0 +1,15 @@
1
+ // Dev workspace (safe to edit)
2
+ import { deposit } from "../_gen/deposit.js";
3
+ import { Agent, fetchAgent, fetchAgents, AGENT_SIZE } from "../_gen/agent.js";
4
+
5
+ // Add custom helpers below.
6
+ // Example:
7
+ // export function depositWithChecks(input) {
8
+ // return deposit(input.programId, input.accounts, input.args);
9
+ // }
10
+
11
+ export { deposit };
12
+ export { Agent };
13
+ export { fetchAgent };
14
+ export { fetchAgents };
15
+ export { AGENT_SIZE };
@@ -0,0 +1,21 @@
1
+ // Dev workspace (safe to edit)
2
+ import { initialize_agent, derive_agent_usdc_account } from "../_gen/initialize_agent.js";
3
+ import { Agent, fetchAgent, fetchAgents, AGENT_SIZE } from "../_gen/agent.js";
4
+ import { Protocol, fetchProtocol, fetchProtocols, PROTOCOL_SIZE } from "../_gen/protocol.js";
5
+
6
+ // Add custom helpers below.
7
+ // Example:
8
+ // export function initialize_agentWithChecks(input) {
9
+ // return initialize_agent(input.programId, input.accounts, input.args);
10
+ // }
11
+
12
+ export { initialize_agent };
13
+ export { derive_agent_usdc_account };
14
+ export { Agent };
15
+ export { fetchAgent };
16
+ export { fetchAgents };
17
+ export { AGENT_SIZE };
18
+ export { Protocol };
19
+ export { fetchProtocol };
20
+ export { fetchProtocols };
21
+ export { PROTOCOL_SIZE };
@@ -0,0 +1,15 @@
1
+ // Dev workspace (safe to edit)
2
+ import { initialize_protocol } from "../_gen/initialize_protocol.js";
3
+ import { Protocol, fetchProtocol, fetchProtocols, PROTOCOL_SIZE } from "../_gen/protocol.js";
4
+
5
+ // Add custom helpers below.
6
+ // Example:
7
+ // export function initialize_protocolWithChecks(input) {
8
+ // return initialize_protocol(input.programId, input.accounts, input.args);
9
+ // }
10
+
11
+ export { initialize_protocol };
12
+ export { Protocol };
13
+ export { fetchProtocol };
14
+ export { fetchProtocols };
15
+ export { PROTOCOL_SIZE };
@@ -0,0 +1,15 @@
1
+ // Dev workspace (safe to edit)
2
+ import { withdraw } from "../_gen/withdraw.js";
3
+ import { Agent, fetchAgent, fetchAgents, AGENT_SIZE } from "../_gen/agent.js";
4
+
5
+ // Add custom helpers below.
6
+ // Example:
7
+ // export function withdrawWithChecks(input) {
8
+ // return withdraw(input.programId, input.accounts, input.args);
9
+ // }
10
+
11
+ export { withdraw };
12
+ export { Agent };
13
+ export { fetchAgent };
14
+ export { fetchAgents };
15
+ export { AGENT_SIZE };
package/package.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "@lutria/agentic-vault-sdk",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "main": "./index.js",
6
+ "exports": "./index.js",
7
+ "dependencies": {
8
+ "@neuron1/willow-runtime": "^0.1.0"
9
+ },
10
+ "publishConfig": {
11
+ "access": "public"
12
+ }
13
+ }