Skip to content

feat(example): MockPendleRouter contract + deploy runbook (scenario A unblock)#20

Open
mike-diamond wants to merge 1 commit into
mainfrom
feat/buildathon-mock-pendle-router-deploy-runbook
Open

feat(example): MockPendleRouter contract + deploy runbook (scenario A unblock)#20
mike-diamond wants to merge 1 commit into
mainfrom
feat/buildathon-mock-pendle-router-deploy-runbook

Conversation

@mike-diamond
Copy link
Copy Markdown
Contributor

Summary

Makes the Buildathon demo's scenario A (Pendle yield swap) actually deployable + runnable, and pre-writes the full deploy runbook so the on-chain deploy (which needs Mike's funded key) is copy-paste.

The gap: the app already referenced MockPendleRouter (src/agent/envelope-builder.ts imports getMockPendleRouterAddress, holds MOCK_PENDLE_ROUTER_ABI, and comments point at contracts/src/MockPendleRouter.sol), but the contract and its deploy script did not exist. Scenario A could not be deployed end-to-end.

Changes

File What
contracts/src/MockPendleRouter.sol Deterministic 1:0.995 mock matching the exact ABI the app expects. Token-agnostic (no real transfers - so it runs on testnet without funding the caller), emits SwapExactTokenForPt, reverts InsufficientPtOut below minPtOut. Apache-2.0.
contracts/script/DeployMockPendleRouter.s.sol Arbitrum Sepolia deploy script (the only chain the off-chain builder targets for the router).
contracts/test/MockPendleRouter.t.sol 5 tests incl. an end-to-end agent-signed envelope -> AgentPolicyGate -> router integration test proving the scenario A on-chain path.
DEPLOY.md Full copy-paste deploy runbook: both chains, the easy-to-forget allow-list step, signer-pair pre-check, deployed.json + decoder-data wiring, post-deploy cast verification, smoke test.
contracts/README.md Pointer to DEPLOY.md.

Verification

cd examples/arbitrum-london/contracts && forge test
# 20 passed (15 AgentPolicyGate + 5 MockPendleRouter), 0 failed

cd examples/arbitrum-london && npx tsc --noEmit
# clean, exit 0

Mock fidelity

The mock's fixed 995/1000 rate is exactly what buildPendleEnvelope assumes: it sets minPtOut = amountIn * (10000 - slippageBps) / 10000, so any declared slippage of 50 bps or looser succeeds and anything tighter reverts InsufficientPtOut - the same shape a real router would present. The integration test pins the 50 bps boundary.

What this does NOT do

  • Deploy anything. Contracts still need a funded-key forge script run (Mike) - the whole point of DEPLOY.md.
  • Touch scenario C (Robinhood RWA) - its buildRwaEnvelope still throws "not implemented" (Phase 2 Day 10). DEPLOY.md deploys the Robinhood gate only, for the multi-chain claim.
  • Add real token custody / pricing / PT minting to the mock (deliberately out of scope; would obscure the review-and-sign flow).

Notes for review

  • MockPendleRouter is intentionally stateless and token-free. If you want the demo to show a real ERC-20 pull (approve + transferFrom), that is a larger change and would need a mock input token + an approve leg in the envelope.
  • DEPLOY.md flags the two silent-failure traps explicitly: skipping the allow-list, and a signer-pair mismatch. Both compile + deploy fine and only revert at execute time.

Leaving this open for your review - not merging.

…nario A

The Buildathon demo app referenced MockPendleRouter (envelope-builder.ts
imports getMockPendleRouterAddress, holds MOCK_PENDLE_ROUTER_ABI, points at
contracts/src/MockPendleRouter.sol) but the contract and its deploy script did
not exist - scenario A (Pendle yield swap) was undeployable.

- contracts/src/MockPendleRouter.sol: deterministic 1:0.995 mock matching the
  ABI the app already expects. Token-agnostic (no real transfers), emits
  SwapExactTokenForPt, reverts InsufficientPtOut below minPtOut. Apache-2.0.
- contracts/script/DeployMockPendleRouter.s.sol: Arbitrum Sepolia deploy script.
- contracts/test/MockPendleRouter.t.sol: 5 tests incl. an end-to-end
  agent-signed envelope -> AgentPolicyGate -> router integration test.
- DEPLOY.md: full copy-paste deploy runbook (both chains, allow-list step,
  signer-pair pre-check, deployed.json + decoder-data wiring, smoke test).
- contracts/README.md: pointer to DEPLOY.md.

Verification: forge test 20 passed (15 gate + 5 router), app tsc --noEmit clean.
Contracts still need a funded-key deploy (Mike) - see DEPLOY.md.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
txkit-docs Ready Ready Preview, Comment May 29, 2026 1:36pm
txkit-land Ready Ready Preview, Comment May 29, 2026 1:36pm
txkit-story Ready Ready Preview, Comment May 29, 2026 1:36pm

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