Skip to content

Solana M2: swap origination, SOL launch pairs, numéraire quoting#497

Open
LandynDev wants to merge 13 commits into
contract-v2from
feat/solana-m2
Open

Solana M2: swap origination, SOL launch pairs, numéraire quoting#497
LandynDev wants to merge 13 commits into
contract-v2from
feat/solana-m2

Conversation

@LandynDev

Copy link
Copy Markdown
Collaborator

Solana M2: swap origination, SOL launch pairs, numéraire quoting

feat/solana-m2contract-v2

Summary

Un-stubs swap origination on Solana and flips the subnet to SOL-based launch pairs. A user can now drive a swap end-to-end (verified live on a local stack — see the alw-utils companion PR), and the rate machinery is re-anchored from the old TAO leg to the SOL leg.

What changed

Swap intake (was stubbed)

  • solana/client.pyopen_or_request + resolve_pool instruction builders (+ layouts disc/args, SLOT_HASHES). Account order/borsh cross-checked against the Rust #[derive(Accounts)].
  • validator/solana_swap_loop.py + forward.py — default-on validator resolve-crank: each forward step resolves closed pools into reservations (idempotent, read-only-aware, fault-isolated).
  • cli/swap_commands/swap_intake.py (new) — pure taker amount math: best-miner selection + sol_amount/from_amount/to_amount (SOL leg = the bounded notional), via the shared calculate_to_amount. swap.py:swap now wired to it.

SOL launch pairs + rate gate (B8)

  • chains.pycanonical_pair re-anchored: SOL is the canonical source (rate reads "X per 1 SOL").
  • constants.pyDIRECTION_POOLS flipped to sol↔btc / sol↔tao @ 0.25 each.
  • utils/rate.pyis_executable_rate + min_executable_tao_legmin_executable_sol_leg re-anchored from the TAO leg to the SOL leg (bounds are SOL lamports). Scoring call-sites updated. Dead TAO helpers removed.

SOL-numéraire quoting

  • cli/swap_commands/numeraire.py (new) + alw miner quotes — one price per chain ("X per 1 SOL") derives every pair direction (optional symmetric spread). On-chain MinerQuote unchanged.

Reserve path

  • validator/axon_handlers.py:handle_swap_reserve — restubbed as a simple FCFS entry (user → validator → on-behalf lottery): rejects if the miner is unbound/inactive/busy, else accepts. Removed the dead reservation_pins table (replaced by the on-chain Reservation PDA).

Program id

  • Repointed declare_id! + Anchor.toml + pdas.PROGRAM_ID to a committed dev keypair.

⚠️ Reviewer notes (must read)

  • The committed program keypair (smart-contracts/solana/target/deploy/allways_swap_manager-keypair.json) is DEV-ONLY — it exists so the local program id is reproducible across clones. Testnet/mainnet deploys use a separate, uncommitted keypair.
  • handle_swap_reserve is an intentional FCFS stub — the user→validator entry point for the Ventura Labs browser-swap product. The on-behalf open_or_request call + request-window selection are a follow-up (not part of this PR).

Robustness (surfaced by the live --full stack)

  • neurons/base/validator.pyresync_metagraph overran metagraph.hotkeys[uid] when the re-synced metagraph
    had fewer hotkeys than the cached self.hotkeys (a settling subnet); zip-truncate fix + 2 regression tests.
    Also: step-error handler now logs the origin file:line (the gap that made this hard to diagnose).

Testing

  • 526 unit + 6 integration (live solana-test-validator) + 25 contract on-chain tests green; ruff clean.
  • Full swap lifecycle verified live to COMPLETED in all four combos — sol↔btc (--fast) and sol↔tao
    (--full, real subtensor) — plus an asserted timeout-slash path (see the alw-utils full-e2e.sh PR).

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.

1 participant