feat: Pendle V2 action provider (PT buy/sell + market info)#1146
Open
Ridwannurudeen wants to merge 1 commit intocoinbase:mainfrom
Open
feat: Pendle V2 action provider (PT buy/sell + market info)#1146Ridwannurudeen wants to merge 1 commit intocoinbase:mainfrom
Ridwannurudeen wants to merge 1 commit intocoinbase:mainfrom
Conversation
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.
🟡 Heimdall Review Status
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-broadcasttx = {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_infoor the public/core/v1/{chainId}/markets/activelisting.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
/convertendpoint.TypeScript provider will follow in a separate PR.
Follows the
AaveActionProviderand Hyperlane (#1144) layout (provider, schemas, constants, utils, README, changelog, unit tests with a mockedEvmWalletProvider).Tests
Unit tests: 16/16 passing.
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 lintandmake formatclean 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