Skip to content

feat: Pendle V2 action provider (PT buy/sell + market info)#1146

Open
Ridwannurudeen wants to merge 1 commit intocoinbase:mainfrom
Ridwannurudeen:feat/pendle-action-provider
Open

feat: Pendle V2 action provider (PT buy/sell + market info)#1146
Ridwannurudeen wants to merge 1 commit intocoinbase:mainfrom
Ridwannurudeen:feat/pendle-action-provider

Conversation

@Ridwannurudeen
Copy link
Copy Markdown

Description

Closes #1143.

Adds a Pendle V2 action provider so AgentKit agents can buy and sell Principal Tokens (PT) directly.

Three actions:

  • swap_exact_token_for_pt — buy PT on a market with an underlying ERC-20.
  • swap_exact_pt_for_token — sell PT back to an underlying ERC-20.
  • get_pendle_market_info — read PT/YT/SY addresses, expiry, and underlying for a market.

Origin chains: Base, Ethereum, Arbitrum mainnets. Pendle V2 deploys the canonical router (0x888888888889758F76e7103c6CbF23ABbF58F946) at the same address on every supported chain.

How it works. Swap calldata is fetched from Pendle's hosted SDK (POST /core/v3/sdk/{chainId}/convert) at action time — that endpoint handles the V2 router's complex routing and aggregator selection, returning ready-to-broadcast tx = {to, data, value} plus a list of required ERC-20 approvals. The provider applies those approvals against the router and broadcasts the prepared transaction via the wallet provider. Per Pendle's docs the calldata is point-in-time (slippage and guess bounds embedded), so each action call fetches fresh calldata immediately before broadcast.

Active markets are not hard-coded since they expire by maturity — agents look them up via get_pendle_market_info or the public /core/v1/{chainId}/markets/active listing.

YT trading and LP add/remove are intentionally out of scope here per the "Happy to scope a first PR to PT-only" comment in #1143; they can be added in follow-ups against the same /convert endpoint.

TypeScript provider will follow in a separate PR.

Follows the AaveActionProvider and Hyperlane (#1144) layout (provider, schemas, constants, utils, README, changelog, unit tests with a mocked EvmWalletProvider).

Tests

Unit tests: 16/16 passing.

$ make test  # filtered to action_providers/pendle
========================== test session starts ==========================
collected 16 items

tests/action_providers/pendle/test_pendle_provider.py ....         [ 25%]
tests/action_providers/pendle/test_pendle_schemas.py .......       [ 68%]
tests/action_providers/pendle/test_pendle_swap.py .....            [100%]

========================== 16 passed in 0.19s ===========================

Coverage: supports_network, chain ID resolution (supported + unsupported), schema validation (all three actions, default + custom slippage), buy-PT happy path (asserts approval is for the router with the SDK-returned amount, asserts tx data matches the SDK response), unsupported network early-exit, insufficient balance early-exit, sell-PT happy path, market info markdown rendering.

Lint / format: make lint and make format clean on the added files.

Live test: Pending. Happy to verify end-to-end with a small Base PT-USDe buy/sell once a maintainer is reviewing — will paste the tx hash + Pendle market URL in a follow-up comment.

Checklist

  • Added documentation to all relevant README.md files
  • Added a changelog entry

Implements `swap_exact_token_for_pt`, `swap_exact_pt_for_token`, and
`get_pendle_market_info` actions so AgentKit agents can buy and sell
Pendle V2 PT positions directly.

Origin chains supported: Base, Ethereum, Arbitrum mainnets.

Swap calldata is fetched at action time from Pendle's hosted SDK
(POST /core/v3/sdk/{chainId}/convert) which handles the V2 router's complex
routing and aggregator selection. Required ERC-20 approvals returned by the
SDK are applied against the canonical Pendle Router
(0x888888888889758F76e7103c6CbF23ABbF58F946) before the prepared transaction
is broadcast.

Market metadata (PT/YT/SY addresses, expiry, underlying) is read from
Pendle's /core/v1/{chainId}/markets/{address} endpoint. Active markets are
not hardcoded since they expire by maturity; agents look them up via
`get_pendle_market_info`.

YT trading and LP add/remove are intentionally out of scope for this PR
and can be added in follow-ups against the same SDK endpoints.

Closes coinbase#1143.
@cb-heimdall
Copy link
Copy Markdown

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

@github-actions github-actions Bot added documentation Improvements or additions to documentation action provider New action provider python labels Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action provider New action provider documentation Improvements or additions to documentation python

Development

Successfully merging this pull request may close these issues.

feat: Pendle V2 action provider (PT/YT/LP)

2 participants