feat(lending-health): add T0 read-only Kamino lending position monitor#110
Open
CECILIA-MULANDI wants to merge 3 commits into
Open
feat(lending-health): add T0 read-only Kamino lending position monitor#110CECILIA-MULANDI wants to merge 3 commits into
CECILIA-MULANDI wants to merge 3 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
lending-health, a T0 read-only tool plugin that monitors a Solana wallet's Kamino Lend positions.api_base_url,env,market_pubkey,health_amber_bps, andhealth_red_bps.Custody tier
T0. No transaction builder, no signer, no wallet secret, no write RPC method. Cannot sign, borrow, repay, deposit, withdraw, or move funds. Cannot hit an arbitrary endpoint: API URL and market pubkey are operator config, not tool arguments. Permissions requested are
http_client(two well-known Kamino paths, GET only, both hardcoded in the shim) andconfig_read(endpoint URL, market pubkey, env, alert thresholds).Threat model, two prompt-injection transcripts, and defenses (base58 32-byte validation,
deny_unknown_fields, obligation echo check, NaN/negative rejection, tag range check) are in the plugin README.Layout
Follows the
redact-textreference exactly:src/lending_health.rs, zero wasm or HTTP dependency, exercised by 50 host tests via plaincargo test.#[cfg(target_family = "wasm")]shim insrc/lib.rsthat validates args, discovers obligations, fetches metrics, aggregates, and emits structured logs through theloggingimport.manifest.tomldeclares only the two permissions the plugin actually uses.#[serde(deny_unknown_fields)]onExecuteArgsandadditionalProperties: falseplus base58 regex on the JSON Schema.Validation
zeroclaw plugin install plugins/lending-healthaccepts the manifest,zeroclaw plugin listshows the plugin,zeroclaw plugin info lending-healthreads capabilities and permissions.wasm32-wasip2 notes
The stock Solana client stack does not compile for
wasm32-wasip2. The dependency set is deliberately narrow:waki 0.5.1for blocking WASI HTTP. Waki vendors its ownwit-bindgen 0.34alongside our0.46; both coexist. Waki emitswasi:http@0.2.4imports while the current host baseline is@0.2.6. Both link without issue.serde_jsonfor one hand-shaped GET per API endpoint and defensive response parsers.bs58 0.5for public-key validation.solana-program, nosolana-client. Nothing else was needed at v0.1.Kamino returns Decimal fields as JSON strings for precision. The parser accepts either string or number, and rejects NaN, positive infinity, and negatives before any arithmetic. Health calc uses f64 for the ratio then rounds to u32 basis points, so tier comparisons against operator config are bit-exact.
Release component size: about 374 KB with
opt-level = "s",lto = true,strip = true,codegen-units = 1.Security & Privacy Impact
http_clientandconfig_readonly. No filesystem, no sockets, no memory backend.api_base_url, both hardcoded in the shim. Method is always GET. Only operator-supplied config controls the host.Compatibility
v0.2 plan
getMultipleAccountsInfoon the obligation and referenced reserves, with hand-rolled borsh decoders. Same policy core and report shape.