> For the complete documentation index, see [llms.txt](https://reports.immunefi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://reports.immunefi.com/spectra-finance/43402-sc-insight-function-getptunderlyingunit-could-be-marked-external.md).

# #43402 \[SC-Insight] Function \`getPTUnderlyingUnit\` could be marked external

**Submitted on Apr 5th 2025 at 15:48:56 UTC by @PotEater for** [**Audit Comp | Spectra Finance**](https://immunefi.com/audit-competition/audit-comp-spectra-finance)

* **Report ID:** #43402
* **Report Type:** Smart Contract
* **Report severity:** Insight
* **Target:** <https://github.com/immunefi-team/Spectra-Audit-Competition/blob/main/src/router/util/RouterUtil.sol>
* **Impacts:**

## Description

## Brief/Intro

The function `getPTUnderlyingUnit` is marked as public, however it is not used internally anywhere, so it could be marked external to save gas.

## Vulnerability details

Public functions can be called internally and externally at the same time. In such case, marking a function public would make sense. However, the mentioned functions are not used internally within the contract.

This means the functions can be marked external to save gas.

## Impact Details

Functions marked `public` cost more gas than external functions. This is gas/code optimization.

Changing this function to external will save gas.

## References

<https://github.com/immunefi-team/Spectra-Audit-Competition/blob/1cebdc67a9276fd87105d13f302fd77d000d0c0b/src/router/util/RouterUtil.sol#L831>

## Proof of Concept

## Proof of Concept

```solidity
    function getPTUnderlyingUnit(address _pt) public view returns (uint256) { // @audit-issue function could be marked external
        return getUnit(IPrincipalToken(_pt).underlying());
    }
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://reports.immunefi.com/spectra-finance/43402-sc-insight-function-getptunderlyingunit-could-be-marked-external.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
