Skip to content

feat(defi): add asset-leasing example (Anchor + Quasar)#39

Open
mikemaccana wants to merge 2 commits into
mainfrom
claude/asset-leasing-skill-audit-lqSbo
Open

feat(defi): add asset-leasing example (Anchor + Quasar)#39
mikemaccana wants to merge 2 commits into
mainfrom
claude/asset-leasing-skill-audit-lqSbo

Conversation

@mikemaccana

@mikemaccana mikemaccana commented May 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds a new defi/asset-leasing example demonstrating onchain securities lending — the same bilateral deal structure used by TradFi stock-loan desks — with two full implementations.

Anchor (defi/asset-leasing/anchor/)

Seven instruction handlers covering the complete bilateral lease lifecycle:

create_leasetake_leasepay_lease_fee / top_up_collateralreturn_lease / liquidate / close_expired

  • PDA-backed leased and collateral vaults; per-second fee accrual via last_paid_timestamp
  • Pyth PriceUpdateV2 staleness + feed-id pinning guard on liquidation
  • Token-2022 compatible via TokenInterface
  • LiteSVM integration test suite (11 tests) covering every handler, error path, and branch scenario

Quasar port (defi/asset-leasing/quasar/)

Same seven handlers, same Lease state layout (byte-for-byte compatible with the Anchor version), same PDA seed conventions. Differences: one-byte explicit discriminators, no init_if_needed ATA creation, classic Token only, one active lease per holder.

README (defi/asset-leasing/anchor/README.md)

  • Finance concepts explained for readers unfamiliar with securities lending; Investopedia links on every financial term at first mention
  • Program flow section with three named participants: Alice (holder, earns yield on idle NVDAx inventory), Bob (short seller, bearish thesis on NVIDIA), and Carol (keeper bot, earns liquidation bounty). Uses USDC and NVDAx as primary example tokens; TSLAx noted as a parallel case
  • Each lifecycle step lists the instruction handler called and every account that changes, with before/after values in table form
  • Bilateral vs pooled lending comparison
  • Full safety and edge-case reference covering all error variants and deliberate design trade-offs

Test plan

  • cargo check --lib in defi/asset-leasing/anchor/programs/asset-leasing (verified clean locally)
  • anchor build && anchor test in the Anchor workspace
  • cargo test in the Quasar workspace
  • README renders correctly on GitHub

https://claude.ai/code/session_01Etk82ApiAusLAUezvmzVts

Adds a new defi/asset-leasing example demonstrating onchain securities
lending — the same primitive that underpins TradFi stock-loan desks —
with two full implementations:

**Anchor** (defi/asset-leasing/anchor/)
- Seven instruction handlers covering the complete bilateral lease
  lifecycle: create_lease → take_lease → pay_lease_fee /
  top_up_collateral → return_lease / liquidate / close_expired.
- PDA-backed leased and collateral vaults; per-second fee accrual via
  last_paid_timestamp; Pyth PriceUpdateV2 staleness + feed-id guard on
  liquidation; Token-2022 compatible via TokenInterface.
- LiteSVM integration test suite (11 tests) covering every handler,
  error path, and branch scenario.

**Quasar port** (defi/asset-leasing/quasar/)
- Same seven handlers, same Lease state layout (byte-for-byte
  compatible with the Anchor version), same PDA seed conventions.
- Differs from the Anchor version in: one-byte explicit discriminators,
  no init_if_needed ATA creation, classic Token only (not Token-2022),
  one active lease per holder (no lease_id in PDA seed).

**README** (defi/asset-leasing/anchor/README.md)
- Explains the securities-lending model for readers unfamiliar with
  finance; Investopedia links on every financial term at first mention.
- Program flow section with three named participants: Alice (holder,
  earns yield on idle inventory), Bob (short seller, bearish thesis on
  NVIDIA), and Carol (keeper bot, earns liquidation bounty). Uses USDC
  and NVDAx as primary example tokens; TSLAx noted as a parallel case.
- Each lifecycle step lists the instruction handler called and every
  account that changes, with before/after values in table form.
- Complete lifecycle reference with exact numbers that match the
  LiteSVM tests one-to-one.
- Bilateral vs pooled lending comparison.
- Safety and edge-case section covering all error variants and
  deliberate design trade-offs.

https://claude.ai/code/session_01Etk82ApiAusLAUezvmzVts
@mikemaccana mikemaccana force-pushed the claude/asset-leasing-skill-audit-lqSbo branch from f332fcf to f93f93d Compare June 2, 2026 17:28
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.

3 participants