Skip to content
Business logic Audit finding Intermediate

Invalid calculation of position TVL in Pendle connector

The Pendle connector computed a position's total value locked by multiplying LP and PT balances by rates that are denominated in the underlying asset, not in SY tokens as the code assumed. This produced an understated TVL for the position, which fed into the protocol-wide TVL figure.

0xAlix2 Follow

Originally disclosed on Code4rena

Submitted by 0xAlix2

Impact

Pendle connector allows protocol managers to deposit some underlying asset in return for some SY tokens, which can be used to mint PT and YT tokens. PT and YT can be deposited in markets and in return for LP tokens and some claimable rewards. These LP tokens should be considered when calculating the TVL of the position, to do this the protocol is using getLpToAssetRate, which from the docs:

getLpToAssetRate: Serves the same purpose, but in terms of SY’s asset.

This means that it returns the price of LP in terms of the underlying asset (which is USDT in the below example); however, the protocol is using this function assuming that it returns the price of LP in terms of SY, through:

SYAmount += lpBalance * IPMarket(market).getLpToAssetRate(10) / 1e18;

The above also applies to getPtToAssetRate.

This will cause an inaccurate representation of the Connector’s TVL affecting the whole protocol’s TVL.

Proof of Concept

function testInvalidPendleTVL() public {
    (IPStandardizedYield _SY, IPPrincipalToken _PT, IPYieldToken _YT) = IPMarket(pendleUsdtMarket).readTokens();
    uint256 USDTamount = 100e6;

    _dealERC20(USDT, address(connector), USDTamount);

    vm.startPrank(owner);

    // Update tokens in registry
    connector.updateTokenInRegistry(USDT);

    // TVL is around 100 USDC
    // Connector holds 100 USDT
    assertEq(accountingManager.TVL() / 1e6, 99);
    assertEq(IERC20(USDT).balanceOf(address(connector)) / 1e6, 100);

    // Supply USDT to the market
    connector.supply(pendleUsdtMarket, USDTamount);

    // TVL is still around 100 USDC
    // Connector holds 0 USDT and around 100 SY
    assertEq(accountingManager.TVL() / 1e6, 99);
    assertEq(IERC20(USDT).balanceOf(address(connector)), 0);
    assertEq(_SY.balanceOf(address(connector)) / 1e6, 99);

    // Mint PT and YT
    connector.mintPTAndYT(pendleUsdtMarket, _SY.balanceOf(address(connector)) / 2);

    // TVL is still around 100 USDC
    // Connector holds 0 USDT, 49 PT, 49 YT and 49 SY
    assertEq(accountingManager.TVL() / 1e6, 100);
    assertEq(IERC20(USDT).balanceOf(address(connector)), 0);
    assertEq(_SY.balanceOf(address(connector)) / 1e6, 49);
    assertEq(_PT.balanceOf(address(connector)) / 1e6, 49);
    assertEq(_YT.balanceOf(address(connector)) / 1e6, 49);

    // Deposit SY and PT into the market
    connector.depositIntoMarket(
        IPMarket(pendleUsdtMarket), _SY.balanceOf(address(connector)), _PT.balanceOf(address(connector))
    );
    vm.roll(block.number + 20);
    vm.warp(block.timestamp + 1 hours);

    // TVL drops to 59 USDC - which is wrong because of the invalid TVL calculation
    // Connector holds 0 USDT, 49 YT, 29 LP, 0 SY and 0 PT
    assertEq(accountingManager.TVL() / 1e6, 59);
    assertEq(IERC20(_YT).balanceOf(address(connector)) / 1e6, 49);
    assertEq(IERC20(pendleUsdtMarket).balanceOf(address(connector)) / 1e6, 29);
    assertEq(_SY.balanceOf(address(connector)), 0);
    assertEq(_PT.balanceOf(address(connector)), 0);
}

Recommended Mitigation Steps

Refactor PendleConnector::_getPositionTVL to take into consideration that getLpToAssetRate and getPtToAssetRate calculate the price of LP in terms of the underlying asset and not SY.

HadiEsna (NOYA) confirmed

gzeon (judge) increased severity to High


The original report as published on Code4rena, by 0xAlix2. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the TVL calculation multiplied LP and PT balances by getLpToAssetRate and getPtToAssetRate, which return values in terms of the underlying asset, while the code treated the result as an SY-denominated amount.

Impact

The connector's reported TVL could be materially understated, which in turn distorts the whole protocol's TVL figure.

What the attacker needed

A Pendle market position in the connector

The fix

The position TVL calculation should be refactored to treat getLpToAssetRate and getPtToAssetRate as returning prices in terms of the underlying asset rather than SY.

How it was found

  1. Fund the connector with underlying USDT and register the token, then read the TVL.
  2. Supply the USDT to the Pendle market and observe the TVL.
  3. Mint PT and YT from half of the SY balance and observe the TVL.
  4. Deposit SY and PT into the market, advance the block and time, then observe the TVL drop.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A protocol holds tokens and needs to report how much they are worth in total, called TVL (total value locked). It converted some token balances into value using a price helper, but that helper gave the price in a different unit than the code expected, so the reported total came out too low. A wrong total can mislead users and any logic that relies on it.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by 0xAlix2

View all

39 more disclosed reports, best first.

More from NOYA

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.