# Loss of funds in PendleConnector.depositIntoMarket()

PendleConnector.depositIntoMarket assumed skim() refunds unused SY/PT, but skim() sends surplus to Pendle treasury, so excess tokens are lost and MEV-bot-skimmed.

- Payout: Audit contest
- Severity: high
- Program: NOYA
- Found by: alexxander
- Disclosed: 2025-02-17
- Write-up quality: 7/10
- Original: https://github.com/code-423n4/2024-04-noya-findings/issues/1363
- Library page: https://bugbountylibrary.com/r/c4%3A2024-04-noya%3AH-05
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:code4rena sev:high tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:business-logic

**Target:** PendleConnector.depositIntoMarket / PendleMarketV3.mint
**Root cause:** depositIntoMarket transfers SY/PT then calls market.mint with those amounts as upper bounds; mint consumes less than supplied, and the code assumes skim() returns the surplus to the caller, but skim() forwards surplus to the Pendle treasury.
**Steps:**
1. Call `depositIntoMarket(market, SYamount, PTamount)` with SY/PT amounts exceeding what mint needs.
2. Contract `safeTransfer`s SYamount and PTamount to the market.
3. `market.mint(address(this), SYamount, PTamount)` mints LP using only the required amounts, leaving surplus SY/PT in the market.
4. `market.skim()` sends the surplus to the Pendle treasury, not the connector, so the connector loses the difference.
**How found:** Code-reading: noticed the comment claiming skim() recovers surplus tokens, then checked PendleMarketV3.skim() source and saw it transfers surplus to the treasury rather than the caller.
**Exploitation:** Any caller/manager passing amounts above the mint requirement (or MEV searchers triggering the surplus) causes the excess SY/PT to be skimmed to the Pendle treasury; the connector permanently loses those tokens.
**Insight:** When integrating with third-party contracts, verify what helper functions like skim() actually do with surplus—read the source, don't trust comments; mint-style functions taking upper bounds leave dust that may be claimable by others.

## Proof of concept (copied exactly from the original report)

**depositIntoMarket transfers then mint and skim**

```
function depositIntoMarket(IPMarket market, uint256 SYamount, uint256 PTamount) external onlyManager nonReentrant {
    (IPStandardizedYield _SY, IPPrincipalToken _PT,) = IPMarket(market).readTokens();
    IERC20(address(_SY)).safeTransfer(address(market), SYamount);
    IERC20(address(_PT)).safeTransfer(address(market), PTamount);
    market.mint(address(this), SYamount, PTamount);
    market.skim();
    emit DepositIntoMarket(address(market), SYamount, PTamount);
}
```

