get_marinade_state
Retrieve current Marinade Finance protocol state including staked assets, mint address, price, and rewards data.
Instructions
Retrieve the current state of the Marinade Finance protocol, including information about staked assets, mint address, price, rewards, and other relevant data.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools.ts:98-172 (handler)The core handler (callback) for the 'get_marinade_state' tool. Instantiates a Marinade SDK client, fetches the current protocol state, serializes it (handling PublicKeys, BNs, circular refs, and filtering problematic objects), and returns formatted JSON or error.callback: async () => { try { const marinade = new Marinade() const marinadeStateRaw = await marinade.getMarinadeState(); const visited = new WeakSet(); const marinadeState = JSON.parse(JSON.stringify(marinadeStateRaw, (key, value) => { if (value === null || typeof value !== 'object') { return value; } if (visited.has(value)) { return '[Circular Reference]'; } visited.add(value); if (value && value.constructor?.name === 'PublicKey') { return value.toString(); } if (value && value.constructor?.name === 'BN') { return value.toString(); } const problematicTypes = [ 'Marinade', 'MarinadeReferralProgram', 'RpcWebSocketClient', 'Connection', 'EventEmitter', 'Events' ]; if (value.constructor && problematicTypes.includes(value.constructor.name)) { return '[Filtered Object: ' + value.constructor.name + ']'; } if (typeof value === 'function' || (value && value._events)) { return undefined; } return value; })); return { content: [ { type: "text", text: JSON.stringify(marinadeState, null, 2), }, ], }; } catch (err) { const isAbort = (err as Error)?.name === "AbortError"; return { content: [ { type: "text", text: JSON.stringify( { error: isAbort ? "Request timed out" : "Failed to fetch Marinade State", reason: String((err as Error)?.message ?? err), }, null, 2 ), }, ], }; } }
- src/tools.ts:93-173 (registration)Registration of the 'get_marinade_state' tool in the publicTools array, including name, title, description, empty inputSchema, and reference to the handler callback.{ name: "get_marinade_state", title: "Get Marinade State", description: "Retrieve the current state of the Marinade Finance protocol, including information about staked assets, mint address, price, rewards, and other relevant data.", inputSchema: {}, callback: async () => { try { const marinade = new Marinade() const marinadeStateRaw = await marinade.getMarinadeState(); const visited = new WeakSet(); const marinadeState = JSON.parse(JSON.stringify(marinadeStateRaw, (key, value) => { if (value === null || typeof value !== 'object') { return value; } if (visited.has(value)) { return '[Circular Reference]'; } visited.add(value); if (value && value.constructor?.name === 'PublicKey') { return value.toString(); } if (value && value.constructor?.name === 'BN') { return value.toString(); } const problematicTypes = [ 'Marinade', 'MarinadeReferralProgram', 'RpcWebSocketClient', 'Connection', 'EventEmitter', 'Events' ]; if (value.constructor && problematicTypes.includes(value.constructor.name)) { return '[Filtered Object: ' + value.constructor.name + ']'; } if (typeof value === 'function' || (value && value._events)) { return undefined; } return value; })); return { content: [ { type: "text", text: JSON.stringify(marinadeState, null, 2), }, ], }; } catch (err) { const isAbort = (err as Error)?.name === "AbortError"; return { content: [ { type: "text", text: JSON.stringify( { error: isAbort ? "Request timed out" : "Failed to fetch Marinade State", reason: String((err as Error)?.message ?? err), }, null, 2 ), }, ], }; } } },
- src/tools.ts:97-97 (schema)Input schema definition for the tool, which is an empty object (no input parameters required).inputSchema: {},