Skip to content

feat(api): add migrate_adapter rebalance keeper - #512

Merged
collinsezedike merged 25 commits into
mainfrom
feat/469-migrate-adapter-keeper
Aug 16, 2026
Merged

feat(api): add migrate_adapter rebalance keeper#512
collinsezedike merged 25 commits into
mainfrom
feat/469-migrate-adapter-keeper

Conversation

@collinsezedike

@collinsezedike collinsezedike commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Removes MeridianRouter entirely: per-user delegated rebalancing is structurally impossible on Stellar, token transfers and burns always require the token holder's own signature and there is no allowance/delegation primitive
  • Adds a scheduled migration keeper (packages/stellar-sdk-helpers/src/migration-keeper.ts) that compares live rates across a vault's candidate protocol adapters and calls the existing, already-admin-gated migrate_adapter when a candidate clears a configured minimum improvement, with the same retry, deadline-budget, and structured-failure-reporting shape as the existing accrue keeper
  • This is not yet functional against the live testnet vault, two independent gaps remain, both tracked separately rather than rushed: rate comparison is deliberately pluggable and defaults to always-unknown ("never migrate"), since neither Blend nor DeFindex's adapter exposes a ready-made comparable rate today ([Feature] Implement real rate sources for the migration keeper #511); and the live testnet vault predates migrate_adapter being added to vault/src/lib.rs and doesn't have the function at all, confirmed directly against the live contract ([Bug] Live testnet vault predates migrate_adapter, needs redeployment #514). See apps/docs/operations/migration-keeper.md
  • Deploys and initializes a real MeridianDefindexAdapter on testnet (CAJVTA7EC3ZL3G4WSU4QIRB7RU7SUFUUJDEB7JE6CQQNPE7QC5OBSAM6) against the existing DeFindex testnet vault, so there's a genuine second candidate to evaluate once the gaps above close; it is not the vault's active adapter. Deliberately not wired into packages/shared/src/constants.ts, that file gates a required CI check verifying the vault address's on-chain bytecode against source, and [Bug] Live testnet vault predates migrate_adapter, needs redeployment #514 already fails it independent of this address; set MERIDIAN_DEFINDEX_ADAPTER_ID directly instead
  • New api/v1/keepers/rebalance endpoint. MERIDIAN_MIGRATION_KEEPER_SECRET_KEY is a separate, higher-trust key from the accrue keeper's since migrate_adapter is admin-gated and accrue() is not. Its vercel.json cron entry is known to be non-functional on the Hobby plan (same limitation the existing accrue keeper's cron already hits), tracked separately in [Chore] Move keeper scheduling off Vercel Cron #513
  • Extracts the accrue keeper's retry and transaction-submission logic into shared keeper-retry.ts/keeper-tx.ts modules so the new migration keeper reuses them instead of duplicating a third copy; closes out several items from [Chore] Deduplicate retry/error-handling logic in the accrual keeper #510 as a result (tracked there)

Test plan

  • cargo build --workspace passes with the router package removed
  • pnpm typecheck passes across stellar-sdk-helpers, api, shared
  • pnpm test passes: 166 tests in stellar-sdk-helpers (18 new for the migration keeper), 35 in api (3 new for the rebalance endpoint)
  • Manually verified the deployed MeridianDefindexAdapter on testnet via stellar contract invoke: get_protocol returns defindex, get_pool returns the configured DeFindex vault, total_assets returns 0
  • Manually verified the live vault's actual callable methods via stellar contract invoke -- --help: no migrate_adapter, confirming [Bug] Live testnet vault predates migrate_adapter, needs redeployment #514

Closes #469

@vercel

vercel Bot commented Aug 14, 2026

Copy link
Copy Markdown

Deployment failed for project meridian with the following error:

Hobby accounts are limited to daily cron jobs. This cron expression (*/15 * * * *) would run more than once per day. Upgrade to the Pro plan to unlock all Cron Jobs features on Vercel.

Learn More: https://vercel.link/3Fpeeb1

@collinsezedike
collinsezedike force-pushed the feat/469-migrate-adapter-keeper branch from c2d2b6e to 0d4cc58 Compare August 15, 2026 14:08
@collinsezedike
collinsezedike merged commit d9a80b5 into main Aug 16, 2026
8 of 9 checks passed
@collinsezedike
collinsezedike deleted the feat/469-migrate-adapter-keeper branch August 16, 2026 11:13
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.

[Feature] Automatic protocol-yield routing via migrate_adapter keeper

1 participant