Skip to content

Lending: remove individual addresses from market and price-feed seeds#73

Merged
mikemaccana merged 4 commits into
mainfrom
claude/busy-pasteur-eMVnc
Jun 21, 2026
Merged

Lending: remove individual addresses from market and price-feed seeds#73
mikemaccana merged 4 commits into
mainfrom
claude/busy-pasteur-eMVnc

Conversation

@mikemaccana

Copy link
Copy Markdown
Collaborator

Follow-up to the merged lending example (#44). Markets and admin structs shouldn't be identified by an individual's address — this removes people's pubkeys from the PDA seeds.

Changes

  • LendingMarket is now seeded by ["lending_market", market_id] — a u64 index, no owner in the seed. owner stays a stored field and authorizes admin instructions via has_one = owner. One owner can run several independent, risk-isolated markets (0, 1, 2 …).
  • PriceFeed is now seeded by ["price_feed", market, mint] — scoped to a market, not to any individual. set_price requires the market's owner to sign, so prices can't be squatted, a reserve binds to its own market's feed, and isolated markets can price the same asset independently. (In production the feed is an external Switchboard account with no program seeds.)

Scope

Applied to both the Anchor and Quasar programs, with test harnesses, READMEs, and CHANGELOGs updated.

Tests

Anchor: 22 tests pass (cargo test); IDL build verified. Quasar: 6 tests pass. Build with anchor build / cargo-build-sbf first so tests can load the .so.

https://claude.ai/code/session_01RwE8f8ahP5S6SDNTsXmpj9


Generated by Claude Code

claude added 4 commits June 21, 2026 20:53
A market keyed on the owner's address can only ever exist once per owner, which
contradicts the multi-market isolation the program is meant to support, and is
inconsistent with the repo's own convention (the order-book Market is seeded by
its mint pair, not by an admin's address). LendingMarket is now seeded by a
unique market_id (a client-chosen Pubkey, like token-swap's Amm); owner is a
stored field and admin handlers authorize with has_one = owner. Reserves,
obligations, and vaults already key off the market account address, so they're
unchanged. Mirrored into the Quasar port (market_id passed as a reference
account) and the test harnesses; READMEs/CHANGELOGs updated.

https://claude.ai/code/session_01RwE8f8ahP5S6SDNTsXmpj9
Replaces the Pubkey market_id with a per-owner u64 index: the market PDA is now
seeded by (owner, market_id), e.g. "owner's market 0". An integer is more
readable than an opaque pubkey and needs no keypair; scoping it under the owner
keeps each owner's index space collision-free without a global registry (a bare
global integer would invite the same first-come land-grab the oracle fix
removed). Applied to Anchor and Quasar (Quasar takes market_id as an
instruction-data u64 seed, dropping the reference account), with test harnesses,
READMEs, and CHANGELOGs updated.

https://claude.ai/code/session_01RwE8f8ahP5S6SDNTsXmpj9
Markets and admin structs shouldn't be identified by a person's address.

- LendingMarket is now seeded by ["lending_market", market_id] — a u64 index,
  no owner in the seed. owner remains a stored field and authorizes admin
  instructions via has_one = owner.
- PriceFeed is now seeded by ["price_feed", market, mint] — scoped to a market,
  not to an individual. set_price requires the market's owner to sign, so prices
  can't be squatted, a reserve binds to its own market's feed, and isolated
  markets can price the same asset independently.

Applied to both Anchor and Quasar, with test harnesses, READMEs, and CHANGELOGs
updated. Anchor 22 tests + Quasar 6 tests pass; IDL build verified.

https://claude.ai/code/session_01RwE8f8ahP5S6SDNTsXmpj9
The Solana skill's naming rule is to avoid abbreviations and use full
words. Two Quasar comments shortened 'liquidation threshold' to 'liq
threshold'; the Anchor side already spells it out. Align them.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RwE8f8ahP5S6SDNTsXmpj9
@mikemaccana mikemaccana merged commit 924a07c into main Jun 21, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants